本文整理汇总了Python中entry.Entry.grab_focus方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.grab_focus方法的具体用法?Python Entry.grab_focus怎么用?Python Entry.grab_focus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry.Entry
的用法示例。
在下文中一共展示了Entry.grab_focus方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: double_click
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import grab_focus [as 别名]
def double_click(self, widget, item, column):
print "DEBUG double_click"
if not column == item.ENTRY_COLUMN:
return
if item.entry:
item.entry.grab_focus()
return
item.entry_buffer.set_property('cursor-visible', True)
hbox = gtk.HBox(False)
align = gtk.Alignment(0, 0, 1, 1)
entry = Entry()
entry.set_data("item", item)
entry.set_data("button_press", False)
entry.set_buffer(item.entry_buffer)
entry.set_size_request(item.get_column_widths()[column]-4, 0)
entry.connect("press-return", lambda w: hbox.destroy())
entry.connect("destroy", self.edit_done, hbox, item)
entry.connect_after("focus-in-event", self.entry_focus_changed, item)
entry.connect_after("focus-out-event", self.entry_focus_changed, item)
self.pack_start(hbox, False, False)
self.set_data("entry_widget", entry)
hbox.pack_start(entry, False, False)
hbox.pack_start(align)
hbox.show_all()
entry.set_can_focus(True)
entry.grab_focus()
entry.select_all()
item.entry = entry
示例2: __init__
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import grab_focus [as 别名]
class WindowHelper:
def __init__(self, plugin, window):
self._window = window
self._plugin = plugin
self._entry = None
self._accel = gtk.AccelGroup()
self._accel.connect_group(gtk.keysyms.C, gtk.gdk.SUPER_MASK, 0, self._do_command)
self._window.add_accel_group(self._accel)
def deactivate(self):
self._window.remove_accel_group(self._accel)
self._window = None
self._plugin = None
def update_ui(self):
pass
def _do_command(self, group, obj, keyval, mod):
view = self._window.get_active_view()
if not view:
return False
if not self._entry:
self._entry = Entry(self._window.get_active_view())
self._entry.connect('destroy', self.on_entry_destroy)
self._entry.grab_focus()
return True
def on_entry_destroy(self, widget):
self._entry = None
示例3: WindowActivatable
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import grab_focus [as 别名]
class WindowActivatable(GObject.Object, Gedit.WindowActivatable):
__gtype_name__ = "CommanderWindowActivatable"
window = GObject.property(type=Gedit.Window)
def __init__(self):
GObject.Object.__init__(self)
def do_activate(self):
self._entry = None
self._view = None
self.install_ui()
def do_deactivate(self):
self.uninstall_ui()
def do_update_state(self):
pass
def install_ui(self):
manager = self.window.get_ui_manager()
self._action_group = Gtk.ActionGroup("GeditCommanderPluginActions")
self._action_group.add_toggle_actions([('CommanderModeAction', None,
_('Commander Mode'), '<Ctrl>period',
_('Start commander mode'), self.on_commander_mode)])
manager.insert_action_group(self._action_group, -1)
self._merge_id = manager.add_ui_from_string(ui_str)
def uninstall_ui(self):
manager = self.window.get_ui_manager()
manager.remove_ui(self._merge_id)
manager.remove_action_group(self._action_group)
manager.ensure_update()
def on_commander_mode(self, action, user_data=None):
view = self.window.get_active_view()
if not view:
return False
if action.get_active():
if not self._entry or view != self._view:
self._entry = Entry(view)
self._entry.connect('destroy', self.on_entry_destroy)
self._entry.grab_focus()
self._view = view
elif self._entry:
self._entry.destroy()
self._view = None
return True
def on_entry_destroy(self, widget, user_data=None):
self._entry = None
self._action_group.get_action('CommanderModeAction').set_active(False)
示例4: __init__
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import grab_focus [as 别名]
class WindowHelper:
def __init__(self, plugin, window):
self._window = window
self._plugin = plugin
self._entry = None
self._view = None
self.install_ui()
def install_ui(self):
manager = self._window.get_ui_manager()
self._action_group = gtk.ActionGroup("PlumaCommanderPluginActions")
self._action_group.add_toggle_actions([('CommanderModeAction', None, _('Commander Mode'), '<Ctrl>period', _('Start commander mode'), self.on_commander_mode)])
manager.insert_action_group(self._action_group, -1)
self._merge_id = manager.add_ui_from_string(ui_str)
def uninstall_ui(self):
manager = self._window.get_ui_manager()
manager.remove_ui(self._merge_id)
manager.remove_action_group(self._action_group)
manager.ensure_update()
def deactivate(self):
self.uninstall_ui()
self._window = None
self._plugin = None
def update_ui(self):
pass
def on_commander_mode(self, action):
view = self._window.get_active_view()
if not view:
return False
if action.get_active():
if not self._entry or view != self._view:
self._entry = Entry(view)
self._entry.connect('destroy', self.on_entry_destroy)
self._entry.grab_focus()
self._view = view
elif self._entry:
self._entry.destroy()
self._view = None
return True
def on_entry_destroy(self, widget):
self._entry = None
self._action_group.get_action('CommanderModeAction').set_active(False)
示例5: CommanderWindowActivatable
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import grab_focus [as 别名]
class CommanderWindowActivatable(GObject.Object, Gedit.WindowActivatable):
window = GObject.property(type=Gedit.Window)
def __init__(self):
GObject.Object.__init__(self)
def do_activate(self):
self._entry = None
self._view = None
action = Gio.SimpleAction.new_stateful("commander", None, GLib.Variant.new_boolean(False))
action.connect('activate', self.activate_toggle)
action.connect('change-state', self.commander_mode)
self.window.add_action(action)
def do_deactivate(self):
self.window.remove_action("commander")
def do_update_state(self):
pass
def activate_toggle(self, action, parameter):
state = action.get_state()
action.change_state(GLib.Variant.new_boolean(not state.get_boolean()))
def commander_mode(self, action, state):
view = self.window.get_active_view()
if not view:
return False
active = state.get_boolean()
if active:
if not self._entry or view != self._view:
self._entry = Entry(view)
self._entry.connect('destroy', self.on_entry_destroy)
self._entry.grab_focus()
self._view = view
elif self._entry:
self._entry.destroy()
self._view = None
action.set_state(GLib.Variant.new_boolean(active))
return True
def on_entry_destroy(self, widget, user_data=None):
self._entry = None
self.window.lookup_action("commander").change_state(GLib.Variant.new_boolean(False))
示例6: __init__
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import grab_focus [as 别名]
class WindowHelper:
def __init__(self, plugin, window):
self._window = window
self._plugin = plugin
self._entry = None
accel_path = '<gedit>/plugins/commander/activate'
accel = gtk.accel_map_lookup_entry(accel_path)
if accel == None:
gtk.accel_map_add_entry(accel_path, gtk.keysyms.period, gtk.gdk.CONTROL_MASK)
self._accel = gtk.AccelGroup()
self._accel.connect_by_path(accel_path, self._do_command)
self._window.add_accel_group(self._accel)
def deactivate(self):
self._window.remove_accel_group(self._accel)
self._window = None
self._plugin = None
def update_ui(self):
pass
def _do_command(self, group, obj, keyval, mod):
view = self._window.get_active_view()
if not view:
return False
if not self._entry:
self._entry = Entry(self._window.get_active_view())
self._entry.connect('destroy', self.on_entry_destroy)
self._entry.grab_focus()
return True
def on_entry_destroy(self, widget):
self._entry = None