GUI Programming Using Tkinter
来源:互联网 发布:扫码群发软件 编辑:程序博客网 时间:2024/05/21 09:26
1、代码块
from tkinter import * # Import all definitions from tkinterclass WidgetsDemo: def __init__(self): window = Tk() # Create a window window.title("Widgets Demo") # Set a title # Add a check button, and a radio button to frame1 frame1 = Frame(window) # Create and add a frame to window frame1.pack() self.v1 = IntVar() cbtBold = Checkbutton(frame1, text = "Bold", variable = self.v1, command = self.processCheckbutton) self.v2 = IntVar() rbRed = Radiobutton(frame1, text = "Red", bg = "red", variable = self.v2, value = 1, command = self.processRadiobutton) rbYellow = Radiobutton(frame1, text = "Yellow", bg = "Yellow", variable = self.v2, value = 2, command = self.processRadiobutton) cbtBold.grid(row = 1, column = 1) rbRed.grid(row = 1, column = 2) rbYellow.grid(row = 1, column = 3) # Add a label, an entry, a button, and a message to frame2 frame2 = Frame(window) frame2.pack() label = Label(frame2, text = "Enter your name: ") self.name = StringVar() entryName = Entry(frame2, textvariable = self.name) btGetName = Button(frame2, text = "Get Name", command = self.processButton) message = Message(frame2, text = "It is a widgets demo") label.grid(row = 1, column = 1) entryName.grid(row = 1, column = 2) btGetName.grid(row = 1, column = 3) message.grid(row = 1, column = 4) #Add text text = Text(window) # Create and add text to the window text.pack() text.insert(END, "Tip\nThe best way to learn Tkinter is to read ") text.insert(END, "these carefully designed examples and use them ") text.insert(END, "to create your applications. ") window.mainloop() def processCheckbutton(self): print("check button is " + ("Checked " if self.v1.get() == 1 else "Unchecked ")) def processRadiobutton(self): print(("Red" if self.v2.get() == 1 else "Yellow") + " is selected ") def processButton(self): print("Your name is " + self.name.get())WidgetsDemo() # Create GUI
2、效果图
0 0
- GUI Programming Using Tkinter
- GUI Programming Using Tkinter (Canvas)
- GUI Programming Using Tkinter (Label Entry Button Radiobutton)
- Python GUI Programming (Tkinter)
- Python GUI (Tkinter)
- Python Tkinter制作GUI
- python GUI Tkinter 模块
- Tkinter--GUI布局
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- Python Gui 学习 Tkinter
- python GUI编程(Tkinter)
- Python Gui 学习 Tkinter
- python GUI编程(Tkinter)
- Tkinter模块GUI
- Quartz.NET学习系列(三)--- Cron触发器
- hdu 1671 Phone List(trie)
- mysql timeout知多少
- 详解Objective-C runtime
- 15-03-14读书笔记
- GUI Programming Using Tkinter
- Android环境搭建——执行SDK Manager.exe无反应
- CBO之B*Tree Index Range Scan - IRS算法
- [leetcode #20 stack]Valid Parentheses
- String类
- ListView的子项中包含EditText,由于复用引起的Editext中的内容显示异常的解决方案
- POJ 3268 Silver Cow Party(dijkstra求单源最短路)
- 发展
- 关于Eclipse的Android项目,在直接运行可以,打包安装就报错,说某个类不存在的解决