Sunday 15 September 2013

Keep showing context menu when a popup window is opened

Keep showing context menu when a popup window is opened

I am trying to show a calendar from a context menu. At first, I included
it as a Gtk.MenuItem, but after reading this answer, I am now showing the
calendar as a popup window when the user hovers over a menu item.
When the user hovers over 'Set due date', the calendar is supposed to show
up right beside it. It is shown when activate signal (
on_set_due_via_calendar ) fires from the 'Set due date' menu item. Here's
the code for it -
def on_set_due_via_calendar(self, widget):
rect = widget.get_allocation()
x, y = widget.window.get_origin()
menu_width, menu_height = widget.get_toplevel().window.get_size()
calendar_width, calendar_height = self.calendar.get_size()
self.calendar.show_at_position(x + rect.x + calendar_width + menu_width,
y + rect.y + calendar_height)
The problem I'm facing is that the menu disappears as soon as the window
is shown ( Perhaps it works that way ). I want it to keep getting
displayed until the user clicks somewhere else ( i.e. - Treat the calendar
as a submenu ).
Here are the screens showing the issue -

No comments:

Post a Comment