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

国防科技大学计算机基础课程笔记02信息编码

1.机内码和国标码 国标码就是我们非常熟悉的这个GB2312,但是因为都是16进制&#xff0c;因此这个了16进制的数据既可以翻译成为这个机器码&#xff0c;也可以翻译成为这个国标码&#xff0c;所以这个时候很容易会出现这个歧义的情况&#xff1b; 因此&#xff0c;我们的这个国…...

可靠性+灵活性:电力载波技术在楼宇自控中的核心价值

可靠性灵活性&#xff1a;电力载波技术在楼宇自控中的核心价值 在智能楼宇的自动化控制中&#xff0c;电力载波技术&#xff08;PLC&#xff09;凭借其独特的优势&#xff0c;正成为构建高效、稳定、灵活系统的核心解决方案。它利用现有电力线路传输数据&#xff0c;无需额外布…...

工业自动化时代的精准装配革新:迁移科技3D视觉系统如何重塑机器人定位装配

AI3D视觉的工业赋能者 迁移科技成立于2017年&#xff0c;作为行业领先的3D工业相机及视觉系统供应商&#xff0c;累计完成数亿元融资。其核心技术覆盖硬件设计、算法优化及软件集成&#xff0c;通过稳定、易用、高回报的AI3D视觉系统&#xff0c;为汽车、新能源、金属制造等行…...

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别

OpenPrompt 和直接对提示词的嵌入向量进行训练有什么区别 直接训练提示词嵌入向量的核心区别 您提到的代码: prompt_embedding = initial_embedding.clone().requires_grad_(True) optimizer = torch.optim.Adam([prompt_embedding...

Unsafe Fileupload篇补充-木马的详细教程与木马分享(中国蚁剑方式)

在之前的皮卡丘靶场第九期Unsafe Fileupload篇中我们学习了木马的原理并且学了一个简单的木马文件 本期内容是为了更好的为大家解释木马&#xff08;服务器方面的&#xff09;的原理&#xff0c;连接&#xff0c;以及各种木马及连接工具的分享 文件木马&#xff1a;https://w…...

Java求职者面试指南:Spring、Spring Boot、MyBatis框架与计算机基础问题解析

Java求职者面试指南&#xff1a;Spring、Spring Boot、MyBatis框架与计算机基础问题解析 一、第一轮提问&#xff08;基础概念问题&#xff09; 1. 请解释Spring框架的核心容器是什么&#xff1f;它在Spring中起到什么作用&#xff1f; Spring框架的核心容器是IoC容器&#…...

使用Spring AI和MCP协议构建图片搜索服务

目录 使用Spring AI和MCP协议构建图片搜索服务 引言 技术栈概览 项目架构设计 架构图 服务端开发 1. 创建Spring Boot项目 2. 实现图片搜索工具 3. 配置传输模式 Stdio模式&#xff08;本地调用&#xff09; SSE模式&#xff08;远程调用&#xff09; 4. 注册工具提…...

DeepSeek源码深度解析 × 华为仓颉语言编程精粹——从MoE架构到全场景开发生态

前言 在人工智能技术飞速发展的今天&#xff0c;深度学习与大模型技术已成为推动行业变革的核心驱动力&#xff0c;而高效、灵活的开发工具与编程语言则为技术创新提供了重要支撑。本书以两大前沿技术领域为核心&#xff0c;系统性地呈现了两部深度技术著作的精华&#xff1a;…...

ubuntu系统文件误删(/lib/x86_64-linux-gnu/libc.so.6)修复方案 [成功解决]

报错信息&#xff1a;libc.so.6: cannot open shared object file: No such file or directory&#xff1a; #ls, ln, sudo...命令都不能用 error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory重启后报错信息&…...

Axure 下拉框联动

实现选省、选完省之后选对应省份下的市区...