Example #1
0
    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()
Example #2
0
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 )
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
Example #4
0
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 ()
def _check_libs():
    try:
        import pygtk
        pygtk.require('2.0')
        import gtk
        import gnome
        import gnome.ui
        gnome.ui.authentication_manager_init()
        import gconf
        import gobject
        gobject.threads_init()
        import gnomevfs
    except ImportError:
        print '%s needs pygtk and gnome-python >= 2.12!' % NAME
        sys.exit(1)

    try:
        import pygst
        pygst.require('0.10')
        import gst
    except ImportError:
        print '%s needs python-gstreamer 0.10!' % NAME
        sys.exit(1)

    print '  using Gstreamer version: %s' % (
            '.'.join([str(s) for s in gst.gst_version]))
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:%s@%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
Example #7
0
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)
Example #8
0
def get_gtk_keymap(ignore_keys=[None, "VoidSymbol"], add_if_missing=[]):
    """
        Augment the keymap we get from gtk.gdk.keymap_get_default()
        by adding the keyval_name.
        We can also ignore some keys
    """
    import pygtk
    pygtk.require("2.0")
    import gtk
    keymap = gtk.gdk.keymap_get_default()
    keycodes=[]
    max_entries = 1
    for i in range(0, 2**8):
        entries = keymap.get_entries_for_keycode(i)
        if entries:
            max_entries = max(max_entries, len(entries))
            for keyval, keycode, group, level in entries:
                name = gtk.gdk.keyval_name(keyval)
                if name not in ignore_keys:
                    keycodes.append((nn(keyval), nn(name), nn(keycode), nn(group), nn(level)))
                if name in add_if_missing:
                    add_if_missing.remove(name)
    #TODO: do this server-side to ensure all modifiers can be set
    if add_if_missing:
        for name in add_if_missing:
            keycodes.append((0, name, 0, 0, 0))
    return keycodes
Example #9
0
    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)
Example #10
0
		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()
Example #11
0
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)
Example #12
0
 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()
Example #13
0
File: nits.py Project: jeansch/nits
 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
Example #14
0
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)
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)
Example #16
0
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()
Example #17
0
    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)
    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()
Example #19
0
def import_pygtk():
    try:
        import pygtk
    except ImportError:
        raise errors.BzrCommandError("PyGTK not installed.")
    pygtk.require('2.0')
    return pygtk
Example #20
0
 def init_pygtk(self):
     """
     Make sure we have GTK+ >= 2.0
     """
     import pygtk
     pygtk.require('2.0')
     del pygtk
Example #21
0
def import_gtk2():
    import pygtk

    pygtk.require("2.0")
    import gtk

    return gtk
Example #22
0
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
Example #23
0
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)
Example #24
0
    def parse_config(self):
        self.config = ConfigParser.RawConfigParser()
        self.config.readfp(StringIO.StringIO(self.default_config))
        self.config.read([
            '/etc/marchobmenu/menu.conf',
            os.path.expanduser('~/.config/marchobmenu/menu.conf')
        ])

        self.show_icons = self.config.getboolean('Icons', 'show')
        if self.show_icons:
            self.default_icon = self.config.get('Icons', 'default')
            self.icon_size = self.config.getint('Icons', 'size')
            self.use_gtk_theme = self.config.getboolean('Icons', 'use_gtk_theme')
            if self.use_gtk_theme:
                try:
                    import pygtk
                    pygtk.require('2.0')
                    import gtk
                    gtk_settings = gtk.settings_get_default()
                    self.theme = gtk_settings.get_property('gtk-icon-theme-name')
                except:
                    self.use_gtk_theme = False
                    self.theme = self.config.get('Icons','theme')
            else:
                self.theme = self.config.get('Icons','theme')
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
Example #26
0
def main(command_args):
	"""Implements the logic of the 0desktop command.
	@param command_args: the command-line arguments"""
	parser = OptionParser(usage=_("usage: %prog [options] [URI]"))
	parser.add_option("-m", "--manage", help=_("manage added applications"), action='store_true')
	parser.add_option("-v", "--verbose", help=_("more verbose output"), action='count')
	parser.add_option("-V", "--version", help=_("display version information"), action='store_true')

	(options, args) = parser.parse_args(command_args)

	if options.verbose:
		if options.verbose == 1:
			logger.setLevel(logging.INFO)
		else:
			logger.setLevel(logging.DEBUG)
		hdlr = logging.StreamHandler()
		fmt = logging.Formatter("%(levelname)s:%(message)s")
		hdlr.setFormatter(fmt)
		logger.addHandler(hdlr)

	if options.version:
		import zeroinstall
		print("0desktop (zero-install) " + zeroinstall.version)
		print("Copyright (C) 2013 Thomas Leonard")
		print(_("This program comes with ABSOLUTELY NO WARRANTY,"
				"\nto the extent permitted by law."
				"\nYou may redistribute copies of this program"
				"\nunder the terms of the GNU Lesser General Public License."
				"\nFor more information about these matters, see the file named COPYING."))
		sys.exit(0)

	if not args:
		interface_uri = None
	elif len(args) == 1:
		interface_uri = args[0]
	else:
		parser.print_help()
		sys.exit(1)

	if sys.version_info[0] < 3:
		import pygtk
		pygtk.require('2.0')
	else:
		from zeroinstall.gtkui import pygtkcompat
		pygtkcompat.enable()
		pygtkcompat.enable_gtk(version = '3.0')
	import gtk

	if options.manage:
		from zeroinstall.gtkui.applistbox import AppListBox, AppList
		from zeroinstall.injector.iface_cache import iface_cache
		box = AppListBox(iface_cache, AppList())
	else:
		from zeroinstall.gtkui.addbox import AddBox
		box = AddBox(interface_uri)

	box.window.connect('destroy', gtk.main_quit)
	box.window.show()
	gtk.main()
def clipboard(clip_text):
	import pygtk
	pygtk.require('2.0')
	import gtk
	clipboard = gtk.clipboard_get()
	text = clipboard.wait_for_text()
	clipboard.set_text(clip_text)
	clipboard.store()
Example #28
0
def check_versions():
    print("[gtk2.py] CEF Python {ver}".format(ver=cef.__version__))
    print("[gtk2.py] Python {ver} {arch}".format(
            ver=platform.python_version(), arch=platform.architecture()[0]))
    print("[gtk2.py] GTK {ver}".format(ver='.'.join(
                                           map(str, list(gtk.gtk_version)))))
    assert cef.__version__ >= "55.3", "CEF Python v55.3+ required to run this"
    pygtk.require('2.0')
Example #29
0
 def has_pygtk():
     try:
         import pygtk
         pygtk.require('2.0')
         import gtk
         return True
     except:
         return False
Example #30
0
def imports():
    import pygtk
    pygtk.require('2.0')
    import gtk
    from xpcom import components
    from xpcom.server import WrapObject
    from xpcomponents import BrowserImpl
    import sys
    globals().update(locals())
Example #31
0
def run_gui(args):
    parser = OptionParser(usage=_("usage: %prog [options] interface"))
    parser.add_option("",
                      "--before",
                      help=_("choose a version before this"),
                      metavar='VERSION')
    parser.add_option("", "--cpu", help=_("target CPU type"), metavar='CPU')
    parser.add_option("",
                      "--command",
                      help=_("command to select"),
                      metavar='COMMAND')
    parser.add_option("-d",
                      "--download-only",
                      help=_("fetch but don't run"),
                      action='store_true')
    parser.add_option("-g",
                      "--force-gui",
                      help=_("display an error if there's no GUI"),
                      action='store_true')
    parser.add_option("",
                      "--message",
                      help=_("message to display when interacting with user"))
    parser.add_option("",
                      "--not-before",
                      help=_("minimum version to choose"),
                      metavar='VERSION')
    parser.add_option("",
                      "--os",
                      help=_("target operation system type"),
                      metavar='OS')
    parser.add_option("-r",
                      "--refresh",
                      help=_("check for updates of all interfaces"),
                      action='store_true')
    parser.add_option("",
                      "--select-only",
                      help=_("only download the feeds"),
                      action='store_true')
    parser.add_option("-s",
                      "--source",
                      help=_("select source code"),
                      action='store_true')
    parser.add_option("",
                      "--systray",
                      help=_("download in the background"),
                      action='store_true')
    parser.add_option("-v",
                      "--verbose",
                      help=_("more verbose output"),
                      action='count')
    parser.add_option("-V",
                      "--version",
                      help=_("display version information"),
                      action='store_true')
    parser.add_option("",
                      "--with-store",
                      help=_("add an implementation cache"),
                      action='append',
                      metavar='DIR')

    parser.disable_interspersed_args()

    (options, args) = parser.parse_args(args)

    if options.verbose:
        logger = logging.getLogger()
        if options.verbose == 1:
            logger.setLevel(logging.INFO)
        else:
            logger.setLevel(logging.DEBUG)

    if options.version:
        import gui
        print("0launch-gui (zero-install) " + gui.version)
        print("Copyright (C) 2010 Thomas Leonard")
        print(
            _("This program comes with ABSOLUTELY NO WARRANTY,"
              "\nto the extent permitted by law."
              "\nYou may redistribute copies of this program"
              "\nunder the terms of the GNU Lesser General Public License."
              "\nFor more information about these matters, see the file named COPYING."
              ))
        sys.exit(0)

    def nogui(ex):
        if options.force_gui:
            fn = logging.warn
        else:
            fn = logging.info
            fn("No GUI available", exc_info=ex)
        sys.exit(100)

    with warnings.catch_warnings():
        if not options.force_gui:
            warnings.filterwarnings("ignore")
        if sys.version_info[0] < 3:
            try:
                import pygtk
                pygtk.require('2.0')
            except ImportError as ex:
                nogui(ex)

        import gui

        try:
            if sys.version_info[0] > 2:
                from zeroinstall.gtkui import pygtkcompat
                pygtkcompat.enable()
                pygtkcompat.enable_gtk(version='3.0')
            import gtk
        except (ImportError, ValueError) as ex:
            nogui(ex)

        if gtk.gdk.get_display() is None:
            try:
                raise SafeException("Failed to connect to display.")
            except SafeException as ex:
                nogui(ex)  # logging needs this as a raised exception

    handler = gui.GUIHandler()

    config = load_config(handler)

    if options.with_store:
        from zeroinstall import zerostore
        for x in options.with_store:
            config.stores.stores.append(zerostore.Store(os.path.abspath(x)))

    if len(args) < 1:

        @tasks. async
        def prefs_main():
            import preferences
            box = preferences.show_preferences(config)
            done = tasks.Blocker('close preferences')
            box.connect('destroy', lambda w: done.trigger())
            yield done

        tasks.wait_for_blocker(prefs_main())
        sys.exit(0)

    interface_uri = args[0]

    if len(args) > 1:
        parser.print_help()
        sys.exit(1)

    import mainwindow, dialog

    r = requirements.Requirements(interface_uri)
    r.parse_options(options)

    widgets = dialog.Template('main')

    driver = Driver(config=config, requirements=r)
    root_iface = config.iface_cache.get_interface(interface_uri)
    driver.solver.record_details = True

    window = mainwindow.MainWindow(driver,
                                   widgets,
                                   download_only=bool(options.download_only),
                                   select_only=bool(options.select_only))
    handler.mainwindow = window

    if options.message:
        window.set_message(options.message)

    root = config.iface_cache.get_interface(r.interface_uri)
    window.browser.set_root(root)

    window.window.connect('destroy', lambda w: handler.abort_all_downloads())

    if options.systray:
        window.use_systray_icon()

    @tasks. async
    def main():
        force_refresh = bool(options.refresh)
        while True:
            window.refresh_button.set_sensitive(False)
            window.browser.set_update_icons(force_refresh)

            solved = driver.solve_with_downloads(force=force_refresh,
                                                 update_local=True)

            if not window.systray_icon:
                window.show()
            yield solved
            try:
                window.refresh_button.set_sensitive(True)
                window.browser.highlight_problems()
                tasks.check(solved)
            except Exception as ex:
                window.report_exception(ex)

            if window.systray_icon and window.systray_icon.get_visible() and \
               window.systray_icon.is_embedded():
                if driver.solver.ready:
                    window.systray_icon.set_tooltip(
                        _('Downloading updates for %s') %
                        root_iface.get_name())
                    window.run_button.set_active(True)
                else:
                    # Should already be reporting an error, but
                    # blink it again just in case
                    window.systray_icon.set_blinking(True)

            refresh_clicked = dialog.ButtonClickedBlocker(
                window.refresh_button)
            yield refresh_clicked, _recalculate

            if refresh_clicked.happened:
                force_refresh = True

    tasks.wait_for_blocker(main())
Example #32
0
PYGTKVERSION = "2.0"

try:
    import pygtk
    pygtk.require(PYGTKVERSION)
except:
    print "PyGTK version", PYGTKVERSION, "required."
    sys.exit(1)

try:
    import gtk
except:
    sys.exit(1)


class AboutDialog:
    """
    The about dialog from the main Help menu in the Menu Bar.
    """

    name = 'images2cot'
    version = '1.2.3.4'
    copyright = 'Copyright (C) 2009, Geographic Information Network of Alaska,\
 University of Alaska Fairbanks'

    comments = 'my comments'
    license = 'MIT License'
    website = 'http://gina.alaska.edu/'
    authors = [('Jonathan Sawyer')]
    documenters = [('Jonathan Sawyer')]
Example #33
0
    |  gtkreactor.install()

Then use twisted.internet APIs as usual.  The other methods here are not
intended to be called directly.

API Stability: stable

Maintainer: U{Itamar Shtull-Trauring<mailto:[email protected]>}
"""

__all__ = ['install']

# System Imports
try:
    import pygtk
    pygtk.require('1.2')
except ImportError, AttributeError:
    pass  # maybe we're using pygtk before this hack existed.
import gtk
import sys, time
from zope.interface import implements

# Twisted Imports
from twisted.python import log, threadable, runtime, failure, components
from twisted.internet.interfaces import IReactorFDSet

# Sibling Imports
from twisted.internet import main, posixbase, selectreactor

reads = {}
writes = {}
Example #34
0
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation under version 2 of the license.          #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################

import pygtk; pygtk.require("2.0")
import gtk
import datastore
from datastore import E_NAME, E_DATA, E_EDITABLE, E_PARENT, E_MODIFIED

def get_dragdestdata(treeview, context, x, y, selection, info, etime):
    iter, value = cselected(treeview,x,y)
    model = treeview.get_model()
    if value == True:
        ldata = data
        print"global data=", data
        drop_info = treeview.get_dest_row_at_pos(x,y)
        print "DROP INFO IS:"; print drop_info
        if drop_info:
            path, position = drop_info
            iteri = model.get_iter(path)
Example #35
0
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'''


import os, threading
import errno
import string
import re
import datetime
from sys import stderr
import pygtk; pygtk.require("2.0") # make sure we have the right version
import gtk
import grp
import pwd, cPickle
from gettext import gettext as _

from porthole.version import version
from porthole._xml.xmlmgr import XMLManager, XMLManagerError
from porthole import config
from porthole.utils import debug

def get_icon_for_package(package):
    """Return an icon for a package"""
    # if it's installed, find out if it can be upgraded
    if package and package.get_installed():
        icon = gtk.STOCK_YES
Example #36
0
# CDDL HEADER END
#

import threading
import sys
import os
import time
import getopt
import locale
import shutil
import fcntl
from bisect import insort

try:
    import pygtk
    pygtk.require("2.4")
except:
    pass
try:
    import gtk
    import gtk.glade
    gtk.gdk.threads_init()
except:
    sys.exit(1)
try:
    import glib
    import gobject
except:
    sys.exit(1)

from os.path import abspath, dirname, join, pardir
Example #37
0
--- dynagui.py.orig	2007-12-13 21:04:43 UTC
+++ dynagui.py
@@ -27,17 +27,17 @@ import sys
 import pygtk; pygtk.require('2.0')
 import gtk
 import gobject
-from libs.canvas import MyCanvas
-from libs import lab_io
-from libs.lab import lab
-from libs.gui_router import GuiRouter
-from libs.dynamips_properties_dialog import DynamipsPropertiesDialog
-from libs.C3600_properties_dialog import C3600PropertiesDialog
-from libs.C7200_properties_dialog import C7200PropertiesDialog
-from libs.frsw_properties_dialog import FRSwitchPropertiesDialog
-from libs.atmsw_properties_dialog import ATMSwitchPropertiesDialog
-from libs.ethsw_properties_dialog import EthSwitchPropertiesDialog
-from libs.util import RouterSelectionDialog
+from dynagui_libs.canvas import MyCanvas
+from dynagui_libs import lab_io
+from dynagui_libs.lab import lab
+from dynagui_libs.gui_router import GuiRouter
+from dynagui_libs.dynamips_properties_dialog import DynamipsPropertiesDialog
+from dynagui_libs.C3600_properties_dialog import C3600PropertiesDialog
+from dynagui_libs.C7200_properties_dialog import C7200PropertiesDialog
+from dynagui_libs.frsw_properties_dialog import FRSwitchPropertiesDialog
+from dynagui_libs.atmsw_properties_dialog import ATMSwitchPropertiesDialog
+from dynagui_libs.ethsw_properties_dialog import EthSwitchPropertiesDialog
+from dynagui_libs.util import RouterSelectionDialog
 
 
 ui_popup = \
Example #38
0
def main(command_args):
    """Implements the logic of the 0desktop command.
	@param command_args: the command-line arguments"""
    parser = OptionParser(usage=_("usage: %prog [options] [URI]"))
    parser.add_option("-m",
                      "--manage",
                      help=_("manage added applications"),
                      action='store_true')
    parser.add_option("-v",
                      "--verbose",
                      help=_("more verbose output"),
                      action='count')
    parser.add_option("-V",
                      "--version",
                      help=_("display version information"),
                      action='store_true')

    (options, args) = parser.parse_args(command_args)

    if options.verbose:
        logger = logging.getLogger()
        if options.verbose == 1:
            logger.setLevel(logging.INFO)
        else:
            logger.setLevel(logging.DEBUG)
        hdlr = logging.StreamHandler()
        fmt = logging.Formatter("%(levelname)s:%(message)s")
        hdlr.setFormatter(fmt)
        logger.addHandler(hdlr)

    if options.version:
        import zeroinstall
        print("0desktop (zero-install) " + zeroinstall.version)
        print("Copyright (C) 2009 Thomas Leonard")
        print(
            _("This program comes with ABSOLUTELY NO WARRANTY,"
              "\nto the extent permitted by law."
              "\nYou may redistribute copies of this program"
              "\nunder the terms of the GNU Lesser General Public License."
              "\nFor more information about these matters, see the file named COPYING."
              ))
        sys.exit(0)

    if not args:
        interface_uri = None
    elif len(args) == 1:
        interface_uri = args[0]
    else:
        parser.print_help()
        sys.exit(1)

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

    if options.manage:
        from zeroinstall.gtkui.applistbox import AppListBox, AppList
        from zeroinstall.injector.iface_cache import iface_cache
        box = AppListBox(iface_cache, AppList())
    else:
        from zeroinstall.gtkui.addbox import AddBox
        box = AddBox(interface_uri)

    box.window.connect('destroy', gtk.main_quit)
    box.window.show()
    gtk.main()
Example #39
0
#!/usr/bin/env python
'''
PyShot is a small light weight screenshot utility written in pygtk.
Some features include zoom-in, zoom-out, delay setting
Authors: Ikey Doherty <*****@*****.**>, Nick Canupp <*****@*****.**>
Packaging: Kendall Weaver <*****@*****.**>
License: GPL
'''

try:
    import pygtk
    pygtk.require("2.0")
except:
    print "You do not have the required PyGTK for this application."
try:
    import gtk
    from time import sleep
    import threading
except:
    print "You do not appear to have PyGTK installed"


class Shotter:
    def __init__(self):
        self.ui_file = '/usr/lib/pyshot/interface.ui'
        self.ui = gtk.Builder()
        self.ui.add_from_file(self.ui_file)
        self.spinner = self.ui.get_object("spinbutton")
        adj = gtk.Adjustment()
        adj.set_upper(30)
        adj.set_lower(0)
Example #40
0
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

GNU Radio Companion is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
"""

import pygtk
pygtk.require('2.0')
import gtk
from Constants import MIN_WINDOW_WIDTH, MIN_WINDOW_HEIGHT, DND_TARGETS


class DrawingArea(gtk.DrawingArea):
    """
    DrawingArea is the gtk pixel map that graphical elements may draw themselves on.
    The drawing area also responds to mouse and key events.
    """
    def __init__(self, flow_graph):
        """
        DrawingArea contructor.
        Connect event handlers.

        Args:
Example #41
0
    def __init__(self, diagram, data, props):
        import pygtk
        pygtk.require("2.0")
        import gtk

        self.diagram = diagram
        self.data = data
        self.props = props

        self.win = gtk.Window()
        self.win.connect("delete_event", self.on_delete)
        self.win.set_title("Group Properties")

        box1 = gtk.VBox()
        self.win.add(box1)
        box1.show()

        box2 = gtk.VBox(spacing=2)
        box2.set_border_width(10)
        box1.pack_start(box2)
        box2.show()

        self.checkboxes = []
        self.optionmenues = []
        if len(props):
            table = gtk.Table(2, len(props), 0)
        else:
            table = gtk.Table(2, 1, 0)
        table.set_row_spacings(2)
        table.set_col_spacings(5)
        table.set_border_width(5)
        if len(props):
            y = 0
            for s in props.keys():
                w = gtk.CheckButton(s)
                self.checkboxes.append(w)
                table.attach(w, 0, 1, y, y + 1)
                w.show()
                menu = gtk.Menu()
                milist = None
                for opt in props[s].opts:
                    #print opt
                    menuitem = gtk.RadioMenuItem(milist, str(opt.value))
                    milist = menuitem  # GSlist
                    menu.append(menuitem)
                    menuitem.show()
                menu.show()
                w = gtk.OptionMenu()
                w.set_menu(menu)
                self.optionmenues.append(w)
                table.attach(w, 1, 2, y, y + 1)
                w.show()
                y = y + 1
        else:
            w = gtk.Label(
                "The selected objects don't share any\n properties to change at once."
            )
            table.attach(w, 0, 1, y, y + 1)
            w.show()
        box2.pack_start(table)
        table.show()

        separator = gtk.HSeparator()
        box1.pack_start(separator, expand=0)
        separator.show()

        box2 = gtk.VBox(spacing=10)
        box2.set_border_width(10)
        box1.pack_start(box2, expand=0)
        box2.show()

        button = gtk.Button("Ok")
        button.connect("clicked", self.on_ok)
        box2.pack_start(button)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()
        button.show()
        self.win.show()