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


Python KanoButton.set_sensitive方法代码示例

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


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

示例1: AudioTemplate

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [as 别名]
class AudioTemplate(Gtk.Box):
    """
    Template for audio screens
    """

    def __init__(self, img_path, title, description):
        Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)

        if img_path:
            self.image = Gtk.Image.new_from_file(img_path)
            self.pack_start(self.image, False, False, 0)
        self.heading = Heading(title, description)

        icon_path = os.path.join(MEDIA_DIR, "play-sound.png")
        self.kano_button = KanoButton(text="PLAY SOUND", color="blue",
                                      icon_filename=icon_path)
        self.kano_button.pack_and_align()
        self.kano_button.set_margin_top(10)
        self.pack_start(self.heading.container, False, False, 0)
        self.pack_start(self.kano_button.align, False, False, 0)

        button_box = Gtk.ButtonBox(spacing=15)
        button_box.set_layout(Gtk.ButtonBoxStyle.CENTER)

        self.yes_button = KanoButton("YES")
        self.yes_button.set_sensitive(False)
        self.no_button = KanoButton("NO", color="red")
        self.no_button.set_sensitive(False)
        button_box.pack_start(self.yes_button, False, False, 0)
        button_box.pack_start(self.no_button, False, False, 0)
        button_box.set_margin_bottom(5)

        self.pack_start(button_box, False, False, 15)
开发者ID:JMassapina,项目名称:kano-init-flow,代码行数:35,代码来源:audio_screen.py

示例2: CharacterEdit

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [as 别名]
class CharacterEdit(Gtk.EventBox):
    '''Offer the user the option to modify their avatar
    '''

    def __init__(self, win, char_creator):
        Gtk.EventBox.__init__(self)

        self._win = win

        # Should this be inherited, passed as a variable, or global?
        # Could be a member variable in window.
        # self.char_creator = self._win.get_char_creator()
        self.char_creator = char_creator
        self._win.pack_in_main_content(self.char_creator)
        self.char_creator.reset_selected_menu_items()

        self._save_changes_button = KanoButton(_("Save changes").upper())
        self._save_changes_button.connect('clicked', self.save_changes)
        self._save_changes_button.set_sensitive(False)

        self.char_creator.connect(
            'character_changed',
            self._make_button_sensitive
        )

        discard_changes_button = OrangeButton(_("Discard").upper())
        discard_changes_button.connect('clicked', self.discard)
        discard_changes_button.set_margin_left(100)
        empty_label = Gtk.Label("")

        button_box = Gtk.ButtonBox()
        button_box.pack_start(discard_changes_button, False, False, 0)
        button_box.pack_start(self._save_changes_button, False, False, 0)
        button_box.pack_start(empty_label, False, False, 0)

        self._win.pack_in_bottom_bar(button_box)
        self._win.show_all()

        # Hide all the pop ups
        self.char_creator._hide_pop_ups()

    def save_changes(self, widget):
        self.char_creator.save()
        self._go_back_to_display_screen()

    def discard(self, widget):
        self.char_creator.update_from_saved_image()
        self._go_back_to_display_screen()

    def _go_back_to_display_screen(self):
        '''Don't save, just go back to the edit character screen
        '''
        self._win.empty_main_content()
        self._win.empty_bottom_bar()
        self._win.menu_bar.enable_buttons()
        CharacterDisplay(self._win)

    def _make_button_sensitive(self, widget=None):
        self._save_changes_button.set_sensitive(True)
开发者ID:KanoComputing,项目名称:kano-profile,代码行数:61,代码来源:character_screens.py

示例3: SetProxy

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

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

        self.heading = Heading(
            _("Proxy"),
            _("Connect via a friend")
        )

        grid = Gtk.Grid(column_homogeneous=False, column_spacing=10, row_spacing=10)

        self.kano_button.connect('button-release-event', self.apply_changes)
        self.kano_button.connect('key-release-event', self.apply_changes)
        self.win.top_bar.enable_prev()
        self.win.change_prev_callback(self.go_to_wifi)

        self.ip_entry = Gtk.Entry()
        self.ip_entry.props.placeholder_text = _("IP address")
        self.ip_entry.connect('key-release-event', self.proxy_enabled)

        self.username_entry = Gtk.Entry()
        self.username_entry.props.placeholder_text = _("Username")
        self.username_entry.connect('key-release-event', self.proxy_enabled)

        self.port_entry = Gtk.Entry()
        self.port_entry.props.placeholder_text = _("Port")
        self.port_entry.connect('key-release-event', self.proxy_enabled)

        self.password_entry = Gtk.Entry()
        self.password_entry.props.placeholder_text = _("Password")
        self.password_entry.set_visibility(False)
        self.password_entry.connect('key-release-event', self.proxy_enabled)

        password_box = Gtk.Box()
        password_box.add(self.password_entry)

        self.checkbutton = Gtk.CheckButton(_("enable proxy"))
        self.read_config()
        self.checkbutton.connect('clicked', self.proxy_status)
        self.checkbutton.set_can_focus(False)

        bottom_row = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        bottom_row.pack_start(self.checkbutton, False, False, 0)
        bottom_row.pack_start(self.kano_button, False, False, 60)
        bottom_row.set_margin_bottom(30)
        bottom_row.set_margin_left(70)

        grid.attach(self.ip_entry, 0, 0, 2, 2)
        grid.attach(self.username_entry, 0, 2, 2, 2)
        grid.attach(self.port_entry, 2, 0, 2, 2)
        grid.attach(password_box, 2, 2, 3, 2)

        grid_alignment = Gtk.Alignment(xscale=0, xalign=0.5, yscale=0, yalign=0.2)
        grid_alignment.add(grid)

        self.pack_start(self.heading.container, False, False, 0)
        self.pack_start(grid_alignment, True, True, 0)
        self.pack_end(bottom_row, False, False, 0)

        self.proxy_status(self.checkbutton)
        self.kano_button.set_sensitive(False)

        # Change text of kano button depending on if proxy is enabled
        if self.checkbutton.get_active():
            self.kano_button.set_label(_("ENABLE PROXY"))
        else:
            self.kano_button.set_label(_("DISABLE PROXY"))

        self.win.show_all()

    def clear_entries(self):
        self.ip_entry.set_text("")
        self.username_entry.set_text("")
        self.port_entry.set_text("")
        self.password_entry.set_text("")

    def go_to_wifi(self, widget=None, event=None):
        self.win.clear_win()
        SetWifi(self.win)

    # Update for proxy
    def read_config(self):
        self.enable_proxy, data, _ = get_all_proxies()
        self.enabled_init = self.enable_proxy
        if self.enable_proxy:
            try:
                self.ip_entry.set_text(data['host'])
                self.port_entry.set_text(data['port'])
                if data['username']:
                    self.username_entry.set_text(data['username'])
                if data['password']:
                    self.password_entry.set_text(data['password'])
            except:
                # Something went wrong > disable proxy
                set_all_proxies(False)
                common.proxy_enabled = False
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例4: PasswordScreen

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [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: EditableList

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

    def __init__(self, size_x=400, size_y=150):
        Gtk.Grid.__init__(self)

        self.set_row_spacing(10)
        self.set_column_spacing(10)

        scroll = ScrolledWindow()
        scroll.set_size_request(size_x, size_y)
        scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)

        self.edit_list_store = Gtk.ListStore(str)
        self.edit_list = Gtk.TreeView(self.edit_list_store)
        self.edit_list.set_headers_visible(False)

        renderer = Gtk.CellRendererText()
        renderer.set_property('editable', True)
        renderer.connect('edited', self._item_edited_handler)
        renderer.connect('editing-started', self._item_edit_started)
        renderer.connect('editing-canceled', self._item_edit_canceled)
        column = Gtk.TreeViewColumn(cell_renderer=renderer, text=0)
        self.edit_list.append_column(column)

        self._add_btn = KanoButton(_("ADD"))
        self._add_btn.connect('button-release-event', self.add)
        self._rm_btn = KanoButton(_("REMOVE"))
        self._set_rm_btn_state()
        self._rm_btn.connect('button-release-event', self.rm)

        scroll.add_with_viewport(self.edit_list)

        self.attach(scroll, 0, 0, 2, 1)
        self.attach(self._add_btn, 0, 1, 1, 1)
        self.attach(self._rm_btn, 1, 1, 1, 1)

    def __contains__(self, item):
        return item in [row[0] for row in self.edit_list_store]

    def add(self, button, event):
        self.edit_list_store.append([''])

        self.edit_list.grab_focus()

        row = len(self.edit_list_store) - 1
        col = self.edit_list.get_column(0)
        self.edit_list.set_cursor(row, col, start_editing=True)
        self._rm_btn.set_sensitive(False)

    def rm(self, button=None, event=None):
        selection = self.edit_list.get_selection()
        dummy, selected = selection.get_selected()

        if not selected:
            return

        self.edit_list_store.remove(selected)
        self._set_rm_btn_state()

    def _item_edited_handler(self, cellrenderertext, path, new_text):
        if new_text is None:
            # FIXME: the reason for the os.system here is that the 'edited' signal
            # triggers on a key-pressed-event and the dialog closes on release. So
            # you would only see the dialog while holding down the 'ENTER' key.
            title = _("Invalid website given")
            description = _("\nWe need to make sure the website URL is valid.\n" \
                            "Please enter the full URL as it appears in your browser.\n\n" \
                            "Example: http://www.google.com\n")
            buttons = _("OK:red:1")
            cmd = 'kano-dialog title="{}" description="{}" buttons="{}" no-taskbar &'.format(
                  title.encode('utf8'), description.encode('utf8'), buttons.encode('utf8'))
            os.system(cmd)
            self.rm()

        else:
            selection = self.edit_list.get_selection()
            dummy, selected = selection.get_selected()

            if new_text and new_text not in self:
                self.edit_list_store.set_value(selected, 0, new_text)
            else:
                row = self.edit_list_store[selected]
                old_text = row[0]

                if not old_text:
                    self.rm()

        self._add_btn.set_sensitive(True)
        self._set_rm_btn_state()

    def _item_edit_started(self, *_):
        self._add_btn.set_sensitive(False)

    def _item_edit_canceled(self, *_):
        self._add_btn.set_sensitive(True)
        self.rm()

    def _set_rm_btn_state(self):
        state = len(self.edit_list_store) != 0

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

示例6: LoginWithKanoWorldView

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

    def __init__(self, greeter):
        Gtk.Grid.__init__(self)

        self.get_style_context().add_class('password')
        self.set_row_spacing(12)

        self.greeter = greeter

        title = Heading(_('Login with Kano World'),
                        _('Enter your Kano World details.'))
        self.attach(title.container, 0, 0, 1, 1)

        self.username = Gtk.Entry()
        self.username.set_placeholder_text('username')
        self.attach(self.username, 0, 1, 1, 1)

        self.password = Gtk.Entry()
        self.password.set_visibility(False)
        self.password.set_placeholder_text('password')
        self.attach(self.password, 0, 2, 1, 1)

        self.login_btn = KanoButton(_('LOGIN'))
        self.login_btn.connect('clicked', self._btn_login_pressed)
        self.attach(self.login_btn, 0, 3, 1, 1)

    def _btn_login_pressed(self, event=None, button=None):
        '''
        Authenticates against Kano World. If successful synchronizes to a local
        Unix account, and tells lightdm to go forward with local a login.
        '''
        logger.debug('Synchronizing Kano World account')
        self.login_btn.start_spinner()
        self.login_btn.set_sensitive(False)

        t = threading.Thread(target=self._thr_login)
        t.start()

    def _thr_login(self):
        loggedin = False
        reason = ''

        # TODO: Disable the "login" button unless these entry fields are non-empty
        # Collect credentials from the view
        self.unix_password = self.password.get_text()
        self.world_username = self.username.get_text()
        self.unix_username = self.username.get_text()
        atsign = self.unix_username.find('@')
        if atsign != -1:
            # For if we are in "staging" mode (see /etc/kano-world.conf)
            self.unix_username = self.unix_username[:atsign]

        # Now try to login to Kano World
        try:
            logger.debug('Authenticating user: {} to Kano World'.format(self.username.get_text()))
            (loggedin, reason) = kano_world_authenticate(self.username.get_text(), self.password.get_text())
            logger.debug('Kano World auth response: {} - {}'.format(loggedin, reason))
        except Exception as e:
            reason = str(e)
            logger.debug('Kano World auth Exception: {}'.format(reason))
            pass

        if not loggedin:
            # Kano world auth unauthorized
            # FIXME: Localizing the below string fails with an exception
            GObject.idle_add(self._error_message_box, 'Failed to authenticate to Kano World', reason)
            return
        else:
            # We are authenticated to Kano World: proceed with forcing local user
            rc = -1
            try:
                # Create the local unix user, bypass kano-init-flow, login & sync to Kano World
                createuser_cmd = 'sudo /usr/bin/kano-greeter-account {} {} {}'.format(
                    self.unix_username, self.unix_password, self.world_username)
                _, _, rc = run_cmd(createuser_cmd)
                if rc == 0:
                    logger.debug('Local user created correctly: {}'.format(self.unix_username))
                elif rc == 1:
                    logger.debug('Local user already exists, proceeding with login: {}'.format(self.unix_username))

                created = True
            except:
                created = False

            if not created:
                logger.debug('Error creating new local user: {}'.format(self.unix_username))
                GObject.idle_add(self._error_message_box, "Could not create local user", rc)
                return

            # Tell Lidghtdm to proceed with login session using the new user
            # We bind LightDM at this point only, this minimizes the number of attempts
            # to bind the Greeter class to a view, which he does not like quite well.
            logger.debug('Scheduling lightdm authentication in math thread')
            GObject.idle_add(self._auth_call)

    def _auth_call(self):
        logger.debug('Starting lightdm authentication')
        self._reset_greeter()
        self.greeter.authenticate(self.unix_username)
#.........这里部分代码省略.........
开发者ID:comuri,项目名称:kano-greeter,代码行数:103,代码来源:login_with_kw_view.py

示例7: RegistrationScreen

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [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

示例8: SetAccount

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [as 别名]

#.........这里部分代码省略.........
        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?"),
                _("You will lose all the data on this account!"),
                [
                    {
                        'label': _("CANCEL"),
                        'color': 'red',
                        'return_value': False
                    },
                    {
                        'label': _("OK"),
                        'color': 'green',
                        'return_value': True
                    }
                ],
                parent_window=self.win
            )
            do_delete_user = kdialog.run()
            if do_delete_user:
                self.disable_buttons()
                try:
                    delete_user()
                except UserError as e:
                    kdialog = kano_dialog.KanoDialog(
                        _("Error deleting user"),
                        str(e),
                        parent_window=self.win
                    )
                    return

                kdialog = kano_dialog.KanoDialog(
                    _("To finish removing this account, you need to reboot"),
                    _("Do you want to reboot?"),
                    [
                        {
                            'label': _("LATER"),
                            'color': 'grey',
                            'return_value': False
                        },
                        {
                            'label': _("REBOOT NOW"),
                            'color': 'orange',
                            'return_value': True
                        }
                    ],
                    parent_window=self.win
                )
                do_reboot_now = kdialog.run()
                if do_reboot_now:
                    os.system("sudo systemctl reboot")

    # Disables both buttons and makes the temp 'flag' folder
    def disable_buttons(self):

        self.add_button.set_sensitive(False)
        self.remove_button.set_sensitive(False)
        self.added_or_removed_account = True
开发者ID:,项目名称:,代码行数:104,代码来源:

示例9: ResetPassword

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [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

示例10: NetworkScreen

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [as 别名]

#.........这里部分代码省略.........
        '''Add a grey border to the widget that is entered as an argument.
        This is done by creating a grey event box and packing a white box with
        a margin in it.
        '''

        white_foreground = Gtk.EventBox()
        white_foreground.get_style_context().add_class('white')
        white_foreground.set_margin_left(3)
        white_foreground.set_margin_bottom(3)
        white_foreground.set_margin_top(3)
        white_foreground.set_margin_right(3)

        # Pack the scrolled window into an event box to give the illusion of a
        # border
        grey_border = Gtk.EventBox()
        grey_border.get_style_context().add_class('grey')
        grey_border.add(white_foreground)

        white_foreground.add(widget)

        return grey_border

    def _create_refresh_connect_buttons(self):
        '''Create the buttons used for the refresh button and the
        to connect to a network, and pack them into a button box.
        Returns the button box.
        '''

        self._connect_btn = KanoButton(_("CONNECT"))
        self._connect_btn.pack_and_align()
        self.connect_handler = self._connect_btn.connect(
            'clicked', self._first_time_connect
        )
        self._connect_btn.set_sensitive(False)
        self._refresh_btn = self._create_refresh_button()

        # For now, show both connect and refresh buttons
        buttonbox = Gtk.ButtonBox()
        buttonbox.set_layout(Gtk.ButtonBoxStyle.CENTER)
        buttonbox.set_spacing(10)
        buttonbox.pack_start(self._refresh_btn, False, False, 0)
        buttonbox.pack_start(self._connect_btn.align, False, False, 0)

        if self._win.is_plug():
            self._skip_btn = WhiteButton(_("Skip"))
            buttonbox.pack_start(self._skip_btn, False, False, 0)
            self._skip_btn.connect('clicked', self.skip)
        else:
            blank_label = Gtk.Label("")
            buttonbox.pack_start(blank_label, False, False, 0)

        return buttonbox

    # Attached to a callback, hence the extra argument
    def skip(self, skip_btn=None):
        # Exit with an extreme exit code so the init-flow knows the user
        # pressed SKIP
        sys.exit(100)

    def _set_connect_btn_status(self, connect=True):
        self._connect_btn.disconnect(self.connect_handler)

        if connect:
            self.connect_handler = self._connect_btn.connect(
                'clicked', self._first_time_connect
            )
开发者ID:KanoComputing,项目名称:kano-settings,代码行数:70,代码来源:NetworkScreen.py

示例11: FeedbackWindow

# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import set_sensitive [as 别名]
class FeedbackWindow(MainWindow):
    CLOSE_FEEDBACK = 0
    KEEP_OPEN = 1
    LAUNCH_WIFI = 2
    WIDTH = 400

    def __init__(self, bug_report=False):
        '''
        Initialises the window, creating a report or contact window
        '''
        MainWindow.__init__(self, subject='Kano Desktop Feedback Widget')
        self.bug_report = bug_report
        if self.bug_report:
            self.report_window()
        else:
            self.contact_window()

    def contact_window(self):
        '''
        Contact Us window
        Contains text view and a Send button
        '''
        # delete the directory containing all the info we'll send, and recreate
        delete_tmp_dir()
        create_tmp_dir()

        ApplicationWindow.__init__(
            self,
            _('Contact Us'),  # noqa: F821
            self.WIDTH,
            0.35
        )

        screen = Gdk.Screen.get_default()
        specific_provider = Gtk.CssProvider()
        specific_provider.load_from_path(Media.media_dir() + 'css/style.css')
        style_context = Gtk.StyleContext()
        style_context.add_provider_for_screen(screen, specific_provider,
                                              Gtk.STYLE_PROVIDER_PRIORITY_USER)

        # Make sure this window has no icon in the task bar
        # so it plays nice with kdesk-blur
        self.set_property('skip-taskbar-hint', True)

        self._grid = Gtk.Grid()

        # Create top bar
        self._top_bar = TopBar(
            title=_("Contact Us"),  # noqa: F821
            window_width=self.WIDTH,
            has_buttons=False
        )
        self._top_bar.set_close_callback(Gtk.main_quit)
        self.set_decorated(True)
        self.set_titlebar(self._top_bar)

        # Create Text view
        self._text = Gtk.TextView()
        self._text.set_editable(True)
        self._text.set_wrap_mode(Gtk.WrapMode.WORD_CHAR)
        self._text.set_size_request(self.WIDTH, -1)

        self._textbuffer = self._text.get_buffer()
        self._textbuffer.set_text(
            _("Type your feedback here!")  # noqa: F821
        )
        self._clear_buffer_handler_id = self._textbuffer.connect(
            "insert-text", self.clear_buffer
        )

        scrolledwindow = ScrolledWindow()
        scrolledwindow.set_vexpand(True)
        scrolledwindow.set_policy(Gtk.PolicyType.NEVER,
                                  Gtk.PolicyType.AUTOMATIC)
        scrolledwindow.apply_styling_to_widget()
        scrolledwindow.add(self._text)
        scrolledwindow.set_margin_left(2)
        scrolledwindow.set_margin_right(2)
        scrolledwindow.set_margin_top(2)
        scrolledwindow.set_margin_bottom(2)

        # Very hacky way to get a border: create a grey event box
        # which is a little bigger than the widget below
        border = Gtk.EventBox()
        border.get_style_context().add_class("grey")
        border.add(scrolledwindow)
        self._grid.attach(border, 0, 0, 1, 1)
        border.set_margin_left(20)
        border.set_margin_right(20)
        border.set_margin_top(10)
        border.set_margin_bottom(20)

        # Create send button
        self._send_button = KanoButton(
            _("SEND")  # noqa: F821
        )
        self._send_button.set_sensitive(False)
        self._send_button.connect("button_press_event", self.send_feedback)
        self._send_button.pack_and_align()
        self._send_button.align.set_padding(10, 10, 0, 0)
#.........这里部分代码省略.........
开发者ID:KanoComputing,项目名称:kano-feedback,代码行数:103,代码来源:FeedbackWindow.py


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