本文整理汇总了Python中higwidgets.higbuttons.HIGButton.set_focus_on_click方法的典型用法代码示例。如果您正苦于以下问题:Python HIGButton.set_focus_on_click方法的具体用法?Python HIGButton.set_focus_on_click怎么用?Python HIGButton.set_focus_on_click使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类higwidgets.higbuttons.HIGButton
的用法示例。
在下文中一共展示了HIGButton.set_focus_on_click方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HIGClosableTabLabel
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import set_focus_on_click [as 别名]
class HIGClosableTabLabel(HIGHBox):
__gsignals__ = { 'close-clicked' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, ()) }
def __init__(self, label_text=""):
gobject.GObject.__init__(self)
#HIGHBox.__init__(self, spacing=4)
self.label_text = label_text
self.__create_widgets()
#self.propery_map = {"label_text" : self.label.get_label}
def __create_widgets(self):
self.label = HIGAnimatedLabel(self.label_text)
self.close_image = gtk.Image()
self.close_image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
self.close_button = HIGButton()
self.close_button.set_size_request(22, 22)
self.close_button.set_relief(gtk.RELIEF_NONE)
self.close_button.set_focus_on_click(False)
self.close_button.add(self.close_image)
self.ok_image = gtk.Image()
self.ok_image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_BUTTON)
self.ok_button = HIGButton()
self.ok_button.set_size_request(22, 22)
self.ok_button.set_relief(gtk.RELIEF_NONE)
self.ok_button.set_focus_on_click(False)
self.ok_button.add(self.ok_image)
self.close_button.connect('clicked', self.__close_button_clicked)
self.ok_button.connect('clicked', self.__ok_button_clicked)
self.label.connect('button-press-event', self.on_button_press_event)
self.label.entry.connect('focus-out-event', self.on_entry_focus_out)
for w in (self.label, self.close_button, self.ok_button):
self.pack_start(w, False, False, 0)
self.show_all()
self.switch_button_mode(False) # Change to label mode
# def do_get_property(self, property):
# func = self.property_map.get(property, None)
# if func:
# return func()
# else:
# raise
def on_entry_focus_out(self, widget, event):
self.switch_button_mode(False)
def on_button_press_event(self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS:
self.switch_button_mode(True)
def switch_button_mode(self, mode):
"""Switch button from editing mode (True) to label mode (False)
"""
if mode:
self.close_button.hide()
self.ok_button.show()
else:
self.ok_button.hide()
self.close_button.show()
def __close_button_clicked(self, widget):
self.emit('close-clicked')
def __ok_button_clicked(self, widget):
self.label.on_entry_activated(self.label.entry)
self.switch_button_mode(False)
def get_text(self):
return self.label.get_text()
def set_text(self, text):
self.label.set_text(text)
def get_label(self):
return self.label.get_label()
def set_label(self, label):
self.label.set_text(label)
def get_animated_label(self):
return self.label
示例2: HIGClosableTabLabel
# 需要导入模块: from higwidgets.higbuttons import HIGButton [as 别名]
# 或者: from higwidgets.higbuttons.HIGButton import set_focus_on_click [as 别名]
class HIGClosableTabLabel(HIGHBox):
__gsignals__ = { 'close-clicked' : (gobject.SIGNAL_RUN_LAST,
gobject.TYPE_NONE, ()) }
def __init__(self, label_text=""):
gobject.GObject.__init__(self)
#HIGHBox.__init__(self, spacing=4)
self.label_text = label_text
self.__create_widgets()
#self.propery_map = {"label_text" : self.label.get_label}
def __create_widgets(self):
self.label = HIGAnimatedLabel(self.label_text)
self.editing = False
self.image = gtk.image_new_from_stock(gtk.STOCK_CLOSE,
gtk.ICON_SIZE_MENU)
self.button = HIGButton()
self.button.set_relief(gtk.RELIEF_NONE)
self.button.set_focus_on_click(False)
self.button.add(self.image)
self.button.set_name('tabNotebookButton')
self.button.connect('clicked', self.__on_button_clicked)
self.button.connect('style-set', self.__on_button_style_set)
self.label.connect('button-press-event', self.on_button_press_event)
self.label.entry.connect('focus-out-event', self.on_entry_focus_out)
self.pack_start(self.label, False, False, 0)
self.pack_end(self.button, False, False, 0)
self.show_all()
self.switch_button_mode(False)
def on_entry_focus_out(self, widget, event):
self.switch_button_mode(False)
def on_button_press_event(self, widget, event):
if event.type == gtk.gdk._2BUTTON_PRESS:
self.switch_button_mode(True)
def switch_button_mode(self, mode):
"""Switch button from editing mode (True) to label mode (False)
"""
if mode:
self.image.set_from_stock(gtk.STOCK_APPLY, gtk.ICON_SIZE_MENU)
else:
self.image.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU)
self.editing = mode
parent = self.get_parent()
if parent:
parent.queue_draw()
def __on_button_clicked(self, widget):
if self.editing:
self.label.on_entry_activated(self.label.entry)
self.switch_button_mode(False)
else:
self.emit('close-clicked')
def __on_button_style_set(self, widget, prev_style):
w, h = gtk.icon_size_lookup_for_settings(self.image.get_settings(),
gtk.ICON_SIZE_MENU)
self.image.set_size_request(w, h)
def get_text(self):
return self.label.get_text()
def set_text(self, text):
self.label.set_text(text)
def get_label(self):
return self.label.get_label()
def set_label(self, label):
self.label.set_text(label)
def get_animated_label(self):
return self.label