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


Python KanoButton.set_size_request方法代码示例

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


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

示例1: SetAccount

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_size_request [as 别名]
class SetAccount(Gtk.Box):
    def __init__(self, win):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.win = win
        self.win.set_main_widget(self)

        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.win.go_to_home)

        self.added_or_removed_account = False

        main_heading = Heading(
            _("System account settings"),
            _("Set your account")
        )

        self.pass_button = KanoButton(_("CHANGE PASSWORD"))
        self.pass_button.pack_and_align()
        self.pass_button.connect('button-release-event', self.go_to_password_screen)
        self.pass_button.connect('key-release-event', self.go_to_password_screen)

        self.add_button = KanoButton(_("ADD ACCOUNT"))
        self.add_button.set_size_request(200, 44)
        self.add_button.connect('button-release-event', self.add_account)
        self.add_button.connect('key-release-event', self.add_account)

        self.remove_button = KanoButton(_("REMOVE ACCOUNT"), color='red')
        self.remove_button.set_size_request(200, 44)
        self.remove_button.connect('button-release-event', self.remove_account_dialog)
        self.remove_button.connect('key-release-event', self.remove_account_dialog)

        button_container = Gtk.Box()
        button_container.pack_start(self.add_button, False, False, 10)
        button_container.pack_start(self.remove_button, False, False, 10)

        button_align = Gtk.Alignment(xscale=0, xalign=0.5)
        button_align.add(button_container)

        accounts_heading = Heading(
            _("Accounts"),
            _("Add or remove accounts")
        )

        # Check if we already scheduled an account add or remove
        # We import kano-init locally to avoid circular dependency
        # the packages.
        try:
            from kano_init.utils import is_any_task_scheduled
            if is_any_task_scheduled():
                self.disable_buttons()
        except ImportError:
            self.disable_buttons()

        self.pack_start(main_heading.container, False, False, 0)
        self.pack_start(self.pass_button.align, False, False, 0)
        self.pack_start(accounts_heading.container, False, False, 0)
        self.pack_start(button_align, False, False, 0)

        self.win.show_all()

    def go_to_password_screen(self, widget, event):

        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:
            self.win.clear_win()
            SetPassword(self.win)

    # Gets executed when ADD button is clicked
    def add_account(self, widget=None, event=None):
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:
            kdialog = None

            try:
                # add new user command
                add_user()
            except UserError as e:
                kdialog = kano_dialog.KanoDialog(
                    _("Error creating new user"),
                    str(e),
                    parent_window=self.win
                )
            else:
                kdialog = kano_dialog.KanoDialog(
                    _("Reboot the system"),
                    _("A new account will be created next time you reboot."),
                    parent_window=self.win
                )

                # Tell user to reboot to see changes
                common.need_reboot = True

            kdialog.run()
            self.disable_buttons()

    # Gets executed when REMOVE button is clicked
    def remove_account_dialog(self, widget=None, event=None):
        if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:
            # Bring in message dialog box
            kdialog = kano_dialog.KanoDialog(
                _("Are you sure you want to delete the current user?"),
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:


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