Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword or section
Like this
2Activity

Table Of Contents

0 of .
Results for:
No results containing your search query
P. 1
tkinter

tkinter

Ratings: (0)|Views: 2,281|Likes:
Published by YanciGarro

More info:

Published by: YanciGarro on Mar 03, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

03/03/2011

pdf

text

original

 
Tkinter reference: a GUIfor Python
John W. Shipman
2008-01-24 20:04
Abstract
Describes the
Tkinter
widget set for constructing graphical user interfaces (GUIs) in the Pythonprogramming language.This publication is available inWeb form
1
and also as aPDF document
2
. Please forward anycomments to
tcc-doc@nmt.edu
.
Table of Contents
1. What is Tkinter?.......................................................................................................................22. A minimal application..............................................................................................................33. Layout management.................................................................................................................43.1. The
method....................................................................................................43.2. Other grid management methods...................................................................................53.3. Configuring column and row sizes.................................................................................53.4. Making the root window resizeable................................................................................64. Standard attributes...................................................................................................................74.1. Dimensions...................................................................................................................74.2. Coordinate system.........................................................................................................74.3. Colors...........................................................................................................................84.4. Type fonts.....................................................................................................................84.5. Anchors........................................................................................................................94.6. Relief styles.................................................................................................................104.7. Bitmaps.......................................................................................................................104.8. Cursors.......................................................................................................................114.9. Images........................................................................................................................124.10. Geometry strings........................................................................................................124.11. Window names...........................................................................................................135. The
widget................................................................................................................136. The
widget................................................................................................................156.1. Canvas concepts...........................................................................................................166.2. Methods on
objects.........................................................................................176.3. The canvas arc object....................................................................................................216.4. The canvas bitmap object..............................................................................................226.5. The canvas image object...............................................................................................226.6. The canvas line object...................................................................................................226.7. The canvas oval object..................................................................................................236.8. The canvas polygon object............................................................................................24
1
2
1Tkinter referenceNew Mexico Tech Computer Center
 
6.9. The canvas rectangle object...........................................................................................256.10. The canvas text object.................................................................................................256.11. The canvas window object...........................................................................................267. The
widget......................................................................................................278. The
widget..................................................................................................................298.1. Scrolling an
widget............................................................................................329. The
widget..................................................................................................................3310. The
widget................................................................................................................3411. The
widget............................................................................................................3511.1. Scrolling a
widget........................................................................................3812. The
widget..................................................................................................................3812.1. Menu item creation (
) options........................................................................4113. The
widget......................................................................................................4114. The
widget....................................................................................................4315. The
widget................................................................................................................4616. The
widget........................................................................................................4916.1. The scrollbar
callback...................................................................................5116.2. Connecting scrollbars to other widgets........................................................................5117. The
widget...................................................................................................................5217.1. Indices in text widgets.................................................................................................5417.2. Marks in text widgets..................................................................................................5517.3. Images in text widgets.................................................................................................5517.4. Windows in text widgets.............................................................................................5517.5. Tags in text widgets....................................................................................................5517.6. Setting tabs in a
widget......................................................................................5617.7. Methods on
widgets...........................................................................................5618.
: Top-level window methods..................................................................................6219. Universal widget methods.....................................................................................................6320. Standardizing appearance.....................................................................................................7020.1. How to name a widget class........................................................................................7120.2. How to name a widget instance...................................................................................7120.3. Resource specification lines.........................................................................................7120.4. Rules for resource matching........................................................................................7221. Connecting your application logic to the widgets....................................................................7322. Control variables: the values behind the widgets....................................................................7423. Focus: routing keyboard input...............................................................................................7624. Events..................................................................................................................................7724.1. Levels of binding........................................................................................................7724.2. Event sequences.........................................................................................................7824.3. Event types................................................................................................................7924.4. Event modifiers..........................................................................................................7924.5. Key names.................................................................................................................8024.6. Writing your handler..................................................................................................8224.7. The extra arguments trick............................................................................................8324.8. Virtual events.............................................................................................................84
1.What is Tkinter?
Tkinter is a GUI (graphical user interface) widget set for Python. This document contains only thecommoner features.
New Mexico Tech Computer CenterTkinter reference2
 
This document applies to Python 1.5 and Tkinter 8.0.4 running in the X Window system under Linux.Your version may vary.Pertinent references:
3
by Fredrik Lundh.
Python and Tkinter Programming
by John Grayson (Manning, 2000, ISBN 1-884777-81-3).
4
: general information about the Python language.We'll start by looking at the visible part of Tkinter: creating the widgets and arranging them on thescreen. Later we will talk about how to connect the face
the
front panel
”
of the application to thelogic behind it.
2. A minimal application
Here is a trivial Tkinter program containing only a Quit button:
#!/usr/local/bin/python
1
from Tkinter import *
2
class Application(Frame):
3
def __init__(self, master=None):Frame.__init__(self, master)
4
self.grid()
5
self.createWidgets()def createWidgets(self):self.quitButton = Button ( self, text="Quit",command=self.quit )
6
self.quitButton.grid()
7
app = Application()
8
app.master.title("Sample application")
9
app.mainloop()
10
1
This line makes the script self-executing, assuming that your system has the Python interpreter atpath
/usr/local/bin/python
.
2
This line imports the entire Tkinter package into your program's namespace.
3
Your application class must inherit from Tkinter's
Frame
class.
4
Calls the constructor for the parent class,
Frame
.
5
Necessary to make the application actually appear on the screen.
6
Creates a button labeled
Quit
.
7
Places the button on the application.
8
The main program starts here by instantiating the
Application
class.
9
This method call sets the title of the window to
Sample application
.
10
Starts the application's main loop, waiting for mouse and keyboard events.
3
4
3Tkinter referenceNew Mexico Tech Computer Center

Activity (2)

You've already reviewed this. Edit your review.
1 thousand reads
1 hundred reads

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->