How to get started in GUI Programming?

Claudio Grondi claudio.grondi at freenet.de
Sun Nov 27 08:56:22 EST 2005


<peter.mosley at talk21.com> schrieb im Newsbeitrag
news:1132927360.270239.64670 at f14g2000cwb.googlegroups.com...
> I am trying to learn GUI programming in Python, but have to confess I
> am finding it difficult.
>
> I am not an experienced programmer - just someone who from time to
> time writes small programs for my use.  Over the years I have moved
> from GWBASIC to QBASIC to Visual Basic, and now trying to move across
> to a Linux platform.  Python seems to be the best compromise between
> the limitations of command line basic programming and the total
> incomprehensibility of C.
>
> Googling around it seems the best GUI is either Tkinter or PyGtk.  I
> found a book which recommended PyGtk, as it had a graphical design
> option,  Glade.  Coming from a VB background I latched onto that and
> bought the book (Beginning Python, Wrox), but it was a disappointment
> (or more accurately a complete waste of money) - there was
> insufficient detail in the text.
>
> I've found the tutorial and reference manual on the PyGtk web site,
> but although I've made some progress, I keep reaching points where I
> have insufficient background to understand them. Currently I'm stuck
> on dialog boxes (the code seems immensely complex for the equivalent of
>   MsgBox("Do you really want to do this ",vbYesNo) and I haven't
> got it to work properly yet) and loading graphical images in anything
> other than their original size, but every new step brings another
> struggle
>
> I've seen reference to a Tkinter book - something like 'Python
> and Tkinter Programming' but it seems to be out of print and
> unavailable.
>
> Can anyone offer any suggestions as to the least painful way forwards?
>

>From what you write I conclude, that it is maybe a very good idea to stay
with Visual Basic and use it to create the appropriate ActiveX components
you need in Python and then register them to use it from Python. This way
you can 'marry' what you have already created in Visual Basic easily with
Python.
>From what I currently know, there is no 100% cross-platform solution for GUI
related tasks, because each platform has own specifics which usually are
very interesting for use in own programming and that kills as a consequence
the cross-platform usage.

# For example a Yes/No/Abort dialog box can be achieved using the WSHOM.OCX
available in Windows as follows:

import win32com.client
axWshShell = win32com.client.Dispatch("WScript.Shell") # WSHOM.OCX

axWshShell_Popup_Icon_Critical             =   16
axWshShell_Popup_Button_AbortRetryIgnore   =    2
axWshShell_Popup_NoAutoclose               =    0

intRetVal = axWshShell.Popup(
### Raise a message box:
   " The Popup() Text" + "\n" +
   "",
   axWshShell_Popup_NoAutoclose,
   " The Popup() Title:",
   axWshShell_Popup_Icon_Critical + axWshShell_Popup_Button_AbortRetryIgnore
)

axWshShell_Popup_Clicked_Abort             =    3  # [Abort]  button
axWshShell_Popup_Clicked_Retry             =    4  # [Retry]  button
axWshShell_Popup_Clicked_Ignore            =    5  # [Ignore] button

if(intRetVal ==  axWshShell_Popup_Clicked_Abort):
  print 'Abort clicked, return value = %i'%(intRetVal,)

if(intRetVal ==  axWshShell_Popup_Clicked_Retry):
  print 'Retry clicked, return value = %i'%(intRetVal,)

if(intRetVal ==  axWshShell_Popup_Clicked_Ignore):
  print 'Ignore clicked, return value = %i'%(intRetVal,)

Hope this is what are you looking for, isn't it?

Claudio





More information about the Python-list mailing list