本文整理匯總了Python中ubuntutweak.widgets.dialogs.QuestionDialog.run方法的典型用法代碼示例。如果您正苦於以下問題:Python QuestionDialog.run方法的具體用法?Python QuestionDialog.run怎麽用?Python QuestionDialog.run使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ubuntutweak.widgets.dialogs.QuestionDialog
的用法示例。
在下文中一共展示了QuestionDialog.run方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: check_version
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def check_version(self):
gtk.gdk.threads_enter()
version = TweakSettings.get_version()
if version > VERSION:
dialog = QuestionDialog(
_(
"A newer version: %s is available online.\nWould you like to update?\n\nNote: if you prefer to update from the source code, you can disable this feature in Preferences."
)
% version,
title=_("Software Update"),
)
update = False
if dialog.run() == gtk.RESPONSE_YES:
update = True
dialog.destroy()
if update:
dialog = UpdateDialog(parent=self.get_toplevel())
dialog.run()
dialog.destroy()
gtk.gdk.threads_leave()
示例2: clean_selected_ppa
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def clean_selected_ppa(self):
self.set_busy()
# name_list is to display the name of PPA
# url_list is to identify the ppa
name_list = []
url_list = []
for id in self.get_list():
#TODO
try:
name_list.append(SOURCE_PARSER.get_name(int(id)))
url_list.append(SOURCE_PARSER.get_url(int(id)))
except:
name_list.append(ppa.get_short_name(id))
url_list.append(id)
package_view = DowngradeView()
package_view.update_model(url_list)
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
select_pkgs = package_view.get_downgrade_packages()
sw.add(package_view)
#TODO the logic is a little ugly, need to improve the BaseMessageDialog
if not select_pkgs:
message = _("It's safe to purge the PPA, no packages need to be downgraded.")
sw.hide()
else:
message = _("To safely purge the PPA, the following packages must be downgraded.")
sw.show_all()
sw.set_size_request(500, 100)
dialog = QuestionDialog(message, title=_("You're going to purge: %s") % ', '.join(name_list))
dialog.set_resizable(True)
dialog.vbox.pack_start(sw, True, True, 0)
dialog.show()
response = dialog.run()
dialog.destroy()
# Workflow
# 1. Downgrade all the PPA packages to offical packages #TODO Maybe not official? Because anther ppa which is enabled may have newer packages then offical
# 2. If succeed, disable PPA, or keep it
if response == gtk.RESPONSE_YES:
self.set_busy()
log.debug("The select pkgs is: %s", str(select_pkgs))
dialog = CleanPpaDialog(self.get_toplevel(), select_pkgs, url_list)
dialog.run()
dialog.destroy()
if dialog.error == False:
self.show_success_dialog()
else:
self.show_failed_dialog()
self.update_ppa_model()
self.unset_busy()
else:
self.update_ppa_model()
# TODO refresh source?
self.__check_list = []
self.emit('cleaned')
self.unset_busy()
示例3: on_have_update
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_have_update(self, client, id, entry, data):
if entry.get_value().get_bool():
dialog = QuestionDialog(_('New application data available, would you like to update?'))
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
dialog = FetchingDialog(get_app_data_url(), self.get_toplevel())
dialog.connect('destroy', self.on_app_data_downloaded)
dialog.run()
dialog.destroy()
示例4: on_have_update
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_have_update(self, client, id, entry, data):
if entry.get_value().get_bool():
if self.check_update():
dialog = QuestionDialog(_("New source data available, would you like to update?"))
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
dialog = FetchingDialog(get_source_data_url(), self.get_toplevel())
dialog.connect("destroy", self.on_source_data_downloaded)
dialog.run()
dialog.destroy()
示例5: on_idle_check
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_idle_check(self):
gtk.gdk.threads_enter()
if self.check_update():
dialog = QuestionDialog(_('New application data available, would you like to update?'))
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
dialog = FetchingDialog(APP_URL, self.get_toplevel())
dialog.connect('destroy', self.on_app_data_downloaded)
dialog.run()
dialog.destroy()
gtk.gdk.threads_leave()
示例6: on_reset_button_clicked
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_reset_button_clicked(self, widget):
iter = self.backup_combobox.get_active_iter()
model = self.backup_combobox.get_model()
dir = self.dir_label.get_text()
if dir.count("/") == 2:
message = _("Would you like to reset settings for: <b>%s</b>?") % dir
else:
message = _("Would you like to reset all settings under: <b>%s</b>?") % dir
addon_message = _("<b>NOTES</b>: Whilst resetting, your desktop may be unresponsive for a moment.")
dialog = QuestionDialog(message + "\n\n" + addon_message)
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
if dir.count("/") == 1:
for line in open(path):
stdout, stderr = do_reset_task(line.strip())
else:
stdout, stderr = do_reset_task(dir)
if stderr:
log.error(stderr)
# TODO raise error or others
return
InfoDialog(_("Reset Successful!\nYou may need to restart your desktop for changes to take effect")).launch()
示例7: on_recover_button_clicked
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_recover_button_clicked(self, widget):
iter = self.backup_combobox.get_active_iter()
model = self.backup_combobox.get_model()
dir = self.dir_label.get_text()
path = model.get_value(iter, 1)
if dir.count("/") == 2:
message = _("Would you like to recover the backup: <b>%s/%s</b>?") % (dir, os.path.basename(path)[:-4])
else:
message = _("Would you like to recover the backup of all <b>%s</b> settings named <b>%s</b>?") % (
dir,
os.path.basename(path)[:-4],
)
addon_message = _("<b>NOTES</b>: While recovering, your desktop may be unresponsive for a moment.")
dialog = QuestionDialog(message + "\n\n" + addon_message)
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
if dir.count("/") == 1:
for line in open(path):
stdout, stderr = do_recover_task(line.strip())
else:
stdout, stderr = do_recover_task(path)
if stderr:
log.error(stderr)
# TODO raise error or others
return
InfoDialog(
_("Recovery Successful!\nYou may need to restart your desktop for changes to take effect")
).launch()
示例8: on_restore_directory
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_restore_directory(self, widget):
model, iter = self.get_selection().get_selected()
userdir = model.get_value(iter, COLUMN_DIR)
dialog = QuestionDialog(
_(
"Ubuntu Tweak will restore the selected "
"directory to it's default location.\n"
"However, you must move your files back into place manually.\n"
"Do you wish to continue?"
)
)
if dialog.run() == gtk.RESPONSE_YES:
newdir = os.path.join(os.getenv("HOME"), self.uf.get_restorename(userdir))
self.uf.set_userdir(userdir, newdir)
model.set_value(iter, COLUMN_PATH, newdir)
if not os.path.exists(newdir):
os.mkdir(newdir)
elif os.path.isfile(newdir):
os.remove(newdir)
os.mkdir(newdir)
dialog.destroy()
示例9: show_changes
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def show_changes(self):
dialog = QuestionDialog("Install ?")
res = dialog.run()
dialog.hide()
if res == gtk.RESPONSE_YES:
return True
else:
return False
示例10: on_change_icon_clicked
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_change_icon_clicked(self, widget):
dialog = gtk.FileChooserDialog(_('Choose a new logo image'),
action=gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT,
gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
filter = gtk.FileFilter()
filter.set_name(_("PNG image (*.png)"))
filter.add_mime_type("image/png")
dialog.set_current_folder(os.path.expanduser('~'))
dialog.add_filter(filter)
if module_check.get_codename() == 'karmic':
dest = os.path.expanduser('~/.icons/%s/places/24/start-here.png' % self.__setting.get_icon_theme())
else:
dest = os.path.expanduser('~/.icons/%s/apps/24/start-here.png' % self.__setting.get_icon_theme())
revert_button = dialog.action_area.get_children()[-1]
if not os.path.exists(dest):
revert_button.set_sensitive(False)
filename = ''
response = dialog.run()
if response == gtk.RESPONSE_ACCEPT:
filename = dialog.get_filename()
dialog.destroy()
if filename:
pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
w, h = pixbuf.get_width(), pixbuf.get_height()
if w != 24 or h != 24:
ErrorDialog(_("This image size isn't suitable for the panel.\nIt should be 24x24.")).launch()
return
else:
os.system('mkdir -p %s' % os.path.dirname(dest))
os.system('cp %s %s' % (filename, dest))
image = gtk.image_new_from_file(dest)
widget.set_image(image)
elif response == gtk.RESPONSE_DELETE_EVENT:
dialog.destroy()
os.remove(dest)
image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here', size=24, force_reload=True))
widget.set_image(image)
else:
dialog.destroy()
return
dialog = QuestionDialog(_('Do you want your changes to take effect immediately?'))
if dialog.run() == gtk.RESPONSE_YES:
os.system('killall gnome-panel')
dialog.destroy()
示例11: on_clean_thumbnails_clicked
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_clean_thumbnails_clicked(self, widget):
question = QuestionDialog(_('The thumbnail cache will be deleted. Do you wish to continue?'),
title = _('Warning'))
if question.run() == gtk.RESPONSE_YES:
question.destroy()
dialog = CleanDialog(widget.get_toplevel())
dialog.run()
InfoDialog(_('Clean up Successful!')).launch()
self.set_clean_button_label(widget)
else:
question.destroy()
示例12: upgrade_sources
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def upgrade_sources(self):
dialog = QuestionDialog(_('After a successful distribution upgrade, '
'any third-party sources you use will be disabled by default.\n'
'Would you like to re-enable any sources disabled by Update Manager?'),
title=_('Upgrade Third Party Sources'))
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
proxy.upgrade_sources(self.__get_disable_string(), UPGRADE_DICT)
if not self.check_source_upgradable():
InfoDialog(_('Upgrade Successful!')).launch()
else:
ErrorDialog(_('Upgrade Failed!')).launch()
self.emit('call', 'ubuntutweak.modules.sourceeditor', 'update_source_combo', {})
self.update_thirdparty()
示例13: on_hostname_button_clicked
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_hostname_button_clicked(self, widget, label):
dialog = QuestionDialog(_('Please enter your new hostname. Blank characters should not be used.'),
title = _('New hostname'))
vbox = dialog.vbox
entry = gtk.Entry()
vbox.pack_start(entry, False, False, 0)
vbox.show_all()
res = dialog.run()
dialog.destroy()
if res == gtk.RESPONSE_YES:
new_name = entry.get_text()
proxy.exec_command('hostname %s' % new_name)
if os.popen('hostname').read().strip() == new_name:
label.set_label(new_name)
示例14: on_delete_button_clicked
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_delete_button_clicked(self, widget):
def try_remove_record_in_root_backup(dir, path):
rootpath = build_backup_prefix("/".join(dir.split("/")[:2])) + os.path.basename(path)
if os.path.exists(rootpath):
lines = open(rootpath).read().split()
lines.remove(path)
if len(lines) == 0:
os.remove(rootpath)
else:
new = open(rootpath, "w")
new.write("\n".join(lines))
new.close()
def try_remove_all_subback(path):
for line in open(path):
os.remove(line.strip())
iter = self.backup_combobox.get_active_iter()
model = self.backup_combobox.get_model()
dir = self.dir_label.get_text()
path = model.get_value(iter, 1)
if dir.count("/") == 2:
dialog = QuestionDialog(
_("Would you like to delete the backup: <b>%s/%s</b>?") % (dir, os.path.basename(path)[:-4])
)
else:
dialog = QuestionDialog(
_("Would you like to delete the backup of all <b>%s</b> settings named <b>%s</b>?")
% (dir, os.path.basename(path)[:-4])
)
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
if dir.count("/") == 2:
try_remove_record_in_root_backup(dir, path)
else:
try_remove_all_subback(path)
os.remove(path)
self.update_backup_model(dir)
示例15: on_reset_button_clicked
# 需要導入模塊: from ubuntutweak.widgets.dialogs import QuestionDialog [as 別名]
# 或者: from ubuntutweak.widgets.dialogs.QuestionDialog import run [as 別名]
def on_reset_button_clicked(self, widget):
iter = self.backup_combobox.get_active_iter()
model = self.backup_combobox.get_model()
dir = self.dir_label.get_text()
if dir.count('/') == 2:
message = _('Would you like to reset settings for: <b>%s</b>?') % dir
else:
message = _('Would you like to reset all settings under: <b>%s</b>?') % dir
addon_message = _('<b>NOTES</b>: Whilst resetting, your desktop may be unresponsive for a moment.')
dialog = QuestionDialog(message + '\n\n' + addon_message)
response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
stdout, stderr = do_reset_task(dir)
if stderr:
log.error(stderr)
#TODO raise error or others
return
self.__show_successful_with_logout_button(_('Reset Successful!\nYou may need to restart your desktop for changes to take effect'))