本文整理汇总了Python中gi.repository.Gtk.get_current_event_time方法的典型用法代码示例。如果您正苦于以下问题:Python Gtk.get_current_event_time方法的具体用法?Python Gtk.get_current_event_time怎么用?Python Gtk.get_current_event_time使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gi.repository.Gtk
的用法示例。
在下文中一共展示了Gtk.get_current_event_time方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signal_tv_button_pressed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def signal_tv_button_pressed(self, _, event):
if event.button == Gdk.BUTTON_SECONDARY:
selected_tasks = self._get_selected_tasks()
if not selected_tasks:
self.menu_item_cancel.set_sensitive(False)
self.menu_item_paused.set_sensitive(False)
else:
self.menu_item_cancel.set_sensitive(True)
self.menu_item_paused.set_sensitive(True)
tasks_are_paused = [task.state == 'Paused' for task in selected_tasks]
if any(tasks_are_paused):
self.menu_item_paused.set_active(True)
self.menu_item_paused.set_inconsistent(not all(tasks_are_paused))
else:
self.menu_item_paused.set_active(False)
self.menu_item_paused.set_inconsistent(False)
self.popup_menu.popup(None, None, None, None, event.button, Gtk.get_current_event_time())
return True
return
示例2: _do_popup_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def _do_popup_menu(self, event):
menu = Gtk.Menu()
try:
self.populate_popup(menu)
except NotImplementedError:
return False
else:
menu.show_all()
if event is not None:
button = event.button
event_time = event.time
else:
button = 0
event_time = Gtk.get_current_event_time()
menu.attach_to_widget(self)
menu.popup(None, None, None, None, button, event_time)
示例3: mpl_signal_canvas_button_pressed
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def mpl_signal_canvas_button_pressed(self, event):
if event.button != 3:
return
self.popup_menu.menu.popup(None, None, None, None, event.button, Gtk.get_current_event_time())
return True
示例4: popup_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def popup_menu(self, *args):
self.popup.popup(None, None, None, None, 0, Gtk.get_current_event_time())
示例5: show_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def show_menu(self, event=None):
"""
Show popup menu.
"""
if (Gtk.MAJOR_VERSION >= 3) and (Gtk.MINOR_VERSION >= 22):
# new from gtk 3.22:
self.popup_at_pointer(event)
else:
if event:
self.popup(None, None, None, None,
event.get_button()[1], event.time)
else:
self.popup(None, None, None, None,
0, Gtk.get_current_event_time())
#self.popup(None, None, None, None, 0, 0)
示例6: leftclick
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def leftclick(self, status_icon):
if not self.thr.is_alive():
self.thr.start()
button = 1
time = Gtk.get_current_event_time()
position = Gtk.StatusIcon.position_menu
self.nm_menu().popup(None, None, position, status_icon, button, time)
示例7: button_press_event
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def button_press_event(self, treeview, event):
if event.button == 3: # right click
pathinfo = treeview.get_path_at_pos(int(event.x), int(event.y))
if pathinfo is not None:
path, col = pathinfo[0], pathinfo[1]
treeview.grab_focus()
treeview.set_cursor(path, col, 0)
self.menu.show_all()
self.menu.popup(None, None, None, None, event.button,
Gtk.get_current_event_time())
return True
return False
示例8: mouse_click
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def mouse_click(self, tv, event):
# right click on a note
try:
self.rightclickmenu.destroy()
except: pass
if event.button == 3:
# get selected port
self.rightclickmenu = Gtk.Menu()
note_selected = []
(model, pathlist) = tv.get_selection().get_selected_rows()
for path in pathlist :
tree_iter = model.get_iter(path)
idz = model.get_value(tree_iter,1)
note_selected.append(idz)
i1 = Gtk.MenuItem("delete")
i2 = Gtk.MenuItem("rename")
i1.connect("activate", self.delete_note, note_selected)
i2.connect("activate", self.rename_note, note_selected)
self.rightclickmenu.append(i1)
self.rightclickmenu.append(i2)
# show all
self.rightclickmenu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
self.rightclickmenu.show_all()
示例9: signal_tv_button_press
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def signal_tv_button_press(self, _, event):
if event.button == Gdk.BUTTON_SECONDARY:
model, treeiter = self.treeview.get_selection().get_selected()
if treeiter:
named_row = _ModelNamedRow(*model[treeiter])
self.menu_item_edit.set_sensitive((named_row.st_mode & stat.S_IFDIR) == 0)
sensitive = treeiter is not None
for menu_item in self._menu_items_req_selection:
menu_item.set_sensitive(sensitive)
self.popup_menu.popup(None, None, None, None, event.button, Gtk.get_current_event_time())
return True
return
示例10: on_new_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def on_new_clicked(self, widget, data=None):
widget.get_menu().popup(None, None, None, None, 1, Gtk.get_current_event_time())
示例11: show_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def show_menu(self):
"""
Displays right click context menu
"""
if self.content_provider.status:
self.menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
示例12: __on_properties_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def __on_properties_clicked(self, button):
"""
Handles settings button clicked event and displays context menu
:param button:
"""
self.__menu.popup(None, button, None, button, 0, Gtk.get_current_event_time())
示例13: popup_menu
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def popup_menu(self, event=None):
'''This method actually pops up the menu.
@param event: the gdk event that triggered this action
@implementation: can be overloaded, e.g. to populate the menu
dynamically.
'''
if not self.get_property('sensitive'):
return
if event: # we came from button-press-event or similar
button = event.button
time = event.time
if self.button.get_active():
return
else:
button = 0
time = Gtk.get_current_event_time()
self.button.handler_block(self._clicked_signal)
self.button.set_active(True)
self.button.handler_unblock(self._clicked_signal)
self.menu.connect('deactivate', self._deactivate_menu)
self.menu.show_all()
self.menu.set_property('rect_anchor_dx', -1) # This is needed to line up menu with borderless button
self.menu.popup_at_widget(self, Gdk.Gravity.NORTH_WEST, Gdk.Gravity.SOUTH_WEST, event)
示例14: _on_clicked
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def _on_clicked(self, button):
self._menu.popup(None, None, None, None, 0, Gtk.get_current_event_time())
示例15: _create_toolitems
# 需要导入模块: from gi.repository import Gtk [as 别名]
# 或者: from gi.repository.Gtk import get_current_event_time [as 别名]
def _create_toolitems(self):
iconSize = Gtk.IconSize.SMALL_TOOLBAR
for text, tooltip_text, image_num, callback, callback_arg, scroll \
in self.toolitems:
if text is None:
self.insert( Gtk.SeparatorToolItem(), -1 )
continue
image = Gtk.Image()
image.set_from_stock(image_num, iconSize)
tbutton = Gtk.ToolButton()
tbutton.set_label(text)
tbutton.set_icon_widget(image)
self.insert(tbutton, -1)
if callback_arg:
tbutton.connect('clicked', getattr(self, callback),
callback_arg)
else:
tbutton.connect('clicked', getattr(self, callback))
if scroll:
tbutton.connect('scroll_event', getattr(self, callback))
tbutton.set_tooltip_text(tooltip_text)
# Axes toolitem, is empty at start, update() adds a menu if >=2 axes
self.axes_toolitem = Gtk.ToolItem()
self.insert(self.axes_toolitem, 0)
self.axes_toolitem.set_tooltip_text(
'Select axes that controls affect')
align = Gtk.Alignment (xalign=0.5, yalign=0.5, xscale=0.0, yscale=0.0)
self.axes_toolitem.add(align)
self.menubutton = Gtk.Button ("Axes")
align.add (self.menubutton)
def position_menu (menu):
"""Function for positioning a popup menu.
Place menu below the menu button, but ensure it does not go off
the bottom of the screen.
The default is to popup menu at current mouse position
"""
x0, y0 = self.window.get_origin()
x1, y1, m = self.window.get_pointer()
x2, y2 = self.menubutton.get_pointer()
sc_h = self.get_screen().get_height()
w, h = menu.size_request()
x = x0 + x1 - x2
y = y0 + y1 - y2 + self.menubutton.allocation.height
y = min(y, sc_h - h)
return x, y, True
def button_clicked (button, data=None):
self.axismenu.popup (None, None, position_menu, 0,
Gtk.get_current_event_time())
self.menubutton.connect ("clicked", button_clicked)