摘要: 1 class Person(object): # 创建类 2 def __init__(self, name): # 构造函数 3 self.name = name 4 5 def getName(self): # 类中的方法(函数) 6 return self.name 7 8 def colo 阅读全文
posted @ 2019-12-04 17:59 做梦者造梦 阅读(3592) 评论(0) 推荐(0) 编辑
摘要: 1 from tkinter import * 2 def printSelection(): 3 print(cities[int(var.get())]) 4 lab.config(text="你选择了"+cities[int(var.get())]) 5 6 root = Tk() 7 roo 阅读全文
posted @ 2019-12-03 21:23 做梦者造梦 阅读(261) 评论(0) 推荐(0) 编辑
摘要: from tkinter import * def printSelection(): num = var.get() if num == 1: lab.config(text="你是男生") else: lab.config(text="你是女生") root =Tk() root.title(" 阅读全文
posted @ 2019-12-03 18:25 做梦者造梦 阅读(617) 评论(0) 推荐(0) 编辑
摘要: tkinter的trace() 的参数w是写入追踪 from tkinter import * def callback(*args): xl.set(xE.get()) print("改变的数据:",xE.get()) root = Tk() root.title("tkinter的trace() 阅读全文
posted @ 2019-12-02 23:07 做梦者造梦 阅读(1571) 评论(2) 推荐(1) 编辑
摘要: 下面用set()实现,这里用了一个标记记录点击的状态,不管内容是什么点了就变 1 from tkinter import * 2 3 def btn_hit(): 4 global msg_on 5 if msg_on == False: 6 msg_on=True 7 x.set("I like 阅读全文
posted @ 2019-12-02 20:51 做梦者造梦 阅读(3393) 评论(0) 推荐(0) 编辑
摘要: 1 from tkinter import * 2 counter = 30 3 def run_counter(digit): 4 def counting(): 5 global counter 6 counter -= 1 7 digit.config(text=str(counter)) 8 阅读全文
posted @ 2019-12-02 12:00 做梦者造梦 阅读(432) 评论(0) 推荐(0) 编辑