当前位置: 首页 > 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通了:...

生成xcframework

打包 XCFramework 的方法 XCFramework 是苹果推出的一种多平台二进制分发格式&#xff0c;可以包含多个架构和平台的代码。打包 XCFramework 通常用于分发库或框架。 使用 Xcode 命令行工具打包 通过 xcodebuild 命令可以打包 XCFramework。确保项目已经配置好需要支持的平台…...

进程地址空间(比特课总结)

一、进程地址空间 1. 环境变量 1 &#xff09;⽤户级环境变量与系统级环境变量 全局属性&#xff1a;环境变量具有全局属性&#xff0c;会被⼦进程继承。例如当bash启动⼦进程时&#xff0c;环 境变量会⾃动传递给⼦进程。 本地变量限制&#xff1a;本地变量只在当前进程(ba…...

【OSG学习笔记】Day 18: 碰撞检测与物理交互

物理引擎&#xff08;Physics Engine&#xff09; 物理引擎 是一种通过计算机模拟物理规律&#xff08;如力学、碰撞、重力、流体动力学等&#xff09;的软件工具或库。 它的核心目标是在虚拟环境中逼真地模拟物体的运动和交互&#xff0c;广泛应用于 游戏开发、动画制作、虚…...

从WWDC看苹果产品发展的规律

WWDC 是苹果公司一年一度面向全球开发者的盛会&#xff0c;其主题演讲展现了苹果在产品设计、技术路线、用户体验和生态系统构建上的核心理念与演进脉络。我们借助 ChatGPT Deep Research 工具&#xff0c;对过去十年 WWDC 主题演讲内容进行了系统化分析&#xff0c;形成了这份…...

页面渲染流程与性能优化

页面渲染流程与性能优化详解&#xff08;完整版&#xff09; 一、现代浏览器渲染流程&#xff08;详细说明&#xff09; 1. 构建DOM树 浏览器接收到HTML文档后&#xff0c;会逐步解析并构建DOM&#xff08;Document Object Model&#xff09;树。具体过程如下&#xff1a; (…...

MODBUS TCP转CANopen 技术赋能高效协同作业

在现代工业自动化领域&#xff0c;MODBUS TCP和CANopen两种通讯协议因其稳定性和高效性被广泛应用于各种设备和系统中。而随着科技的不断进步&#xff0c;这两种通讯协议也正在被逐步融合&#xff0c;形成了一种新型的通讯方式——开疆智能MODBUS TCP转CANopen网关KJ-TCPC-CANP…...

《基于Apache Flink的流处理》笔记

思维导图 1-3 章 4-7章 8-11 章 参考资料 源码&#xff1a; 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…...

Spring数据访问模块设计

前面我们已经完成了IoC和web模块的设计&#xff0c;聪明的码友立马就知道了&#xff0c;该到数据访问模块了&#xff0c;要不就这俩玩个6啊&#xff0c;查库势在必行&#xff0c;至此&#xff0c;它来了。 一、核心设计理念 1、痛点在哪 应用离不开数据&#xff08;数据库、No…...

C# 求圆面积的程序(Program to find area of a circle)

给定半径r&#xff0c;求圆的面积。圆的面积应精确到小数点后5位。 例子&#xff1a; 输入&#xff1a;r 5 输出&#xff1a;78.53982 解释&#xff1a;由于面积 PI * r * r 3.14159265358979323846 * 5 * 5 78.53982&#xff0c;因为我们只保留小数点后 5 位数字。 输…...

SiFli 52把Imagie图片,Font字体资源放在指定位置,编译成指定img.bin和font.bin的问题

分区配置 (ptab.json) img 属性介绍&#xff1a; img 属性指定分区存放的 image 名称&#xff0c;指定的 image 名称必须是当前工程生成的 binary 。 如果 binary 有多个文件&#xff0c;则以 proj_name:binary_name 格式指定文件名&#xff0c; proj_name 为工程 名&…...