An Introduction To Tkinter

2y ago
13 Views
3 Downloads
732.61 KB
90 Pages
Last View : 17d ago
Last Download : 3m ago
Upload by : Camryn Boren
Transcription

Review Copy. Do not redistribute! 1999-12-01 22:15An Introduction to Tkinterby Fredrik LundhCopyright 1999 by Fredrik LundhFredrik LundhCopyright (c) 1999 by Fredrik Lundh

Review Copy. Do not redistribute! 1999-12-01 22:15Preface .iToolbars . 26Status Bars. 279. Dialog Windows . 29Grid Layouts . 34Validating Data. 36I. Introducing Tkinter .2II. Tkinter Reference. 371. What's Tkinter?.12. Hello, Tkinter . 2Running the Example . 2Details . 23. Hello, Again . 4Running the Example . 4Details . 5More on widget references . 6More on widget names. 64. Tkinter Classes . 8Widget classes .8Mixins . 9Implementation mixins . 9Geometry mixins . 9Widget configuration management . 95. Widget Configuration.11Configuration Interface .11Backwards Compatibility.126. Widget Styling .13Colors .13Color Names .13RGB Specifications.13Fonts . 14Font descriptors . 14Font names .15System fonts . 16X Font Descriptors. 16Text Formatting .17Borders .17Relief .17Focus Highlights . 18Cursors. 187. Events and Bindings. 19Events . 19The Event Object.21Instance and Class Bindings.21Protocols. 23Other Protocols . 248. Application Windows.25Base Windows . 25Menus . 2510. The BitmapImage Class . 38When to use the BitmapImage Class .38Patterns. 38Methods .38Options . 3811. The Button Widget.40When to use the Button Widget .40Patterns.40Methods . 41Helpers. 41Options . 4112. The Canvas Widget .44When to use the Canvas Widget. 44Concepts .44Items . 44Coordinate Systems . 45Item Specifiers . 45Printing . 46Patterns. 46Methods .46Printing .48Searching for Items. 49Manipulating Tags .50Special Methods for Text Items.51Scrolling.51Options . 5213. The Canvas Arc Item .54Methods . 54Options . 5514. The Canvas Bitmap Item. 57Bitmaps. 57Methods . 58Options . 5815. The Canvas Image Item. 59Methods . 59coords . 59itemconfigure . 59Options . 5916. The Canvas Line Item. 61Methods . 61Options . 61iiiTable of ContentsCopyright (c) 1999 by Fredrik Lundh

Review Copy. Do not redistribute! 1999-12-01 22:1517. The Canvas Oval Item.63Methods . 63Options . 6318. The Canvas Polygon Item .64Methods .64Options . 6419. The Canvas Rectangle Item. 66Methods .66Options . 6620. The Canvas Text Item . 67Methods . 67Options . 6721. The Canvas Window Item .69Methods .69Options . 6922. The Checkbutton Widget . 70When to use the Checkbutton Widget . 70Patterns. 70Methods .71Options .7123. The DoubleVar Class. 75When to use the DoubleVar Class . 75Patterns. 75Methods . 7524. The Entry Widget . 76When to use the Entry Widget . 76Concepts . 76Indexes. 76Patterns. 76Methods . 77Selection Methods. 77Scrolling Methods . 78Options . 7825. The Font Class .80Patterns.80Methods .80Functions .80Options . 8126. The Frame Widget .82When to use the Frame Widget . 82Patterns. 82Methods .82Options . 8227. The Grid Geometry Manager.84When to use the Grid Manager .84Patterns.84Methods .86Widget Methods .86Manager Methods . 87Options . 8728. The IntVar Class.89When to use the IntVar Class .89Patterns.89Methods .8929. The Label Widget .90When to use the Label Widget.90Patterns.90Methods . 91Options . 9130. The Listbox Widget. 93When to use the Listbox Widget . 93Patterns. 93Methods .96Selection Methods. 97Scrolling Methods . 97Options .9831. The Menu Widget . 100When to use the Menu Widget . 100Patterns. 100Methods . 102Displaying Menus . 104Options . 10432. The Menubutton Widget . 107When to use the Menubutton Widget. 107Patterns. 107Methods . 107Options . 10733. The Message Widget . 108When to use the Message Widget. 108Patterns. 108Methods . 108Options .10834. The Pack Geometry Manager .110When to use the Pack Manager .110Patterns.110Methods .110Widget Methods .110Manager Methods .110Options . 11135. The PhotoImage Class.112When to use the PhotoImage Class.112Patterns.112Methods .112Options .11336. The Place Geometry Manager .115When to use the Place Manager . 115iiiivCopyright (c) 1999 by Fredrik Lundh

Review Copy. Do not redistribute! 1999-12-01 22:15Patterns. 115Methods .116Options . 11737. The Radiobutton Widget.118When to use the Radiobutton Widget.118Patterns.118Methods .119Options . 12038. The Scale Widget. 123When to use the Scale Widget . 123Patterns. 123Methods . 123Options . 12339. The Scrollbar Widget .125When to use the Scrollbar Widget.125Patterns.125Methods . 126Options . 12640. The StringVar Class . 129When to use the StringVar Class . 129Patterns. 129Methods . 12941. The Text Widget . 130When to use the Text Widget . 130Concepts . 130Indexes. 130Lines and columns .131Line endings .131Named indexes.131Coordinates . 132Embedded objects. 132Expressions . 132Marks . 132Tags. 133Patterns.135Methods .137Methods for Marks. 138Methods for Embedded Windows. 139Methods for Embedded Images . 140image create . 140index .141delete .141image cget .141image config.141image names .141Methods for Tags .141tag add. 142tag remove. 142tag delete . 142tag config.

In addition to the Tk interface module, Tkinter includes a number of Python modules. The two most important modules are the Tkinter module itself, and a module called Tkconstants. The former automatically imports the latter, so to use Tkinter, all you need to do is to import one module: import Tkinter Or,

Related Documents:

Python 1 and 2; renamed to tkinter in Python 3). If Tkinter is available, then no errors occur, as demonstrated in the following: import tkinter If your Python interpreter was not compiled with Tkinter enabled, the module import fails. You might need to recompile your Python interpreter to gain access to Tkinter. This usually

Tkinter is largely unchanged between python 2 and python 3, with the major difference being that the tkinter package and modules were renamed. Importing in python 2.x In python 2.x, the tkinter package is named Tkinter, and related packages have their own names. For example, the following shows a typical set of import statements for python 2.x:

"Tkinter is Python's de facto standard GUI (Graphical User Interface) package. It is a thin object oriented layer on top of Tcl/Tk." Tkinter examples you may have seen. Tkinter examples you may have seen. With ttk, you get a nicer look. Themed widgets can match the platform. .

Setup Begin with this import statement: from tkinter import * Note: In earlier versions of Python, this module was called Tkinter, not tkinter Then create an object of type Tk: top Tk() This is the top-level window of your GUI program You can use any name for it; in these slide

programming in Python, using Tkinter . There are several GUI interfaces available in Python: Tkinter is the Python interface to the Tk GUI toolkit. wxPython is an open-source Python interface for wxWindows. JPython is a Python port for Java which gives Python scripts access

Based on Tcl/Tk. Popular open-source scripting language/GUI widget set developed by John Ousterhout (90s) Tk used in a wide variety of other languages (Perl, Ruby, PHP, etc.) Cross-platform (Unix/Windows/MacOS) It's small ( 25 basic widgets) 3 Tkinter Hello World A very short example: from Tkinter import Label

python hello1.py The following window appears. Figure 2-1. Running the program To stop the program, just close the window. Details We start by importing the Tkinter module. It contains all classes, functions and other things needed to work with the Tk toolkit. In most cases, you can simply import everything from Tkinter into your module's .

Analog-rich MCUs for mixed-signal applications Large portfolio available from NOW! 32.512KB Flash memory 32.128-pin packages Performance 170MHz Cortex-M4 coupled with 3x accelerators Rich and Advanced Integrated Analog ADC, DAC, Op-Amp, Comp. Safety and security focus