Thread: Starting Python
View Single Post
Join Date: Oct 2004
Posts: 3,858
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 867
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: Starting Python

 
0
  #8
Mar 27th, 2005
The IDLE integrated development environment that comes with the normal Python installation is really a GUI program. It uses Tkinter as the GUI interface/library, also part of the normal installation. Tkinter uses tcl script language to do the work.

Here is a typical Python code example using Tkinter ...
  1. # explore the Tkinter GUI toolkit
  2.  
  3. try:
  4. # for Python2
  5. import Tkinter as tk
  6. except ImportError:
  7. # for Python3
  8. import tkinter as tk
  9.  
  10. # create a window frame
  11. frame1 = tk.Tk()
  12. # create a label
  13. label1 = tk.Label(frame1, text="Hello, world!")
  14. # pack the label into the window frame
  15. label1.pack()
  16.  
  17. frame1.mainloop() # run the event-loop/program
This code should run on Windows and Unix (PC or Mac). On a Windows machine save the program with a .pyw extension. This way it associates with pythonw.exe and avoids the ugly black DOS display popping up.

You can also find much Tkinter detail at:
http://infohost.nmt.edu/tcc/help/pub...ter/index.html

There is another GUI library worth mentioning, it's wxPython based on C++. The code is more efficient for GUI stuff. The download of the installer is free, look at http://wiki.wxpython.org/

You can get wxPython for either Windows or Linux. There are some wxPython GUI examples in the DaniWeb Python Code Snippets. Here is a very nice wxPython tutorial I like to recommend, it will give you a good overview (examples work on Windows, Linux, or Unix):
http://wiki.wxpython.org/index.cgi/AnotherTutorial

Note: GUI stands for Graphical User Interface. It's the usual Window matter like frames, buttons, labels, editboxes.
Last edited by vegaseat; Aug 16th, 2009 at 10:19 pm. Reason: [code=python] tag
May 'the Google' be with you!
Reply With Quote