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


Python Button.set_label方法代码示例

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


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

示例1: FootBox

# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_label [as 别名]
class FootBox(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)

        self.set_size_request(-1, 35)

        self.apply_method = None
        self.init_ui()

        self.timer = Timer(3000, self.__clear_tips)

        Dispatcher.connect("button-change", self.set_button)
        Dispatcher.connect("set-tip", self.set_tip)

        event_manager.add_callback("update-delete-button", self.__on_update_delete_button)

    def __on_update_delete_button(self, name, obj, data):
        #self.btn_delete.set_child_visible(data)
        self.queue_draw()

    def expose_line(self, widget, event):
        cr = widget.window.cairo_create()
        rect = widget.allocation
        style.draw_out_line(cr, rect)

    def init_ui(self):
        self.tip_align = gtk.Alignment(0, 0.5, 0, 1)
        self.tip = Label("",
                         text_x_align=pango.ALIGN_CENTER,
                         label_width=500)
        self.tip_align.set_padding(5, 5, 20, 0)
        self.tip_align.add(self.tip)


        self.btn_delete = Button(_("Delete"))
        self.btn_delete.connect("clicked", self.delete_click)
        self.btn_delete.set_no_show_all(True)
        self.btn_save = Button()
        self.btn_save.connect("clicked", self.button_click)

        button_box = gtk.HBox(spacing=10)
        button_box.pack_start(self.btn_delete)
        button_box.pack_start(self.btn_save)

        self.buttons_align = gtk.Alignment(1, 0.5, 0, 0)
        self.buttons_align.set_padding(0, 0, 0, 10)
        self.buttons_align.add(button_box)
        self.pack(self, [self.tip_align], True, True)
        self.pack_end(self.buttons_align, False, False)
    
    def pack(self, parent, widgets, expand=False, fill=False):
        for widget in widgets:
            parent.pack_start(widget, expand, fill)

    def set_lock(self, state):
        self.__setting_module.set_lock(state)

    def get_lock(self):
        return self.__setting_module.get_lock()

    def set_button(self, widget, content, state):
        self.btn_save.set_label(_("Save"))
        self.btn_save.set_sensitive(state)

    def delete_click(self, widget):
        if self.focus_connection:
            Dispatcher.delete_setting(self.focus_connection)
            Dispatcher.to_main_page()

    def show_delete(self, connection):
        self.btn_delete.show()
        self.focus_connection = connection

    def hide_delete(self):
        self.btn_delete.hide()
        self.focus_connection = None
            

        #if content == "save":
            #if state and not self.get_lock():
                #Dispatcher.emit("setting-saved")
            #else:
                #self.btn_save.set_label(_("connect"))
                #self.btn_save.set_sensitive(False)
        #else:
            #self.btn_save.set_label(_("connect"))
            #self.btn_save.set_sensitive(True)

    def get_button(self):
        return self.__setting_module.get_button_state()

    def set_setting(self, module):
        self.__setting_module = module

    def button_click(self, widget):
        #if self.btn_save.label == "save":
        Dispatcher.emit("setting-saved")
        #elif self.btn_save.label == _("connect"):
            #Dispatcher.set_tip("setting saved")
            #Dispatcher.emit("setting-appled")
#.........这里部分代码省略.........
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:103,代码来源:foot_box_ui.py

示例2: DetailPage

# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_label [as 别名]
class DetailPage(gtk.VBox):
    """
    class docs
    """

    def __init__(self):
        """
        init docs
        """
        gtk.VBox.__init__(self)

        self.__background_settings = deepin_gsettings.new("com.deepin.dde.background")

        self.draw_title_background = self.draw_tab_title_background
        self.theme = None

        self.wallpaper_box = gtk.VBox()
        self.window_theme_box = gtk.VBox()
        self.wallpaper_view = WallpaperView(padding_x=30, padding_y=ITEM_PADDING_Y)
        self.wallpaper_view_sw = self.wallpaper_view.get_scrolled_window()
        self.wallpaper_view_sw.set_size_request(-1, 426)

        position_group, self.position_combobox = get_combo_group(
            _("Position"), DRAW_COMBO_ITEM, self.on_position_combox_selected
        )
        time_group, self.time_combobox = get_combo_group(_("Duration"), TIME_COMBO_ITEM, self.on_time_combox_selected)

        self.__is_random = True
        if self.__background_settings.get_int("background-duration") == 0:
            self.__is_random = False
        self.unorder_play, self.random_toggle = get_toggle_group(
            _("Random"), self.__on_random_toggled, self.__is_random
        )
        self.button_align = gtk.Alignment()
        self.button_box = gtk.HBox(spacing=5)
        self.select_all_button = Button(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)
        self.select_all_button.connect("clicked", self.__on_select_all)
        self.delete_button = Button(_("Delete"))
        self.delete_button.set_size_request(80, WIDGET_HEIGHT)
        self.delete_button.connect("clicked", self.__on_delete)
        self.button_box.pack_start(self.select_all_button, False, False)
        self.button_box.pack_start(self.delete_button, False, False)
        self.button_align.add(self.button_box)

        self.action_bar = gtk.HBox(spacing=26)
        self.action_bar.pack_start(position_group, False, False)
        self.action_bar.pack_start(time_group, False, False)
        self.action_bar.pack_start(self.unorder_play, False, False)
        self.action_bar.pack_end(self.button_align, False, False)
        action_bar_align = gtk.Alignment()
        action_bar_align.set_size_request(-1, STATUS_HEIGHT)
        action_bar_align.set_padding(5, 5, 50, 20)
        action_bar_align.add(self.action_bar)

        self.wallpaper_box.pack_start(self.wallpaper_view_sw, True, True)
        self.wallpaper_box.pack_start(action_bar_align, False, False)

        self.pack_start(self.wallpaper_box, False, False)

        event_manager.add_callback("select-wallpaper", self.on_wallpaper_select)
        event_manager.add_callback("apply-wallpaper", self.__on_wallpaper_apply)
        event_manager.add_callback("add-wallpapers", self.__on_add_wallpapers)

    def __random_enable(self):
        self.time_combobox.set_sensitive(True)
        self.unorder_play.set_child_visible(True)
        self.random_toggle.set_child_visible(True)
        self.random_toggle.set_active(self.theme.get_background_random_mode())

    def __random_disable(self):
        self.time_combobox.set_sensitive(False)
        self.unorder_play.set_child_visible(False)
        self.random_toggle.set_child_visible(False)
        self.random_toggle.set_active(self.theme.get_background_random_mode())

    def on_wallpaper_select(self, name, obj, select_item):
        if self.wallpaper_view.is_randomable():
            self.__random_enable()
        else:
            self.__random_disable()

        if self.wallpaper_view.is_select_all():
            self.select_all_button.set_label(_("Clear all"))
        else:
            self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

    def __on_wallpaper_apply(self, name, obj, select_item):
        self.__random_disable()

        if self.wallpaper_view.is_select_all():
            self.select_all_button.set_label(_("Clear all"))
        else:
            self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

    def __on_select_all(self, widget):
        self.wallpaper_view.select_all()
        if self.wallpaper_view.is_select_all():
#.........这里部分代码省略.........
开发者ID:martyr-deepin,项目名称:deepin-system-settings,代码行数:103,代码来源:detail_page.py

示例3: DeletePage

# 需要导入模块: from dtk.ui.button import Button [as 别名]
# 或者: from dtk.ui.button.Button import set_label [as 别名]
class DeletePage(gtk.VBox):
    '''
    class docs
    '''
	
    def __init__(self):
        '''
        init docs
        '''
        gtk.VBox.__init__(self)

        self.draw_title_background = self.draw_tab_title_background
        self.theme = None
        
        self.delete_view = DeleteView(padding_x=30, padding_y=ITEM_PADDING_Y)
        self.delete_view_sw = self.delete_view.get_scrolled_window()
        
        self.action_align = gtk.Alignment()
        self.action_align.set_padding(5, 5, 510, 5)
        self.action_box = gtk.HBox(spacing = 10)
        self.back_button = Button(_("Back"))
        self.back_button.set_size_request(80, WIDGET_HEIGHT)
        self.back_button.connect("clicked", self.__on_back)
        self.select_all_button = Button(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)
        self.select_all_button.connect("clicked", self.__on_select_all)
        self.delete_button = Button(_("Delete"))
        self.delete_button.set_size_request(80, WIDGET_HEIGHT)
        self.delete_button.connect("clicked", self.__on_delete)
        self.action_box.pack_start(self.select_all_button, False, False)
        self.action_box.pack_start(self.delete_button, False, False)
        self.action_box.pack_start(self.back_button, False, False)
        self.action_align.add(self.action_box)
        
        self.pack_start(self.delete_view_sw, True, True)
        self.pack_start(self.action_align, False, False)

        event_manager.add_callback("select-delete-wallpaper", self.__on_select_delete_wallpaper)

    def __on_back(self, widget):
        event_manager.emit("back-to-detailpage", self.theme)

    def __on_select_delete_wallpaper(self, name, obj, select_item):
        if self.delete_view.is_select_all():                                    
            self.select_all_button.set_label(_("Clear all"))                 
        else:                                                                   
            self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

    def __on_select_all(self, widget):
        self.delete_view.select_all()
        if self.delete_view.is_select_all():
            self.select_all_button.set_label(_("Clear all"))
        else:
            self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)

    def __delete_confirm(self):
        self.delete_view.delete_wallpaper()

    def __on_delete(self, widget):
        if self.delete_view.is_deletable():
            dlg = ConfirmDialog(_("Delete Wallpaper"),                                  
                                _("Are you sure delete wallpaper?"), 
                                300,                                                
                                100,                                                
                                lambda : self.__delete_confirm(),                   
                                None,                                               
                                True, 
                                CONTENT_FONT_SIZE)                                               
            dlg.show_all()

    def draw_tab_title_background(self, cr, widget):
        rect = widget.allocation
        cr.set_source_rgb(1, 1, 1)    
        cr.rectangle(0, 0, rect.width, rect.height - 1)
        cr.fill()

    def set_theme(self, theme):
        self.theme = theme
        self.delete_view.set_theme(self.theme)
        self.select_all_button.set_label(_("Select all"))
        self.select_all_button.set_size_request(80, WIDGET_HEIGHT)
        
    def draw_mask(self, cr, x, y, w, h):
        '''
        Draw mask interface.
        
        @param cr: Cairo context.
        @param x: X coordiante of draw area.
        @param y: Y coordiante of draw area.
        @param w: Width of draw area.
        @param h: Height of draw area.
        '''
        cr.set_source_rgb(1, 1, 1)
        cr.rectangle(x, y, w, h)
        cr.fill()
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:99,代码来源:delete_page.py


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