百度360必应搜狗淘宝本站头条
当前位置:网站首页 > IT知识 > 正文

ttkbootstrap 设计师 强大升级,带来更多控件和创意自由!

liuian 2024-12-11 15:44 44 浏览

1.引言:

在之前文章中介绍到ttkbootstrap:

https://mp.weixin.qq.com/s/zXJ3neKA7OTCUI4afao22w

现ttkbootstrap 设计师升级到v2.8.6引入了更多标准控件,如按钮、输入框、下拉菜单等。这些控件不仅拥有简洁而现代的外观,而且还具备高度可定制性。设计师可以根据自己的风格和需求,轻松调整控件的样式、尺寸和布局,从而实现独特的设计效果。

除了新增的控件,ttkbootstrap 设计师升级还为设计师提供了更多的控件属性和方法。这些属性和方法使得设计师能够更精细地控制控件的外观和行为。例如,设计师可以通过属性来设置按钮的颜色、背景图像和边框样式,以及通过方法来监听按钮的点击事件和执行自定义动作。这些功能为设计师提供了更大的创意自由度和交互性。

2. 支持的控件

1.目前支持的控件看下图示例:

2. 所有这些控件都是通过ttkbootstrap 设计师拖拉设计属性所得,比如下面设计按钮控件:


3. 注册界面例子

通过ttkbootstrap 设计师 制作一个注册界面只需要几分钟时间


以下是生成的tkkbootstrap代码:

import tkinter as tk
import ttkbootstrap as ttk
from PIL import ImageTk, Image
from ttkbootstrap.constants import *
from ttkbootstrap.dialogs import Messagebox as msgbox


root = ttk.Window(themename="litera", title="注册", size=(340, 402), hdpi=False, resizable=(False, False) )
root.place_window_center()
style = ttk.Style()
style.configure("TRadiobutton", font=("Segoe UI" , 12))
radiobutton2 = ttk.Radiobutton(text="女", value=2, bootstyle="primary")
radiobutton_checkedIndex = ttk.IntVar()
radiobutton2.configure(variable=radiobutton_checkedIndex)
radiobutton2.place(relx=191/340, rely=187/402, width=50, height=21)
static5 = ttk.Label(text="用户性别:", font=("Segoe UI" , 12), foreground="#000000", anchor=tk.E, bootstyle="primary")
static5.place(relx=20/340, rely=188/402, width=84, height=30)
static3 = ttk.Label(text="确认密码:", font=("Segoe UI" , 12), foreground="#000000", anchor=tk.E, bootstyle="primary")
static3.place(relx=20/340, rely=106/402, width=84, height=30)
static = ttk.Label(text="用户名称:", font=("Segoe UI" , 12), foreground="#000000", anchor=tk.E, bootstyle="primary")
static.place(relx=20/340, rely=23/402, width=84, height=30)
static2 = ttk.Label(text="用户密码:", font=("Segoe UI" , 12), foreground="#000000", anchor=tk.E, bootstyle="primary")
static2.place(relx=20/340, rely=64/402, width=84, height=30)
style.configure("TRadiobutton", font=("Segoe UI" , 12))
radiobutton1 = ttk.Radiobutton(text="男", value=1, bootstyle="primary")
radiobutton_checkedIndex.set(1)
radiobutton1.configure(variable=radiobutton_checkedIndex)
radiobutton1.place(relx=123/340, rely=187/402, width=50, height=21)
static6 = ttk.Label(text="出生日期:", font=("Segoe UI" , 12), foreground="#000000", anchor=tk.E, bootstyle="primary")
static6.place(relx=20/340, rely=230/402, width=84, height=30)
style.configure("TCheckbutton", font=("Segoe UI" , 12))
checkbox2 = ttk.Checkbutton(text="运动", bootstyle="primary")
checkbox2.checked = ttk.BooleanVar(value=False)
checkbox2.configure(variable=checkbox2.checked)
checkbox2.place(relx=188/340, rely=271/402, width=71, height=23)
edit3 = ttk.Entry(font=("Segoe UI" , 9), bootstyle="primary")
edit3.place(relx=114/340, rely=101/402, width=178, height=26)
edit3.configure(foreground="#000000")
combobox = ttk.Combobox(values=["普通用户","vip用户","管理员"],font=("Segoe UI" , 9), foreground="#000000", bootstyle="primary")
combobox.place(relx=114/340, rely=140/402, width=178, height=23)
combobox.current(0)
style.configure("TButton", font=("Segoe UI" , 12))
button = ttk.Button(text="提交", takefocus=False, bootstyle="success")
button.place(relx=130/340, rely=329/402, width=86, height=47)
style.configure("TCheckbutton", font=("Segoe UI" , 12))
checkbox1 = ttk.Checkbutton(text="阅读", bootstyle="primary")
checkbox1.checked = ttk.BooleanVar(value=False)
checkbox1.configure(variable=checkbox1.checked)
checkbox1.place(relx=115/340, rely=271/402, width=71, height=23)
static8 = ttk.Label(text="兴趣爱好:", font=("Segoe UI" , 12), foreground="#000000", anchor=tk.E, bootstyle="primary")
static8.place(relx=20/340, rely=271/402, width=84, height=30)
static4 = ttk.Label(text="用户类型:", font=("Segoe UI" , 12), foreground="#000000", anchor=tk.E, bootstyle="primary")
static4.place(relx=20/340, rely=147/402, width=84, height=30)
datetimepick = ttk.DateEntry(bootstyle="warning")
datetimepick.place(relx=114/340, rely=224/402, width=178, height=26)
style.configure("TCheckbutton", font=("Segoe UI" , 12))
checkbox3 = ttk.Checkbutton(text="音乐", bootstyle="primary")
checkbox3.checked = ttk.BooleanVar(value=False)
checkbox3.configure(variable=checkbox3.checked)
checkbox3.place(relx=261/340, rely=271/402, width=71, height=23)
edit = ttk.Entry(font=("Segoe UI" , 9), bootstyle="primary")
edit.place(relx=114/340, rely=23/402, width=178, height=26)
edit.configure(foreground="#000000")
edit2 = ttk.Entry(font=("Segoe UI" , 9), bootstyle="primary")
edit2.place(relx=114/340, rely=62/402, width=178, height=26)
edit2.configure(foreground="#000000")


def button_onClick(event):
  msgbox.show_info(datetimepick.entry.get())




button.bind("<Button-1>", button_onClick)
root.mainloop()

4. 完善的文档和教程

ttkbootstrap 官方网站有完善的api文档,而ttkbootstrap设计师本人正在写文档和视频教程,可到下面QQ群里下载体验和获取教程:

ttkbootstrap 设计师QQ群: 438272872

QQ:45561810

相关推荐

GCI: Another key public good for international community

MembersofadelegationofhighschoolstudentsfromtheU.S.stateofWashingtonposeforaphotoa...

kube on kube 实现思路分享(kube-scheduler)

这里的kubeonkube,是指建立K8s元集群,纳管其他业务K8s集群,通过声明式API管理集群的创建、增删节点等。参考https://github.com/kubean-i...

China and India hold the key to a more inclusive global future

ByMayaMajueranLead:AsChinaandIndiamark75yearsofdiplomaticties,theircooperationcouldse...

日本真子公主的婚礼又要提上日程了吗?未婚夫:债务问题已解决

日本明仁天皇将于今年3月31日退位,德仁皇太子即将成为新一任的天皇。在平成时代最后的倒计时中,明仁天皇的孙女真子公主的婚事却又一次进入了人们的视野。(viaTheTelegraph)关注日本皇室的...

kratos源码分析系列(1)(kvm源码解析与应用 pdf)

https://github.com/go-kratos/kratos是b站开源的一个微服务框架,整体来看它结合grpc生态中的grpc-gateway,以及wire依赖注入和众多常用的trace,m...

【2.C#基础】6.循环语句(c#循环语句例子)

6.循环语句当需要多次执行同一个处理时,就需要用到循环语句。一般情况下,循环的流程图如下:6.1while循环C#中的while循环语句在给定的条件为真的情况下会重复执行目标语句。格式如下:...

使用 Google Wire 在 Go 中进行依赖注入

关注点分离、松耦合系统和依赖反转原则等概念在软件工程中是众所周知的,并且在创建良好的计算机程序过程中至关重要。在本文中,我们将讨论一个同时应用了这三个原则的技术,称为依赖注入。我们将尽可能地实践,更加...

用 Golang封装你的API(golang封装dll)
用 Golang封装你的API(golang封装dll)

每日分享最新,最流行的软件开发知识与最新行业趋势,希望大家能够一键三连,多多支持,跪求关注,点赞,留言。@头条创作挑战赛本文探讨了在用Golang封装你的API的过程以及几个不同的编程步骤。我做了一个非常有限的时间来证明如何为客户正在开...

2025-05-09 20:03 liuian

Terraform 实战 | 万字长文(terrify是什么意思中文)

Terraform是什么Terraform(https://www.terraform.io/)是HashiCorp旗下的一款开源(Go语言开发)的DevOps基础架构资源管理运维工具,可...

Go 语言入门:环境安装(go语言安装 window)

一、前言这里不同于其他人的Go语言入门,环境安装我向来注重配置,比如依赖包、缓存的默认目录。因为前期不弄好,后面要整理又影响这影响那的,所以就干脆写成文章,方便后期捡起。二、安装1.安装包htt...

Go语言进阶之Go语言高性能Web框架Iris项目实战-项目结构优化EP05

前文再续,上一回我们完成了用户管理模块的CURD(增删改查)功能,功能层面,无甚大观,但有一个结构性的缺陷显而易见,那就是项目结构过度耦合,项目的耦合性(Coupling),也叫耦合度,进而言之,模块...

如何将Go项目与Docker结合实现高效部署

在现代软件开发中,使用Docker部署应用程序已经成为一种标准实践。本文将深入探讨如何将Go项目与Docker结合,实现高效、可靠的部署过程。通过详细的步骤和丰富的示例,你将能够迅速掌握这一流程。准备...

五分钟轻松熟悉一个k8s Operator应用制作

简介:operator是一种kubernetes的扩展形式,可以帮助用户以Kubernetes的声明式API风格自定义来管理应用及服务,operator已经成为分布式应用在k8s集群部...

程序员的副业秘籍!一款可以快速搭建各类系统的后台管理系统

系统简介这是一个基于Gin+Vue+ElementUI(或ArcoDesign、AntDesign)的系统快速开发平台,采用了前后端分离,旨在帮助用户快速完成各类系统的基础功能搭建。平...

使用 Go 语言开发区块链钱包的项目目录结构设计

在开发区块链钱包时,项目的目录结构应该清晰、模块化,确保代码的可维护性和扩展性。基于Go的惯例,结合区块链钱包的功能需求,以下是一个较为合理的目录结构示例:1.目录结构blockchain-wa...