本文整理汇总了Python中preferences.Preferences.run方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.run方法的具体用法?Python Preferences.run怎么用?Python Preferences.run使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preferences.Preferences
的用法示例。
在下文中一共展示了Preferences.run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import run [as 别名]
class GUI:
def __init__(self):
"""Initializes the window and create pointers for all the important widgets.
This function also runs some code to add functionality.
"""
# Initialize the window and several other objects in the instance
self.initialize_window()
# Properties instance to handle the preferences window
self.preferences = Preferences(self.main_window)
# Now setup the variables needed for file access
try:
self.setup_file_access()
except Exception, e:
# In case of error, the user must change the preferences
log(e.__class__.__name__)
log(e)
self.preferences.run()
self.setup_file_access()
self.modified = set() # Store the names of the modified files
# The next variable takes care of each file by holding the choices made for
# it. The values of the dictionary are Annotator objects, where information
# about the annotations made in the file
self.results = {}
# This flag determines whether signal handling should take place. It is True
# when the interface is being adjusted programatically
self.backend = False
开发者ID:davidsbatista,项目名称:Toponym-Disambiguation-Using-Ontology-Based-Semantic-Similarity,代码行数:35,代码来源:annota.py
示例2: IndicatorSysmonitor
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import run [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
示例3: IndicatorSysmonitor
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import run [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