博客
关于我
Python GUI tkinter库 自学20
阅读量:277 次
发布时间:2019-03-01

本文共 1109 字,大约阅读时间需要 3 分钟。

颜色框 文件选择框及读取文件内容

1、颜色框

from tkinter import *from tkinter.colorchooser import *window = Tk()window.geometry("500x200")def test1():    s1 = askcolor(color="red", title="选择背景色")    print(s1)    # s1 的值是:((255.99609375, 0.0, 0.0), '#ff0000')    window.config(bg=s1[1])Button(window, text="选择背景色", command=test1).pack()window.mainloop()

2、文件选择框

from tkinter import *from tkinter.filedialog import *window = Tk()window.geometry("500x200")def test1():    f1 = askopenfilename(title="上传文件",                         initialdir="d:", filetypes=[("视频文件", ".mp4")])    # print(f1)    show["text"] = f1Button(window, text="选择编辑的视频文件", command=test1).pack()show = Label(window, width=10, height=5, bg="green")show.pack()window.mainloop()

3、读取文件内容

from tkinter import *from tkinter.filedialog import *window = Tk()window.geometry("500x200")def test1():    with askopenfile(title="上传文件",                     initialdir="d:", filetypes=[("文本文件", ".txt")]) as f:        show["text"] = f.read()Button(window, text="选择读取的文本文件", command=test1).pack()show = Label(window, width=10, height=5, bg="green")show.pack()window.mainloop()

转载地址:http://wkho.baihongyu.com/

你可能感兴趣的文章
navicat导入.sql文件出错2006- MySQLserver has gone away
查看>>
Navicat导入海量Excel数据到数据库(简易介绍)
查看>>
Navicat工具Oracle数据库复制 or 备用、恢复功能(评论都在谈论需要教)
查看>>
Navicat工具中建立数据库索引
查看>>
navicat工具查看MySQL数据库_表占用容量_占用空间是多少MB---Linux工作笔记048
查看>>
navicat怎么导出和导入数据表
查看>>
Navicat怎样同步两个数据库中的表
查看>>
Navicat怎样筛选数据
查看>>
Navicat报错connection is being used
查看>>
Navicat报错:1045-Access denied for user root@localhost(using passwordYES)
查看>>
Navicat控制mysql用户权限
查看>>
navicat操作mysql中某一张表后, 读表时一直显示正在载入,卡死不动,无法操作
查看>>
Navicat连接mysql 2003 - Can't connect to MySQL server on ' '(10038)
查看>>
Navicat连接mysql数据库中出现的所有问题解决方案(全)
查看>>
Navicat连接Oracle出现Oracle library is not loaded的解决方法
查看>>
Navicat连接Oracle数据库以及Oracle library is not loaded的解决方法
查看>>
Navicat连接sqlserver提示:未发现数据源名并且未指定默认驱动程序
查看>>
navicat连接远程mysql数据库
查看>>
Navicat通过存储过程批量插入mysql数据
查看>>
Navicat(数据库可视化操作软件)安装、配置、测试
查看>>