当前位置: 首页>>代码示例>>Python>>正文


Python gtk.gtk_version方法代码示例

本文整理汇总了Python中gtk.gtk_version方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.gtk_version方法的具体用法?Python gtk.gtk_version怎么用?Python gtk.gtk_version使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gtk的用法示例。


在下文中一共展示了gtk.gtk_version方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: widget_pixbuf

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gtk_version [as 别名]
def widget_pixbuf(widget, maxsize=None):
    """Generate a pixbuf of a widget"""
    if gtk.gtk_version < (2, 14):
        return(None)

    pixmap = widget.get_snapshot()
    (width, height) = pixmap.get_size()
    pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
    pixbuf.get_from_drawable(pixmap, pixmap.get_colormap(), 0, 0, 0, 0, width,
            height)

    longest = max(width, height)

    if maxsize is not None:
        factor = float(maxsize) / float(longest)

    if not maxsize or (width * factor) > width or (height * factor) > height:
        factor = 1

    scaledpixbuf = pixbuf.scale_simple(int(width * factor), int(height * factor), gtk.gdk.INTERP_BILINEAR)

    return(scaledpixbuf) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:24,代码来源:util.py

示例2: position_popup_group_menu

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gtk_version [as 别名]
def position_popup_group_menu(self, menu, widget):
        """Calculate the position of the group popup menu"""
        _screen_w = gtk.gdk.screen_width()
        screen_h = gtk.gdk.screen_height()

        if gtk.gtk_version >= (2, 14):
            widget_win = widget.get_window()
        else:
            widget_win = widget.window
        widget_x, widget_y = widget_win.get_origin()
        _widget_w, widget_h = widget_win.get_size()

        _menu_w, menu_h = menu.size_request()

        if widget_y + widget_h + menu_h > screen_h:
            menu_y = max(widget_y - menu_h, 0)
        else:
            menu_y = widget_y + widget_h

        return(widget_x, menu_y, 1) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:22,代码来源:terminal.py

示例3: _on_aboutMenuItem_activate

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gtk_version [as 别名]
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") 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:21,代码来源:gtk2manhole.py

示例4: open_url

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gtk_version [as 别名]
def open_url(self, url, prepare=False):
        """Open a given URL, conditionally unpacking it from a VTE match"""
        oldstyle = False

        if prepare == True:
            url = self.prepare_url(url)
        dbg('open_url: URL: %s (prepared: %s)' % (url, prepare))

        if self.config['use_custom_url_handler']:
            dbg("Using custom URL handler: %s" %
                self.config['custom_url_handler'])
            try:
                subprocess.Popen([self.config['custom_url_handler'], url])
                return
            except:
                dbg('custom url handler did not work, falling back to defaults')

        if gtk.gtk_version < (2, 14, 0) or \
           not hasattr(gtk, 'show_uri') or \
           not hasattr(gtk.gdk, 'CURRENT_TIME'):
            oldstyle = True

        if oldstyle == False:
            try:
                gtk.show_uri(None, url, gtk.gdk.CURRENT_TIME)
            except:
                oldstyle = True

        if oldstyle == True:
            dbg('Old gtk (%s,%s,%s), calling xdg-open' % gtk.gtk_version)
            try:
                subprocess.Popen(["xdg-open", url])
            except:
                dbg('xdg-open did not work, falling back to webbrowser.open')
                import webbrowser
                webbrowser.open(url) 
开发者ID:OWASP,项目名称:NINJA-PingU,代码行数:38,代码来源:terminal.py

示例5: prepNotebook

# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import gtk_version [as 别名]
def prepNotebook(notebook=None, group=1):
    """
    Setup a notebook for use in vwindows/vviews.
    """
    if notebook == None:
        notebook = gtk.Notebook()
    if gtk.gtk_version[0] >= 2 and gtk.gtk_version[1] >= 12:
        notebook.connect("create-window", createNotebookWindow)
    notebook.set_group_id(group)
    return notebook 
开发者ID:joxeankoret,项目名称:nightmare,代码行数:12,代码来源:notebook.py


注:本文中的gtk.gtk_version方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。