我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用gtk.gtk_version()。
def _on_aboutMenuItem_activate(self, widget, *unused): import sys from os import path self.output.append("""\ a Twisted Manhole client Versions: %(twistedVer)s Python %(pythonVer)s on %(platform)s GTK %(gtkVer)s / PyGTK %(pygtkVer)s %(module)s %(modVer)s http://twistedmatrix.com/ """ % {'twistedVer': copyright.longversion, 'pythonVer': sys.version.replace('\n', '\n '), 'platform': sys.platform, 'gtkVer': ".".join(map(str, gtk.gtk_version)), 'pygtkVer': ".".join(map(str, gtk.pygtk_version)), 'module': path.basename(__file__), 'modVer': __version__, }, "local")
def check_requirements(self): try: import gtk except ImportError: raise CheckFailed("Requires pygtk") except RuntimeError: raise CheckFailed('pygtk present, but import failed.') else: version = (2, 2, 0) if gtk.pygtk_version < version: raise CheckFailed( "Requires pygtk %d.%d.%d or later. " "Found %d.%d.%d" % (version + gtk.pygtk_version)) ext = self.get_extension() self.add_flags(ext) check_include_file(ext.include_dirs, os.path.join("gtk", "gtk.h"), 'gtk') check_include_file(ext.include_dirs, os.path.join("pygtk", "pygtk.h"), 'pygtk') return 'Gtk: %s pygtk: %s' % ( ".".join(str(x) for x in gtk.gtk_version), ".".join(str(x) for x in gtk.pygtk_version))
def _PageTreeView_init_(self, ui): ''' This is a slightly modified copy of PageTreeView constructor with one additional column for icons. ''' BrowserTreeView.__init__(self) self.set_name('zim-pageindex') self.ui = ui self._cleanup = None # temporary created path that needs to be removed later column = gtk.TreeViewColumn('_pages_') self.append_column(column) # Added Icon column. cr0 = gtk.CellRendererPixbuf() column.pack_start(cr0, expand = False) column.set_attributes(cr0, pixbuf = ICON_COL) cr1 = gtk.CellRendererText() cr1.set_property('ellipsize', pango.ELLIPSIZE_END) column.pack_start(cr1, True) column.set_attributes(cr1, text=NAME_COL, style=STYLE_COL, foreground=FGCOLOR_COL, weight=WEIGHT_COL) cr2 = self.get_cell_renderer_number_of_items() column.pack_start(cr2, False) column.set_attributes(cr2, text=N_CHILD_COL, weight=WEIGHT_COL) if gtk.gtk_version >= (2, 12) \ and gtk.pygtk_version >= (2, 12): self.set_tooltip_column(TIP_COL) self.set_headers_visible(False) self.set_enable_search(True) self.set_search_column(0) self.enable_model_drag_source( gtk.gdk.BUTTON1_MASK, (INTERNAL_PAGELIST_TARGET,), gtk.gdk.ACTION_LINK | gtk.gdk.ACTION_MOVE ) self.enable_model_drag_dest( (INTERNAL_PAGELIST_TARGET,), gtk.gdk.ACTION_MOVE )