本文整理汇总了Python中entry.Entry.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.connect方法的具体用法?Python Entry.connect怎么用?Python Entry.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类entry.Entry
的用法示例。
在下文中一共展示了Entry.connect方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: double_click
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import connect [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 connect [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 connect [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 connect [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 connect [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 connect [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
示例7: SpinBox
# 需要导入模块: from entry import Entry [as 别名]
# 或者: from entry.Entry import connect [as 别名]
class SpinBox(gtk.VBox):
'''
SpinBox.
@undocumented: set_sensitive
@undocumented: size_change_cb
@undocumented: press_increase_button
@undocumented: press_decrease_button
@undocumented: handle_key_release
@undocumented: stop_update_value
@undocumented: increase_value
@undocumented: decrease_value
@undocumented: adjust_value
@undocumented: update
@undocumented: update_and_emit
@undocumented: expose_spin_bg
@undocumented: create_simple_button
'''
__gsignals__ = {
"value-changed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
"key-release" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_INT,)),
}
def __init__(self,
value=0,
lower=0,
upper=100,
step=10,
default_width=55,
check_text=is_float,
):
'''
Initialize SpinBox class.
@param value: Initialize value, default is 0.
@param lower: Lower value, default is 0.
@param upper: Upper value, default is 100.
@param step: Step value, default is 10.
@param default_width: Default with, default is 55 pixel.
@param check_text: The check function, default is is_float to check value is float.
'''
gtk.VBox.__init__(self)
self.current_value = value
self.lower_value = lower
self.upper_value = upper
self.step_value = step
self.update_delay = 100 # milliseconds
self.increase_value_id = None
self.decrease_value_id = None
# Init.
self.default_width = default_width
self.default_height = 22
self.arrow_button_width = 19
self.background_color = ui_theme.get_alpha_color("text_entry_background")
self.acme_color = ui_theme.get_alpha_color("text_entry_acme")
self.point_color = ui_theme.get_alpha_color("text_entry_point")
self.frame_point_color = ui_theme.get_alpha_color("text_entry_frame_point")
self.frame_color = ui_theme.get_alpha_color("text_entry_frame")
# Widget.
arrow_up_button = self.create_simple_button("up", self.press_increase_button)
arrow_down_button = self.create_simple_button("down", self.press_decrease_button)
button_box = gtk.VBox()
button_box.pack_start(arrow_up_button, False, False)
button_box.pack_start(arrow_down_button, False, False)
self.value_entry = Entry(str(value))
self.value_entry.check_text = check_text
self.value_entry.connect("press-return", lambda entry: self.update_and_emit(int(entry.get_text())))
self.main_align = gtk.Alignment()
self.main_align.set(0.5, 0.5, 0, 0)
hbox = gtk.HBox()
hbox.pack_start(self.value_entry, False, False)
hbox.pack_start(button_box, False, False)
hbox_align = gtk.Alignment()
hbox_align.set(0.5, 0.5, 1.0, 1.0)
hbox_align.set_padding(0, 1, 0, 0)
hbox_align.add(hbox)
self.main_align.add(hbox_align)
self.pack_start(self.main_align, False, False)
# Signals.
self.connect("size-allocate", self.size_change_cb)
self.main_align.connect("expose-event", self.expose_spin_bg)
def set_sensitive(self, sensitive):
'''
Internal function to wrap `set_sensitive`.
'''
super(SpinBox, self).set_sensitive(sensitive)
self.value_entry.set_sensitive(sensitive)
def get_value(self):
'''
Get current value.
@return: Return current value.
'''
#.........这里部分代码省略.........