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


Python Label.set_sensitive方法代码示例

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


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

示例1: MirrorsBox

# 需要导入模块: from dtk.ui.label import Label [as 别名]
# 或者: from dtk.ui.label.Label import set_sensitive [as 别名]
class MirrorsBox(BaseBox):
    def __init__(self):
        BaseBox.__init__(self)

        self.current_mirror_item = None

        self.select_best_mirror_button_texts = {
                "normal": _("Select the best mirror"),
                "wait": _("Waiting"),
                "success": _("Successfully")
                }

        self.main_box.pack_start(self.create_mirror_select_table(), True, True)
        self.main_box.pack_start(self.create_source_update_frequency_table(), False, True)
        self.mirror_test_obj = None

        global_event.register_event("mirror-test-finished", self.finish_mirror_test)
        global_event.register_event("cancel-mirror-test", self.cancel_mirror_test)
        global_event.register_event("mirror-backend-changed", self.mirror_changed_handler)

    def create_source_update_frequency_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        dir_title_label = Label(_("Refresh package lists"))

        # auto update check button
        self.is_auto_update_button = CheckButton(label_text=_('Upgrade automatically'))
        self.is_auto_update_button.connect('released', self.change_auto_update)
        self.is_auto_update_button.set_active(utils.is_auto_update())

        self.update_label = Label(_("Time interval: "))
        self.update_spin = SpinBox(int(get_update_interval()), 0, 168, 1)
        self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v))
        self.hour_lablel = Label(_(" hour"))
        self.hour_lablel.set_size_request(50, 12)
        spin_hbox = gtk.HBox(spacing=3)
        spin_hbox.pack_start(self.update_label, False, False)
        spin_hbox.pack_start(self.update_spin, False, False)
        spin_hbox.pack_start(self.hour_lablel, False, False)

        main_table.attach(dir_title_label, 0, 2, 0, 1, yoptions=gtk.FILL)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xoptions=gtk.FILL)
        main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
        return main_table

    def change_auto_update(self, widget, data=None):
        widget_active = widget.get_active()
        self.update_spin.set_sensitive(widget_active)
        self.update_label.set_sensitive(widget_active)
        self.hour_lablel.set_sensitive(widget_active)

        utils.set_auto_update(widget_active)

        daemon_running = is_dbus_name_exists(DSC_UPDATE_DAEMON_NAME)
        if widget_active and not daemon_running:
            dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
            subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
        elif not widget_active and daemon_running:
            session = dbus.SessionBus()
            dbus_obj = session.get_object(DSC_UPDATE_DAEMON_NAME, DSC_UPDATE_DAEMON_PATH)
            iface = dbus.Interface(dbus_obj, DSC_UPDATE_DAEMON_NAME)
            iface.quit()

    def select_best_mirror(self, widget):
        widget.set_label(self.select_best_mirror_button_texts["wait"])
        widget.set_sensitive(False)
        global_event.emit("toggle-waiting-dialog", True)
        utils.ThreadMethod(self.change_to_nearest_mirror_thread, (widget, )).start()

    def cancel_mirror_test(self):
        if self.mirror_test_obj:
            self.mirror_test_obj.cancel()
            self.mirror_test_obj = None
            self.finish_mirror_test("")

    def change_to_nearest_mirror_thread(self, widget):
        from mirror_speed.ip_detect import get_nearest_mirrors
        hostnames = get_nearest_mirrors()
        self.mirror_test_obj = MirrorTest(hostnames)
        hostname = self.mirror_test_obj.run()
        for mirror in self.mirrors_list:
            if mirror.hostname == hostname:
                global_event.emit("mirror-test-finished", mirror)
                break

    def finish_mirror_test(self, mirror):
        for item in self.mirror_view.visible_items:
            if item.mirror == mirror:
                self.mirror_view.visible_item(item)
        self.select_best_mirror_button.set_sensitive(True)
        self.select_best_mirror_button.set_label(self.select_best_mirror_button_texts["normal"])

    def create_mirror_select_table(self):
        main_table = gtk.Table(3, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)

        mirror_select_title = Label(_("Select mirror"))
        self.select_best_mirror_button = Button(self.select_best_mirror_button_texts["normal"])
#.........这里部分代码省略.........
开发者ID:kissthink,项目名称:deepin-store,代码行数:103,代码来源:preference.py

示例2: Form

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

#.........这里部分代码省略.........
            "320 x 240",
            "320 x 480",
            "400 x 240",
            "480 x 800",
            "540 x 960",
            "600 x 1024",
            "640 x 480",
            "720 x 1280",
            "800 x 480",
            "800 x 600",
            "1024 x 600",
            "1024 x 768",
            "1152 x 864",
        ]
        self.ratio_items = []
        for ratio in self.__ratio_list:
            self.ratio_combo.append_text(ratio)
            self.ratio_items.append((ratio, ratio))
        self.ratio_combo.set_active(5)
        # brand_combo.
        brand_items = []
        for brand in self.read_xml.brand_dict.keys():
            brand_po = brand
            if self.brand_dict.has_key(brand):
                brand_po = self.brand_dict[brand]
            brand_items.append((brand_po, brand))

        self.brand_combo.set_items(brand_items, 0)
        # self.brand_combo.add_items(brand_items, 0)

        self.brand_combo.prepend_text(_("No Presets"))
        self.brand_combo.connect("changed", self.brand_combo_item_selected)
        # model_combo.
        self.model_label.set_sensitive(False)
        self.model_combo.set_sensitive(False)
        self.model_combo.prepend_text(_("No Model"))
        self.model_combo.connect("changed", self.model_combo_item_selected)
        #
        self.save_chooser_btn.set_size_request(75, 21)
        self.save_chooser_btn.connect("clicked", self.save_chooser_btn_clicked)

        # path_entry.
        PATH_ENTRY_WIDTH = 240
        PATH_ENTRY_HEIGHT = 22
        self.save_path_entry.set_sensitive(False)
        self.save_path_entry.set_text(self.get_home_path())
        self.save_path_entry.set_size(PATH_ENTRY_WIDTH, PATH_ENTRY_HEIGHT)
        self.close_btn.connect("clicked", lambda w: self.hide_all())
        # higt_set_btn.
        self.higt_set_btn.connect("clicked", self.higt_set_btn_clicked)

        # form body box add main fixed.
        self.body_table_ali = gtk.Alignment()
        self.body_table_ali.set_padding(6, 0, 0, 0)
        self.body_table = gtk.Table(rows=6, columns=4, homogeneous=False)
        self.body_table_ali.add(self.body_table)

        self.brand_model_hbox = gtk.HBox()
        top, bottom = 5, 5
        brand_position = eval(_("('brand_position', 20)"))
        model_position = eval(_("('model_position', 20)"))
        self.brand_hbox_ali, self.brand_hbox = self.create_hbox(
            bottom, top, 15 + int(brand_position[1]), 0, self.brand_label, self.brand_combo
        )
        self.model_hbox_ali, self.model_hbox = self.create_hbox(
            bottom, top, 50 - int(model_position[1]), 0, self.model_label, self.model_combo
开发者ID:martyr-deepin,项目名称:deepin-media-player,代码行数:70,代码来源:gui.py

示例3: DscPreferenceDialog

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

#.........这里部分代码省略.........
        self.update_spin.connect("value-changed", lambda w, v: set_update_interval(v))
        self.hour_lablel = Label(_(" hour"))
        self.hour_lablel.set_size_request(50, 12)
        spin_hbox = gtk.HBox(spacing=3)
        spin_hbox.pack_start(self.update_label, False, False)
        spin_hbox.pack_start(self.update_spin, False, False)
        spin_hbox.pack_start(self.hour_lablel, False, False)

        main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.is_auto_update_button, 0, 1, 2, 3, xpadding=10, xoptions=gtk.FILL)
        main_table.attach(spin_hbox, 1, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)

        if is_auto_update():
            self.is_auto_update_button.set_active(True)
        else:
            self.is_auto_update_button.toggled()

        return main_table

    def create_download_dir_table(self):    
        main_table = gtk.Table(4, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)
        
        dir_title_label = Label(_("Download settings"))
        dir_title_label.set_size_request(200, 12)
        label_align = gtk.Alignment()
        label_align.set_padding(0, 0, 0, 0)
        label_align.add(dir_title_label)

        download_number_label = Label(_('Max download task number: '))
        self.download_number_comobox = ComboBox(
                items = [(str(i+1), i+1) for i in range(10)],
                select_index = int(get_download_number())-1,
                )
        self.download_number_comobox.connect("item-selected", self.download_number_comobox_changed)
        download_number_hbox = gtk.HBox(spacing=5)
        download_number_hbox.pack_start(download_number_label, False, False)
        download_number_hbox.pack_start(self.download_number_comobox, False, False)
        
        change_download_dir_label = Label(_("Download directory: "))
        self.dir_entry = InputEntry()
        self.dir_entry.set_text(get_software_download_dir())
        self.dir_entry.set_editable(False)
        self.dir_entry.set_size(200, 25)
        
        modify_button = Button(_("Change"))
        modify_button.connect("clicked", self.change_download_save_dir)
        download_dir_hbox = gtk.HBox(spacing=5)
        download_dir_hbox.pack_start(change_download_dir_label, False, False)
        download_dir_hbox.pack_start(self.dir_entry, False, False)
        download_dir_hbox.pack_start(modify_button, False, False)
        
        main_table.attach(label_align, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(download_number_hbox, 0, 2, 2, 3, xpadding=10, xoptions=gtk.FILL)
        main_table.attach(download_dir_hbox, 0, 2, 3, 4, xpadding=10, xoptions=gtk.FILL)
        return main_table

    def create_uninstall_box(self):
        main_table = gtk.Table(2, 2)
        main_table.set_row_spacings(CONTENT_ROW_SPACING)
        uninstall_title_label = Label(_("On uninstall software"))
        uninstall_title_label.set_size_request(350, 12)
        
        # mini_check_button

        self.delete_check_button = CheckButton(_("Delete configuration files"))
        self.delete_check_button.set_active(get_purg_flag())
        self.delete_check_button.connect("toggled", lambda w: set_purge_flag(self.delete_check_button.get_active()))
        
        main_table.attach(uninstall_title_label, 0, 2, 0, 1, yoptions=gtk.FILL, xpadding=8)
        main_table.attach(create_separator_box(), 0, 2, 1, 2, yoptions=gtk.FILL)
        main_table.attach(self.delete_check_button, 0, 1, 2, 3, yoptions=gtk.FILL)
        
        return main_table

    def change_download_save_dir(self, widget):
        local_dir = WinDir(False).run()
        if local_dir:
            local_dir = os.path.expanduser(local_dir)
            if local_dir != get_software_download_dir():
                self.dir_entry.set_editable(True)        
                self.dir_entry.set_text(local_dir)
                self.dir_entry.set_editable(False)
                set_software_download_dir(local_dir)
                global_event.emit('download-directory-changed')

    def download_number_comobox_changed(self, widget, name, value, index):
        set_download_number(value)
        global_event.emit('max-download-number-changed', value)

    def change_auto_update(self, widget, data=None):
        self.update_spin.set_sensitive(widget.get_active())
        set_auto_update(widget.get_active())
        self.update_label.set_sensitive(widget.get_active())
        self.hour_lablel.set_sensitive(widget.get_active())
        dsc_daemon_path = os.path.join(get_parent_dir(__file__, 2), 'update_data/apt/dsc-daemon.py')
        if widget.get_active():
            subprocess.Popen(['python', dsc_daemon_path], stderr=subprocess.STDOUT, shell=False)
开发者ID:menghun3,项目名称:deepin-software-center-1,代码行数:104,代码来源:preference.py

示例4: PPPConf

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

#.........这里部分代码省略.........

            self.nopcomp.set_active(nopcomp == None)
            self.noaccomp.set_active(noaccomp == None)
            
            if ipsec_enabled:
                self.ip_sec_enable.set_active(True)

                ipsec_group_name = self.vpn_setting.get_data_item("ipsec-group-name")
                ipsec_gateway_id = self.vpn_setting.get_data_item("ipsec-gateway-id")
                ipsec_psk = self.vpn_setting.get_data_item("ipsec-psk")
                self.group_name.set_text(ipsec_group_name)
                self.gateway_id.set_text(ipsec_gateway_id)
                self.pre_shared_key.set_text(ipsec_psk)

            else:
                self.ip_sec_enable.set_active(False)

        if lcp_echo_failure == None and lcp_echo_interval == None:
            self.ppp_echo.set_active(False)
        else:
            self.ppp_echo.set_active(True)

        self.init_signal()
        self.init_lock = False
        self.require_mppe.emit("toggled")
        self.init_lock = True
        self.init_ui()
        #==================================
        # Connect signal
    def enable_ipsec_cb(self, widget):
        active = widget.get_active()
        if active:
            self.vpn_setting.set_data_item("ipsec-enabled", "yes")
            self.group_name.set_sensitive(True)
            self.gateway_id.set_sensitive(True)
            self.pre_shared_key.set_sensitive(True)

            ipsec_group_name = self.vpn_setting.get_data_item("ipsec-group-name")
            ipsec_gateway_id = self.vpn_setting.get_data_item("ipsec-gateway-id")
            ipsec_psk = self.vpn_setting.get_data_item("ipsec-psk")
            
            #print ipsec_group_name
            self.group_name.set_text(ipsec_group_name)
            self.gateway_id.set_text(ipsec_gateway_id)
            self.pre_shared_key.set_text(ipsec_psk)
            self.init_ui()
        else:
            self.vpn_setting.delete_data_item("ipsec-enabled")
            self.group_name.set_text("")
            self.gateway_id.set_text("")
            self.pre_shared_key.set_text("")

            self.group_name.set_sensitive(False)
            self.gateway_id.set_sensitive(False)
            self.pre_shared_key.set_sensitive(False)
            self.init_ui()

    def entry_focus_out_cb(self, widget, event, key):
        text = widget.get_text()
        if text and key != "name":
            self.vpn_setting.set_data_item(key, text)
        else:
            self.vpn_setting.delete_data_item(key)
    def entry_changed_cb(self, widget, string, key):
        if string == "":
            #print key,"entry is empty"
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:70,代码来源:vpn_config.py


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