Python基础 GUI 编程 Tkinter

xiaoxiao2021-02-28  27

GUI编程

运行示例

#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Python基础 Tkinter GUI 编程 # GUI 编程 from tkinter import * # GUI 布局 class Application(Frame): def __init__(self, master = None): Frame.__init__(self, master) self.pack() self.createWidgets() def createWidgets(self): # 文本框 self.helloLabel = Label(self, text="你好,Python") # widge 父容器 self.helloLabel.pack() # 输入框 self.nameInput = Entry(self) self.nameInput.pack() # 按钮 self.quitButton = Button(self, text="退出", command = self.quit) self.quitButton.pack() # 实例化 app = Application() # 设置窗口标题 app.master.title("Tkinter 示例") # 主消息循环 app.mainloop()
转载请注明原文地址: https://www.6miu.com/read-2300195.html

最新回复(0)