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


Python gi.require_version方法代码示例

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


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

示例1: is_quartz

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def is_quartz():
    """
    Tests to see if Python is currently running with gtk and
    windowing system is Mac OS-X's "quartz".
    """
    if mac():
        try:
            import gi
            gi.require_version('Gtk', '3.0')
            gi.require_version('Gdk', '3.0')
            from gi.repository import Gtk
            from gi.repository import Gdk
        except ImportError:
            return False
        return Gdk.Display.get_default().__class__.__name__.endswith("QuartzDisplay")
    return False 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:18,代码来源:constfunc.py

示例2: _looks_like_require_version

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def _looks_like_require_version(node):
    # Return whether this looks like a call to gi.require_version(<name>, <version>)
    # Only accept function calls with two constant arguments
    if len(node.args) != 2:
        return False

    if not all(isinstance(arg, nodes.Const) for arg in node.args):
        return False

    func = node.func
    if isinstance(func, nodes.Attribute):
        if func.attrname != 'require_version':
            return False
        if isinstance(func.expr, nodes.Name) and func.expr.name == 'gi':
            return True

        return False

    if isinstance(func, nodes.Name):
        return func.name == 'require_version'

    return False 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:24,代码来源:brain_gi.py

示例3: get_icon_by_name

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def get_icon_by_name(name, size=256):
    try:
        gi.require_version('Gtk', '3.0')
        from gi.repository import Gtk
    except:
        raise MissingDependencies(
            'Unable to lookup system icons!',
            ['gir1.2-gtk-3.0']
        )

    icon_theme = Gtk.IconTheme.get_default()
    icon = icon_theme.lookup_icon(name, size, 0)
    if icon:
        file_path = icon.get_filename()
        _type = get_type_by_filepath(file_path)
        return _type(file_path)
    else:
        raise IconNotFound(name) 
开发者ID:masmu,项目名称:pulseaudio-dlna,代码行数:20,代码来源:images.py

示例4: _looks_like_require_version

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def _looks_like_require_version(node):
    # Return whether this looks like a call to gi.require_version(<name>, <version>)
    # Only accept function calls with two constant arguments
    if len(node.args) != 2:
        return False

    if not all(isinstance(arg, nodes.Const) for arg in node.args):
        return False

    func = node.func
    if isinstance(func, nodes.Attribute):
        if func.attrname != "require_version":
            return False
        if isinstance(func.expr, nodes.Name) and func.expr.name == "gi":
            return True

        return False

    if isinstance(func, nodes.Name):
        return func.name == "require_version"

    return False 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:24,代码来源:brain_gi.py

示例5: __init__

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def __init__(self, *args, **kwargs):
		StatusIcon.__init__(self, *args, **kwargs)
		
		try:
			import gi
			gi.require_version('AppIndicator3', '0.1')
			from gi.repository import AppIndicator3 as appindicator
			
			self._status_active  = appindicator.IndicatorStatus.ACTIVE
			self._status_passive = appindicator.IndicatorStatus.PASSIVE
		except (ImportError, ValueError):
			raise NotImplementedError
		
		category = appindicator.IndicatorCategory.APPLICATION_STATUS
		# Whatever icon is set here will be used as a tooltip icon during the entire time to icon is shown
		self._tray = appindicator.Indicator.new("syncthing-gtk", self._get_icon(), category)
		self._tray.set_menu(self._get_popupmenu())
		self._tray.set_title(self.TRAY_TITLE) 
开发者ID:kozec,项目名称:syncthing-gtk,代码行数:20,代码来源:statusicon.py

示例6: init_gi_clipboard

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def init_gi_clipboard():
    import gi
    gi.require_version('Gtk', '3.0')
    from gi.repository import Gtk, Gdk
    cb = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

    def copy_gi(text):
        cb.set_text(text, -1)
        cb.store()

    def paste_gi():
        clipboardContents = cb.wait_for_text()
        # for python 2, returns None if the clipboard is blank.
        if clipboardContents is None:
            return ''
        else:
            return clipboardContents

    return copy_gi, paste_gi 
开发者ID:mass-immersion-approach,项目名称:MIA-Dictionary-Addon,代码行数:21,代码来源:Pyperclip.py

示例7: __init__

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def __init__(self):
        """Initialization method of :class:`dragonfire.stray.SystemTrayIcon` class.
        """

        import gi
        gi.require_version('Gtk', '3.0')
        from gi.repository import Gtk
        self.Gtk = Gtk

        self.icon = self.Gtk.StatusIcon()
        self.icon.set_title("Dragonfire")
        if os.path.isfile(TRAY_ICON):
            self.icon.set_from_file(TRAY_ICON)
        else:
            self.icon.set_from_file(DEVELOPMENT_DIR + TRAY_ICON_ALT)
        self.icon.connect('popup-menu', self.popup_menu)
        self.Gtk.main() 
开发者ID:DragonComputer,项目名称:Dragonfire,代码行数:19,代码来源:stray.py

示例8: notify

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def notify(message, title='AutomaThemely'):
    import gi
    gi.require_version('Notify', '0.7')
    from gi.repository import Notify, GLib

    if not Notify.is_initted():
        Notify.init('AutomaThemely')

    n = Notify.Notification.new(title, message, get_resource('automathemely.svg'))
    try:  # I don't even know... https://bugzilla.redhat.com/show_bug.cgi?id=1582833
        n.show()
    except GLib.GError as e:
        if str(e) != 'g-dbus-error-quark: Unexpected reply type (16)' \
                and str(e) != 'g-dbus-error-quark: GDBus.Error:org.freedesktop.DBus.Error.NoReply: Message recipient ' \
                              'disconnected from message bus without replying (4)':
            raise e 
开发者ID:C2N14,项目名称:AutomaThemely,代码行数:18,代码来源:utils.py

示例9: _register_require_version

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def _register_require_version(node):
    # Load the gi.require_version locally
    try:
        import gi
        gi.require_version(node.args[0].value, node.args[1].value)
    except Exception:
        pass

    return node 
开发者ID:AtomLinter,项目名称:linter-pylama,代码行数:11,代码来源:brain_gi.py

示例10: __init__

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def __init__(self, path, cached=True, size=256):
        try:
            gi.require_version('Rsvg', '2.0')
            from gi.repository import Rsvg
        except:
            raise MissingDependencies(
                'Unable to convert SVG image to PNG!', ['gir1.2-rsvg-2.0']
            )
        try:
            import cairo
        except:
            raise MissingDependencies(
                'Unable to convert SVG image to PNG!', ['cairo']
            )

        tmp_file = tempfile.NamedTemporaryFile()
        image_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, size, size)
        rsvg_handle = Rsvg.Handle.new_from_file(path)

        context = cairo.Context(image_surface)
        context.scale(
            float(size) / rsvg_handle.props.height,
            float(size) / rsvg_handle.props.width
        )
        rsvg_handle.render_cairo(context)
        image_surface.write_to_png(tmp_file.name)

        BaseImage.__init__(self, tmp_file.name, cached=True) 
开发者ID:masmu,项目名称:pulseaudio-dlna,代码行数:30,代码来源:images.py

示例11: _register_require_version

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def _register_require_version(node):
    # Load the gi.require_version locally
    try:
        import gi

        gi.require_version(node.args[0].value, node.args[1].value)
    except Exception:
        pass

    return node 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:12,代码来源:brain_gi.py

示例12: has_display

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def has_display():
    """
    Tests to see if Python is currently running with gtk
    """
    # FIXME: currently, Gtk.init_check() requires all strings
    # in argv, and we might have unicode.
    temp, sys.argv = sys.argv, sys.argv[:1]
    try:
        import gi
        gi.require_version('Gtk', '3.0')
        gi.require_version('Gdk', '3.0')
        from gi.repository import Gtk
        from gi.repository import Gdk
    except ImportError:
        return False

    try:
        test = Gtk.init_check(temp) and \
            Gdk.Display.get_default()
        sys.argv = temp
        return bool(test)
    except:
        sys.argv = temp
        return False

# A couple of places add menu accelerators using <alt>, which doesn't
# work with Gtk-quartz. <Meta> is the usually correct replacement, but
# in one case the key is a number, and <meta>number is used by Spaces
# (a mac feature), so we'll use control instead. 
开发者ID:GenealogyCollective,项目名称:gprime,代码行数:31,代码来源:constfunc.py

示例13: assert_valid_output_file

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def assert_valid_output_file(output_video_location):
    '''
    Given a file, validates it is a video (mp4) file
    '''
    import gi
    gi.require_version('Gst', '1.0')
    from gi.repository import Gst, GLib

    Gst.init(None)
    mainloop = GLib.MainLoop()

    # We create a pipeline so that we can read the file and check it:
    pipeline = Gst.ElementFactory.make("playbin")
    pipeline.set_property('uri','file://'+output_video_location)
    playsink = pipeline.get_by_name('playsink')
    playsink.set_property('video-sink', Gst.ElementFactory.make('fakesink'))
    pipeline.set_state(Gst.State.PAUSED)

    def after_a_second():
        assert pipeline.get_state(0).state == Gst.State.PAUSED
        element = pipeline.get_by_name('inputselector1')
        caps = element.get_static_pad('src').get_current_caps()
        assert caps.to_string() == 'audio/x-raw, format=(string)F32LE, layout=(string)interleaved, rate=(int)48000, channels=(int)2, channel-mask=(bitmask)0x0000000000000003'

        element = pipeline.get_by_name('inputselector0')
        caps = element.get_static_pad('src').get_current_caps()
        assert caps.to_string() == 'video/x-raw, format=(string)NV12, width=(int)640, height=(int)360, interlace-mode=(string)progressive, multiview-mode=(string)mono, multiview-flags=(GstVideoMultiviewFlagsSet)0:ffffffff:/right-view-first/left-flipped/left-flopped/right-flipped/right-flopped/half-aspect/mixed-mono, pixel-aspect-ratio=(fraction)1/1, chroma-site=(string)jpeg, colorimetry=(string)bt601, framerate=(fraction)30/1'

        pipeline.set_state(Gst.State.NULL)
        mainloop.quit()

    GLib.timeout_add(1000, after_a_second)
    mainloop.run() 
开发者ID:bbc,项目名称:brave,代码行数:35,代码来源:test_file_output.py

示例14: check11_osmgpsmap

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def check11_osmgpsmap(self):
        '''osmgpsmap'''
        # Start check
        OSMGPSMAP_MIN_VERSION = (1, 0)
        OSMGPSMAP_FOUND = False

        try:
            from gi import Repository
            repository = Repository.get_default()
            if repository.enumerate_versions("OsmGpsMap"):
                gi.require_version('OsmGpsMap', '1.0')
                from gi.repository import OsmGpsMap as osmgpsmap
                try:
                    osmgpsmap_str = osmgpsmap._version
                    OSMGPSMAP_FOUND = True
                except Exception:  # any failure to 'get' the version
                    osmgpsmap_str = 'unknown version'
            else:
                osmgpsmap_str = 'not found'

        except ImportError:
            osmgpsmap_str = 'not found'

        if OSMGPSMAP_FOUND:
            result = ("* osmgpsmap " + osmgpsmap_str + " (Success version " +
                      verstr(OSMGPSMAP_MIN_VERSION) +
                      " or greater installed.)")
        else:
            result = ("* osmgpsmap " + osmgpsmap_str + " (Requires version " +
                      verstr(OSMGPSMAP_MIN_VERSION) + " or greater)")

        # End check
        self.append_text(result) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:35,代码来源:PrerequisitesCheckerGramplet.py

示例15: check19_geocodeglib

# 需要导入模块: import gi [as 别名]
# 或者: from gi import require_version [as 别名]
def check19_geocodeglib(self):
        '''geocodeglib
        # added to gramps master v5.1.0
        #TODO: add to gramps-v check

        https://github.com/gramps-project/gramps/blob/maintenance/gramps50/gramps/plugins/lib/maps/placeselection.py
        '''
        self.append_text("\n")
        # Start check
        geocodeglib_min_ver = "1.0"

        try:
            gi.require_version('GeocodeGlib', '1.0')
            from gi.repository import GeocodeGlib
            geocodeglib_ver = str(GeocodeGlib._version)
            GEOCODEGLIB = True
        except Exception:
            geocodeglib_ver = "Not found"
            GEOCODEGLIB = False

        if GEOCODEGLIB:
            result = ("* geocodeglib " + geocodeglib_ver +
                      " (Success version " + geocodeglib_min_ver +
                      " or greater installed.)")
        else:
            result = ("* geocodeglib " + geocodeglib_ver +
                      " (Requires version " + geocodeglib_min_ver +
                      " or greater installed.)")

        # End check
        self.append_text(result) 
开发者ID:gramps-project,项目名称:addons-source,代码行数:33,代码来源:PrerequisitesCheckerGramplet.py


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