ttkbootstrap界面美化系列之Notebook(四)
在简单的界面设计中,Notebook也是常用的组件之一,Notebook组件的引入可以根据标签来切换不同的界面。使得界面更有层次感,不必都挤在一个界面上。在tkinter中就有Notebook组件,在ttkbootstrap中,同样也对Notebook进行了引入并做了对应的美化。
一:Notebook接口
查看Notebook的接口可以通过help来看
print(help(ttk.Notebook))
Help on class Notebook in module tkinter.ttk:class Notebook(Widget)| Notebook(*args, **kwargs)|| Ttk Notebook widget manages a collection of windows and displays| a single one at a time. Each child window is associated with a tab,| which the user may select to change the currently-displayed window.|| Method resolution order:| Notebook| Widget| tkinter.Widget| tkinter.BaseWidget| tkinter.Misc| tkinter.Pack| tkinter.Place| tkinter.Grid| builtins.object|| Methods defined here:|| __init__(self, *args, **kwargs)|| add(self, child, **kw)| Adds a new tab to the notebook.|| If window is currently managed by the notebook but hidden, it is| restored to its previous position.|| config = configure(self, cnf=None, **kwargs)|| configure(self, cnf=None, **kwargs)|| enable_traversal(self)| Enable keyboard traversal for a toplevel window containing| this notebook.|| This will extend the bindings for the toplevel window containing| this notebook as follows:|| Control-Tab: selects the tab following the currently selected| one|| Shift-Control-Tab: selects the tab preceding the currently| selected one|| Alt-K: where K is the mnemonic (underlined) character of any| tab, will select that tab.|| Multiple notebooks in a single toplevel may be enabled for| traversal, including nested notebooks. However, notebook traversal| only works properly if all panes are direct children of the| notebook.|| forget(self, tab_id)| Removes the tab specified by tab_id, unmaps and unmanages the| associated window.|| hide(self, tab_id)| Hides the tab specified by tab_id.|| The tab will not be displayed, but the associated window remains| managed by the notebook and its configuration remembered. Hidden| tabs may be restored with the add command.
...
...
...
通过dir来查看Notebook支持的属性和方法
['_Misc__winfo_getint', '_Misc__winfo_parseitem', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_bind', '_configure', '_displayof', '_do', '_getboolean', '_getconfigure', '_getconfigure1', '_getdoubles', '_getints', '_grid_configure', '_gridconvvalue', '_last_child_ids', '_nametowidget', '_noarg_', '_options', '_register', '_report_exception', '_root', '_setup', '_subst_format', '_subst_format_str', '_substitute', '_tclCommands', '_unbind', '_windowingsystem', 'add', 'after', 'after_cancel', 'after_idle', 'anchor', 'bbox', 'bell', 'bind', 'bind_all', 'bind_class', 'bindtags', 'cget', 'clipboard_append', 'clipboard_clear', 'clipboard_get', 'columnconfigure', 'config', 'configure', 'deletecommand', 'destroy', 'enable_traversal', 'event_add', 'event_delete', 'event_generate', 'event_info', 'focus', 'focus_displayof', 'focus_force', 'focus_get', 'focus_lastfor', 'focus_set', 'forget', 'getboolean', 'getdouble', 'getint', 'getvar', 'grab_current', 'grab_release', 'grab_set', 'grab_set_global', 'grab_status', 'grid', 'grid_anchor', 'grid_bbox', 'grid_columnconfigure', 'grid_configure', 'grid_forget', 'grid_info', 'grid_location', 'grid_propagate', 'grid_remove', 'grid_rowconfigure', 'grid_size', 'grid_slaves', 'hide', 'identify', 'image_names', 'image_types', 'index', 'info', 'info_patchlevel', 'insert', 'instate', 'keys', 'lift', 'location', 'lower', 'mainloop', 'nametowidget', 'option_add', 'option_clear', 'option_get', 'option_readfile', 'pack', 'pack_configure', 'pack_forget', 'pack_info', 'pack_propagate', 'pack_slaves', 'place', 'place_configure', 'place_forget', 'place_info', 'place_slaves', 'propagate', 'quit', 'register', 'rowconfigure', 'select', 'selection_clear', 'selection_get', 'selection_handle', 'selection_own', 'selection_own_get', 'send', 'setvar', 'size', 'slaves', 'state', 'tab', 'tabs', 'tk_bisque', 'tk_focusFollowsMouse', 'tk_focusNext', 'tk_focusPrev', 'tk_setPalette', 'tk_strictMotif', 'tkraise', 'unbind', 'unbind_all', 'unbind_class', 'update', 'update_idletasks', 'wait_variable', 'wait_visibility', 'wait_window', 'waitvar', 'winfo_atom', 'winfo_atomname', 'winfo_cells', 'winfo_children', 'winfo_class', 'winfo_colormapfull', 'winfo_containing', 'winfo_depth', 'winfo_exists', 'winfo_fpixels', 'winfo_geometry', 'winfo_height', 'winfo_id', 'winfo_interps', 'winfo_ismapped', 'winfo_manager', 'winfo_name', 'winfo_parent', 'winfo_pathname', 'winfo_pixels', 'winfo_pointerx', 'winfo_pointerxy', 'winfo_pointery', 'winfo_reqheight', 'winfo_reqwidth', 'winfo_rgb', 'winfo_rootx', 'winfo_rooty', 'winfo_screen', 'winfo_screencells', 'winfo_screendepth', 'winfo_screenheight', 'winfo_screenmmheight', 'winfo_screenmmwidth', 'winfo_screenvisual', 'winfo_screenwidth', 'winfo_server', 'winfo_toplevel', 'winfo_viewable', 'winfo_visual', 'winfo_visualid', 'winfo_visualsavailable', 'winfo_vrootheight', 'winfo_vrootwidth', 'winfo_vrootx', 'winfo_vrooty', 'winfo_width', 'winfo_x', 'winfo_y']
二:Notebook创建
import ttkbootstrap as ttk
from ttkbootstrap.constants import *root = ttk.Window( title="主窗口", #设置窗口的标题themename="yeti", #设置主题yetisize=(400,200), #窗口的大小)nb = ttk.Notebook()
nb.pack(fill=BOTH, expand=True)b1 = ttk.Button(nb, text="solid", bootstyle="info-solid")
b1.pack(side=LEFT, padx=5, pady=10)
nb.add(b1, text='选项卡1')b2 = ttk.Button(nb, text="outline", bootstyle="warning-outline")
b2.pack(side=LEFT, padx=5, pady=10)
nb.add(b2, text='选项卡2')root.mainloop()
可以看到创建了一个Notebook,加入了两个标签页,每个标签页中放一个按钮,上面是一个最基本的创建Notebook的用例,ttk.Notebook也有很多参数
原始链接:tkinter.ttk — Tk themed widgets — Python 3.12.2 documentation
三:Notebook主题
Notebook可以用自带的主题,也可以自己定制主题
nb = ttk.Notebook(root, bootstyle=SUCCESS)
定制主题如下
import ttkbootstrap as ttk
from ttkbootstrap.constants import *root = ttk.Window( title="主窗口", #设置窗口的标题themename="yeti", #设置主题yetisize=(400,200), #窗口的大小)s = ttk.Style()
s.configure('Custom.TNotebook', foreground='pink', background='yellow', borderwidth=10)
s.configure('Custom.TNotebook.Tab', foreground='blue', background='orange', borderwidth=10)
s.map('Custom.TNotebook.Tab', foreground=[('selected', 'red')], background=[('selected', 'blue')])nb = ttk.Notebook(root,style='Custom.TNotebook')
nb.pack(fill=BOTH, expand=True)b1 = ttk.Button(nb, text="solid", bootstyle="info-solid")
b1.pack(side=LEFT, padx=5, pady=10)
nb.add(b1, text='选项卡1')b2 = ttk.Button(nb, text="outline", bootstyle="warning-outline")
b2.pack(side=LEFT, padx=5, pady=10)
nb.add(b2, text='选项卡2')root.mainloop()
相关文章:

ttkbootstrap界面美化系列之Notebook(四)
在简单的界面设计中,Notebook也是常用的组件之一,Notebook组件的引入可以根据标签来切换不同的界面。使得界面更有层次感,不必都挤在一个界面上。在tkinter中就有Notebook组件,在ttkbootstrap中,同样也对Notebook进行了…...
MySQL8存储过程整合springboot
注意:调用使用mybatis-plus3形式调用,可能会有些区别 1. 创建存储过程 -- -- 生成员工工号的存储过程 DELIMITER $$ CREATE PROCEDURE generate_employee_number(OUT employeeNumber VARCHAR(20)) -- 解释 out 一个返回值 BEGINDECLARE prefix VARCHAR…...
Acwing 1238.日志统计 双指针
小明维护着一个程序员论坛。现在他收集了一份”点赞”日志,日志共有 N� 行。 其中每一行的格式是: ts id 表示在 ts 时刻编号 id 的帖子收到一个”赞”。 现在小明想统计有哪些帖子曾经是”热帖”。 如果一个帖子曾在任意一个长度为 D 的…...
Matlab-R2022b-安装文件分享
一、MATLAB主要特点和功能 MATLAB是一款强大的科学计算软件,专门用于算法开发、数据分析、数值计算以及科学数据可视化。 以下是一些MATLAB的主要特点和功能: 1.矩阵运算: MATLAB的名字来源于"Matrix Laboratory"(矩阵实验室&…...

Flutter开发之objectbox
Flutter开发之objectbox 在之前进行iOS开发的时候使用WCDB去进行管理数据库很方便,它支持ORM(Object-Relational Mapping,对象关系映射),用于实现面向对象编程语言里不同类型系统的数据之间的转换。 那么在Flutter开发…...
AI Drug Discovery Design(学习路线)
AIDD,即AI Drug Discovery & Design,是近年来非常火热的技术应用,已经介入到新药设计到研发的大部分环节当中,为新药发现与开发带来了极大的助力。其学习路线涉及多个学科和领域的知识。以下是一个可能的AIDD学习路线…...

【软考】设计模式之状态模式
目录 1. 说明2. 应用场景3. 结构图4. 构成5. 优缺点5.1 优点5.2 缺点 6. java示例6.1 非状态模式6.1.1 问题分析6.1.2 接口类6.1.2 实现类6.1.3 客户端6.1.4 结果截图 6.2 状态模式6.2.1 抽象状态类6.2.2 状态类6.2.3 上下文类6.2.4 上下文类 1. 说明 1.允许一个对象在其内部状…...
MNN介绍、安装与编译:移动端深度学习推理引擎
MNN介绍、安装与编译:移动端深度学习推理引擎 引言第一部分:MNN简介第二部分:MNN的安装第三部分:MNN的编译结语 引言 大家好,这里是程序猿代码之路。在移动设备上实现高效的深度学习模型推理一直是人工智能领域的一个挑…...

A Simple Problem with Integers(线段树)
目录 描述 输入 输出 样例输入 样例输出 思路 建树 第一次错误解法(正确解法在下面,可跳过这一步) 正确解法 code 描述 You have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of …...
单元测试(UT)用例简介
单元测试(Unit Testing, UT)用例是一系列预先设计好的、针对软件最小可测试单元的测试场景。每一个单元测试用例都是为了验证一个独立代码单元(如函数、方法、类)的行为是否符合预期。这些用例通常包含以下几个关键组成部分&#…...
Java通过反射机制获取类对象下的属性值
目录 以类USER为例: 使用Java的反射机制获取Column的name为“user_name”的类属性值 以类USER为例: import lombok.Data; import javax.persistence.*; import java.io.Serializable;Data Table(name "user_info") public class User imple…...
IDEA插件开发-File -> New->Project中添加一个myOptions
写一个IDEA插件,在IDEA的File -> New -> Project 中添加一个选项myOptions ,点击myOptions 后弹出一个提示对话框:被点击了 为了在IntelliJ IDEA中创建一个插件,您需要遵循一系列的步骤来开发和集成您的功能。下面是一个简化的指南&am…...

海量数据处理项目-账号微服务和流量包数据库表+索引规范(下)
海量数据处理项目-账号微服务和流量包数据库表索引规范(下) 第2集 账号微服务和流量包数据库表索引规范讲解《下》 简介:账号微服务和流量包数据库表索引规范讲解 账号和流量包的关系:一对多traffic流量包表思考点 海量数据下每…...

Nodejs 16与 gitbook搭建属于你自己的书本网站-第一篇
最近想重新搭建一个网站来存放自己的相关知识点,并向网络公开,有个hexo博客其实也不错的,但是总感觉hexo很多花里胡哨的玩意,导致挂载的博客异常卡,这样反而不利于我自己回顾博客了,于是我就开始钻研这个鬼…...

服务器被CC攻击之后怎么办?
1.取消域名绑定取消域名绑定后Web服务器的CPU能够马上恢复正常状态,通过IP进行访问连接一切正常。但是不足之处也很明显,取消或者更改域名对于别人的访问带来了不变,另外,对于针对IP的CC攻击它是无效的,就算更换域名攻…...

pygame通过重心坐标 用纹理填充三角形
texture_x int(alpha * texture_image.get_width()) texture_y int(beta * texture_image.get_height())为什么没有gama 2024/3/30 15:45:52 在使用重心坐标进行纹理映射时,通常是通过计算 alpha 和 beta 来确定纹理图片上的对应位置,而 gamma 通常是…...
Leetcode 611. 有效三角形的个数
给定一个包含非负整数的数组 nums ,返回其中可以组成三角形三条边的三元组个数。 示例 1: 输入: nums [2,2,3,4] 输出: 3 解释:有效的组合是: 2,3,4 (使用第一个 2) 2,3,4 (使用第二个 2) 2,2,3 示例 2: 输入: nums [4,2,3,4] 输出: 4 提示: 1 < nums.len…...

Openfeign
Openfeign 相关扩展 在 2020 以前的 SpringCloud 采用 Ribbon 作为负载均衡,但是 2020 年之后,SpringCloud 吧 Ribbon 移除了,而是使用自己编写的 LoadBalancer 替代. 因此,如果在没有加入 LoadBalancer 依赖的情况下,…...

五、基于KubeAdm搭建多节点K8S集群
如需查阅上一步骤,请点击下面链接:四、戴尔R630本地服务器Linux Centos7.9系统安装docker-ce-20.10.10-3.el7版本-CSDN博客文章浏览阅读727次,点赞12次,收藏13次。1、准备工作3、Linux Centos7.9系统的iDRAC远程管理、网络设置、SecureCRT远程登录终端、企业级静态ip地址配…...

PC电脑技巧[笔记本通过网线访问设备CMW500]
笔记本局域网访问设备 现在我有一台CMW500,我要用笔记本去访问它,但是我发现没有路由器就是不能够访问,通过网线连接设备就是ping不通: 这里设置TCP/IPv4的IP地址如下,这时候就可以pin通了:...

超短脉冲激光自聚焦效应
前言与目录 强激光引起自聚焦效应机理 超短脉冲激光在脆性材料内部加工时引起的自聚焦效应,这是一种非线性光学现象,主要涉及光学克尔效应和材料的非线性光学特性。 自聚焦效应可以产生局部的强光场,对材料产生非线性响应,可能…...
CVPR 2025 MIMO: 支持视觉指代和像素grounding 的医学视觉语言模型
CVPR 2025 | MIMO:支持视觉指代和像素对齐的医学视觉语言模型 论文信息 标题:MIMO: A medical vision language model with visual referring multimodal input and pixel grounding multimodal output作者:Yanyuan Chen, Dexuan Xu, Yu Hu…...
pam_env.so模块配置解析
在PAM(Pluggable Authentication Modules)配置中, /etc/pam.d/su 文件相关配置含义如下: 配置解析 auth required pam_env.so1. 字段分解 字段值说明模块类型auth认证类模块,负责验证用户身份&am…...

剑指offer20_链表中环的入口节点
链表中环的入口节点 给定一个链表,若其中包含环,则输出环的入口节点。 若其中不包含环,则输出null。 数据范围 节点 val 值取值范围 [ 1 , 1000 ] [1,1000] [1,1000]。 节点 val 值各不相同。 链表长度 [ 0 , 500 ] [0,500] [0,500]。 …...

《通信之道——从微积分到 5G》读书总结
第1章 绪 论 1.1 这是一本什么样的书 通信技术,说到底就是数学。 那些最基础、最本质的部分。 1.2 什么是通信 通信 发送方 接收方 承载信息的信号 解调出其中承载的信息 信息在发送方那里被加工成信号(调制) 把信息从信号中抽取出来&am…...

《基于Apache Flink的流处理》笔记
思维导图 1-3 章 4-7章 8-11 章 参考资料 源码: https://github.com/streaming-with-flink 博客 https://flink.apache.org/bloghttps://www.ververica.com/blog 聚会及会议 https://flink-forward.orghttps://www.meetup.com/topics/apache-flink https://n…...
工业自动化时代的精准装配革新:迁移科技3D视觉系统如何重塑机器人定位装配
AI3D视觉的工业赋能者 迁移科技成立于2017年,作为行业领先的3D工业相机及视觉系统供应商,累计完成数亿元融资。其核心技术覆盖硬件设计、算法优化及软件集成,通过稳定、易用、高回报的AI3D视觉系统,为汽车、新能源、金属制造等行…...
JavaScript基础-API 和 Web API
在学习JavaScript的过程中,理解API(应用程序接口)和Web API的概念及其应用是非常重要的。这些工具极大地扩展了JavaScript的功能,使得开发者能够创建出功能丰富、交互性强的Web应用程序。本文将深入探讨JavaScript中的API与Web AP…...

五子棋测试用例
一.项目背景 1.1 项目简介 传统棋类文化的推广 五子棋是一种古老的棋类游戏,有着深厚的文化底蕴。通过将五子棋制作成网页游戏,可以让更多的人了解和接触到这一传统棋类文化。无论是国内还是国外的玩家,都可以通过网页五子棋感受到东方棋类…...

工厂方法模式和抽象工厂方法模式的battle
1.案例直接上手 在这个案例里面,我们会实现这个普通的工厂方法,并且对比这个普通工厂方法和我们直接创建对象的差别在哪里,为什么需要一个工厂: 下面的这个是我们的这个案例里面涉及到的接口和对应的实现类: 两个发…...