本文整理汇总了Python中preferences.Preferences.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.destroy方法的具体用法?Python Preferences.destroy怎么用?Python Preferences.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preferences.Preferences
的用法示例。
在下文中一共展示了Preferences.destroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IndicatorSysmonitor
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import destroy [as 别名]
#.........这里部分代码省略.........
def update_indicator_guide(self):
guide = self.sensor_mgr.get_guide()
#self.ind.set_property("label-guide", guide)
def update(self, data):
# data is the dict of all sensors and their values
# { name, label }
# look through data and find out if there are any icons to be set
for sensor in data:
test_str = data[sensor].lower()
if "use_icon" in test_str:
path = data[sensor].split(":")[1]
print(path)
self.ind.set_icon_full(path, "")
# now strip the icon output from data so that it is not displayed
remaining = test_str.split("use_icon")[0].strip()
if not remaining:
remaining = " "
data[sensor] = remaining
if "clear_icon" in test_str:
self.ind.set_icon_full(self.tindicator, "")
remaining = test_str.split("clear_icon")[0].strip()
if not remaining:
remaining = " "
data[sensor] = remaining
label = self.sensor_mgr.get_label(data)
Gdk.threads_enter()
self.ind.set_label(label.strip())
Gdk.threads_leave()
#self.ind.set_title(label.strip())
def load_settings(self):
self.sensor_mgr.load_settings()
self.sensor_mgr.initiate_fetcher(self)
self.update_indicator_guide()
# @staticmethod
def save_settings(self):
self.sensor_mgr.save_settings()
# actions raised from menu
def on_preferences_activated(self, event=None):
"""Raises the preferences dialog. If it's already open, it's
focused"""
if self._preferences_dialog is not None:
self._preferences_dialog.present()
return
self._preferences_dialog = Preferences(self)
self._preferences_dialog.run()
self._preferences_dialog = None
def on_full_sysmon_activated(self, event=None):
os.system('gnome-system-monitor &')
def on_exit(self, event=None, data=None):
"""Action call when the main programs is closed."""
# cleanup temporary indicator icon
os.remove(self.tindicator)
# close the open dialogs
if self._help_dialog is not None:
self._help_dialog.destroy()
if self._preferences_dialog is not None:
self._preferences_dialog.destroy()
logging.info("Terminated")
self.alive.clear() # DM: why bother with Event() ???
try:
Gtk.main_quit()
except RuntimeError:
pass
def _on_help(self, event=None, data=None):
"""Raise a dialog with info about the app."""
if self._help_dialog is not None:
self._help_dialog.present()
return
self._help_dialog = Gtk.MessageDialog(
None, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
Gtk.ButtonsType.OK, None)
self._help_dialog.set_title(_("Help"))
self._help_dialog.set_markup(HELP_MSG)
self._help_dialog.run()
self._help_dialog.destroy()
self._help_dialog = None
示例2: IndicatorSysmonitor
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import destroy [as 别名]
#.........这里部分代码省略.........
def update_indicator_guide(self):
guide = self.sensor_mgr.get_guide()
def update(self, data):
# data is the dict of all sensors and their values
# { name, label }
# look through data and find out if there are any icons to be set
for sensor in data:
test_str = data[sensor].lower()
if "use_icon" in test_str:
path = data[sensor].split(":")[1]
print(path)
self.ind.set_icon_full(path, "")
# now strip the icon output from data so that it is not displayed
remaining = test_str.split("use_icon")[0].strip()
if not remaining:
remaining = " "
data[sensor] = remaining
if "clear_icon" in test_str:
self.ind.set_icon_full(self.tindicator, "")
remaining = test_str.split("clear_icon")[0].strip()
if not remaining:
remaining = " "
data[sensor] = remaining
label = self.sensor_mgr.get_label(data)
def update_label(label):
self.ind.set_label(label)
return False
if label and self.ind:
GLib.idle_add(update_label, label.strip())
def load_settings(self):
self.sensor_mgr.load_settings()
self.sensor_mgr.initiate_fetcher(self)
self.update_indicator_guide()
# @staticmethod
def save_settings(self):
self.sensor_mgr.save_settings()
# actions raised from menu
def on_preferences_activated(self, event=None):
"""Raises the preferences dialog. If it's already open, it's
focused"""
if self._preferences_dialog is not None:
self._preferences_dialog.present()
return
self._preferences_dialog = Preferences(self)
self._preferences_dialog.run()
self._preferences_dialog = None
def on_full_sysmon_activated(self, event=None):
os.system('gnome-system-monitor &')
def on_exit(self, event=None, data=None):
"""Action call when the main programs is closed."""
# cleanup temporary indicator icon
os.remove(self.tindicator)
# close the open dialogs
if self._help_dialog is not None:
self._help_dialog.destroy()
if self._preferences_dialog is not None:
self._preferences_dialog.destroy()
logging.info("Terminated")
self.alive.clear() # DM: why bother with Event() ???
try:
Gtk.main_quit()
except RuntimeError:
pass
def _on_help(self, event=None, data=None):
"""Raise a dialog with info about the app."""
if self._help_dialog is not None:
self._help_dialog.present()
return
self._help_dialog = Gtk.MessageDialog(
None, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.INFO,
Gtk.ButtonsType.OK, None)
self._help_dialog.set_title(_("Help"))
self._help_dialog.set_markup(HELP_MSG)
self._help_dialog.run()
self._help_dialog.destroy()
self._help_dialog = None