本文整理汇总了Python中label.Label.set_size_request方法的典型用法代码示例。如果您正苦于以下问题:Python Label.set_size_request方法的具体用法?Python Label.set_size_request怎么用?Python Label.set_size_request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类label.Label
的用法示例。
在下文中一共展示了Label.set_size_request方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ComboBox
# 需要导入模块: from label import Label [as 别名]
# 或者: from label.Label import set_size_request [as 别名]
class ComboBox(gtk.VBox):
'''
ComboBox class.
@undocumented: set_size_request
@undocumented: auto_set_size
@undocumented: on_drop_button_press
@undocumented: on_combo_single_click
@undocumented: on_focus_in_combo
@undocumented: on_focus_out_combo
@undocumented: items
@undocumented: on_expose_combo_frame
'''
__gsignals__ = {
"item-selected" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (str, gobject.TYPE_PYOBJECT, int,)),
"key-release" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (str, gobject.TYPE_PYOBJECT, int,)),
}
def __init__(self,
items=[],
droplist_height=None,
select_index=0,
max_width=None,
fixed_width=None,
min_width = 120,
min_height = 100,
editable=False,
):
'''
Initialize ComboBox class.
@param items: Init item list, default is empty list.
@param droplist_height: The height of droplist, default is None that droplist's height will calculate with items' height automatically.
@param select_index: Init index of selected item, default is 0.
@param max_width: Maximum width of combobox, default is None.
@param fixed_width: Fixed width of combobox, after you set this value combobox won't care the width of droplist and items, default is None.
@param min_width: Minimum width of combobox, default is 120 pixels.
@param min_height: Minimum height of combobox, default is 100 pixels.
@param editable: Set True to make combobox can edit, default is False.
'''
gtk.VBox.__init__(self)
self.set_can_focus(True)
# Init variables.
self.focus_flag = False
self.select_index = select_index
self.editable = editable
if self.editable:
self.padding_x = 0
else:
self.padding_x = 5
self.combo_list = ComboList(min_width=min_width,
max_width=max_width,
fixed_width=fixed_width,
min_height=min_height,
max_height=droplist_height)
self.drop_button = DisableButton(
(ui_theme.get_pixbuf("combo/dropbutton_normal.png"),
ui_theme.get_pixbuf("combo/dropbutton_hover.png"),
ui_theme.get_pixbuf("combo/dropbutton_press.png"),
ui_theme.get_pixbuf("combo/dropbutton_disable.png")),
)
self.drop_button_width = ui_theme.get_pixbuf("combo/dropbutton_normal.png").get_pixbuf().get_width()
self.panel_align = gtk.Alignment()
self.panel_align.set(0.5, 0.5, 0.0, 0.0)
if self.editable:
self.label = Entry()
else:
self.label = Label("", enable_select=False, enable_double_click=False)
self.label.connect("button-press-event", self.on_drop_button_press)
self.panel_align.set_padding(0, 0, self.padding_x, 0)
self.panel_align.add(self.label)
# Init items.
self.add_items(items)
# set selected index
if len(items) > 0:
self.set_select_index(select_index)
hbox = gtk.HBox()
hbox.pack_start(self.panel_align, True, False)
hbox.pack_start(self.drop_button, False, False)
box_align = gtk.Alignment()
box_align.set(0.5, 0.5, 0.0, 0.0)
box_align.add(hbox)
self.add(box_align)
# Connect signals.
box_align.connect("expose-event", self.on_expose_combo_frame)
self.drop_button.connect("button-press-event", self.on_drop_button_press)
self.connect("focus-in-event", self.on_focus_in_combo)
self.connect("focus-out-event", self.on_focus_out_combo)
self.combo_list.treeview.connect("button-press-item", self.on_combo_single_click)
#.........这里部分代码省略.........
示例2: TimeSpinBox
# 需要导入模块: from label import Label [as 别名]
# 或者: from label.Label import set_size_request [as 别名]
#.........这里部分代码省略.........
(self.time_comma_width, text_comma_height) = get_content_size(" : ")
if event.x < self.padding_x + self.time_width:
self.set_time = self.SET_HOUR
return
if event.x > self.padding_x + self.time_width and event.x < self.padding_x + (self.time_width + self.time_comma_width) * 2:
self.set_time = self.SET_MIN
return
if event.x > self.padding_x + self.time_width + self.time_comma_width * 2:
self.set_time = self.SET_SEC
return
def value_changed(self):
'''
Emit `value-changed` signal.
'''
if self.__24hour:
self.emit("value-changed", self.hour_value, self.min_value, self.sec_value)
else:
if time.localtime().tm_hour <= 12:
self.emit("value-changed", self.hour_value, self.min_value, self.sec_value)
else:
self.emit("value-changed", self.hour_value + 12, self.min_value, self.sec_value)
def size_change_cb(self, widget, rect):
'''
Internal callback for `size-allocate` signal.
'''
if rect.width > self.width:
self.width = rect.width
self.set_size_request(self.width, self.height)
self.time_label.set_size_request(self.width - self.arrow_button_width, self.height - 2)
def press_increase_button(self, widget, event):
'''
Internal callback when user press increase arrow.
'''
if self.set_time == self.SET_HOUR:
self.__pressed_button = True
self.hour_value += 1
if self.__24hour:
if self.hour_value >= 24:
self.hour_value = 0
else:
if self.hour_value >= 12:
self.hour_value = 1
elif self.set_time == self.SET_MIN:
self.__pressed_button = True
self.min_value += 1
if self.min_value >= 60:
self.min_value = 0
elif self.set_time == self.SET_SEC:
self.__pressed_button = True
self.sec_value += 1
if self.sec_value >= 60:
self.sec_value = 0
else:
pass
self.value_changed()
self.queue_draw()
def press_decrease_button(self, widget, event):