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


Python KanoButton.set_padding方法代码示例

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


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

示例1: LoggedIn

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_padding [as 别名]
class LoggedIn(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title='Profile')
        self.set_size_request(200, 150)
        self.set_decorated(False)
        self.set_position(Gtk.WindowPosition.CENTER)
        self.set_resizable(False)
        self.ok_button = KanoButton(_("OK"))
        self.ok_button.pack_and_align()
        self.ok_button.set_padding(20, 20, 0, 0)
        self.ok_button.connect("clicked", Gtk.main_quit)
        self.title = Heading(_("Logged in!"), _("You're already logged in"))
        self.main_container = Gtk.Box(
            orientation=Gtk.Orientation.VERTICAL, spacing=0)
        self.add(self.main_container)
        self.main_container.pack_start(self.title.container, False, False, 0)
        self.main_container.pack_start(self.ok_button.align, False, False, 0)

        # To get a logout button, uncomment out the lines below
        #self.logout_button = OrangeButton(_("Log out?"))
        #self.logout_button.connect("clicked", self.logout)
        #self.main_container.pack_start(self.logout_button, False, False, 0)

        self.connect('delete-event', Gtk.main_quit)
        self.show_all()

    def logged_out_screen(self):
        for child in self.main_container:
            self.main_container.remove(child)
        self.title.set_text(_("Logged out!"), "")
        self.main_container.pack_start(self.title.container, False, False, 0)
        self.main_container.pack_start(self.alignment, False, False, 0)

    def logout(self, event):
        remove_token()
        self.logged_out_screen()

    def close_window(self, event, button, win):
        self.ok_button.disconnect_handlers()
        cursor.arrow_cursor(None, None, win)
        Gtk.main_quit()
开发者ID:japonophile,项目名称:kano-profile,代码行数:43,代码来源:logged_in.py

示例2: ResetPassword

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_padding [as 别名]
class ResetPassword(Gtk.Box):

    def __init__(self, win):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        self.win = win
        self.win.set_decorated(False)
        self.win.set_main_widget(self)

        self.heading = Heading(
            _("Reset your password"),
            _("We'll send a new password to your email")
        )
        self.pack_start(self.heading.container, False, False, 10)

        self.labelled_entries = LabelledEntries([
            {"heading": _("Email"), "subheading": ""}
        ])
        align = Gtk.Alignment(xscale=0, xalign=0.5)
        self.pack_start(align, False, False, 15)

        self.labelled_entries.set(0, 0, 1, 1)
        self.labelled_entries.set_hexpand(True)

        align.add(self.labelled_entries)

        # Read email from file
        user_email = get_email()

        self.email_entry = self.labelled_entries.get_entry(0)
        self.email_entry.set_text(user_email)
        self.email_entry.connect("key-release-event", self.activate)

        self.button = KanoButton(_("Reset password").upper())
        self.button.pack_and_align()
        self.button.connect("button-release-event", self.activate)
        self.button.connect("key-release-event", self.activate)
        self.button.set_padding(30, 30, 0, 0)

        self.pack_start(self.button.align, False, False, 0)
        self.win.show_all()

    def activate(self, widget, event):
        if not hasattr(event, 'keyval') or event.keyval == 65293:
            watch_cursor = Gdk.Cursor(Gdk.CursorType.WATCH)
            self.win.get_window().set_cursor(watch_cursor)
            self.button.set_sensitive(False)
            self.button.start_spinner()

            thread = threading.Thread(target=self.send_new_password)
            thread.start()

    def send_new_password(self):
        # User may change email
        email = self.labelled_entries.get_entry(0).get_text()
        success, text = reset_password(email)
        if success:
            title = _("Success!")
            description = _("Sent new password to your email")
            button_dict = {
                _("Go to login screen").upper(): {"return_value": 12},
                _("Quit").upper(): {"return_value": 10, "color": "red"}
            }
        else:
            title = _("Something went wrong!")
            description = text
            button_dict = {
                _("Quit").upper(): {"return_value": 10, "color": "red"},
                _("Try again").upper(): {"return_value": 11}
            }

        GObject.idle_add(
            self.finished_thread_cb,
            title,
            description,
            button_dict
        )

    def finished_thread_cb(self, title, description, button_dict):
        kdialog = KanoDialog(
            title,
            description,
            button_dict=button_dict,
            parent_window=self.win
        )
        response = kdialog.run()

        self.win.get_window().set_cursor(None)
        self.button.stop_spinner()
        self.button.set_sensitive(True)

        if response == 10:
            Gtk.main_quit()
        # stay put
        elif response == 11:
            pass
        elif response == 12:
            self.go_to_login_screen()

    def go_to_login_screen(self):
#.........这里部分代码省略.........
开发者ID:japonophile,项目名称:kano-profile,代码行数:103,代码来源:login.py


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