本文整理汇总了Python中options.Options.getNotifications方法的典型用法代码示例。如果您正苦于以下问题:Python Options.getNotifications方法的具体用法?Python Options.getNotifications怎么用?Python Options.getNotifications使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类options.Options
的用法示例。
在下文中一共展示了Options.getNotifications方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PyazanGTK
# 需要导入模块: from options import Options [as 别名]
# 或者: from options.Options import getNotifications [as 别名]
class PyazanGTK(object):
def __init__(self):
self.mainloop = gobject.MainLoop()
self.status_icon = gtk.StatusIcon()
self.status_icon.set_from_file(TRAYICON)
self.options = Options()
self.ui = UiDict(os.path.join(XML, 'pyazan_ui.xml'))
self.ui['pref_window'].set_icon_from_file(TRAYICON)
self.attach_signals()
self.load_options()
self.plugin_handler = PluginGTK(self)
gobject.timeout_add_seconds(60, self.update_tool_tip)
def update_tool_tip(self):
prayer, time = self.praynotifier.now
tooltiplist = str(self.praynotifier).split("\n")
currentindex = PRAYER_NAMES.index(prayer)+2
if len(tooltiplist) > currentindex:
tooltiplist[currentindex] = "<u>%s</u>" % tooltiplist[currentindex]
nicetime = str(getTimeDiff(self.praynotifier.waitingfor[1])).split(":")[0:2]
tooltiplist.append("\nTime until next prayer %s" % ":".join(nicetime))
if hasattr(self.status_icon.props, 'tooltip_markup'):
self.status_icon.props.tooltip_markup = "\n".join(tooltiplist)
else:
self.status_icon.set_tooltip("\n".join(tooltiplist))
return True
def load_options(self):
praynotifies = self.options.getNotifications()
self.location = self.options.getLocation()
self.praynotifier = PrayerTimesNotifier(self.location, praynotifies)
self.update_tool_tip()
self.ui["txt_location"].set_text(str(self.location))
#set notify times in preference menu
for prayer_name in PRAYER_NAMES:
enabled = prayer_name in praynotifies
self.ui["chkbnt_%s" % prayer_name].set_active(enabled)
def apply_config(self, *args):
#set prayer events
pray_names_to_notify = list()
for prayer_name in PRAYER_NAMES:
if self.ui["chkbnt_%s" % prayer_name].get_active():
pray_names_to_notify.append(prayer_name)
self.options.setNotifications(pray_names_to_notify)
self.praynotifier.alert_on = pray_names_to_notify
#set location
self.location.timezone = self.get_time_zone()
self.praynotifier.praytime.location = self.location
self.options.setLocation(self.location)
self.plugin_handler.save()
self.options.save()
self.update_tool_tip()
def get_time_zone(self):
timezone = 'AUTO'
if not self.ui['rdbtn_tz_auto'].get_active():
iter = self.ui['cmbbox_tz_select'].get_active_iter()
if iter:
model = self.ui['cmbbox_tz_select'].get_model()
timezone = model.get_value(iter, 1)
return timezone
def settings_ok(self, *args):
self.apply_config(*args)
self.close_options_window(*args)
def start(self):
self.praynotifier.start()
self.mainloop.run()
def load_location(self, *args):
from location_ui import Location_ui
Location_ui(self)
def attach_signals(self):
#connect events
self.ui["pref_window"].connect("delete-event", lambda a,b: a.hide() or True)
self.ui["menuitem_quit"].connect("activate", self.quit)
self.ui["menuitem_options"].connect("activate", self.show_options_window)
self.ui["btn_pref_cancel"].connect("released", self.close_options_window)
self.ui["btn_pref_apply"].connect("released", self.apply_config)
self.ui["btn_pref_ok"].connect("released", self.settings_ok)
self.ui["btn_change_loc"].connect("released", self.load_location)
self.ui["pref_window"].connect("delete-event", lambda a,b: a.hide() or True)
self.status_icon.connect("popup-menu", self.show_status_icon_popup)
def quit(self, *args):
self.mainloop.quit()
#.........这里部分代码省略.........