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


Python pygtk.require方法代码示例

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


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

示例1: X_is_running

# 需要导入模块: import pygtk [as 别名]
# 或者: from pygtk import require [as 别名]
def X_is_running():
        try:
            import pygtk
            pygtk.require('2.0')
            import gtk

            from subprocess import Popen, PIPE
            p = Popen(["xset", "-q"], stdout=PIPE, stderr=PIPE)
            p.communicate()
            return p.returncode == 0
        except:
            return False 
开发者ID:yuxiaokui,项目名称:Intranet-Penetration,代码行数:14,代码来源:start.py

示例2: copy_url

# 需要导入模块: import pygtk [as 别名]
# 或者: from pygtk import require [as 别名]
def copy_url(url):
    """Copy the url into the clipboard."""
    # try windows first
    try:
        import win32clipboard
    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:yt-project,项目名称:yt,代码行数:34,代码来源:lodgeit.py

示例3: create_M_file

# 需要导入模块: import pygtk [as 别名]
# 或者: from pygtk import require [as 别名]
def create_M_file() :
    p = os.path.join(NCAM_DIR, NGC_DIR, 'M123')
    with open(p, 'wb') as f :
        f.write('#!/usr/bin/env python\n# coding: utf-8\n')

        f.write("import gtk\nimport os\nimport pygtk\npygtk.require('2.0')\nfrom gtk import gdk\n\n")

        f.write("fname = '%s'\n" % os.path.join(NCAM_DIR, CATALOGS_DIR, 'no_skip_dlg.conf'))
        f.write('if os.path.isfile(fname) :\n    exit(0)\n\n')

        f.write("msg = '%s'\n" % _('Stop LinuxCNC program,
toggle the shown button,
then restart'))
        f.write("msg1 = '%s'\n" % _('Skip block not active'))
        f.write("icon_fname = '%s'\n\n" % os.path.join(NCAM_DIR, GRAPHICS_DIR, 'skip_block.png'))

        f.write('dlg = gtk.MessageDialog(parent = None, flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, type = gtk.MESSAGE_WARNING, buttons = gtk.BUTTONS_NONE, message_format = msg1)\n\n')

        f.write("dlg.set_title('NativeCAM')\ndlg.format_secondary_markup(msg)\n\n")

        f.write('dlg.set_image(gtk.Image())\n')
        f.write('dlg.get_image().set_from_pixbuf(gdk.pixbuf_new_from_file_at_size(icon_fname, 80, 80))\n\n')

        f.write('cb = gtk.CheckButton(label = "%s")\n' % _("Do not show again"))
        f.write('dlg.get_content_area().pack_start(cb, True, True, 0)\n')
        f.write('dlg.add_button(gtk.STOCK_OK, gtk.RESPONSE_OK).grab_focus()\n\n')

        f.write('dlg.set_keep_above(True)\ndlg.show_all()\n\ndlg.run()\n')
        f.write("if cb.get_active() :\n    open(fname, 'w').close()\n")
        f.write('exit(0)\n')

    os.chmod(p, 0o755)
    mess_dlg(_('LinuxCNC needs to be restarted now')) 
开发者ID:FernV,项目名称:NativeCAM,代码行数:33,代码来源:ncam.py

示例4: copy_url

# 需要导入模块: import pygtk [as 别名]
# 或者: from pygtk import require [as 别名]
def copy_url(url):
    """Copy the url into the clipboard."""
    # try windows first
    try:
        import win32clipboard
    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
        for prog in 'pbcopy', 'xclip':
            try:
                client = Popen([prog], stdin=PIPE)
            except OSError:
                continue
            else:
                client.stdin.write(url)
                client.stdin.close()
                client.wait()
                break
        else:
            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:
        win32clipboard.OpenClipboard()
        win32clipboard.EmptyClipboard()
        win32clipboard.SetClipboardText(url)
        win32clipboard.CloseClipboard() 
开发者ID:softwarefactory-project,项目名称:software-factory,代码行数:38,代码来源:lodgeit.py


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