1 / 25
文档名称:

python tkinter.ppt

格式:ppt   页数:25页
下载后只包含 1 个 PPT 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

python tkinter.ppt

上传人:rabbitco 2016/1/9 文件大小:0 KB

下载得到文件列表

python tkinter.ppt

文档介绍

文档介绍:Python Short Python Short CourseCourseLecture 6: Tk GraphicsLecture 6: Tk GraphicsRichard P. MullerMaterials and Process Simulation CenterJune 22, 2000? 2000 Richard P. Muller2Tk Tk OverviewOverview?Set of widgets designed by John K. Ousterhout, 1987?Based on Apple Hypercard idea of putting together graphics program?Tk == Tool Kit?Mean to be driven by Tcl (Toolkit Control Language)–Many people find Tcl limited–Can also drive Tk with Perl, Python?Tkinter is the Python Tk Interface–Very easy to use? 2000 Richard P. Muller3Hello, WorldHello, Worldfrom Tkinter import *w=Label(text="Hello, World!")()()?Label() defines a label to be displayed–text= specifies a parameter to be passed in?pack() resizes the window to the proper size?mainloop() enters the event loop, and the program idles until a button is pushed, a menu is pulled, etc. It has to idle until the program is killed, since we didn't define any events.? 2000 Richard P. Muller4Events (Hello, Goodbye)Events (Hello, Goodbye)from Tkinter import *w=Label(text="Hello, World).pack()b=Button(text="Goodbye",command='exit').pack()mainloop()?Button label defined by text parameter?Button defines a callback function, something to run when it is pushed.?Now mainloop() has an event to catch, so when we push the button, mainloop() executes the mand.? 2000 Richard P. Muller5Creating a Molecular EditorCreating a Molecular EditorMenu barLabelText area (for geometry input)Text entryRadio buttonsCheckbox? 2000 Richard P. Muller6Molecular Editor OverviewMolecular Editor Overview?We're going to whiz through this fairly quickly–Example is online for those who want more–Just a survey of some different widgets–How you can build a professional looking interface? 2000 Richard P. Muller7Widgets Creation RoutineWidgets Creation Routine def makeWidgets(self): frame = Frame(self) (frame) (frame) (frame) (frame)