Python GUI programming platforms for Windows

By popular demand, I've added a section on PyGTK. See bottom of post.

There are several platforms for programming Windows GUI applications in Python. Below I outline a few of them, with a simple "hello world" example for each. Where I've lifted the example from another site, there's a link to the source.



Tkinter is the ubiquitous GUI toolkit for Python. It's cross platform and easy to use, but it looks non-native on just about every platform. There are various add-ons and improvements you can find to improve the look and feel, but the basic problem is that the toolkit implements its own widgets, rather than using the native ones provided on the platform.


  • Most portable GUI toolkit for Python
  • Very easy to use, with pythonic API


  • Non-native look and feel out of the box

Hello world example (code source):

import Tkinter as Tk
la = Tk.Label(None, text='Hello World!', font=('Times', '18'))

Back to Top


wxPython is probably the most popular GUI toolkit for Python. It's a wrapper for the wxWidgets C++ toolkit, and as such it betrays a few unpythonic edges (like lumpy case, getters and setters, and funky C++ errors creeping up occasionally). There are a few pythonification efforts on top of wxPython, such as dabo and (the now apparently moribund) wax.


  • Highly cross platform
  • Relatively mature and robust
  • Uses native Windows widgets for authentic look and feel


  • Must include large wx runtime when packaging with py2exe (adds ~7 MB)
  • Cross platform nature makes accessing some native platform features (like ActiveX) difficult to impossible

Hello world example (code source):

import wx

class Application(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, 'My GUI', size=(300, 200))
        panel = wx.Panel(self)
        sizer = wx.BoxSizer(wx.VERTICAL)
        txt = wx.StaticText(panel, -1, 'Hello World!')
        sizer.Add(txt, 0, wx.TOP|wx.LEFT, 20)

app = wx.App(0)

Back to Top

.NET with IronPython

IronPython is a .NET implementation of Python. As of 1.0 it has full support for Python 2.4 features, and the 2.0 version will duplicate the Python 2.5 feature set. Although there are many CPython libraries/modules that won't run under IronPython (namely, the ones relying on compiled extensions that have not yet been ported), this lack is partially made up by the huge .NET library.

One cool thing about IronPython is that you can easily create lightweight .exe files that you can ship off to your friends — although you pay for this with a dependency on the .NET runtime, which you can't count on random Windows users to have installed.

Of course, when you go the IronPython route, you take all that comes with it: the good things, like access to .NET libraries and possibly the easiest/cleanest optimization path of any Python implementation (C#); and the bad things, like dependence on the .NET runtime and danger of getting caught on the MS upgrade treadmill.

Another way of getting at the .NET libraries is Python.NET, which adds two files to your Python directory to enable you to call the CLR from CPython.


  • Leverage .NET libraries
  • Easily create .exe files


  • Depends on .NET runtime

Hello world example (code source):

import sys

import clr

from System.Windows.Forms import Application, Form

class HelloWorldForm(Form):

    def __init__(self):
        self.Text = 'Hello World'
        self.Name = 'Hello World'

form = HelloWorldForm()

Back to Top


PyQT is probably the third most widely used GUI toolkit, after wxPython and Tkinter. It has a dual commercial/GPL license (Edit: but it does let you use other open-source licenses; see comments below). I have to admit that this made it a non-starter for me: I don't want to pay for my toolkit when there are others just as good or better that are free; and when I do release open-source software, I want to choose my own license. For others, the GPL might be a non-issue or a plus, so I've left it off my pro/con list.

[Edit] PyQT will be available under the LGPL as of March 2009. Fantastic news.


  • Highly cross platform
  • Very easy to use
  • Highly mature
  • Decent looking widgets


  • Somewhat non-native look and feel (though much better than Tkinter)
  • Must include large runtime when packaging with py2exe

Hello world example (from PyQT docs):

PyQT screen shot
import sys
from PyQt4 import QtGui

app = QtGui.QApplication(sys.argv)

hello = QtGui.QPushButton("Hello world!")
hello.resize(100, 30)


Back to Top


Pyglet is kind of the new kid on the block in terms of GUI toolkits, but it sure made a splash. It implements its own windowing system, but with no dependencies other than Python (for Python 2.5 users). You will need OpenGL to do decent 3D graphics, but that's hardly a black mark for pyglet — other libraries would love to make it this easy.


  • High degree of freedom for GUI creation
  • Only depends on Python
  • Large number of widgets


  • Purposely doesn't duplicate the native platform look and feel
  • Although there are a lot of widgets, you'll have to roll your own for many things the platform gives you for free.

Hello world example (slightly modified from code source):
hello world with pyglet screenshot

from pyglet import font
from pyglet import window

win = window.Window(width=300, height=150, caption="Hello World")

ft = font.load('Arial', 36)
text = font.Text(ft, 'Hello, World!')

while not win.has_exit:

Back to Top

Win32 with ctypes

Of course, all you really need to write GUI applications on Windows with Python is your trusty ctypes module and a well worn copy of Petzold. The benefit of this style is that you're working right down at the system API level, with nothing to get in your way. The disadvantage is that you're working right down at the system API level, with nothing to relieve you from all that boilerplate (unless you write your own abstraction layer on top; see Venster, below…).


  • Enables high level of control
  • Straightforward if familiar with Win32 API
  • No added complexity or buried functionality due to need to be cross-platform
  • Lightest of all Windows GUI programming methods using Python


  • All the complexity and inconsistency of Win32 API in gory detail
  • Lack of high-level libraries (have to write more code)

Hello world example (long, ain't it?):
Win32 GUI screen shot

from ctypes import *
import win32con

WNDPROC = WINFUNCTYPE(c_long, c_int, c_uint, c_int, c_int)

NULL = c_int(win32con.NULL)
_user32 = windll.user32

def ErrorIfZero(handle):
    if handle == 0:
        raise WinError()
        return handle

CreateWindowEx = _user32.CreateWindowExW
CreateWindowEx.argtypes = [c_int,
CreateWindowEx.restype = ErrorIfZero

class WNDCLASS(Structure):
    _fields_ = [('style', c_uint),
                ('lpfnWndProc', WNDPROC),
                ('cbClsExtra', c_int),
                ('cbWndExtra', c_int),
                ('hInstance', c_int),
                ('hIcon', c_int),
                ('hCursor', c_int),
                ('hbrBackground', c_int),
                ('lpszMenuName', c_wchar_p),
                ('lpszClassName', c_wchar_p)]

    def __init__(self,
                 style=win32con.CS_HREDRAW | win32con.CS_VREDRAW,

        if not instance:
            instance = windll.kernel32.GetModuleHandleW(c_int(win32con.NULL))
        if not icon:
            icon = _user32.LoadIconW(c_int(win32con.NULL),
        if not cursor:
            cursor = _user32.LoadCursorW(c_int(win32con.NULL),
        if not background:
            background = windll.gdi32.GetStockObject(c_int(win32con.WHITE_BRUSH))


class RECT(Structure):
    _fields_ = [('left', c_long),
                ('top', c_long),
                ('right', c_long),
                ('bottom', c_long)]
    def __init__(self, left=0, top=0, right=0, bottom=0 ):
        self.left = left = top
        self.right = right
        self.bottom = bottom

class PAINTSTRUCT(Structure):
    _fields_ = [('hdc', c_int),
                ('fErase', c_int),
                ('rcPaint', RECT),
                ('fRestore', c_int),
                ('fIncUpdate', c_int),
                ('rgbReserved', c_wchar * 32)]

class POINT(Structure):
    _fields_ = [('x', c_long),
                ('y', c_long)]
    def __init__( self, x=0, y=0 ):
        self.x = x
        self.y = y

class MSG(Structure):
    _fields_ = [('hwnd', c_int),
                ('message', c_uint),
                ('wParam', c_int),
                ('lParam', c_int),
                ('time', c_int),
                ('pt', POINT)]

def pump_messages():
    """Calls message loop"""
    msg = MSG()
    pMsg = pointer(msg)

    while _user32.GetMessageW(pMsg, NULL, 0, 0):

    return msg.wParam

class Window(object):
    """Wraps an HWND handle"""

    def __init__(self, hwnd=NULL):
        self.hwnd = hwnd

        self._event_handlers = {}

        # Register event handlers
        for key in dir(self):
            method = getattr(self, key)
            if hasattr(method, "win32message") and callable(method):
                self._event_handlers[method.win32message] = method

    def GetClientRect(self):
        rect = RECT()
        _user32.GetClientRect(self.hwnd, byref(rect))
        return rect

    def Create(self,
            exStyle=0 ,        #  DWORD dwExStyle

        self.hwnd = CreateWindowEx(exStyle,
        return self.hwnd

    def Show(self, flag):
        return _user32.ShowWindow(self.hwnd, flag)

    def Update(self):
        if not _user32.UpdateWindow(self.hwnd):
            raise WinError()

    def WndProc(self, hwnd, message, wParam, lParam):

        event_handler = self._event_handlers.get(message, None)
        if event_handler:
            return event_handler(message, wParam, lParam)
        return _user32.DefWindowProcW(c_int(hwnd),

## Lifted shamelessly from WCK (effbot)'s wckTkinter.bind
def EventHandler(message):
    """Decorator for event handlers"""
    def decorator(func):
        func.win32message = message
        return func
    return decorator

class HelloWindow(Window):
    """The application window"""

    def OnPaint(self, message, wParam, lParam):
        """Draw 'Hello World' in center of window"""
        ps = PAINTSTRUCT()
        rect = self.GetClientRect()
        hdc = _user32.BeginPaint(c_int(self.hwnd), byref(ps))
        rect = self.GetClientRect()
        flags = win32con.DT_SINGLELINE|win32con.DT_CENTER|win32con.DT_VCENTER
                          u"Hello, world!",
        _user32.EndPaint(c_int(self.hwnd), byref(ps))
        return 0

    def OnDestroy(self, message, wParam, lParam):
        """Quit app when window is destroyed"""
        return 0

def RunHello():
    """Create window and start message loop"""

    # two-stage creation for Win32 windows
    hello = HelloWindow()

    # register window class…
    wndclass = WNDCLASS(WNDPROC(hello.WndProc))
    wndclass.lpszClassName = u"HelloWindow"

    if not _user32.RegisterClassW(byref(wndclass)):
        raise WinError()

    # …then create Window

    hello.Create( className=wndclass.lpszClassName,
                  windowName=u"Hello World")

    # Show Window



Back to Top


Venster was a very promising wrapper over the Win32 API, borrowing heavily from WTL and ATL windowing techniques. Unfortunately, the project hasn't been updated in several years, and doesn't support the latest versions of Python (especially after was dropped).


  • Rational abstraction layer on top of Win32
  • Use to write native, lightweight (relatively speaking) GUI applications
  • Has most of the cool Win32 tricks like hosting ActiveX and Coolbars


  • Out of date; not updated in several years

Hello world example (code source):
Venster GUI screen shot

from import *
from venster.wtl import *

from venster import gdi

class MyWindow(Window):
    _window_title_ = "Hello World"
    _window_background_ = gdi.GetStockObject(WHITE_BRUSH)
    _window_class_style_ = CS_HREDRAW | CS_VREDRAW

    def OnPaint(self, event):
        ps = PAINTSTRUCT()
        hdc = self.BeginPaint(ps)
        rc = self.GetClientRect()

        msg = "Hello World"
        gdi.TextOut(hdc, rc.width / 2, rc.height / 2, msg, len(msg))


    def OnDestroy(self, event):

myWindow = MyWindow()
application = Application()

Back to Top


PyGTK seems to have a lot going for it as a cross-platform toolkit. It's also licensed under the LGPL, which I like a lot more than the GPL of PyQT. Unfortunately, it doesn't use native Windows widgets; it does a pretty good job of faking it, but it stands out like a Win32, .NET, or wxPython app wouldn't.


  • Cross platform
  • Lots of widgets
  • Voluminous (if somewhat disorganized) documenation


  • Native Win32 widgets not used (looks good, but not quite all the way there)
  • Must include large runtime when packaging with py2exe

Hello world example (code source):
PyGTK screen shot

import pygtk
import gtk

class HelloWorld:

    def hello(self, widget, data=None):
        print "Hello World"

    def delete_event(self, widget, event, data=None):
        print "delete event occurred"
        return False

    def destroy(self, widget, data=None):
        print "destroy signal occurred"

    def __init__(self):
        self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)

        self.window.connect("delete_event", self.delete_event)
        self.window.connect("destroy", self.destroy)

        self.button = gtk.Button("Hello World")
        self.button.connect("clicked", self.hello, None)
        self.button.connect_object("clicked", gtk.Widget.destroy, self.window)


    def main(self):

if __name__ == "__main__":
    hello = HelloWorld()

Back to Top

57 comments to Python GUI programming platforms for Windows

  • Wow. You even talk about Venster and you don’t talk about pygtk?

  • manatlan

    Interesting review …
    But me, for my cross platform apps, I use pygtk, and really happy with it …
    You forget to mention the new uxpython too !? which is an original initiative !

  • @Zootropo
    pygtk is certainly more mainstream than venster, but I’m writing specifically about Windows development. I figure that between Tkinter and PyQT, that’s plenty of non-native widget sets…

    I’ve kind of been keeping my eye on uxpython, but I’d like to see it get beyond alpha before playing with it. I suppose Venster isn’t in much better shape, but I included it because of the potential I see in it.

  • I was appalled when I saw the length and complexity of the ‘Win32 with ctypes’. Just thinking about trying to use Win32 to make a GUI in any language makes me apprehensive. I thought it slightly jocular that you included it as a viable option, haha. I use wxPython.

  • NaturalBornLeader

    Tcl/Tk 8.5 supports the underlying native theme engine. Hopefully the Tcl/Tk bindings get updated.

    8.5 Release:

  • Asd

    Don’t forget Jython and Swing or SWT

  • @David Cimini
    Well, in fairness the Win32 stuff is a lot simpler than wxPython. With wxPython it’s all under the hood, but there you’ve got C++ abstracting away the platform, then wxPython sitting on top of that. Tuck the Python Win32 code away in some libraries, and you get something elegant like Venster. Plus it’s easier to develop because it’s Python. But I don’t think single-platform development is really sexy enough to get enough people to make something like wxWidgets, more’s the pity.

    Yeah, yeah 🙂

  • schlenk

    Nice and fair in general.

    For Tkinter: It does use some native widgets (scrollbars for example, file dialogues and some others), but in general widgets are foreign. For Python 2.6 there would be the possibility to use the new ttk package (there is a wrapper at unpythonic for 2.5 too, see That would bring your looks up to the standard seen at

  • … it betrays a few unpythonic edges (like lumpy case, getters and setters, …) …

    In the current realease of wxPython 2.8.x there’s no need to use getters and setters. The getters and setters are still there, but one can use properties instead.

  • I have written quite a bunch of windows apps with pygtk, it’s no problem and works very well, you should really add it to your list.

  • @tante
    OK, you convinced me 🙂 I added a pygtk example.

    But sorry, jython and a Web server are going to have to wait for the “every possible way to develop a GUI on Windows” post 🙂

  • Feihong Hsu

    “Another way of getting at the .NET libraries is Python.NET, which modifies the CPython executable to enables use of the CLR.”

    This statement is inaccurate. The only thing you need to do to use Python.NET is copy two files into your Python directory (Python.Runtime.dll and clr.pyd). Programming Winforms through Python.NET is easier than through IronPython, since you get to use all the libraries that you’re used to.

  • @Feihong Hsu
    Thanks, I fixed it.

  • h3

    Win32 with ctypes made me cry in disbelief.

  • Asd

    Well, if you don’t want to do the Jython version here it is:

    from javax import swing

    frame=swing.JFrame(“Hello World”)
    frame.size = (300, 300)
    frame.contentPane.add(swing.JLabel(“Hello, World!”))

  • Matt

    Are some of the recent updates to Tk supposed to bring a more native look to apps? Hopefully this will become part of the standard Python distro soon.

  • RoySV

    Please notice the tk “tile” extension as applied to Tkinter. This is a major Tk face lift which brings style-based native look to virtually all platforms. I hope it can be included soon in Tkinter as it is now part of the official 8.5.1 Tcl/Tk release.

  • This was really useful!

    @ Asd what does the Jython window/text look like?


  • Inopia

    I would also like to see Jython/Swing included. Swing may be a bit bloaty to some, but it’s really very powerful. I always say it makes doing simple things complicated, and complicated things simple.

    Since jre 1.6, swing renders natively on windows, linux (gtk), and OSX.

    I think if .NET is included, so should Java 🙂

  • @RoySV
    I have heard of Python programmers hacking together their installations to use the latest version of Tk, but I’m not sure when it will be in the official release. I’ve seen it, and it will definitely make Tkinter a bigger contender as a GUI platform.

    Thanks for the code! It’s not so much the code that keeps me from adding it to my list, but getting it installed and set up on my machine so I could get a screen shot.

    “I think if .NET is included, so should Java :)”
    I can see your point, but this post is specifically about Windows GUI programming, and nowadays that is more and more about .NET…

  • Asd

    That Jython code will appear using the cross platform look and feel by default. Here is some that switches on the native look and feel (I’ve also added a button so the L&F is more obvious):

    from javax.swing import UIManager, JFrame, JButton, JLabel
    from java.awt import FlowLayout

    frame = JFrame(“Hello World”)
    frame.size = (300, 300)
    frame.contentPane.layout = FlowLayout()

    frame.contentPane.add(JLabel(“Hello, World!”))
    frame.visible = 1

    And here is a screenshot under XP:

    Installing Jython is very easy if you have Java installed. Also Java GUIs are a lot more common than you might think, especially for in-house apps in big companies. In that role is outnumbers .NET significantly.

  • The Qt license is GPL+exceptions. Those exceptions let you use it with pretty much any common license, including:

    Academic Free License
    2.0 or 2.1
    Apache Software License
    1.0 or 1.1
    Apache License
    Apple Public Source License
    Artistic license
    From Perl 5.8.0
    BSD license
    “July 22 1999”
    Common Public License
    GNU Library or “Lesser”
    General Public License (LGPL)
    2.0 or 2.1
    Jabber Open Source License
    MIT License
    (as attached)
    Mozilla Public License (MPL)
    1.0 or 1.1
    Open Software License
    OpenSSL license (with original
    SSLeay license) “2003” (“1998”)
    PHP License
    Python license (CNRI Python License)
    (as attached)
    Python Software Foundation License
    Q Public License
    Sleepycat License
    W3C License
    X11 License
    Zlib/libpng License
    (as attached)
    Zope Public License

  • You could give Mozilla’s XULRunner an honorary mention since ActiveState’s work on Open Komodo is making this more attractive (and Mark Hammond did some work on python DOM scripting in Mozilla).

  • @Roberto Alsina
    Thanks, I corrected the section on PyQT

    @Bajusz Tamás
    Yes, I saw that! Very good news.

  • Saw a mention of my project uxpython in my server logs and followed it here 🙂
    HelloWorld in uxpython:
    from uxGUI import *

    class myWindow(uxWindow):
        def init(self):
            self.caption = “Tiny”
            def A1(a): a.ob.text = “You clicked me”

    and my self summary according to criteria in post:

    – Super Python focused, entire toolkit in python no c/c++ disconnect
    – Very flexible and extensible
    – Uses cairo and pango
    – Platform native rendering through cairo eg. GDI on win32

    – Does not use native widgets
    – Limited widgets at this time
    – Alpha quality at this time
    – 4MB of dependencies – cairo,pango and related.

  • @Gerdus van Zyl
    Thanks for the code!

  • Mike Thompson

    Some may find this approach interesting also:

  • TC

    >>@David Cimini
    >>Well, in fairness the Win32 stuff is a lot simpler than >>wxPython. With wxPython it’s all under the hood, but there >>you’ve got C++ abstracting away the platform,

    Have you ever tried using wxPython?
    You can put up a window in less than 10 lines of python, which is far simpler than going through Win32 with or without ctypes.
    There is another level of abstraction for wxPython, called PythonCard, but the gui designer is too tedious and suffers from lack of good documentation. I’ve started with QT/pyQT and have moved to wx without looking back. QT is a pain in the neck to install/compile, wx has a simple installer (at least for windows platforms).

    QT does have a GUI designer, which is cumbersome to use and not like any other (non-python) GUI designers I’ve worked with. If wx had a GOOD GUI designer (which would be like Delphi or VB), it would be icing on the cake. But, I still use wx even without the designer, and still have no regrets.

  • @TC
    I’ve used wxPython fairly extensively. I agree that it’s easier to use. But that doesn’t mean it’s intrinsically simpler; just that the complexity has been done already and tucked away in libraries.

    I find Venster, which is built on top of ctypes, to be easier to use and more powerful than wxPython for Windows programming. That’s probably because I did a lot of Win32 programming back in the day.

    Aside from a much more mature platform, the big win of wxPython over Win32 for Windows-only programming (IMHO) is sizers; but those of course have their own complications.

  • John Henry

    I disagree with TC that:

    There is another level of abstraction for wxPython, called PythonCard, but the gui designer is too tedious and suffers from lack of good documentation.

    I can’t imagine how one can classify the Pythoncard designer as “tedious”. I’ve tried a number of others and I would rate it as “at par”. As to documentation, it’s also “at par” with most of the open source projects. What it lacks in documentation is more than compensated by the many well coded sample programs. I’ve always wanted to look for a “go-to” Python GUI package but so far, I have not found any that are more productive than Pythoncard.

  • Thanks Veryyyyyyy Much

    this is very very usefull

  • QuiGon

    Have you managed to compile PyQt with MinGW?

    When the QtGui is linking I have a trouble:

    mingw32-make[1]: Entering directory `C:/Downloads/_Python/PyQt-win-gpl-4.3.3/QtGui’
    g++ -mthreads -Wl,-enable-stdcall-fixup -Wl,-enable-auto-import -Wl,-enable-runtime-pseudo-reloc -shared -Wl,-subsystem,windows -Wl,-s -o QtGui.pyd sipQtGuicmodule.o sipQtGuiQMap.o sipQtGuiQVector.o sipQtGuiQWorkspace.o sipQtGuiQWidgetAction.o sipQtGuiQWhatsThis.o sipQtGuiQRegExpValidator.o sipQtGuiQDoubleValidator.o sipQtGuiQIntValidator.o sipQtGuiQValidator.o sipQtGuiQUnd

    and etc…

    many many object-files

    The input line is too long)
    mingw32-make[1]: *** [QtGui.pyd] Error 255
    mingw32-make[1]: Leaving directory `C:/Downloads/_Python/PyQt-win-gpl-4.3.3/QtGui’
    mingw32-make: *** [install] Error 2

    so I can’t built PyQt.

  • astigmatik


    1. It’s not really Python. I mean, you don’t import Jython into Python and then start writing GUI. Jython is jython is java. I think the article focuses only those that can be run by the “real” Python.

    2. A more jythonic code would be:

    frame = JFrame(”Hello World”, size=(300, 300))
    fc = frame.contentPane
    fc.layout = FlowLayout()
    fc.add(JLabel(”Hello, World!”))

  • Gilles


    Maybe it’s just me, but I wish there were a really good GUI environment to write apps in Python for Windows without the weight and deployment issues of .Net. Since the vast majority of users run Windows, I don’t think “cross-platformness” is such an important feature, but wealth of the GUI widgets is.

    At this point, it looks like wxPython is the least bad solution, but its ecosystem is nowhere as rich as the widgets available for C++, Delphi, or .Net.


  • Another nifty toolkit is eagle: It feels very pythonic. Here is a taste:

    from eagle import *
    def my_callback( app, widget ):
       print "Hello World"
       title="Hello World",
          label="Hello World",

    Also, for basic GUIs you may find EasyGUI to be more than sufficient:


  • @Stoyan

    Thanks for the link to eagle. I hadn’t seen this one before.

  • Ibn Saeed


    i found this site while searching for information on GUI Programming in Python and I really loved the article. Excellently written.

    I would like to ask, which would be the easiest platform for beginners into Windows GUI programming in Python.

    Also, is there a GUI IDE for python ?

  • @Ibn

    Tkinter is probably the easiest full-featured GUI framework to get started with.

    As for IDEs, I personally like Komodo Edit.

  • Ibn Saeed

    @Ryan, Hello

    Thanks for replying to my question.

    I have just found site with video tutorials. I think ill try and follow those to getting started with Python and later on Python GUI. Should i start off with that site ?

    I think showmedo uses wxPython along with opthers but not Tkinter, ill search more.

  • @Ibn

    Showmedo is a great site, and wxPython is pretty easy as well. I think that getting started with non-GUI scripting is also a good idea. Try Dive into Python for a good introduction to Python the language.

  • Ibn Saeed


    Thank you for replying to my questions so quickly 🙂

    My main goal is to develop Windows Application which should talk to an online php application such as Ecommerce Store.

    I know PHP programming but I have not experience with Windows Programming

    The reason i want to learn Python is to develop GUI apps for windows. So what would be the best path to take in this regard. Should I start with basic python or start with Phython GUi scripting straight away. ?

  • Ibn Saeed


    Also, should i start with Python 2 or Python 3 ?

  • Ibn Saeed

    Just found this site

    “Dive Into Python 3 will cover Python 3 and its differences from Python 2. Compared to the original Dive Into Python, it will be about 50% revised and 50% new material. I will publish drafts online as I go. The final version will be published on paper by Apress.”

  • @Ibn

    Python has a lot of great facilities for communicating with web services, from urllib/urllib2 to parsers for rss feeds, JSON, HTML, and XML.

    I’ve done the kind of thing you’re describing several times, and I find it’s easiest to write a regular script to do all the communication and processing I need, then write a GUI to go on top of that.

    I also think that starting out with Python 2.x is still the best.

  • Ibn Saeed


    Thanks for the encouragement

    If you dont mind, do you have any examples of the work you have done in this regard.

  • @Ibn

    I don’t think I’ve published any code along these lines, but one recent application I wrote for my own use downloads a page that contains constantly updated links, and displays them in a wxPython grid. Using the GUI, I can filter out links I’ve already seen, or topics that I’m not interested in. I can also aggregate several pages of links into a single grid, and sort the links in various ways. I suppose I could have done the same with an elaborate Greasemonkey script, but I think this is nicer.

    I started by writing a script that downloads 100 pages of links (I only do this once a week, to avoid hammering the server). It then updates my pickled list of links, and saves it to a file.

    I then wrote a GUI that calls the download, update, and pickle code, and displays the list of links in a grid. If I mark a link or topic as uninteresting, the list of links is updated, so I only see things I’m interested in. I’ve found some real gems that way.

    Here are some really simple examples:

    # get my blog's rss feed
    import feedparser
    feed = feedparser.parse("")
    entries = [dict(title=e.title, for e in feed['entries']]
    # get all the links on my home page
    import urllib
    from BeautifulSoup import BeautifulSoup as bs
    page = bs(urllib.urlopen(""))
    links = [dict(link=l["href"], text=l.string) for l in page.findAll("a")]
  • Ibn Saeed


    Thanks for the detailed reply 🙂

    What I want to achieve is to communicate with my ecommerce website. For e.g.

    Have a windows application which could be used to change settings, add products, delete products, update products, check orders, update order statuses etc.

    Also, if a small application could be developed to communicate only the New orders, by displaying a small Ballon Window at the bottom of the taskbar whenever a new order is placed, how many orders are placed etc.

    I hope you get the gist of what I want to achieve. Based on the above, what would be the best possible way to start ?

    Which language should i pursue, i only know PHP right now. and the ecommerce site is in PHP. It gives an option to interact through XML.

    Would all of the above be achievable by Python and wxPython or Tkinter ?

    I apologize for posting so many questions, one after another. I really do appreciate any help you can provide or a path you can suggest i take.

  • If you want to “drive” a website programmatically, then that’s exactly what the mechanize module does. I’ve used it many times, and it’s very useful for that kind of task.

  • Ibn Saeed


    thanks for your help. I will get into python.

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>