对Tkinter学习感兴趣,推荐观看博主的
tkinter 详解视频教程
ttk中虽然添加了Notebook,但其功能过于简单,无法支持双击创建选项卡,删除选项卡等功能,于是自定义了tabview,有需要的朋友,可以参考在tkinter中自定义view的方法,自定义自己的view
源码地址
如果觉得有用,请不要吝啬一颗小星星
import tkinter as tk
from tkinter import messagebox
from tabview import TabView
def create_body():
global body
return tk.Label(body, text="this is body")
def select(index):
print("current selected -->", index)
def remove(index):
print("remove tab -->", index)
if messagebox.askokcancel("标题", "确定要关闭该选项卡吗?"):
return True
else:
return False
root = tk.Tk()
root.geometry("640x300")
tab_view = TabView(root, generate_body=create_body,
select_listen=select, remove_listen=remove)
body = tab_view.body
label_1 = tk.Label(tab_view.body, text="this is tab1")
label_2 = tk.Label(tab_view.body, text="this is tab2")
tab_view.add_tab(label_1, "tabs1")
tab_view.add_tab(label_2, "tabs2")
tab_view.pack(fill="both", expand='yes', pady=2)
root.mainloop()
root = Tk() # 初始框的声明
columns = ("姓名", "IP地址")
treeview = ttk.Treeview(root, height=18, show="headings", columns=column...
浏览器打开
表格视图的使用IOS表格视图由单元格 (一般可重复使用) 组成,用于显示垂直滚动的视图。在iOS 中,表格视图用于显示数据列表,如联系人、待办事项或购物项列表。重要的属性delegatedataSourcerowHeightsectionFooterHeightsectionHeaderHeightseparatorColortableHeaderViewtableFooterView重要的方法-...
浏览器打开
添加Tab(标签)的时候,可以使用的属性有:
21.3.1 compound
如果在Tab的名字中,同时使用了文字和图像,使用compound来定义如何显示文字的位置。具体的用法可以参见第四章Label中关于compound属性的介绍。
21.3.2 padding
定义子控件与Notebook边框之间的填充距离。这个距离是在子控件四边都填充的。如下图所示。填充距离是可以指...
浏览器打开
文章目录1.当鼠标移动到指定控件时,进行文字提醒的控件动图演示:实现代码2.当点击右键时,弹出菜单栏的控件动图演示:实现代码
1.当鼠标移动到指定控件时,进行文字提醒的控件
动图演示:
浏览器打开