Python的tkinter标签和按钮
2021/9/23 22:11:29
本文主要是介绍Python的tkinter标签和按钮,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
小项目:单击按钮,标签字符串改变
修改莫凡Python代码:莫烦Python
import tkinter as tk window = tk.Tk() window.title('666') window.geometry('300x100') var=tk.StringVar() var.set('first Button') theLabel=tk.Label(window,textvariable=var, fg='yellow',bg='blue', font=('宋体',15),width=20,height=2) theLabel.pack() hi_go=False def first_Button(): global hi_go if not hi_go: hi_go = True var.set('') else: hi_go = False var.set('first Button') theButton=tk.Button(window,text='button001',command=first_Button, width=15,height=2) theButton.pack() window.mainloop()
这篇关于Python的tkinter标签和按钮的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-09-30Python编程基础详解
- 2024-09-29点击加载学习:Python编程基础教程
- 2024-09-29数据科学五大Python前端库:第二部分
- 2024-09-27使用python 将ETH账户的资产打散
- 2024-09-26Python编程基础
- 2024-09-2610 种方法写出更好的 Python 代码
- 2024-09-25Python编程基础详解
- 2024-09-25Python编程入门教程
- 2024-09-25从零开始使用Python构建LLaMA 3
- 2024-09-23Python中理解和使用树形结构的简单教程