本文整理汇总了Python中preferences.Preferences.register_monitor方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.register_monitor方法的具体用法?Python Preferences.register_monitor怎么用?Python Preferences.register_monitor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preferences.Preferences
的用法示例。
在下文中一共展示了Preferences.register_monitor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IssueView
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import register_monitor [as 别名]
class IssueView(BottomView, IPreferencesMonitor):
"""
"""
_log = getLogger("IssueView")
label = "Issues"
icon = gtk.STOCK_DIALOG_INFO
scope = View.SCOPE_EDITOR
def __init__(self, context, editor):
BottomView.__init__(self, context)
self._editor = editor
self._handlers = {}
def init(self, context):
self._log.debug("init")
self._preferences = Preferences()
self._show_tasks = self._preferences.get_bool("IssuesShowTasks", True)
self._show_warnings = self._preferences.get_bool("IssuesShowWarnings", True)
self._context = context
self._icons = { Issue.SEVERITY_WARNING : pixbuf_new_from_file(find_resource("icons/warning.png")),
Issue.SEVERITY_ERROR : pixbuf_new_from_file(find_resource("icons/error.png")),
Issue.SEVERITY_INFO : None,
Issue.SEVERITY_TASK : pixbuf_new_from_file(find_resource("icons/task.png")) }
self._store = gtk.ListStore(Pixbuf, str, str, object)
self._view = gtk.TreeView(self._store)
column = gtk.TreeViewColumn()
column.set_title("Message")
pixbuf_renderer = gtk.CellRendererPixbuf()
column.pack_start(pixbuf_renderer, False)
column.add_attribute(pixbuf_renderer, "pixbuf", 0)
text_renderer = gtk.CellRendererText()
column.pack_start(text_renderer, True)
column.add_attribute(text_renderer, "markup", 1)
self._view.append_column(column)
self._view.insert_column_with_attributes(-1, "File", gtk.CellRendererText(), markup=2)
self._handlers[self._view] = self._view.connect("row-activated", self._on_row_activated)
self._scr = gtk.ScrolledWindow()
self._scr.add(self._view)
self._scr.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
self._scr.set_shadow_type(gtk.SHADOW_IN)
self.pack_start(self._scr, True)
# toolbar
self._button_warnings = gtk.ToggleToolButton()
self._button_warnings.set_tooltip_text("Show/Hide Warnings")
image = gtk.Image()
image.set_from_file(find_resource("icons/warning.png"))
self._button_warnings.set_icon_widget(image)
self._button_warnings.set_active(self._show_warnings)
self._handlers[self._button_warnings] = self._button_warnings.connect("toggled", self.__on_warnings_toggled)
self._button_tasks = gtk.ToggleToolButton()
self._button_tasks.set_tooltip_text("Show/Hide Tasks")
imageTask = gtk.Image()
imageTask.set_from_file(find_resource("icons/task.png"))
self._button_tasks.set_icon_widget(imageTask)
self._button_tasks.set_active(self._show_tasks)
self._handlers[self._button_tasks] = self._button_tasks.connect("toggled", self.__on_tasks_toggled)
toolbar = gtk.Toolbar()
toolbar.set_orientation(gtk.ORIENTATION_VERTICAL)
toolbar.set_style(gtk.TOOLBAR_ICONS)
toolbar.set_icon_size(gtk.ICON_SIZE_MENU)
toolbar.insert(self._button_warnings, -1)
toolbar.insert(self._button_tasks, -1)
self.pack_start(toolbar, False)
self._issues = []
self._preferences.register_monitor(self)
self._log.debug("init finished")
def _on_row_activated(self, view, path, column):
"""
A row has been double-clicked on
"""
issue = self._store.get(self._store.get_iter(path), 3)[0]
self._context.activate_editor(issue.file)
#~ # FIXME: this doesn't work correctly
#~ if not self._context.active_editor is None:
#~ self._context.active_editor.select(issue.start, issue.end)
self._editor.select(issue.start, issue.end)
#.........这里部分代码省略.........