python GUI——Tkinter简单实例

运行结果:
tkinter简单实例
运用了Entry,Button,Label,消息弹框等简单控件。

from tkinter import messagebox
from tkinter.filedialog import *

root =Tk()
root.title('QR code')
textPath = StringVar()
videoPath=StringVar()
outPath=StringVar()

def selectFilePath():
    path_ = askopenfilename()
    textPath.set(path_)
# 选取文件路径
def selectDirectoryPath():
    path_ = askdirectory()
    videoPath.set(path_)
#选取文件夹路径
def decode():
    print("decode")
    i = messagebox.showinfo('消息框','编码完成!请到相关路径下查看文件!')
    print(i)#解码结束设置弹框提醒
def encode():
    print("encode")
    i = messagebox.showinfo('消息框', '编码完成!请到相关路径下查看文件!')
    print(i)  # 编码结束设置弹框提醒
Label(root,text = "上传二进制文件:").grid(row = 1, column = 1,padx=20,pady=20,stick=E)
Entry(root,textvariable = textPath).grid(row = 1, column = 3,padx=20,pady=20)
Button(root, text = "路径选择", command = selectFilePath).grid(row = 1, column = 4)
Label(root,text = "保存编码视频:").grid(row = 3, column = 1,padx=20,pady=20,stick=E)
Entry(root,textvariable = videoPath).grid(row = 3, column = 3,padx=20,pady=20)
Button(root, text = "路径选择", command =selectDirectoryPath).grid(row = 3, column = 4)
Button(root, text = "   确认   ", command = encode).grid(row = 5, column =4,padx=20,pady=20,stick=E )#点击确认启动编码
Label(root,text = "上传解码视频:").grid(row = 7, column = 1,padx=20,pady=20,stick=E)
Entry(root,textvariable = outPath).grid(row = 7, column = 3,padx=20,pady=20)
Button(root, text = "路径选择", command = selectFilePath).grid(row = 7, column = 4)
Label(root,text = "保存解码文本:").grid(row = 9, column = 1,padx=20,pady=20,stick=E)
Entry(root,textvariable = outPath).grid(row = 9, column = 3,padx=20,pady=20)
Button(root, text = "路径选择", command = selectDirectoryPath).grid(row =9, column = 4)
Label(root,text = "保存对比文件:").grid(row = 11, column = 1,padx=20,pady=20,stick=E)
Entry(root,textvariable = outPath).grid(row = 11, column = 3,padx=20,pady=20)
Button(root, text = "路径选择", command = selectDirectoryPath).grid(row =11, column = 4)
Button(root, text = "   确认   ", command = decode).grid(row = 13, column =4,padx=20,pady=20,stick=E )#点击确认启动解码

root.mainloop()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值