本文整理汇总了Python中kano.gtk3.kano_dialog.KanoDialog.run方法的典型用法代码示例。如果您正苦于以下问题:Python KanoDialog.run方法的具体用法?Python KanoDialog.run怎么用?Python KanoDialog.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kano.gtk3.kano_dialog.KanoDialog
的用法示例。
在下文中一共展示了KanoDialog.run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: apply_changes
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def apply_changes(self, button, event):
pw_dialog = ParentalPasswordDialog(self.win)
if not pw_dialog.verify():
return
level = self.parental_level.get_value()
set_parental_level(level)
set_setting('Parental-level', level)
# track which parental control level people use
track_data("parental-control-level-changed", {
"level": level
})
if level == 3.0:
# If on the highest parental control, prompt user to relaunch
# the browser
kdialog = KanoDialog(
title_text='Settings',
description_text=("If any browsers are open, please relaunch "
"them for this setting to take effect"),
parent_window=self.win
)
kdialog.run()
else:
# Only reboot for the lower parental controls
common.need_reboot = True
self.win.go_to_home()
示例2: apply_changes
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def apply_changes(self, button, event):
# If enter key is pressed or mouse button is clicked
if not hasattr(event, 'keyval') or event.keyval == Gdk.KEY_Return:
if self.ssh_preference is not is_ssh_enabled():
set_ssh_enabled(self.ssh_preference)
old_debug_mode = self.get_stored_debug_mode()
new_debug_mode = self.debug_button.get_active()
if new_debug_mode == old_debug_mode:
logging.Logger().debug('skipping debug mode change')
self.win.go_to_home()
return
if new_debug_mode:
# set debug on:
logging.set_system_log_level('debug')
logging.Logger().info("setting logging to debug")
msg = _("Activated")
else:
# set debug off:
logging.set_system_log_level('error')
logging.Logger().info("setting logging to error")
msg = _("De-activated")
kdialog = KanoDialog(_("Debug mode"), msg, parent_window=self.win)
kdialog.run()
self.kano_button.set_sensitive(False)
self.win.go_to_home()
示例3: _add
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def _add(self, _, playlist_entry):
playlist_name = playlist_entry.get_text()
if playlist_name == 'Kano':
confirm = KanoDialog('You can\'t add to the "Kano" playlist',
'',
{'BACK': {'return_value': True,
'color': 'red'}},
parent_window=self._main_win)
confirm.run()
return
if playlist_name in playlistCollection.collection:
confirm = KanoDialog(
'The playlist "{}" already exists!'.format(playlist_name),
'Do you want to add the video to this playlist or try again?',
{'USE PLAYLIST': {'return_value': True},
'TRY AGAIN': {'return_value': False, 'color': 'red'}},
parent_window=self._main_win)
response = confirm.run()
if not response:
return
else:
playlist = Playlist(playlist_name)
playlistCollection.add(playlist)
self._return = playlist_name
self.destroy()
示例4: _show_error_dialog
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def _show_error_dialog(self, title, description): # TODO: refactor this
kdialog = KanoDialog(
title,
description,
parent_window=self.win
)
kdialog.run()
示例5: _show_icon_tutorial
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def _show_icon_tutorial(self):
try:
from kano_profile.apps import save_app_state_variable, load_app_state_variable
if load_app_state_variable('kano-apps', 'icon-tutorial-shown'):
return
else:
save_app_state_variable('kano-apps', 'icon-tutorial-shown', True)
except ImportError:
# ignore problems importing kano_profile, as we don't want it to
# be a dependency
pass
kdialog = KanoDialog(
_("Add more apps to the desktop"),
_(
"Click the '+' button to the right of the app name to "
"make it appear on the desktop. You can remove it again "
"by clicking on 'x'."
),
{
_("OK, GOT IT"): {
"return_value": 0,
"color": "green"
}
},
parent_window=self
)
kdialog.set_action_background("grey")
kdialog.title.description.set_max_width_chars(40)
kdialog.run()
示例6: _show_username_taken_dialog
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def _show_username_taken_dialog(self, username): # TODO: refactor this
track_data('world-registration-username-taken', {'username': username})
kd = KanoDialog(
_("This username is taken!"),
_("Try another one"),
parent_window=self.win
)
kd.run()
self.data_screen.username.set_text("")
self.data_screen.validate_username()
self._disable_register_button()
self.data_screen.username.grab_focus()
示例7: delete_user
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
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?'),
description_text = _('Enter {}\'s password - A reboot will be required'.format(self.user)),
widget=password_input,
has_entry=True,
button_dict = [
{
'label': _('Cancel').upper(),
'color': 'red',
'return_value': False
},
{
'label': _('Ok').upper(),
'color': 'green',
'return_value': True
}
])
confirm.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
# Kano Dialog will return False if cancel button is clicked, or text from the entry field if Ok
response=confirm.run()
if response == False:
return
elif type(response) == str and not len(response):
error = KanoDialog(title_text = _('Please enter the password for user {}'.format(self.user)))
error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
error.run()
return
else:
password=response
# Authenticate user and schedule removal. Protect against unknown troubles.
try:
if pam.authenticate(self.user, password):
info = KanoDialog(title_text = _('User {} scheduled for removal'.format(self.user)), \
description_text = _('Press OK to reboot'))
info.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
info.run()
os.system('sudo kano-init schedule delete-user "{}"'.format(self.user))
LightDM.restart()
else:
error = KanoDialog(title_text = _('Incorrect password for user {}'.format(self.user)))
error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
error.run()
except Exception as e:
logger.error('Error deleting account {} - {}'.format(self.user, str(e)))
error = KanoDialog(title_text = _('Could not delete account {}'.format(self.user)))
error.dialog.set_position(Gtk.WindowPosition.CENTER_ALWAYS)
error.run()
示例8: get_sudo_password
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def get_sudo_password(heading, parent=None):
entry = Gtk.Entry()
entry.set_visibility(False)
kdialog = KanoDialog(
title_text=heading,
description_text="Enter your system password - default is kano:",
widget=entry,
has_entry=True,
global_style=True,
parent_window=parent
)
pw = kdialog.run()
del kdialog
del entry
while not pam.authenticate(getpass.getuser(), pw):
fail = KanoDialog(
title_text=heading,
description_text="The password was incorrect. Try again?",
button_dict={
"YES": {
"return_value": 0
},
"CANCEL": {
"return_value": -1,
"color": "red"
}
},
parent_window=parent
)
rv = fail.run()
del fail
if rv < 0:
return
entry = Gtk.Entry()
entry.set_visibility(False)
kdialog = KanoDialog(
title_text=heading,
description_text="Re-enter your system password - default is kano:",
widget=entry,
has_entry=True,
global_style=True,
parent_window=parent
)
pw = kdialog.run()
del kdialog
del entry
return pw
示例9: show_terms_and_conditions
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def show_terms_and_conditions(self, widget):
"""This is the dialog containing the terms and conditions - same as
shown before creating an account
"""
window = widget.get_toplevel()
# TODO: Figure out how/whether the legal text will be translated
legal_text = ""
for file in os.listdir(legal_dir):
with open(legal_dir + file, "r") as f:
legal_text = legal_text + f.read() + "\n\n\n"
kdialog = KanoDialog(_("Terms and conditions"), "", scrolled_text=legal_text, parent_window=window)
kdialog.run()
示例10: verify
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def verify(self):
pw = self.run()
if authenticate_parental_password(pw):
return True
fail = KanoDialog(
title_text='Try again?',
description_text='The password was incorrect. Changes not applied',
parent_window=self.win
)
fail.run()
return False
示例11: _auth_error_cb
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def _auth_error_cb(self, text, message_type=None):
logger.info('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()
示例12: error
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def error(self, msg):
error = KanoDialog(
_('Error updating'), msg,
{
'CLOSE': {
'return_value': True,
'color': 'red'
}
},
parent_window=self)
error.run()
# FIXME: This close doesn't work for some reason
self.close_window()
return False
示例13: _auth_error_cb
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
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()
示例14: _no_updates
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def _no_updates(self):
self.destroy()
self._set_normal_cursor()
no_updates = KanoDialog(
_('No updates available'),
_('Your system is already up to date'),
{
'OK': {
'return_value': True,
'color': 'green'
}
})
no_updates.run()
self.close_window()
示例15: disconnect_wifi
# 需要导入模块: from kano.gtk3.kano_dialog import KanoDialog [as 别名]
# 或者: from kano.gtk3.kano_dialog.KanoDialog import run [as 别名]
def disconnect_wifi():
from kano.network import KwifiCache, disconnect
from kano.gtk3.kano_dialog import KanoDialog
iface = get_wlan_device()
disconnect(iface)
wificache = KwifiCache()
wificache.empty()
kdialog = KanoDialog(
# Text from the content team.
_("Disconnect complete - you're now offline."),
)
kdialog.run()
return 0