当前位置: 首页 > news >正文

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学习路线&#xf…...

【软考】设计模式之状态模式

目录 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 &#xff0c;返回其中可以组成三角形三条边的三元组个数。 示例 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 作为负载均衡&#xff0c;但是 2020 年之后&#xff0c;SpringCloud 吧 Ribbon 移除了&#xff0c;而是使用自己编写的 LoadBalancer 替代. 因此&#xff0c;如果在没有加入 LoadBalancer 依赖的情况下&#xff0c…...

五、基于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通了:...

论文解读:交大港大上海AI Lab开源论文 | 宇树机器人多姿态起立控制强化学习框架(二)

HoST框架核心实现方法详解 - 论文深度解读(第二部分) 《Learning Humanoid Standing-up Control across Diverse Postures》 系列文章: 论文深度解读 + 算法与代码分析(二) 作者机构: 上海AI Lab, 上海交通大学, 香港大学, 浙江大学, 香港中文大学 论文主题: 人形机器人…...

反向工程与模型迁移:打造未来商品详情API的可持续创新体系

在电商行业蓬勃发展的当下&#xff0c;商品详情API作为连接电商平台与开发者、商家及用户的关键纽带&#xff0c;其重要性日益凸显。传统商品详情API主要聚焦于商品基本信息&#xff08;如名称、价格、库存等&#xff09;的获取与展示&#xff0c;已难以满足市场对个性化、智能…...

蓝桥杯 2024 15届国赛 A组 儿童节快乐

P10576 [蓝桥杯 2024 国 A] 儿童节快乐 题目描述 五彩斑斓的气球在蓝天下悠然飘荡&#xff0c;轻快的音乐在耳边持续回荡&#xff0c;小朋友们手牵着手一同畅快欢笑。在这样一片安乐祥和的氛围下&#xff0c;六一来了。 今天是六一儿童节&#xff0c;小蓝老师为了让大家在节…...

系统设计 --- MongoDB亿级数据查询优化策略

系统设计 --- MongoDB亿级数据查询分表策略 背景Solution --- 分表 背景 使用audit log实现Audi Trail功能 Audit Trail范围: 六个月数据量: 每秒5-7条audi log&#xff0c;共计7千万 – 1亿条数据需要实现全文检索按照时间倒序因为license问题&#xff0c;不能使用ELK只能使用…...

跨链模式:多链互操作架构与性能扩展方案

跨链模式&#xff1a;多链互操作架构与性能扩展方案 ——构建下一代区块链互联网的技术基石 一、跨链架构的核心范式演进 1. 分层协议栈&#xff1a;模块化解耦设计 现代跨链系统采用分层协议栈实现灵活扩展&#xff08;H2Cross架构&#xff09;&#xff1a; 适配层&#xf…...

2025 后端自学UNIAPP【项目实战:旅游项目】6、我的收藏页面

代码框架视图 1、先添加一个获取收藏景点的列表请求 【在文件my_api.js文件中添加】 // 引入公共的请求封装 import http from ./my_http.js// 登录接口&#xff08;适配服务端返回 Token&#xff09; export const login async (code, avatar) > {const res await http…...

【HTTP三个基础问题】

面试官您好&#xff01;HTTP是超文本传输协议&#xff0c;是互联网上客户端和服务器之间传输超文本数据&#xff08;比如文字、图片、音频、视频等&#xff09;的核心协议&#xff0c;当前互联网应用最广泛的版本是HTTP1.1&#xff0c;它基于经典的C/S模型&#xff0c;也就是客…...

Typeerror: cannot read properties of undefined (reading ‘XXX‘)

最近需要在离线机器上运行软件&#xff0c;所以得把软件用docker打包起来&#xff0c;大部分功能都没问题&#xff0c;出了一个奇怪的事情。同样的代码&#xff0c;在本机上用vscode可以运行起来&#xff0c;但是打包之后在docker里出现了问题。使用的是dialog组件&#xff0c;…...

【数据分析】R版IntelliGenes用于生物标志物发现的可解释机器学习

禁止商业或二改转载&#xff0c;仅供自学使用&#xff0c;侵权必究&#xff0c;如需截取部分内容请后台联系作者! 文章目录 介绍流程步骤1. 输入数据2. 特征选择3. 模型训练4. I-Genes 评分计算5. 输出结果 IntelliGenesR 安装包1. 特征选择2. 模型训练和评估3. I-Genes 评分计…...

C++.OpenGL (14/64)多光源(Multiple Lights)

多光源(Multiple Lights) 多光源渲染技术概览 #mermaid-svg-3L5e5gGn76TNh7Lq {font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}#mermaid-svg-3L5e5gGn76TNh7Lq .error-icon{fill:#552222;}#mermaid-svg-3L5e5gGn76TNh7Lq .erro…...