• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pygtk.require函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pygtk.require函数的典型用法代码示例。如果您正苦于以下问题:Python require函数的具体用法?Python require怎么用?Python require使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: lineReceived

 def lineReceived(self, line):
     if self.data_mode:
         if line == ".":
             self.sendCode(250, "Ok")
             self.data_mode = 0
             try:
                 self.output.close()
             except BaseException, e:
                 print 'Something strange (%s) appened '
                 'while closing the spool file' % e
             if self.verbose:
                 print "A mail was sent..."
             if self.notify:
                 import pygtk
                 pygtk.require('2.0')
                 import pynotify
                 n = pynotify.Notification("Fake smtpserver",
                                           "a mail was sent...")
                 n.show()
         else:
             try:
                 self.output.write(line + '\n')
             except BaseException, e:
                 print 'Something strange (%s) appened '
                 'while writing to spool file' % e
开发者ID:jeansch,项目名称:nits,代码行数:25,代码来源:nits.py


示例2: __init__

 def __init__(self, consumer_key, consumer_secret):
     auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
     conf = self.__readSettings()
     if conf:
         auth.set_access_token(conf[0], conf[1])
     else:
         import pygtk
         pygtk.require('2.0')
         import gtk
         clipboard = gtk.clipboard_get()
         auth_url = auth.get_authorization_url()
         oldText = clipboard.wait_for_text()
         self.__openUrlInBrowser(auth_url)
         while True:
             verifier = clipboard.wait_for_text()
             if verifier is not None and oldText != verifier and re.compile(r"\d{7}").match(verifier):
                 logger.info("Pass verifier: " + str(verifier))
                 break;
             else:
                 clipboard.clear()
                 logger.info("wrong verifier: " + str(verifier))
                 sleep(1)
         auth.get_access_token(verifier)
     print "ACCESS_KEY = '%s'" % auth.access_token.key
     print "ACCESS_SECRET = '%s'" % auth.access_token.secret
     self.__auth = auth
     self.__writeSettings()
开发者ID:soldierkam,项目名称:pynews,代码行数:27,代码来源:oauth.py


示例3: _check_pygtk

    def _check_pygtk(self, pygtk_version, gtk_version):
        try:
            import gtk
            gtk  # pylint: disable=W0104
        except ImportError:
            try:
                import pygtk
                # This modifies sys.path
                pygtk.require('2.0')
                # Try again now when pygtk is imported
                import gtk
            except ImportError as e:
                # Can't display a dialog here since gtk is not available
                raise SystemExit(
                    "ERROR: PyGTK not found, can't start Stoq: %r" % (e, ))

        if gtk.pygtk_version < pygtk_version:
            self._too_old(project="PyGTK+",
                          url="http://www.pygtk.org/",
                          found=_tuple2str(gtk.pygtk_version),
                          required=pygtk_version)

        if gtk.gtk_version < gtk_version:
            self._too_old(project="Gtk+",
                          url="http://www.gtk.org/",
                          found=_tuple2str(gtk.gtk_version),
                          required=gtk_version)
开发者ID:Guillon88,项目名称:stoq,代码行数:27,代码来源:dependencies.py


示例4: gtk2_dialog

		def gtk2_dialog():

			# GTK+ 2

			import pygtk
			pygtk.require('2.0')

			dialog = gtk.FileChooserDialog(title, None,
										   gtk.FILE_CHOOSER_ACTION_OPEN,
										   (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
											gtk.STOCK_OPEN, gtk.RESPONSE_OK))

			dialog.set_default_response(gtk.RESPONSE_OK)

			if extensions:
				for entry in extensions:
					file_filter = gtk.FileFilter()
					file_filter.set_name(entry)

					for pattern in extensions[entry]:
						file_filter.add_pattern(pattern)

					dialog.add_filter(file_filter)

			dialog.set_select_multiple(multiple_files)

			response = dialog.run()

			if response == gtk.RESPONSE_OK:
				return dialog.get_filenames()

			elif response == gtk.RESPONSE_CANCEL:
				return None

			dialog.destroy()
开发者ID:bharadwaj-raju,项目名称:libdesktop,代码行数:35,代码来源:files.py


示例5: copy_url

def copy_url(url):
    """Copy the url into the clipboard."""
    if sys.platform == 'darwin':
        url = re.escape(url)
        os.system(r"echo %s | pbcopy" % url)
        return True

    try:
        import win32clipboard
        import win32con
        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardText(url)
        win32clipboard.CloseClipboard()
        return True
    except ImportError:
        try:
            if os.environ.get('DISPLAY'):
                import pygtk
                pygtk.require('2.0')
                import gtk
                import gobject
                gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(url)
                gobject.idle_add(gtk.main_quit)
                gtk.main()
                return True
        except:
            pass
    return False
开发者ID:almet,项目名称:oh-my-vim,代码行数:29,代码来源:fpcli.py


示例6: checkTicket347

def checkTicket347():
    """
    Check for a recent enough PyGTK to not leak python integers in message
    processing (mostly affects soundcard, firewire)
    """
    result = messages.Result()
    import pygtk
    pygtk.require('2.0')
    import gobject
    # Really, we want to check for pygobject_version, but that doesn't exist in
    # all versions of pygtk, and this check is sufficient.
    (major, minor, nano) = gobject.pygtk_version
    if (major, minor, nano) < (2, 8, 6):
        m = messages.Warning(T_(
            N_("Version %d.%d.%d of the PyGTK library contains "
                "a memory leak.\n"),
            major, minor, nano),
            mid='ticket-347')
        m.add(T_(N_("The Soundcard and Firewire sources may leak a lot of "
                    "memory as a result, and would need to be restarted "
                    "frequently.\n")))
        m.add(T_(N_("Please upgrade '%s' to version %s or later."),
            'pygtk', '2.8.6'))
        result.add(m)

    result.succeed(None)
    return defer.succeed(result)
开发者ID:offlinehacker,项目名称:flumotion,代码行数:27,代码来源:checks.py


示例7: check_X

def check_X (display, xauth):
    # Checking if I can use X
    os.environ['DISPLAY'] = display
    os.environ['XAUTHORITY'] = xauth

    try:
        import pygtk
        pygtk.require("2.0")

    except:
        pass

    try:
        import gtk

    except:
        print _("You need to install pyGTK or GTKv2,\n"
                "or set your PYTHONPATH correctly.\n"
                "try: export PYTHONPATH= ")
        sys.exit(1)

    try:
        gtk.init_check ()

    except Exception as e:
        print _("Could not open a connection to X!")
        print e
        sys.exit (1)
开发者ID:GNOME,项目名称:gnome-schedule,代码行数:28,代码来源:xwrapper.py


示例8: __init__

    def __init__(self):
        import pygtk
        pygtk.require('2.0')
        import gtk
        import pango

        self.gtk = gtk

        self.gtk.gdk.set_program_class('launchbox')

        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.connect('delete_event', self.on_delete_event)
        self.window.connect('destroy', self.on_destroy)
        self.window.padding = 10

        self.alignment = gtk.Alignment()
        self.alignment.set_padding(10, 10, 10, 10)
        self.window.add(self.alignment)

        self.entry = gtk.Entry()
        self.entry.set_width_chars(24)
        self.entry.modify_font(pango.FontDescription('40'))
        self.alignment.add(self.entry)
        # self.window.set_focus(self.entry)

        self.window.set_position(gtk.WIN_POS_CENTER)
        self.window.show_all()
        self.window.window.focus()

        self.completer = Completer()

        self.window.add_events(gtk.gdk.KEY_PRESS_MASK)
        self.entry.connect('key-press-event', self.on_key_press_event)
        self.entry.connect('key-release-event', self.on_key_release_event)
开发者ID:olemb,项目名称:launchbox,代码行数:34,代码来源:launchbox.py


示例9: genNotify

def genNotify(gn_title="",gn_msg="",gn_duration=5):
    #This will be the generic notification that will be called throughout
    #it will try to contact xbmc first...if it can't it will pass the message to pynotify.
    global os    
    gn_return=""
    msg=urllib.quote(gn_msg)
    #Hopefully that will have 'escaped' characters and encoded accordingly
    urltoget="GET \"http://%s:%[email protected]%s/xbmcCmds/xbmcHttp?command=ExecBuiltIn(Notification(%s, %s,7500))\"" % (gm_xbmcusername,gm_xbmcpassword,gm_xbmcaddress,gn_title,msg)
    logger.debug("Sending xbmc msg via: %s" % urltoget)
    xbmcsuccess= str(os.system(urltoget))
    if "<li>OK" in xbmcsuccess:
        return gn_return
        exit
    try:
       #will doing this import over and over eat memory, or is it clever enough to not? mmm
       import gtk, pygtk, os, os.path, pynotify
       pygtk.require('2.0')
    except:
       gn_return = "Error: need python-notify, python-gtk2 and gtk"
    if not pynotify.init("Timekpr notification"):
        return "timekpr notification failed to initialize"
        sys.exit(1)
    n = pynotify.Notification(gn_title, gn_msg,"file://%s/icon.png" % mypath)
    #n = pynotify.Notification("Moo title", "test", "file:///path/to/icon.png")
    n.set_urgency(pynotify.URGENCY_CRITICAL)
    n.set_timeout(gn_duration*1000) # 5 seconds
    n.set_category("device")
    if not n.show():
        gn_return= "Failed"
    return gn_return
开发者ID:icedfusion,项目名称:misonotifications,代码行数:30,代码来源:gmnotifier.py


示例10: main

def main (args):
    import locale
    import gettext

    import pygtk; pygtk.require('2.0');

    import gobject
    from gobject.option import OptionParser, make_option

    import gtk

    import maindialog
    import config

    locale.setlocale (locale.LC_ALL, "")
    gettext.install (config.PACKAGE, config.LOCALEDIR)

    parser = OptionParser (
            option_list = [
		    # FIXME: remove this when we can get all the default
		    # options
                    make_option ("--version",
                                 action="store_true",
                                 dest="version",
                                 help=config.VERSION),
                ])
    parser.parse_args (args)

    if parser.values.version:
        # Translators: %s is the version number 
        print _("Simple Menu Editor %s") % (config.VERSION)
    else:
        dialog = maindialog.MenuEditorDialog (args)
        gtk.main ()
开发者ID:johnsonc,项目名称:swarm,代码行数:34,代码来源:main.py


示例11: run_osra

def run_osra(osra):
	sdf = " "    
	filedes, filename = tempfile.mkstemp(suffix='.png')

	if os.name=="posix":
		import pygtk
		pygtk.require('2.0')
		import gtk, gobject
		clipboard = gtk.clipboard_get()
		image=clipboard.wait_for_image()
		if not image:
			return sdf
		try:
			image.save(filename,"png")
		except:
			return sdf
	else:
		import ImageGrab
		image = ImageGrab.grabclipboard()
		if not image:
			return sdf
		try:
			image.save(filename)
		except:
			return sdf

	try:
		stdout, stdin, stderr = popen2.popen3('"%s" -f sdf %s' % (osra, filename))
	except:
		os.remove(filename)
		return sdf

	sdf = stdout.read()
	#os.remove(filename)
	return sdf
开发者ID:andrewdefries,项目名称:osra,代码行数:35,代码来源:convert_clipboard_image.py


示例12: check_posix_dependencies

def check_posix_dependencies():
    """
    Returns a list with all the import's problems

    This is run at startup to ease users solving dependencies problems
    """
    resp = []
    try:
        import pygtk
        pygtk.require("2.0")
    except ImportError:
        resp.append("python-gtk2 module not found, please install it")
    except AssertionError:
        resp.append("python-gtk module found, please upgrade to python-gtk2")

    try:
        from twisted.copyright import version
        if [int(x) for x in re.search(r'^(\d+)\.(\d+)\.(\d+)',
                      version).groups()] < [ 2, 2, 0, ]:
            resp.append("python-twisted module is too old, please upgrade it")

    except ImportError:
        resp.append("python-twisted module not found, please install it")

    import gtk
    if not hasattr(gtk, 'StatusIcon'):
        try:
            import egg.trayicon
        except ImportError:
            resp.append("egg.trayicon module not found, please install it")

    return resp
开发者ID:andrewbird,项目名称:vodafone-mobile-connect,代码行数:32,代码来源:startup.py


示例13: __init__

    def __init__(self, path, solution):
        import pygtk
        import gtk

        pygtk.require('2.0')
        self.solution = solution
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.window.show()
        self.window.connect('destroy', self.destroy)
        self.box = gtk.HBox()
        self.image = gtk.Image()
        self.image.set_from_file(path)
        self.entry = gtk.Entry()
        self.entry.connect('activate', self.solve)
        self.button = gtk.Button('Go')
        self.button.connect('clicked', self.solve)

        self.window.add(self.box)
        self.box.pack_start(self.image)
        self.box.pack_start(self.entry)
        self.box.pack_start(self.button)
        self.box.show()
        self.image.show()
        self.button.show()
        self.entry.show()
        self.entry.grab_focus()
开发者ID:mirth,项目名称:captcha_solver,代码行数:26,代码来源:gui.py


示例14: copy_to_clipboard_on_linux

def copy_to_clipboard_on_linux(text):
    """
    Copies a text to Clipboard on Linux.

    http://www.answermysearches.com/
        python-how-to-copy-and-paste-to-the-clipboard-in-linux/286/
    """
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk

        # get the clipboard
        clipboard = gtk.clipboard_get()

        # set the clipboard text data
        clipboard.set_text(text)

        # make our data available to other applications
        clipboard.store()
    except:  # pylint: disable-msg=W0702
        # W0702: No exception type(s) specified
        print "Unexpected error:", sys.exc_info()[0]

        # copying to clipboard using GTK did not work.
        # maybe, Tkinter will work, so try it too.
        copy_to_clipboard_on_windows(text)
开发者ID:caglartoklu,项目名称:servhere,代码行数:27,代码来源:servhere.py


示例15: gtkui_dependency_check

def gtkui_dependency_check():
    '''
    This function verifies that the dependencies that are needed by the GTK user interface are met.
    '''

    print('\tGTK UI dependencies...', end='')

    # Check Gtk
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk, gobject
        assert gtk.gtk_version >= (2, 12)
        assert gtk.pygtk_version >= (2, 12)
        print(common.console_color('\tOK', 'green'))
    except:
        print(common.console_color("\tD'oh!", 'red'))
        print('You have to install GTK and PyGTK versions >=2.12 to be able to '
                'run the GTK user interface.\n'
                '    - On Debian-based distributions: apt-get install python-gtk2\n'
                '    - On Mac: sudo port install py25-gtk')
        sys.exit(1)

    # Check GtkSourceView2
    try:
        print('\tGtkSourceView2...', end='')
        import gtksourceview2
        print(common.console_color('\tOK', 'green'))
    except:
        print(common.console_color("\tD'oh!", 'red'))
        print('GtkSourceView2 not installed! Install it for your platform:\n'
                '    - On Debian-based distributions: apt-get install python-gtksourceview2')
        sys.exit(1)
开发者ID:Wingless-Archangel,项目名称:bokken,代码行数:33,代码来源:dependency_check.py


示例16: gtkui_dependency_check

def gtkui_dependency_check():
    '''
    This function verifies that the dependencies that are needed by the GTK user interface are met.
    '''

    print '\tGTK UI dependencies...',

    # Check Gtk
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk, gobject
        assert gtk.gtk_version >= (2, 12)
        assert gtk.pygtk_version >= (2, 12)
        print OKGREEN + "\tOK" + ENDC
    except:
        print FAIL + "\tD'oh!" + ENDC
        msg = 'You have to install GTK and PyGTK versions >=2.12 to be able to run the GTK user interface.\n'
        msg += '    - On Debian-based distributions: apt-get install python-gtk2\n'
        msg += '    - On Mac: sudo port install py25-gtk'        
        print msg
        sys.exit( 1 )

    # Check GtkSourceView2
    try:
        print '\tGtkSourceView2...',
        import gtksourceview2
        print OKGREEN + "\tOK" + ENDC
    except:
        print FAIL + "\tD'oh!" + ENDC
        print "GtkSourceView2 not installed! Install it for your platform:"
        print "    - On Debian-based distributions: apt-get install python-gtksourceview2"
        sys.exit( 1 )
开发者ID:dvader1,项目名称:bokken,代码行数:33,代码来源:dependency_check.py


示例17: dependency_check

def dependency_check():
    """
    This dependency check function uses the information stored in the platforms
    module to call the function in core.controllers.dependency_check which
    actually checks for the dependencies.
    
    The data in the core.ui.gui.dependency_check.platforms module is actually
    based on the data stored in core.controllers.dependency_check.platforms,
    we extend() the lists present in the base module before passing them to
    mdep_check() 
    """
    should_exit = mdep_check(dependency_set=GUI, exit_on_failure=False)
    
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk
        import gobject
        assert gtk.gtk_version >= (2, 12)
        assert gtk.pygtk_version >= (2, 12)
    except:
        msg = 'The GTK package requirements are not met, please make sure your'\
              ' system meets these requirements:\n'\
              '    - PyGTK >= 2.12\n'\
              '    - GTK >= 2.12\n'
        print msg
        should_exit = True
    
    if should_exit:
        sys.exit(1)
开发者ID:ElAleyo,项目名称:w3af,代码行数:30,代码来源:dependency_check.py


示例18: import_pygtk

def import_pygtk():
    try:
        import pygtk
    except ImportError:
        raise errors.BzrCommandError("PyGTK not installed.")
    pygtk.require('2.0')
    return pygtk
开发者ID:edsrzf,项目名称:dotfiles,代码行数:7,代码来源:__init__.py


示例19: copy_url

def copy_url(url):
    """Copy the url into the clipboard."""
    # try windows first
    try:
        import win32clipboard
        import win32con
    except ImportError:
        # then give pbcopy a try.  do that before gtk because
        # gtk might be installed on os x but nobody is interested
        # in the X11 clipboard there.
        from subprocess import Popen, PIPE
        try:
            client = Popen(['pbcopy'], stdin=PIPE)
        except OSError:
            try:
                import pygtk
                pygtk.require('2.0')
                import gtk
                import gobject
            except ImportError:
                return
            gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD).set_text(url)
            gobject.idle_add(gtk.main_quit)
            gtk.main()
        else:
            client.stdin.write(url)
            client.stdin.close()
            client.wait()
    else:
        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardText(url)
        win32clipboard.CloseClipboard()
开发者ID:AndyWxy,项目名称:my-configs,代码行数:33,代码来源:lodgeit.py


示例20: __init__

    def __init__(self):
        try:
            import pygtk
            pygtk.require("2.0")
        except:
            print "FAILS"
            pass
            
        try:
            import gtk
            import gtk.glade
        except:
            sys.exit(1)

        self.widgetTree = gtk.glade.XML("CreateTask.glade")
        self.window     = self.widgetTree.get_widget("mainWindow")

        dic = { 
            "on_click_create_btn" : self.on_click_create_btn,
            "on_click_cancel_btn" : self.on_click_cancel_btn
        }

        self.widgetTree.signal_autoconnect( dic )
        
        self.set_project_combo()
开发者ID:grzegorzbartman,项目名称:toggl-ubuntu-indicator,代码行数:25,代码来源:indicator-applet-toggl.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python haml.to_html函数代码示例发布时间:2022-05-25
下一篇:
Python pygtail.Pygtail类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap