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


Python KanoButton.set_margin_left方法代码示例

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


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

示例1: third_scroll

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_margin_left [as 别名]
    def third_scroll(self):
        self._clear()

        heading = Gtk.Label('New quest')
        add_class(heading, 'scroll-heading')

        world = Gtk.Image.new_from_file(self._stage.media_path('world.png'))

        copy = [
            "Journey to Kano World",
        ]
        text_widgets = self._get_text_widgets(copy)

        button = KanoButton('OK', color='orange')
        button.connect('clicked', cb_wrapper, self._stage._ctl.next_stage)

        heading.set_margin_top(35)
        self._vbox.pack_start(heading, False, False, 0)

        world.set_margin_top(35)
        self._vbox.pack_start(world, False, False, 0)

        text_widgets[0].set_margin_top(40)
        for w in text_widgets:
            self._vbox.pack_start(w, False, False, 0)

        button.set_margin_top(40)
        button.set_margin_left(80)
        button.set_margin_right(80)
        self._vbox.pack_start(button, False, False, 0)

        self.show_all()
开发者ID:KanoComputing,项目名称:kano-init-flow,代码行数:34,代码来源:main.py

示例2: second_scroll

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_margin_left [as 别名]
    def second_scroll(self):
        self._clear()
        ticks = Gtk.Image.new_from_file(self._stage.media_path('ticks.png'))

        copy = [
            "Complete all of the ticks in a",
            "quest to unlock rewards."
        ]
        text_widgets = self._get_text_widgets(copy)

        chest = Gtk.Image.new_from_file(self._stage.media_path('chest-open.png'))

        button = KanoButton('NEXT', color='orange')
        button.connect('clicked', cb_wrapper, self.third_scroll)

        ticks.set_margin_top(20)
        self._vbox.pack_start(ticks, False, False, 0)

        text_widgets[0].set_margin_top(40)
        for w in text_widgets:
            self._vbox.pack_start(w, False, False, 0)

        chest.set_margin_top(35)
        self._vbox.pack_start(chest, False, False, 0)

        button.set_margin_top(40)
        button.set_margin_left(80)
        button.set_margin_right(80)
        self._vbox.pack_start(button, False, False, 0)

        self.show_all()
开发者ID:KanoComputing,项目名称:kano-init-flow,代码行数:33,代码来源:main.py

示例3: first_scroll

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_margin_left [as 别名]
    def first_scroll(self):
        self._clear()
        copy = [
            "Quests are a series of tasks that you",
            "can complete on your Kano to get",
            "great rewards."
        ]
        text_widgets = self._get_text_widgets(copy)

        img_path = self._stage.media_path('chest-closed.png')
        chest = Gtk.Image.new_from_file(img_path)

        button = KanoButton('NEXT', color='orange')
        button.connect('clicked', cb_wrapper, self.second_scroll)

        text_widgets[0].set_margin_top(30)
        for w in text_widgets:
            self._vbox.pack_start(w, False, False, 0)

        chest.set_margin_top(60)
        self._vbox.pack_start(chest, False, False, 0)

        button.set_margin_top(70)
        button.set_margin_left(80)
        button.set_margin_right(80)
        self._vbox.pack_start(button, False, False, 0)

        self.show_all()
开发者ID:KanoComputing,项目名称:kano-init-flow,代码行数:30,代码来源:main.py

示例4: PasswordScreen

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_margin_left [as 别名]
class PasswordScreen(Gtk.Box):
    def __init__(
        self,
        win,
        wiface,
        network_name,
        encryption,
        wrong_password=False
    ):

        '''
        Show the screen with the option of adding a password
        and connecting to a network
        '''

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

        self._win = win
        self._win.set_main_widget(self)
        self._win.top_bar.enable_prev()
        self._wiface = wiface
        self._network_name = network_name
        self._encryption = encryption

        # Keep track if the user has already entered the wrong password before
        # so that we only pack the "password incorrect" label once
        self._wrong_password_used_before = False

        self._heading = Heading(
            "Connect to the network",
            self._network_name,
            self._win.is_plug(),
            True
        )

        self._heading.set_prev_callback(self._refresh_networks)
        self._heading.container.set_margin_right(20)
        self._heading.container.set_margin_left(20)

        if wrong_password:
            image_path = os.path.join(img_dir, "password-fail.png")
            wrong_password = self._create_wrong_password_label()
            self._heading.container.pack_start(wrong_password, True, True, 0)
        else:
            image_path = os.path.join(img_dir, "password.png")

        self._padlock_image = Gtk.Image.new_from_file(image_path)

        self._password_entry = Gtk.Entry()
        self._password_entry.set_placeholder_text("Password")
        self._password_entry.set_visibility(False)
        self._password_entry.get_style_context().add_class("password_entry")
        self._password_entry.set_margin_left(60)
        self._password_entry.set_margin_right(60)
        self._password_entry.connect("key-release-event",
                                     self._set_button_sensitive)
        # If Enter key is pressed on the password entry, we want to act as
        # though the connect_btn was clicked
        self._password_entry.connect(
            "key-release-event", self._on_connect_key_wrapper
        )

        self._connect_btn = KanoButton("CONNECT")
        self._connect_btn.connect('clicked', self._on_connect)
        self._connect_btn.set_sensitive(False)
        self._connect_btn.set_margin_right(100)
        self._connect_btn.set_margin_left(100)
        self._connect_btn.pack_and_align()

        self._show_password = Gtk.CheckButton.new_with_label("Show password")
        self._show_password.get_style_context().add_class("show_password")
        self._show_password.connect("toggled",
                                    self._change_password_entry_visiblity)
        self._show_password.set_active(True)
        self._show_password.set_margin_left(100)

        vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        self.add(vbox)

        vbox.pack_start(self._heading.container, False, False, 10)
        vbox.pack_start(self._padlock_image, False, False, 10)
        vbox.pack_start(self._password_entry, False, False, 10)
        vbox.pack_start(self._show_password, False, False, 10)
        vbox.pack_end(self._connect_btn.align, False, False, 40)

        # Entry should have the keyboard focus
        self._password_entry.grab_focus()

        self.show_all()

    def _create_wrong_password_label(self):
        label = Gtk.Label("Password incorrect")
        label.get_style_context().add_class("wrong_password_label")
        return label

    def _change_password_entry_visiblity(self, widget):
        '''
        Depending on the checkbox, change the writing in the
        password entry to be readable.
        '''
#.........这里部分代码省略.........
开发者ID:gvsurenderreddy,项目名称:kano-settings,代码行数:103,代码来源:PasswordScreen.py

示例5: RegistrationScreen

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_margin_left [as 别名]
class RegistrationScreen(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.set_decorated(True)

        title = Heading(
            _("Kano World"),
            _("Choose a cool name and secure password")
        )
        self.pack_start(title.container, False, False, 0)

        self.data_screen = GetData()  # TODO: refactor this
        self.data_screen.connect('widgets-filled', self._enable_register_button)
        self.data_screen.connect('widgets-empty', self._disable_register_button)
        self.add(self.data_screen)

        self.register_button = KanoButton(_("JOIN KANO WORLD"))
        self.register_button.set_sensitive(False)
        self.register_button.set_margin_top(10)
        self.register_button.set_margin_left(30)
        self.register_button.set_margin_right(30)
        self.register_button.set_margin_bottom(30)
        self.register_button.connect('clicked', self._on_register_button)
        self.pack_end(self.register_button, False, False, 0)

        self.win.show_all()

    def _enable_register_button(self, widget=None):
        """
        """
        self.register_button.set_sensitive(True)

    def _disable_register_button(self, widget=None):
        """
        """
        self.register_button.set_sensitive(False)

    def _on_register_button(self, widget=None):  # TODO: refactor this
        """
        """
        if not is_internet():
            self._show_not_internet_dialog()
            return

        # Get the username, password and birthday
        data = self.data_screen.get_widget_data()
        email = data['email']
        username = data['username']

        # Validate that the email address format is correct
        email_error = validate_email(email)
        if email_error:
            self._show_error_dialog(_("Incorrect Email address"), email_error)
            return

        if not self._is_username_available(username):
            self._show_username_taken_dialog(username)
            return

        # We can save the username to kano-profile
        # Don't save password as this is private
        self.data_screen.save_username_and_birthday()  # TODO: rename this
        self.data_screen.cache_emails()
        data = self.data_screen.get_widget_data()

        # This means no threads are needed.
        while Gtk.events_pending():  # TODO: why is this needed?
            Gtk.main_iteration()

        # Try and register the account on the server
        password = data['password']
        success, text = register_(email, username, password,
                                  marketing_enabled=True)

        # This should no longer be needed, since this is checked in the first
        # screen. However there is a small chance someone could take the
        # username while the user is in the process of registering
        if not success:
            if text.strip() == _("Cannot register, problem: "
               "Username already registered"):

                self._show_username_taken_dialog(username)

            else:
                logger.info("problem with registration: {}".format(text))
                return_value = 'FAIL'
                self._create_dialog(
                    title=_("Houston, we have a problem"),
                    description=str(text)
                )
                track_data('world-registration-failed', {'reason': text})

        else:
            logger.info("registration successful")

#.........这里部分代码省略.........
开发者ID:KanoComputing,项目名称:kano-profile,代码行数:103,代码来源:RegistrationScreen.py

示例6: BluetoothDeviceItem

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_margin_left [as 别名]
class BluetoothDeviceItem(Gtk.Box):
    __gsignals__ = {
        'pairing': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()),
        'done-pairing': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ()),
    }

    def __init__(self, device):
        Gtk.Box.__init__(self, hexpand=True)

        self.device = device
        device_name = device.name

        dev_label = Gtk.Label(device_name, hexpand=True)
        dev_label.get_style_context().add_class('normal_label')
        self.pack_start(dev_label, False, False, 0)

        self._pair_button = KanoButton()
        self._set_paired_button_state()
        self._pair_button.set_margin_top(10)
        self._pair_button.set_margin_bottom(10)
        self._pair_button.set_margin_left(10)
        self._pair_button.set_margin_right(10)
        self._pair_button.connect('clicked', self.pair)
        self.pack_start(self._pair_button, False, False, 0)

    def _set_paired_button_state(self, *dummy_args, **dummy_kwargs):
        if not self.device.connected:
            label = _("PAIR")
            colour = 'green'
        else:
            label = _("UNPAIR")
            colour = 'red'

        self._pair_button.set_label(label)
        self._pair_button.set_color(colour)

    def error(self, err_msg):
        KanoDialog(err_msg).run()

    def pair(self, *dummy_args, **dummy_kwargs):
        def done_pairing():
            self._set_paired_button_state()
            self.emit('done-pairing')

        @queue_cb(callback=done_pairing, gtk=True)
        def do_pair():
            if not self.device.fuse():
                GObject.idle_add(self.error, _("Pairing failed"))

        @queue_cb(callback=done_pairing, gtk=True)
        def do_unpair():
            if not self.device.unfuse():
                GObject.idle_add(self.error, _("Unpairing failed"))

        self.emit('pairing')

        if self.device.connected:
            pair_fn = do_unpair
            logger.info("Unpairing {}".format(self.device))
        else:
            pair_fn = do_pair
            logger.info("Pairing {}".format(self.device))

        pair_thr = threading.Thread(target=pair_fn)
        pair_thr.start()
开发者ID:,项目名称:,代码行数:67,代码来源:


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