python的GUI编程之Grid布局的使用
2021/10/17 14:11:05
本文主要是介绍python的GUI编程之Grid布局的使用,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import tkinter as tk from tkinter import ttk class Application(): def __init__(self, master): self.master = master self.initWidgets() def initWidgets(self): input1 = tk.Entry(master=self.master, relief=tk.SUNKEN, font=('Courier New', 24), width=25, fg="blue") input1.pack(side=tk.TOP, pady=10) label = tk.Label(master=self.master, text="结果") label.pack(side=tk.TOP) # input2 = tk.Entry(master=self.master, relief=tk.SUNKEN, font=('Courier New', 24), width=25, show="*",fg="blue", state=tk.DISABLED) input2 = tk.Entry(master=self.master, relief=tk.SUNKEN, font=('Courier New', 24), width=25, fg="blue", state=tk.DISABLED) input2.pack(side=tk.TOP, pady=10) p2 = tk.Frame(self.master) p2.pack(side=tk.TOP) names = ("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "+", "-", "*", "/", ".", "=") # 遍历字符串元组 for i in range(len(names)): b = tk.Button(p2, text=names[i], font=('Verdana', 20), width=6) print(i // 4, i % 4) b.grid(row=i // 4, column=i % 4) root = tk.Tk() root.title("Grid布局") Application(root) root.mainloop()
这篇关于python的GUI编程之Grid布局的使用的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-08有遇到过吗?同样的规则 Excel 中 比Python 结果大
- 2024-03-30开始python成长之路
- 2024-03-29python optparse
- 2024-03-29python map 函数
- 2024-03-20invalid format specifier python
- 2024-03-18pool.map python
- 2024-03-18threads in python
- 2024-03-14python Ai 应用开发基础训练,字符串,字典,文件
- 2024-03-13id3 algorithm python
- 2024-03-13sum array elements python