当前位置: 首页>>代码示例>>Python>>正文


Python Label.set_fixed_width方法代码示例

本文整理汇总了Python中label.Label.set_fixed_width方法的典型用法代码示例。如果您正苦于以下问题:Python Label.set_fixed_width方法的具体用法?Python Label.set_fixed_width怎么用?Python Label.set_fixed_width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在label.Label的用法示例。


在下文中一共展示了Label.set_fixed_width方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ComboBox

# 需要导入模块: from label import Label [as 别名]
# 或者: from label.Label import set_fixed_width [as 别名]

#.........这里部分代码省略.........
        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)

    def set_size_request(self, width, height):
        pass

    def auto_set_size(self):
        valid_width = self.combo_list.get_adjust_width()
        remained_width = valid_width - self.drop_button_width - self.padding_x
        if self.editable:
            self.label.set_size_request(remained_width, -1)
        else:
            self.label.set_fixed_width(remained_width)
        self.combo_list.auto_set_size()

    def add_items(self,
                  items,
                  select_index=0,
                  pos=None,
                  clear_first=True,
                  ):
        '''
        Add items with given index.

        @param items: Item list that need add is combo box.
        @param select_index: The index of select item, default is 0.
        @param pos: Position to insert, except you specified index, items will insert at end by default.
        @param clear_first: Whether clear existing items before insert anymore, default is True.
        '''
        # Init combo widgets.
        if clear_first:
            self.combo_list.treeview.clear()
        combo_items = [ComboTextItem(item[0], item[1]) for item in items]
        self.combo_list.treeview.add_items(combo_items, insert_pos=pos)
        self.auto_set_size()
        self.set_select_index(select_index)

    def on_drop_button_press(self, widget, event):

        self.combo_list.hover_select_item()
        height = self.allocation.height
        x, y = self.window.get_root_origin()

        if self.combo_list.get_visible():
            self.combo_list.hide()
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:70,代码来源:combo.py


注:本文中的label.Label.set_fixed_width方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。