Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6635367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:02:43+00:00 2026-05-25T23:02:43+00:00

I want to popup a context menu when the user right-clicks on the header

  • 0

I want to popup a context menu when the user right-clicks on the header row of a Gtk.TreeView. In GTK3, Gtk.TreeViewColumn has a get_button() method, which makes this easy; simply attach the menu to the button and connect it to a ‘clicked’ event. However, in GTK2, this won’t work. You can only call a get_widget() method, which returns None if you haven’t set a widget via set_widget(). I’ve tried putting a Gtk.Label with the column name into a Gtk.EventBox and set that as the widget After connecting the EventBox to a callback for the ‘button_press_event’, clicking on it doesn’t generate the event.

I tried to do something like what’s listed here but doing get_parent() on the column widget returns None, and never reaches the button as their code implies.

What solutions have people found for this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:02:44+00:00Added an answer on May 25, 2026 at 11:02 pm

    This is pretty easy actually, but you need a couple of hacks.

    First you need to force Gtk to create a header button for the GtkTreeViewColumn:

        label = gtk.Label("Column title")
        label.show()
        treeview_column.set_widget(label)
    

    After that you need to fetch the internal GtkButton of the header:

        widget = treeview_column.get_widget()
        while not isinstance(widget, gtk.Button):
            widget = widget.get_parent()
    

    Finally with a button reference you can do something useful:

        def button_release_event(button, event):
            if event.button == 3:
               menu.popup(event)
    
        widget.connect('button-release-event', button_release_event)
    

    This was taken from the kiwi library which has an ObjectList which provides a python list like api for creating GtkTreeViews.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to achieve the effect of a pop-up when the user right-clicks in
I want to create a Window like when a context menu pops up or
I'm trying to get my application to display a popup context menu when a
When click a button,I want to popup a view form bottom,like this! Any help
I have a TextBox and a Popup control. I want the Popup.IsOpen property to
I want to show Popup window contain YouTube video. My question is how to
I need a jquery slideshow with div popup i want to show my image
I work on Asp.Net VS08 C#. Clicking on Button want to show popup. popup
I want to display a popup windo on my rails application... Here is exactly
I want to create a simple multiline Alert popup Alert.show(Blah\\nBlah) shows Blah\nBlah when what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.