background preloader

Python

Facebook Twitter

24.1. Tkinter — Python interface to Tcl/Tk. The Tkinter module (“Tk interface”) is the standard Python interface to the Tk GUI toolkit.

24.1. Tkinter — Python interface to Tcl/Tk

Both Tk and Tkinter are available on most Unix platforms, as well as on Windows systems. (Tk itself is not part of Python; it is maintained at ActiveState.) 24.1.1. Tkinter Modules Most of the time, the Tkinter module is all you really need, but a number of additional modules are available as well. In addition to the Tk interface module, Tkinter includes a number of Python modules. Or, more often: class Tkinter.Tk(screenName=None, baseName=None, className='Tk', useTk=1) The Tk class is instantiated without arguments. Changed in version 2.4: The useTk parameter was added. Tkinter.Tcl(screenName=None, baseName=None, className='Tk', useTk=0) The Tcl() function is a factory function which creates an object much like that created by the Tk class, except that it does not initialize the Tk subsystem. New in version 2.4. Other modules that provide Tk support include: ScrolledText tkColorChooser tkCommonDialog fill. Tutorial - Learn Python in 10 minutes.

NOTE: If you would like some Python development done, my company, Stochastic Technologies, is available for consulting.

Tutorial - Learn Python in 10 minutes

This tutorial is available as a short ebook. The e-book features extra content from follow-up posts on various Python best practices, all in a convenient, self-contained format. All future updates are free for people who purchase it. Preliminary fluff So, you want to learn the Python programming language but can't find a concise and yet full-featured tutorial. Properties Python is strongly typed (i.e. types are enforced), dynamically, implicitly typed (i.e. you don't have to declare variables), case sensitive (i.e. var and VAR are two different variables) and object-oriented (i.e. everything is an object). Getting help Help in Python is always available right in the interpreter. >>> help(5)Help on int object:(etc etc) >>> dir(5)['__abs__', '__add__', ...] >>> abs. Syntax Python has no mandatory statement termination characters and blocks are specified by indentation. Strings. Python: Lambda Functions. Python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called "lambda".

Python: Lambda Functions

This is not exactly the same as lambda in functional programming languages, but it is a very powerful concept that's well integrated into Python and is often used in conjunction with typical functional concepts like filter(), map() and reduce(). This piece of code shows the difference between a normal function definition ("f") and a lambda function ("g"): As you can see, f() and g() do exactly the same and can be used in the same ways. Note that the lambda definition does not include a "return" statement -- it always contains an expression which is returned.

Also note that you can put a lambda definition anywhere a function is expected, and you don't have to assign it to a variable at all. The following code fragments demonstrate the use of lambda functions. Python programming language. Python 2.4 Quick Reference. Style chooser: Modern, Modern B&W, Classic, High contrast or Printing [Hint: Use styles Modern B&W or Printing to print.

Python 2.4 Quick Reference

If you get problems, try printing the PDF versions instead] Contents Front matter Version 2.4 Check updates at Please report errors, inaccuracies and suggestions to Richard Gruet (pqr at rgruet.net). Creative Commons License. Last modified on May 8, 2007 17 Feb 2005, upgraded by Richard Gruet for Python 2.4 03 Oct 2003, upgraded by Richard Gruet for Python 2.3 11 May 2003, rev 4.