Python GUI 编程
来源:互联网 发布:东兴证券下载软件 编辑:程序博客网 时间:2024/06/06 07:19
做一些实用小工具。
1. tkinter
hello world
from tkinter import Tk, Labelroot = Tk()label = Label(root, text="hello world")label.pack() # pack() ⇒ 起到 Layout 布局的作用root.mainloop()
按钮及其事件:
from tkinter import Tk, Frame, Label, Button, Entryfrom tkinter import DoubleVarclass TempConverter: def __init__(self, master): mainframe = Frame(master) mainframe.pack() label1_1 = Label(mainframe, text='deg C') label1_1.grid(row=0, column=0) self.c_val = DoubleVar() entry1_2 = Entry(mainframe, textvariable=self.c_val) entry1_2.grid(row=0, column=1) self.f_val = DoubleVar() label2_1 = Label(mainframe, text='deg F') label2_1.grid(row=1, column=0) label2_2 = Label(mainframe, textvariable=self.f_val) label2_2.grid(row=1, column=1) button = Button(mainframe, text='Convert', command=self.convert) button.grid(row=2, columnspan=2) def convert(self): self.f_val.set(self.c_val.get() * 1.8 + 32)root = Tk()root.wm_title('tmp converter')converter = TempConverter(root)root.mainloop()
通过 grid() 成员的 row 和 column 属性进行布局,layout 如下:
阅读全文
0 0
- Python的GUI编程
- python GUI编程
- python GUI编程
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- python GUI编程
- python的GUI编程
- Python GUI 编程 工具
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- Python GUI编程(Tkinter)
- python GUI编程(Tkinter)
- python GUI编程
- python GUI编程(Tkinter)
- python GUI编程(Tkinter)
- python GUI编程(Tkinter)
- python GUI编程(Tkinter)
- Python GUI tkinter编程
- qt configure
- 页面上报错:Invalid left-hand side in assignment
- 3056: 升降梯口
- 基于spring的shiro配置
- 滑动滤波算法
- Python GUI 编程
- SpringBoot静态资源处理
- test
- 【canvas】非零环绕原则
- Linux第二天的学习记录
- 数据库TPCE benchmark测试工具
- 模板匹配opencv
- 盒子居中(常用的方法)
- c++部分知识