【python】制作一个简单的界面,有手就行的界面~

python窗口界面设计,python界面开发教程 值得注意的是:属性text通常用于实例在第一次呈现时的固定文本,而如果需要在程序执行后发生变化,则可以使用下列方法之一实现:1、用控件实例的configure()方法来改变属性text的值,可使显示的文本发生变化;通常作为功能比较单一的接收单行文本输入的控件,虽然也有许多对其中文本进行操作的方法,但通常用的只有取值方法get()和用于删除文本的delete(起始位置,终止位置),例如:清空输入框为delete(0,END)。关闭窗体程序运行的方法通常用 destory(),而不建议用 quit()。 阅读详情

前言

嗨喽~大家好呀,这里是魔王呐 ❤ ~!

ttkbootstrap 是一个基于 tkinter 的界面美化库,

使用这个工具可以开发出类似前端 bootstrap 风格的 tkinter 桌面程序。

ttkbootstrap 不仅有丰富的案例,同时还有完善的官方文档,可惜是英文的。

不过对于程序员来说,只要用好翻译软件与提供的案例代码,一样可以轻松上手,那么接下来我们就介绍一下这个工具的使用。

准备工作

首先肯定是需要安装一下 ttkbootstrap

版本要新,最好不要用镜像源安装

  • pip install ttkbootstrap

win + R 输入cmd 输入安装命令 或 在pycharm中点击Terminal(终端) 输入安装命令

试手小案例

可以先来个小案例试试手

import ttkbootstrap as ttk
from ttkbootstrap.constants import *

# root = tk.Tk()  # 使用 tkinter 创建窗口对象
root = ttk.Window()  # 使用 ttkbootstrap 创建窗口对象

root.geometry('300x150')

b1 = ttk.Button(root, text="按钮 1", bootstyle=SUCCESS)  # 使用 ttkbootstrap 的组件
b1.pack(side=LEFT, padx=5, pady=10)

b2 = ttk.Button(root, text="按钮 2", bootstyle=(INFO, OUTLINE))   # OUTLINE 是指定边框线
b2.pack(side=LEFT, padx=5, pady=10)

root.mainloop()

开始我们今天的案例教学

1、做个界面

root = tk.Window(themename='litera')
root.geometry('350x500+500+500')
root.title('萌新-注册页面')
root.wm_attributes('-topmost', 1)
root.mainloop()

2、用户注册框

tk.Label(root, width=10).grid()
tk.Label(root, text='用户名:').grid(row=1, column=1, sticky=tk.W, pady=10)
tk.Entry(root, textvariable=username_str_var).grid(row=1, column=2, sticky=tk.W)
tk.Label(root, text='密  码:').grid(row=2, column=1, sticky=tk.W, pady=10)
tk.Entry(root, textvariable=password_str_var).grid(row=2, column=2, sticky=tk.W)

3、性别单选框

# 0 女 1 男 -1 保密
gender_str_var = tk.IntVar()

tk.Label(root, text='性别:').grid(row=4, column=1, sticky=tk.W, pady=10)
radio_frame = tk.Frame()
radio_frame.grid(row=4, column=2, sticky=tk.W)<
如何用python做交互式界面?五分钟教会你。 链接:https://www.zhihu.com/question/60013978/answer/2222608439。商业转载请联系作者获得授权,非商业转载请注明出处。答疑源码分享可关注公众号:Python源码获取。界面中新增了上传头像的按钮。选择一张图片上传之后的效果。作者:python爱好者。界面中新增了注册界面。 阅读详情

相关推荐

Python学习 第五章 图形界面设计

第五章 图形界面设计1 常用的 Python GUI 库1.1 Tkinter1.2 wxPython2 创建Windows窗口3 几何布局管理器3.1 pack几何布局管理器 第一章 函数、模块、包 第二章 数据类型 第三章 控制结构 第四章 面向对象设计 1 常用的 Python GUI 库 1.1 Tkinter Tkinter 模块(TK接口),是 python 的标准 TK GUI 工具包接口。可以在Unix,Windows,Macintosh系统下使用 内置到Python的安装包中,只要安装好p

qq_45256352的博客 3513

Python制作一个简单的GUI-【上篇】

Python做简单GUI1 学习初衷2 配置环境2.1 所用工具说明2.2 配置步骤3 创建一个简单的GUI小程序3.1 写一个简单的小算法(.py文件)3.2 GUI界面的制作3.21 一个简单的GUI3.22 .ui转为.py文件3.23 在pycharm中展示自己创建的GUI界面3.24 建立信号与槽(响应)3.241 建立信号(主窗口程序)3.242 建立槽函数(主函数程序)3.243 ...

qq_40260867的博客 3万+

Python 实现简单的登录注册界面

Python 实现简单的登录注册界面 注意:编写代码之前需要导入很重要的包 import tkinter as tk import pickle from tkinter import messagebox 主要实现的功能 首先在python字典里定义一对值{'admin':'admin'}如果登录成功显示"How are you! admin"。 ...

weixin_34400525的博客 2万+

Python制作登陆界面(1)(超简单)

python制作登陆界面

Ez135的博客 4932

50 行 Python 代码制作一个数据大屏

今天给大家分享一个制作数据大屏的工具,非常的好用,100行左右的Python代码就可以制作出来一个完整的数据大屏,并且代码的逻辑非常容易理解。 PywebIO介绍 Python当中的PywebIO模块可以帮助开发者在不具备HTML和JavaScript的情况下也能够迅速构建Web应用或者是基于浏览器的GUI应用,PywebIO还可以和一些常用的可视化模块联用,制作成一个可视化大屏, 我们先来安装好需要用到的模块 pipinstallpywebio pipinstallcutecharts ...

BYGFJ的博客 2129

如何用Python制作简单又好看的词云?来瞅瞅吧~

一谈到Web页面,可能大家首先想到就是HTML,CSS或JavaScript。 本次小编就给大家介绍一下如何用Python制作一个数据可视化网页,使用到的是Streamlit库。 轻松的将一个Excel数据文件转换为一个Web页面,提供给所有人在线查看。 每当你对Excel文件进行更改保存,Web页面还能够实时进行更新,确实挺不错的。 Streamlit的文档和教程地址如下。 https://docs.streamlit.io/en/stable/ https://streamlit.io/

weixin_56842628的博客 4514

关于Python制作简单的图形界面GUI

#简单的图形界面GUI(Graphical User Interface) from tkinter import * import tkinter.messagebox as messagebox class Application(Frame):   #从Frame派生出Application类,它是所有widget的父容器     def __init__(self,master =

three_co的博客 2万+

【ArcGIS Add-in编程】如何创建ArcMap的下拉菜单插件

step1. VS2010中创建一个空的解决方案step2.创建一个项目 直接点击finish。step3 为该项目创建项目,选择Menu,作为根菜单,而后修改xml中的items项,添加需要放在下拉菜单中的项目,例如一个按钮; step4 现在可以创建项目,作为菜单中的项目。为该项目添加新的项目,选择button 此时 xml文件中,多了该button的项目,将该项目添加到items

吃货小跟班的博客 4431

零基础也能搞定!华为USG6000V防火墙WEB管理界面开启教程

本文详细介绍了华为USG6000V防火墙WEB管理界面的开启教程,从环境准备、网络配置到防火墙初始化,逐步指导用户完成图形化管理界面的搭建。特别适合零基础用户快速掌握企业级防火墙的可视化操作,提升安全管理效率。

grape的博客 788

SAP固定资产原值与净值取值逻辑全解析:从数据表到ABAP实战

在企业资源计划(ERP)系统中,固定资产的价值管理是财务会计的核心模块,其关键在于准确核算资产原值与净值。从技术原理上看,这涉及对资产全生命周期业务(如购置、折旧、转移、报废)的财务建模,以及底层数据表(如ANLC、ANEP)的精准关联与计算。掌握这一逻辑的技术价值在于,能够确保财务报表数据的准确性,满足合规性要求,并为管理决策提供可靠依据。在SAP ECC或S/4HANA系统的应用场景中,ABAP开发者与财务顾问常需通过编写报表程序,从复杂的数据结构中提取资产价值信息。本文聚焦于SAP资产会计模块,深入剖

weixin_30984001的博客 397

基于51单片机+SYN6288语音播报

51单片机控制SYN6288语音播报资料SYN6288模块原理图语音合成命令接线如何接线实现原理程序代码main.csyn6288.cuart.cdelay.c基于 51单片机的其他项目基于51单片机+遥控灯基于51单片机+LCD1602显示基于51单片机+红外遥控解码+LCD1602显示基于51单片机+DHT11温湿度+LCD1602显示基于51单片机+DS18B20温度测温器+LCD1602显示尾声 资料 我用的是绿深电子技术的模块,资料也挺齐全的。也有相关例程。 SYN6288模块原理图 语音合成

weixin_47457689的博客 3万+

三极管自激升压电路设计 - 从参数计算到实践验证

本文详细解析了三极管自激升压电路(焦耳小偷电路)的设计原理与实践方法。通过剖析自激振荡机制与三极管电流关系,指导读者完成从核心参数计算、关键元件选型到面包板搭建调试的全过程。文章重点阐述了如何利用电感、三极管等基础元件实现低压直流到高压的转换,是理解开关电源与电磁能量转换的绝佳实践项目。

weixin_29250573的博客 371

从SRIOV到SIOV:PCIe虚拟化技术下一代革命

如果说SR-IOV是过去十年PCIe虚拟化的“标杆方案”,那SIOV就是为超大规模云数据中心、AI集群量身打造的“破局者”——它解决了SR-IOV难以逾越的扩展性瓶颈,同时平衡了性能、成本与生态兼容性。今天就从“为什么需要SIOV”到“SIOV到底强在哪”,再到“未来要解决什么问题”,做一次全方位深度拆解。

存储随笔 2566

OpenTK简介

OpenTK 因其强大的功能、跨平台特性和灵活性,适用于多种需要图形和计算能力的应用场景,为开发者提供了丰富的可能性和创作空间。

仰望星空的博客 1980

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

上一篇: python带你制作可以随机的自答题程序
下一篇: python基础案例题:进制转换、字符串加密的实现、猜拳游戏、多种方法计算π
魔王不会哭
博客等级 码龄5年 6003粉丝 394原创
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值