您当前的位置: 首页 >  Python

Python编程:tkinter创建GUI可视化界面

彭世瑜 发布时间:2018-02-27 16:35:09 ,浏览量:5

简单的测试一下tkinter


import tkinter as tk
from tkinter import ttk 
from tkinter import messagebox

root = tk.Tk()  # 生成主窗口
root.title("窗体测试程序")   # 窗体名称
root.geometry("400x300")   # 指定窗体大小

label = ttk.Label(root, text="hello world")
label.pack()

# 事件
def click(event):
    messagebox.showinfo("hello world", "this is a some info")

button1 = tk.Button(root, text="tk-button")
button1.bind("", click)
button1.pack(side=tk.LEFT)

button2 = ttk.Button(root, text="ttk-button")
button2.bind("", click)
button2.pack(side=tk.RIGHT)

root.mainloop()  # 消息循环

界面效果:

这里写图片描述

参考: tkinter模块常用参数(python3) https://www.cnblogs.com/aland-1415/p/6849193.html

Tkinter简易教程 https://www.cnblogs.com/tkinter/p/5629578.html

pyhon之Tkinter实例化学习 https://www.cnblogs.com/kaituorensheng/p/3287652.html

Python基础总结(七)(Tkinter的GUI的程序设计) https://www.jianshu.com/p/5c7a1af4aa53

An Introduction to Tkinter (Work in Progress) http://effbot.org/tkinterbook/

关注
打赏
1688896170
查看更多评论

彭世瑜

暂无认证

  • 5浏览

    0关注

    2727博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.1791s