Website hosting service by Active-Venture.com
  

 Back to Index


16.1.4 Mapping Basic Tk into Tkinter

Class commands in Tk correspond to class constructors in Tkinter.

 

    button .fred                =====>  fred = Button()

The master of an object is implicit in the new name given to it at creation time. In Tkinter, masters are specified explicitly.

 

    button .panel.fred          =====>  fred = Button(panel)

The configuration options in Tk are given in lists of hyphened tags followed by values. In Tkinter, options are specified as keyword-arguments in the instance constructor, and keyword-args for configure calls or as instance indices, in dictionary style, for established instances. See section 16.1.6 on setting options.

 

    button .fred -fg red        =====>  fred = Button(panel, fg = "red")
    .fred configure -fg red     =====>  fred["fg"] = red
                                OR ==>  fred.config(fg = "red")

In Tk, to perform an action on a widget, use the widget name as a command, and follow it with an action name, possibly with arguments (options). In Tkinter, you call methods on the class instance to invoke actions on the widget. The actions (methods) that a given widget can perform are listed in the Tkinter.py module.

 

    .fred invoke                =====>  fred.invoke()

To give a widget to the packer (geometry manager), you call pack with optional arguments. In Tkinter, the Pack class holds all this functionality, and the various forms of the pack command are implemented as methods. All widgets in Tkinter are subclassed from the Packer, and so inherit all the packing methods. See the Tix module documentation for additional information on the Form geometry manager.

 

    pack .fred -side left       =====>  fred.pack(side = "left")

 

  

 

2002-2004 Active-Venture.com Webhosting Service

 

Disclaimer: This documentation is provided only for the benefits of our hosting customers.
For authoritative source of the documentation, please refer to http://python.org/doc/

 

Cheap domain registration : Register domain name or buy domain name, including free domain hosting services

 
Active-Domain.com offers cheap domain registration, domain name transfer and domain search services    

Domain registration : Buy domain name or register domain name from $5.95/year only