本文整理汇总了Python中kano.gtk3.buttons.KanoButton.stop_spinner方法的典型用法代码示例。如果您正苦于以下问题:Python KanoButton.stop_spinner方法的具体用法?Python KanoButton.stop_spinner怎么用?Python KanoButton.stop_spinner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kano.gtk3.buttons.KanoButton
的用法示例。
在下文中一共展示了KanoButton.stop_spinner方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SetProxy
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import stop_spinner [as 别名]
#.........这里部分代码省略.........
def lengthy_process():
if self.enable_proxy:
host = self.ip_entry.get_text()
port = self.port_entry.get_text()
username = self.username_entry.get_text()
password = self.password_entry.get_text()
set_all_proxies(enable=True, host=host, port=port, username=username, password=password)
common.proxy_enabled = True
success, text = test_proxy()
if not success:
title = _("Error with proxy")
description = text
return_value = 1
# disable proxy if we couldn't successfully enable it
set_all_proxies(False)
common.proxy_enabled = False
else:
title = _("Successfully enabled proxy")
description = ""
return_value = 0
else:
set_all_proxies(False)
common.proxy_enabled = False
title = _("Successfully disabled proxy")
description = ""
return_value = 0
def done(title, description, return_value):
kdialog = KanoDialog(
title,
description,
[
{
'label': _("OK"),
'color': 'green',
'return_value': return_value
}
],
parent_window=self.win
)
response = kdialog.run()
self.win.get_window().set_cursor(None)
self.kano_button.stop_spinner()
if response == 0:
self.go_to_wifi()
elif response == 1:
self.checkbutton.set_active(False)
self.kano_button.set_sensitive(False)
GObject.idle_add(done, title, description, return_value)
thread = threading.Thread(target=lengthy_process)
thread.start()
# Validation functions
# If the "enable proxy" checkbox is checked/uncheckout, this function is activated
# Disables the text entries if enable proxy is not checked
def proxy_status(self, widget):
self.enable_proxy = widget.get_active()
if self.enable_proxy:
self.ip_entry.set_sensitive(True)
self.port_entry.set_sensitive(True)
self.password_entry.set_sensitive(True)
self.username_entry.set_sensitive(True)
# Run to see if it need enabling
self.proxy_enabled()
self.kano_button.set_label(_("ENABLE PROXY"))
else:
self.ip_entry.set_sensitive(False)
self.port_entry.set_sensitive(False)
self.password_entry.set_sensitive(False)
self.username_entry.set_sensitive(False)
self.kano_button.set_label(_("DISABLE PROXY"))
self.kano_button.set_sensitive(True)
# if proxy enabled: ip address, port are mandatory
def proxy_enabled(self, widget=None, event=None):
# Get IP address
# Get port
# Get
# If these entries are non empty, good - else, disable the next button
ip_text = self.ip_entry.get_text()
port_text = self.port_entry.get_text()
if ip_text == "" or port_text == "":
self.kano_button.set_sensitive(False)
return False
else:
self.kano_button.set_sensitive(True)
return True
return False
示例2: PasswordScreen
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import stop_spinner [as 别名]
#.........这里部分代码省略.........
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.
'''
visibility = self._show_password.get_active()
self._password_entry.set_visibility(visibility)
def _refresh_networks(self, widget=None):
from kano_wifi_gui.RefreshNetworks import RefreshNetworks
RefreshNetworks(self._win)
def _on_connect_key_wrapper(self, widget, event):
if event.keyval == Gdk.KEY_Return:
self._on_connect()
def _on_connect(self, widget=None):
passphrase = self._password_entry.get_text()
ConnectToNetwork(
self._win,
self._network_name,
passphrase,
self._encryption
)
def _set_button_sensitive(self, widget, event):
self._connect_btn.set_sensitive(True)
def _thread_finish(self, success):
if success:
self._success_screen()
else:
self._wrong_password_screen()
def _success_screen(self):
self._win.remove_main_widget()
title = "Success!"
description = "You're connected"
buttons = [
{
"label": "OK",
"color": "green",
"type": "KanoButton",
"callback": Gtk.main_quit
}
]
img_path = os.path.join(img_dir, "internet.png")
self._win.set_main_widget(
Template(
title,
description,
buttons,
self._win.is_plug(),
img_path
)
)
def _disable_widgets_start_spinner(self):
self._connect_btn.start_spinner()
self._connect_btn.set_sensitive(False)
self._win.top_bar.prev_button.set_sensitive(False)
self._password_entry.set_sensitive(False)
self._show_password.set_sensitive(False)
def _enable_widgets_stop_spinner(self):
self._connect_btn.stop_spinner()
self._connect_btn.set_sensitive(True)
self._win.top_bar.prev_button.set_sensitive(True)
self._password_entry.set_sensitive(True)
self._show_password.set_sensitive(True)
示例3: LoginWithKanoWorldView
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import stop_spinner [as 别名]
#.........这里部分代码省略.........
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)
if self.greeter.get_is_authenticated():
logger.debug('User is already authenticated, starting session')
def _reset_greeter(self):
# connect signal handlers to LightDM
self.cb_one = self.greeter.connect('show-prompt', self._send_password_cb)
self.cb_two = self.greeter.connect('authentication-complete',
self._authentication_complete_cb)
self.cb_three = self.greeter.connect('show-message', self._auth_error_cb)
self.greeter.connect_sync()
return (self.cb_one, self.cb_two, self.cb_three)
def _send_password_cb(self, _greeter, text, prompt_type):
logger.debug('Need to show prompt: {}'.format(text))
if _greeter.get_in_authentication():
logger.debug('Sending password to LightDM')
_greeter.respond(self.unix_password)
def _authentication_complete_cb(self, _greeter):
logger.debug('Authentication process is complete')
if not _greeter.get_is_authenticated():
logger.warn('Could not authenticate user {}'.format(self.unix_username))
self._auth_error_cb(_('Incorrect password (The default is "kano")'))
return
logger.info(
'The user {} is authenticated. Starting LightDM X Session'
.format(self.unix_username))
set_last_user(self.unix_username)
if not _greeter.start_session_sync('lightdm-xsession'):
logger.error('Failed to start session')
else:
logger.info('Login failed')
def _auth_error_cb(self, text, message_type=None):
logger.info('There was an error logging in: {}'.format(text))
win = self.get_toplevel()
win.go_to_users()
self.login_btn.stop_spinner()
self.login_btn.set_sensitive(True)
self.newuser_btn.set_sensitive(True)
error = KanoDialog(title_text=_('Error Synchronizing account'),
description_text=text,
parent_window=self.get_toplevel())
error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
error.run()
def _error_message_box(self, title, description):
'''
Show a standard error message box
'''
self.login_btn.stop_spinner()
self.login_btn.set_sensitive(True)
errormsg = KanoDialog(title_text=title,
description_text=description,
button_dict=[
{
'label': _('OK').upper(),
'color': 'red',
'return_value': True
}])
errormsg.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
errormsg.run()
# Clean up password field
self.password.set_text('')
return
def grab_focus(self):
'''
Clear username and password previous text, and gain focus.
'''
self.username.set_text('')
self.password.set_text('')
示例4: PasswordView
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import stop_spinner [as 别名]
#.........这里部分代码省略.........
self.greeter.authenticate(self.user)
def _send_password_cb(self, _greeter, text, prompt_type):
logger.debug(u'Need to show prompt: {}'.format(text))
if _greeter.get_in_authentication():
logger.debug('Sending password to LightDM')
_greeter.respond(self.password.get_text())
def _authentication_complete_cb(self, _greeter):
logger.debug('Authentication process is complete')
if not _greeter.get_is_authenticated():
logger.warn('Could not authenticate user {}'.format(self.user))
self._auth_error_cb(_('Incorrect password (The default is "kano")'))
return
logger.info(
'The user {} is authenticated. Starting LightDM X Session'
.format(self.user))
set_last_user(self.user)
if not _greeter.start_session_sync('lightdm-xsession'):
logger.error('Failed to start session')
else:
logger.info('Login failed')
def _auth_error_cb(self, text, message_type=None):
logger.info(u'There was an error logging in: {}'.format(text))
self.greeter.cancel_authentication()
self.login_btn.stop_spinner()
self.password.set_text('')
win = self.get_toplevel()
error = KanoDialog(
title_text=_('Error Logging In'),
description_text=text,
parent_window=win
)
error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
error.run()
win.go_to_users()
def grab_focus(self, user):
'''
Update username title, clear previous password,
and give focus to password entry field.
'''
self.user = user
self._set_title(create=False)
self.password.set_text('')
self.password.grab_focus()
def delete_user(self, *args):
import pam
password_input = Gtk.Entry()
password_input.set_visibility(False)
password_input.set_alignment(0.5)
confirm = KanoDialog(
title_text = _('Are you sure you want to delete this account?'),
示例5: ResetPassword
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import stop_spinner [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):
#.........这里部分代码省略.........
示例6: NetworkScreen
# 需要导入模块: from kano.gtk3.buttons import KanoButton [as 别名]
# 或者: from kano.gtk3.buttons.KanoButton import stop_spinner [as 别名]
#.........这里部分代码省略.........
'label': _("CLOSE"),
'type': 'KanoButton',
'color': 'red',
'callback': Gtk.main_quit
},
{
'label': _("CONNECT"),
'type': 'KanoButton',
'color': 'green',
'callback': self._go_to_spinner_screen
}
]
img_path = os.path.join(img_dir, "no-wifi.png")
self._win.set_main_widget(
Template(
title,
description,
buttons,
self._win.is_plug(),
img_path
)
)
def _threaded_disconnect(self):
'''
This is needed so we can show a spinner while the user is
disconnecting
'''
disconnect(self._wiface)
def done():
self._disconnect_screen()
self._win.get_window().set_cursor(None)
self._connect_btn.stop_spinner()
self._connect_btn.set_sensitive(True)
GObject.idle_add(done)
def _create_refresh_button(self):
'''Create the refresh button. This it quite involved as you have
to pack an image into the button which need to change when the
cursor hovers over it, and change the cursor to be a
hand over it.
'''
refresh_icon_filepath = os.path.join(img_dir, "refresh.png")
refresh_icon = Gtk.Image.new_from_file(refresh_icon_filepath)
refresh_btn = Gtk.Button()
refresh_btn.get_style_context().add_class('refresh_btn')
refresh_btn.set_image(refresh_icon)
attach_cursor_events(refresh_btn)
# These are here in case we want to change the icon on mouse over
refresh_btn.connect('enter-notify-event', self._set_refresh_hover_icon)
refresh_btn.connect('leave-notify-event', self._set_refresh_normal_icon)
refresh_btn.connect('clicked', self._go_to_spinner_screen)
return refresh_btn
# This is linked to enter-notify-event, hence the extra arguments
def _set_refresh_hover_icon(self, widget=None, event=None):
'''Change the refresh button's icon to the hover icon.
'''
selected_path = os.path.join(img_dir, "rescan-hover.png")
image = Gtk.Image.new_from_file(selected_path)
self._refresh_btn.set_image(image)