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


Python Label.set_sensitive方法代码示例

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


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

示例1: ComboBox

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

#.........这里部分代码省略.........
            (offset_x, offset_y) = widget.translate_coordinates(self, 0, 0)
            (_, px, py, modifier) = widget.get_display().get_pointer()
            droplist_x, droplist_y = px - wx - offset_x - 1, py - wy - offset_y + height - 1
            self.combo_list.show((droplist_x, droplist_y), (0, -height))

    def on_combo_single_click(self, widget, item, column, x, y):
        self.label.set_text(item.title)
        self.combo_list.reset_status()
        if item:
            index = self.combo_list.get_select_index()
            self.combo_list.hide_self()
            self.emit("item-selected", item.title, item.item_value, index)

    def on_focus_in_combo(self, widget, event):
        self.focus_flag = True
        self.queue_draw()

    def on_focus_out_combo(self, widget, event):
        self.focus_flag = False
        self.queue_draw()

    def set_select_index(self, item_index):
        '''
        Set select item with given index.

        @param item_index: The index of selected item.
        '''
        if 0 <= item_index < len(self.items):
            self.combo_list.set_select_index(item_index)
            self.label.set_text(self.items[item_index].title)

    @property
    def items(self):
        return self.combo_list.items

    def get_item_with_index(self, item_index):
        '''
        Get item with given index.

        @param item_index: The index of item that you want get.
        @return: Return item with given index, return None if given index is invalid.
        '''
        if 0 <= item_index < len(self.items):
            item = self.items[item_index]
            return (item.title, item.item_value)
        else:
            return None

    def get_current_item(self):
        '''
        Get current selected item.

        @return: Return current selected item.
        '''
        return self.get_item_with_index(self.get_select_index())

    def get_select_index(self):
        '''
        Get index of select item.

        @return: Return index of selected item.
        '''
        return self.combo_list.get_select_index()

    def set_sensitive(self, sensitive):
        super(ComboBox, self).set_sensitive(sensitive)
        self.label.set_sensitive(sensitive)

    def on_expose_combo_frame(self, widget, event):
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation

        # Draw frame.
        with cairo_disable_antialias(cr):
            cr.set_line_width(1)
            if self.get_sensitive():
                cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("combo_entry_frame").get_color()))
            else:
                cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("disable_frame").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.stroke()

            if self.focus_flag:
                color = (ui_theme.get_color("combo_entry_select_background").get_color(), 0.9)
                cr.set_source_rgba(*alpha_color_hex_to_cairo(color))
                cr.rectangle(rect.x, rect.y, rect.width - 1 - self.drop_button_width, rect.height - 1)
                cr.fill()
                cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_background").get_color(), 0.9)))
                cr.rectangle(rect.x + rect.width - 1 - self.drop_button_width, rect.y, self.drop_button_width, rect.height - 1)
                cr.fill()
            else:
                cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_background").get_color(), 0.9)))
                cr.rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1)
                cr.fill()

        # Propagate expose to children.
        propagate_expose(widget, event)

        return True
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:104,代码来源:combo.py

示例2: ComboBox

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

#.........这里部分代码省略.........
        if len(self.droplist.droplist_items) > 0:
            prev_index = self.droplist.get_prev_index()
            if prev_index != None:
                self.droplist.item_select_index = prev_index
                self.droplist.active_item()
                self.droplist.droplist_items[self.droplist.item_select_index].wrap_droplist_clicked_action()
    
    def select_next_item(self):
        '''Select next item.'''
        if len(self.droplist.droplist_items) > 0:
            next_index = self.droplist.get_next_index()
            if next_index != None:
                self.droplist.item_select_index = next_index
                self.droplist.active_item()
                self.droplist.droplist_items[self.droplist.item_select_index].wrap_droplist_clicked_action()
        
    def key_press_combo(self, widget, event):
        '''Key press combo.'''
        if not self.droplist.get_visible():
            key_name = get_keyevent_name(event)
            if self.keymap.has_key(key_name):
                self.keymap[key_name]()
            
            return True     
        
    def set_select_index(self, item_index):
        '''Set select index.'''
        if 0 <= item_index < len(self.items):
            item = self.items[item_index]
            if item:
                self.select_index = item_index
                self.label.set_text(item[0])
                
    def get_item_with_index(self, item_index):
        '''Get item with index.'''
        if 0 <= item_index < len(self.items):
            return self.items[item_index]                
        else:
            return None
        
    def get_current_item(self):
        '''Get current item.'''
        return self.get_item_with_index(self.select_index)
                
    def key_release_combo(self, widget, event):
        '''Handle key release.'''
        self.emit("key-release", 
                  self.items[self.select_index][0],
                  self.items[self.select_index][1],
                  self.select_index)    
    
    def update_select_content(self, droplist, item_content, item_value, item_index):
        '''Update select content.'''
        self.select_index = item_index
        self.label.set_text(item_content)
        
        self.emit("item-selected", item_content, item_value, item_index)
        
        self.grab_focus()
        
        self.queue_draw()
        
    def set_sensitive(self, sensitive):
        super(ComboBox, self).set_sensitive(sensitive)
        self.label.set_sensitive(sensitive)
        self.dropbutton.set_sensitive(sensitive)
            
    def expose_combobox_frame(self, widget, event):
        '''Expose combo box frame.'''
        # Init.
        cr = widget.window.cairo_create()
        rect = widget.allocation
        
        # Draw frame.
        with cairo_disable_antialias(cr):
            cr.set_line_width(1)
            if self.get_sensitive():
                cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("combo_entry_frame").get_color()))
            else:
                cr.set_source_rgb(*color_hex_to_cairo(ui_theme.get_color("disable_frame").get_color()))
            cr.rectangle(rect.x, rect.y, rect.width, rect.height)
            cr.stroke()
            
            if self.focus_flag:
                cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_select_background").get_color(), 0.9)))
                cr.rectangle(rect.x, rect.y, rect.width - 1 - self.dropbutton_width, rect.height - 1)
                cr.fill()
                
                cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_background").get_color(), 0.9)))
                cr.rectangle(rect.x + rect.width - 1 - self.dropbutton_width, rect.y, self.dropbutton_width, rect.height - 1)
                cr.fill()
            else:
                cr.set_source_rgba(*alpha_color_hex_to_cairo((ui_theme.get_color("combo_entry_background").get_color(), 0.9)))
                cr.rectangle(rect.x, rect.y, rect.width - 1, rect.height - 1)
                cr.fill()
        
        # Propagate expose to children.
        propagate_expose(widget, event)
        
        return True
开发者ID:netphi,项目名称:deepin-ui,代码行数:104,代码来源:combo.py


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