本文整理汇总了Python中preferences.Preferences.connect方法的典型用法代码示例。如果您正苦于以下问题:Python Preferences.connect方法的具体用法?Python Preferences.connect怎么用?Python Preferences.connect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类preferences.Preferences
的用法示例。
在下文中一共展示了Preferences.connect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IssueView
# 需要导入模块: from preferences import Preferences [as 别名]
# 或者: from preferences.Preferences import connect [as 别名]
class IssueView(PanelView):
"""
"""
_log = getLogger("IssueView")
def __init__(self, context, editor):
PanelView.__init__(self, context)
self._log.debug("init")
self._editor = editor
self._handlers = {}
self._preferences = Preferences()
self._preferences.connect("preferences-changed", self._on_preferences_changed)
self._show_tasks = self._preferences.get("issues-show-tasks")
self._show_warnings = self._preferences.get("issues-show-warnings")
self._icons = { Issue.SEVERITY_WARNING : GdkPixbuf.Pixbuf.new_from_file(Resources().get_icon("warning.png")),
Issue.SEVERITY_ERROR : GdkPixbuf.Pixbuf.new_from_file(Resources().get_icon("error.png")),
Issue.SEVERITY_INFO : None,
Issue.SEVERITY_TASK : GdkPixbuf.Pixbuf.new_from_file(Resources().get_icon("task.png")) }
grid = Gtk.Grid()
self.add(grid)
self._store = Gtk.ListStore(GdkPixbuf.Pixbuf, str, str, object)
self._view = Gtk.TreeView(model=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)
column = Gtk.TreeViewColumn()
column.set_title(_("File"))
text_renderer2 = Gtk.CellRendererText()
column.pack_start(text_renderer2, True)
column.add_attribute(text_renderer2, "markup", 2)
self._view.insert_column(column, -1)
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.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
self._scr.set_shadow_type(Gtk.ShadowType.IN)
self._scr.set_hexpand(True)
self._scr.set_vexpand(True)
grid.add(self._scr)
# toolbar
self._button_warnings = Gtk.ToggleToolButton()
self._button_warnings.set_tooltip_text(_("Show/Hide Warnings"))
image = Gtk.Image()
image.set_from_file(Resources().get_icon("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(Resources().get_icon("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.ToolbarStyle.ICONS)
toolbar.set_icon_size(Gtk.IconSize.MENU)
toolbar.insert(self._button_warnings, -1)
toolbar.insert(self._button_tasks, -1)
toolbar.set_vexpand(True)
grid.add(toolbar)
# theme like gtk3
ctx = self._scr.get_style_context()
ctx.set_junction_sides(Gtk.JunctionSides.RIGHT)
ctx = toolbar.get_style_context()
ctx.set_junction_sides(Gtk.JunctionSides.LEFT | Gtk.JunctionSides.RIGHT)
ctx.add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR)
self._issues = []
self.show_all()
#.........这里部分代码省略.........