本文整理汇总了Python中options.Options.update_options方法的典型用法代码示例。如果您正苦于以下问题:Python Options.update_options方法的具体用法?Python Options.update_options怎么用?Python Options.update_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类options.Options
的用法示例。
在下文中一共展示了Options.update_options方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from options import Options [as 别名]
# 或者: from options.Options import update_options [as 别名]
#.........这里部分代码省略.........
if image_url is not None:
urllib.urlretrieve(image_url, path)
image = gtk.Image()
image = gtk.gdk.pixbuf_new_from_file_at_size(path, 100, 40)
self.tree.get_widget("user_thumb").set_from_pixbuf(image)
def on_username_entry_insert_text(self, widget):
"""Check the user database on keypress to see if we have a match"""
entry = self.tree.get_widget("username_entry").get_text()
users = self.usersDB.get_users_like(entry)
if len(users) is 1:
self.tree.get_widget("username_entry").set_text(users[0][0])
def on_password_entry_key_press_event(self, widget, key):
#this logs in the user if they press Enter from the password box
if key.keyval == 65293:
self.on_login_clicked(widget)
def login_auto_completer(self):
self.completion = gtk.EntryCompletion()
self.completion.set_inline_completion(True)
self.completion.set_popup_completion(False)
self.tree.get_widget("username_entry").set_completion(self.completion)
liststore = gtk.ListStore(str)
self.completion.set_model(liststore)
pixbufcell = gtk.CellRendererPixbuf()
self.completion.pack_start(pixbufcell)
self.completion.add_attribute(pixbufcell, 'pixbuf', 3)
self.completion.set_text_column(0)
users = self.usersDB.get_users(all=True)
for user in users:
liststore.append([user[0]])
#this section deals with the OPTIONS WINDOW
def on_options_window_destroy(self, widget, event=False):
self.options_window.hide()
return True
def on_apply_options_clicked(self, widget):
random = self.tree.get_widget("random").get_active()
alpha = self.tree.get_widget("alphabetical").get_active()
startup_check = self.tree.get_widget("startup_check").get_active()
auto_scrobble = self.tree.get_widget("auto_scrobble").get_active()
auto_time = self.tree.get_widget("auto_time").get_active()
scrobble_time = self.tree.get_widget("scrobble_time").get_value()
use_default_time = self.tree.get_widget("use_default_time").get_active()
self.options.update_options(random, alpha,
startup_check, auto_scrobble, auto_time,
scrobble_time, use_default_time)
self.options_window.hide()
def on_auto_time_toggled(self, widget):
active = self.tree.get_widget("auto_time").get_active()
if active:
auto_active = False
else:
auto_active = True
self.tree.get_widget("use_default_time").set_sensitive(auto_active)
self.tree.get_widget("scrobble_time").set_sensitive(auto_active)
def on_authenticate_clicked(self, widget):
"""This is the button in the options menu"""
text = _("Please authenticate MTP-Lastfm in your web browser. \
This is required if you wish to love/tag tracks. \
After the authentication is complete click OK")
message = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO,
gtk.BUTTONS_OK_CANCEL, text)
webservice = webservices.LastfmWebService()
token = webservice.request_session_token()
webservice.request_authorisation(token)
resp = message.run()
message.destroy()
if resp == gtk.RESPONSE_OK:
valid, session_key = webservice.create_web_service_session(token)
if valid is True:
self.usersDB.add_key(self.username, session_key)
self.tree.get_widget("auth_label").set_text(_("User authenticated"))
self.tree.get_widget("authenticate").hide()
self.session_key = session_key
text = _("Authentication complete")
else:
self.tree.get_widget("auth_label").set_text(session_key)
text = session_key
result = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO,
gtk.BUTTONS_OK, text)
result.run()
result.destroy()
def on_about_clicked(self, widget):
response = self.tree.get_widget("about_dialog").run()
if response == gtk.RESPONSE_DELETE_EVENT or response == gtk.RESPONSE_CANCEL:
self.tree.get_widget("about_dialog").hide()
def open_website(self, widget):
buttons = {"user_button" : "http://last.fm/user/%s" % self.username,
"report_bug" : "https://bugs.launchpad.net/mtp-lastfm"}
webbrowser.open_new_tab(buttons[widget.name])
示例2: __init__
# 需要导入模块: from options import Options [as 别名]
# 或者: from options.Options import update_options [as 别名]
#.........这里部分代码省略.........
#this logs in the user if they press Enter from the password box
if key.keyval == 65293:
self.on_login_clicked(widget)
def login_auto_completer(self):
self.completion = gtk.EntryCompletion()
self.completion.set_inline_completion(True)
self.completion.set_popup_completion(False)
self.tree.get_widget("username_entry").set_completion(self.completion)
liststore = gtk.ListStore(str)
self.completion.set_model(liststore)
pixbufcell = gtk.CellRendererPixbuf()
self.completion.pack_start(pixbufcell)
self.completion.add_attribute(pixbufcell, 'pixbuf', 3)
self.completion.set_text_column(0)
users = self.usersDB.get_users(all=True)
for user in users:
liststore.append([user[0]])
#this section deals with the OPTIONS WINDOW
def on_options_window_destroy(self, widget, event=False):
self.options_window.hide()
return True
def on_apply_options_clicked(self, widget):
random = self.tree.get_widget("random").get_active()
alpha = self.tree.get_widget("alphabetical").get_active()
startup_check = self.tree.get_widget("startup_check").get_active()
auto_scrobble = self.tree.get_widget("auto_scrobble").get_active()
auto_time = self.tree.get_widget("auto_time").get_active()
scrobble_time = self.tree.get_widget("scrobble_time").get_value()
use_default_time = self.tree.get_widget("use_default_time").get_active()
self.options.update_options(random, alpha,
startup_check, auto_scrobble, auto_time,
scrobble_time, use_default_time)
self.options_window.hide()
def on_auto_time_toggled(self, widget):
active = self.tree.get_widget("auto_time").get_active()
if active:
auto_active = False
else:
auto_active = True
self.tree.get_widget("use_default_time").set_sensitive(auto_active)
self.tree.get_widget("scrobble_time").set_sensitive(auto_active)
def on_authenticate_clicked(self, widget):
"""This is the button in the options menu"""
text = _("""Please authenticate MTP-Lastfm in your web browser. This is required if you wish to love/tag tracks. After the authentication is complete click OK""")
message = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO,
gtk.BUTTONS_OK_CANCEL, text)
webservice = webservices.LastfmWebService()
token = webservice.request_session_token()
webservice.request_authorisation(token)
resp = message.run()
message.destroy()
if resp == gtk.RESPONSE_OK:
valid, session_key = webservice.create_web_service_session(token)
if valid is True:
self.usersDB.add_key(self.username, session_key)
self.tree.get_widget("auth_label").set_text(_("User authenticated"))
self.tree.get_widget("authenticate").hide()
self.session_key = session_key
text = _("Authentication complete")
else: