1 Star 0 Fork 6

Evgenii/tkinter界面展示

forked from cheney/tkinter界面展示 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
universal_functions.py 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
cheney 提交于 2021-09-04 16:54 +08:00 . New: universal function, etc
import tkinter as tk
import time
import logging, logg
import tkinter.ttk as ttk
# Useful third party website
# https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/frame.html
# https://tkdocs.com/tutorial/widgets.html
# https://www.tutorialspoint.com/python3/python_gui_programming.htm
# current file logger
cf_logger = logging.getLogger('Tk_widgets_sample.universal_functions')
def universal_function():
# https://anzeljg.github.io/rin2/book2/2405/docs/tkinter/universal.html
# details refer to above links
# common use the bind function
# get master
master = tk.Tk()
style = ttk.Style()
# gloabal default style
style.configure('.', font='Arial 19', foreground='yellow', background='red')
# custom style
style.configure('mystyle.TButton', font='Arial 15', foreground='blue', padding=10)
# buttons
btn1 = ttk.Button(master, text='Im using default gloable style')
btn1.pack()
btn2 = ttk.Button(master, text='Im using mystyle', style='mystyle.TButton')
btn2.pack()
#bind
master.bind("<Button-3>", right_click) # right click with mouse
master.bind("<KeyPress-F2>", press_F2)# press F2
master.mainloop()
def right_click(event):
cf_logger.info('right click with bind function.{}'.format(event))
def press_F2(event):
cf_logger.info('F2 press with bind function. {}'.format(event))
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/evgenii/tkinter-interface-display.git
git@gitee.com:evgenii/tkinter-interface-display.git
evgenii
tkinter-interface-display
tkinter界面展示
master

搜索帮助