Tkinter 8.5reference:aGUIfor Python

2y ago
94 Views
6 Downloads
2.08 MB
168 Pages
Last View : 23d ago
Last Download : 2m ago
Upload by : Josiah Pursley
Transcription

Tkinter 8.5 reference: a GUI forPythonJohn W. Shipman2013-12-31 17:59AbstractDescribes the Tkinter widget set for constructing graphical user interfaces (GUIs) in the Pythonprogramming language. Includes coverage of the ttk themed widgets.12This publication is available in Web form and also as a PDF document . Please forward anycomments to tcc-doc@nmt.edu.Table of Contents1. A cross-platform graphical user interface builder for Python . 32. A minimal application . 43. Definitions . 54. Layout management . 54.1. The .grid() method . 64.2. Other grid management methods . 74.3. Configuring column and row sizes . 74.4. Making the root window resizeable . 85. Standard attributes . 95.1. Dimensions . 95.2. The coordinate system . 105.3. Colors . 105.4. Type fonts . 105.5. Anchors . 125.6. Relief styles . 125.7. Bitmaps . 125.8. Cursors . 135.9. Images . 145.10. Geometry strings . 155.11. Window names . 165.12. Cap and join styles . 165.13. Dash patterns . 175.14. Matching stipple patterns . 176. Exception handling . 187. The Button widget . 188. The Canvas widget . 208.1. Canvas coordinates . 228.2. The Canvas display list . 228.3. Canvas object IDs . //www.nmt.edu/tcc/help/pubs/tkinter/tkinter.pdfNew Mexico Tech Computer CenterTkinter 8.5 reference1

8.4. Canvas tags . 228.5. Canvas tagOrId arguments . 228.6. Methods on Canvas widgets . 228.7. Canvas arc objects . 288.8. Canvas bitmap objects . 298.9. Canvas image objects . 308.10. Canvas line objects . 308.11. Canvas oval objects . 328.12. Canvas polygon objects . 338.13. Canvas rectangle objects . 358.14. Canvas text objects . 378.15. Canvas window objects . 389. The Checkbutton widget . 3810. The Entry widget . 4110.1. Scrolling an Entry widget . 4510.2. Adding validation to an Entry widget . 4511. The Frame widget . 4712. The Label widget . 4813. The LabelFrame widget . 5014. The Listbox widget . 5214.1. Scrolling a Listbox widget . 5615. The Menu widget . 5615.1. Menu item creation (coption) options . 5915.2. Top-level menus . 6016. The Menubutton widget . 6117. The Message widget . 6318. The OptionMenu widget . 6419. The PanedWindow widget . 6519.1. PanedWindow child configuration options . 6720. The Radiobutton widget . 6821. The Scale widget . 7122. The Scrollbar widget . 7422.1. The Scrollbar command callback . 7722.2. Connecting a Scrollbar to another widget . 7723. The Spinbox widget . 7824. The Text widget . 8224.1. Text widget indices . 8424.2. Text widget marks . 8624.3. Text widget images . 8624.4. Text widget windows . 8724.5. Text widget tags . 8724.6. Setting tabs in a Text widget . 8724.7. The Text widget undo/redo stack . 8824.8. Methods on Text widgets . 8825. Toplevel: Top-level window methods . 9526. Universal widget methods . 9727. Standardizing appearance . 10527.1. How to name a widget class . 10627.2. How to name a widget instance . 10727.3. Resource specification lines . 10727.4. Rules for resource matching . 10828. ttk: Themed widgets . 1082Tkinter 8.5 referenceNew Mexico Tech Computer Center

28.1. Importing ttk . 10928.2. The ttk widget set . 11029. ttk.Button . 11030. ttk.Checkbutton . 11231. ttk.Combobox . 11532. ttk.Entry . 11633. ttk.Frame . 11834. ttk.Label . 11935. ttk.LabelFrame . 12236. ttk.Menubutton . 12437. ttk.Notebook . 12637.1. Virtual events for the ttk.Notebook widget . 12838. ttk.PanedWindow . 12939. ttk.Progressbar . 13040. ttk.Radiobutton . 13141. ttk.Scale . 13342. ttk.Scrollbar . 13543. ttk.Separator . 13744. ttk.Sizegrip . 13745. ttk.Treeview . 13745.1. Virtual events for the ttk.Treeview widget . 14546. Methods common to all ttk widgets . 14546.1. Specifying widget states in ttk . 14647. Customizing and creating ttk themes and styles . 14648. Finding and using ttk themes . 14749. Using and customizing ttk styles . 14750. The ttk element layer . 14950.1. ttk layouts: Structuring a style . 14950.2. ttk style maps: dynamic appearance changes . 15151. Connecting your application logic to the widgets . 15352. Control variables: the values behind the widgets . 15353. Focus: routing keyboard input . 15553.1. Focus in ttk widgets . 15654. Events . 15754.1. Levels of binding . 15754.2. Event sequences . 15854.3. Event types . 15854.4. Event modifiers . 16054.5. Key names . 16054.6. Writing your handler: The Event class . 16254.7. The extra arguments trick . 16454.8. Virtual events . 16555. Pop-up dialogs . 16555.1. The tkMessageBox dialogs module . 16555.2. The tkFileDialog module . 16755.3. The tkColorChooser module . 1681. A cross-platform graphical user interface builder for PythonTkinter is a GUI (graphical user interface) widget set for Python. This document was written for Python2.7 and Tkinter 8.5 running in the X Window system under Linux. Your version may vary.New Mexico Tech Computer CenterTkinter 8.5 reference3

Pertinent references: Fredrik Lundh, who wrote Tkinter, has two versions of his An Introduction to Tkinter: a more complete341999 version and a 2005 version that presents a few newer features.5 Python 2.7 quick reference : general information about the Python language. For an example of a sizeable working application (around 1000 lines of code), see huey: A color and6font selection tool . The design of this application demonstrates how to build your own compoundwidgets.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 applicationHere is a trivial Tkinter program containing only a Quit button:#!/usr/bin/env pythonimport Tkinter as tk12class Application(tk.Frame):def init (self, master None):tk.Frame. init (self, master)self.grid()self.createWidgets()345def createWidgets(self):self.quitButton tk.Button(self, text 'Quit',6command self.quit)7self.quitButton.grid()app Application()app.master.title('Sample application')app.mainloop()123456789108910This line makes the script self-executing, assuming that your system has Python correctly installed.This line imports the Tkinter module into your program's namespace, but renames it as tk.Your application class must inherit from Tkinter's Frame class.Calls the constructor for the parent class, Frame.Necessary to make the application actually appear on the screen.Creates a button labeled “Quit”.Places the button on the application.The main program starts here by instantiating the Application class.This method call sets the title of the window to “Sample application”.Starts the application's main loop, waiting for mouse and keyboard du/tcc/help/lang/python/examples/huey/454Tkinter 8.5 referenceNew Mexico Tech Computer Center

3. DefinitionsBefore we proceed, let's define some of the common terms.windowThis term has different meanings in different contexts, but in general it refers to a rectangular areasomewhere on your display screen.top-level windowA window that exists independently on your screen. It will be decorated with the standard frameand controls for your system's desktop manager. You can move it around on your desktop. Youcan generally resize it, although your application can prevent thiswidgetThe generic term for any of the building blocks that make up an application in a graphical user interface. Examples of widgets: buttons, radiobuttons

Describes the Tkinterwidget set for constructing graphical user interfaces (GUIs) in the Python programming language. Includes coverage of the ttk themed widgets. This publication is available in Web form 1 and also as a PDF document 2. Please forward any comments to tcc-doc@nmt.edu. Table of Contents 1.

Related Documents:

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:

programming language. Includes coverage of the ttk themed widgets. This publication is available in Web form 1 . A cross-platform graphical user interface builder for Python. Tkinter. is a GUI (graphical user interface) widget set for Python. This document was written for Python 2.7 and.

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

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,

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

"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

A programming manual is also available for each Arm Cortex version and can be used for MPU (memory protection unit) description: STM32 Cortex -M33 MCUs programming manual (PM0264) STM32F7 Series and STM32H7 Series Cortex -M7 processor programming manual (PM0253) STM32 Cortex -M4 MCUs and MPUs programming manual (PM0214)