Python基础 GUI 编程 Tkinter

来源:互联网 发布:淘宝如何找相似图片 编辑:程序博客网 时间:2024/06/05 11:58

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()
原创粉丝点击