title: Python - cross-platform wrapper for GUI libraries?
body: <p>I have seen through <a href="https://stackoverflow.com/questions/3993269/pygtk-vs-pyqt-vs-wxpython-vs-tkinter">python - Pygtk VS Pyqt VS WxPython VS Tkinter</a>; and my question is slightly different. </p>
  
  <p>For instance, I use Ubuntu Gnome, there python-qt is not by default installed; and so if I want to use a python-qt application, I have to download python-qt (plus qt libraries); I'd expect it may be something similar for KDE (or other) desktops...</p>
  
  <p>Well, often I'd need to produce a very simple GUI, and I'd like it to be able to "run anywhere" where there is Python... However, if the user already has some of these libraries, I'd say, why not use them? For complicated stuff, obviously an all-encompassing wrapper would not be viable (after all, all those libraries are cross-platform) - but for simple stuff, like the "hello work" examples below, maybe there is something that already exists? </p>
  
  <p>In comparison to the examples below, I'd imagine something like (pseudocode): </p>
  
  <pre><code>...
  appgui = getCrossPlatformGUI()
  mw = appgui.getMainWindow()
  button = appgui.getButton(args)
  appgui.connect(button, args)
  appgui.show(button)
  ...
  </code></pre>
  
  <p>... where <code>getCrossPlatformGUI()</code> on Linux would first look for <code>python-qt</code>, if not found then <code>python-gtk</code>, then <code>wxWindows</code>, then <code>tkInter</code> (on Windows maybe in a different order, etc) - and would deliver a window/application of the library that has been found on the system, defaulting in all cases with <code>tkInter</code> (which, as I understand, is always built in python). </p>
  
  <p>Many thanks in advance for any answers,<br>
  Cheers!</p>
  
  <p>&nbsp; </p>
  
  <p><code>hello-pyqt.py</code> (<img src="https://i.stack.imgur.com/qiVnn.png" alt="hello-pyqt-ubuntu.png">, <img src="https://i.stack.imgur.com/9UZ0k.png" alt="hello-pyqt-opensuse.png">)</p>
  
  <pre><code>#!/usr/bin/env python
  # http://en.wikibooks.org/wiki/Python_Programming/PyQt4#Hello.2C_world.21
  
  import sys
  from PyQt4 import Qt, QtCore
  
  def sayHello():
    print "Hello, World!"
  
  #####
  
  a = Qt.QApplication(sys.argv)
  
  hellobutton = Qt.QPushButton("Say 'Hello world!'", None)
  
  a.connect(hellobutton, Qt.SIGNAL("clicked()"), sayHello)
  hellobutton.clicked.connect(QtCore.QCoreApplication.instance().quit)
  
  hellobutton.show()
  
  a.exec_()
  </code></pre>
  
  <p><code>hello-pygtk.py</code> (<img src="https://i.stack.imgur.com/PSNTs.png" alt="hello-pygtk-ubuntu.png">, <img src="https://i.stack.imgur.com/NM32o.png" alt="hello-pygtk-opensuse.png">)</p>
  
  <pre><code>#!/usr/bin/env python
  # http://www.pygtk.org/pygtk2tutorial/examples/helloworld.py
  
  import pygtk
  pygtk.require('2.0')
  import gtk
  
  # This is a callback function. The data arguments are ignored
  # in this example. More on callbacks below.
  def sayHello(widget, data=None):
    print "Hello, World!"
  
  def destroy(widget, data=None):
    gtk.main_quit()
  
  #####
  
  window = gtk.Window(gtk.WINDOW_TOPLEVEL)
  window.connect("destroy", destroy)
  
  hellobutton = gtk.Button("Say 'Hello world!'")
  
  hellobutton.connect("clicked", sayHello, None)
  hellobutton.connect_object("clicked", gtk.Widget.destroy, window)
  
  window.add(hellobutton)
  hellobutton.show()
  window.show()
  
  gtk.main()
  </code></pre>