本文整理汇总了Python中entry.Entry.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.destroy方法的具体用法?Python Entry.destroy怎么用?Python Entry.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry.Entry
的用法示例。
在下文中一共展示了Entry.destroy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WindowActivatable
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import destroy [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)
示例2: __init__
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import destroy [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)
示例3: CommanderWindowActivatable
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import destroy [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))