KIVY Button¶

news2024/9/21 11:12:13

Button — Kivy 2.3.0 documentation

Button¶

Jump to API ⇓


Module: kivy.uix.button

Added in 1.0.0

_images/button.jpg

The Button is a Label with associated actions that are triggered when the button is pressed (or released after a click/touch). To configure the button, the same properties (padding, font_size, etc) and sizing system are used as for the Label class:
按钮(Button)是一个带有相关动作的标签(Label),这些动作在按钮被按下(或点击/触摸后释放)时触发。为了配置按钮,我们使用了与标签(Label)类相同的属性(如内边距padding、字体大小font_size等)和尺寸系统。

button = Button(text='Hello world', font_size=14)

To attach a callback when the button is pressed (clicked/touched), use bind:
当按钮被按下(点击/触摸)时,要附加一个回调函数,可以使用bind方法。

def callback(instance):
    print('The button <%s> is being pressed' % instance.text)

btn1 = Button(text='Hello world 1')
btn1.bind(on_press=callback)
btn2 = Button(text='Hello world 2')
btn2.bind(on_press=callback)

If you want to be notified every time the button state changes, you can bind to the Button.state property:
如果你想要在每次按钮状态发生变化时都收到通知,你可以将事件绑定到Button.state属性上:

def callback(instance, value):
    print('My button <%s> state is <%s>' % (instance, value))
btn1 = Button(text='Hello world 1')
btn1.bind(state=callback)

Kv Example:

Button:
    text: 'press me'
    on_press: print("ouch! More gently please")
    on_release: print("ahhh")
    on_state:
        print("my current state is {}".format(self.state))

APIHide Description ⇑


class kivy.uix.button.Button(**kwargs

Bases: kivy.uix.behaviors.button.ButtonBehavior, kivy.uix.label.Label

Button class, see module documentation for more information.

Changed in version 1.8.0: The behavior / logic of the button has been moved to ButtonBehaviors.

background_color¶

Background color, in the format (r, g, b, a).  背景颜色,格式为(r, g, b, a)。

This acts as a multiplier to the texture color. The default texture is grey, so just setting the background color will give a darker result. To set a plain color, set the background_normal to ''.
它作为纹理颜色的一个乘数因子。默认纹理是灰色的,所以仅仅设置背景颜色会得到一个更暗的结果。要设置纯色,请将background_normal属性设置为空字符串('')。

New in version 1.0.8.  此功能在版本1.0.8中新增。

The background_color is a ColorProperty and defaults to [1, 1, 1, 1].
background_color是一个ColorProperty,其默认值为[1, 1, 1, 1](即白色,完全不透明)。

Changed in version 2.0.0: Changed from ListProperty to ColorProperty.
在版本2.0.0中更改:从ListProperty更改为ColorProperty。

background_disabled_down¶

Background image of the button used for the default graphical representation when the button is disabled and pressed.

New in version 1.8.0.

background_disabled_down is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/button_disabled_pressed’.

background_disabled_normal¶

Background image of the button used for the default graphical representation when the button is disabled and not pressed.
按钮的背景图像,用于在按钮被禁用且被按下时的默认图形表示。

New in version 1.8.0.   此功能在版本1.8.0中新增。

background_disabled_normal is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/button_disabled’.

background_down¶

Background image of the button used for the default graphical representation when the button is pressed.

按钮的背景图像,用于按钮被按下时的默认图形表示。

New in version 1.0.4.  此功能在版本1.0.4中新增。

background_down is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/button_pressed’.
background_disabled_down是一个StringProperty,其默认值为'atlas://data/images/defaulttheme/button_disabled_pressed'

background_normal¶

Background image of the button used for the default graphical representation when the button is not pressed.
按钮的背景图像,用于按钮未被按下时的默认图形表示。

New in version 1.0.4.   此功能在版本1.0.4中新增。

background_normal is a StringProperty and defaults to ‘atlas://data/images/defaulttheme/button’.
background_normal是一个StringProperty,其默认值为  'atlas://data/images/defaulttheme/button'

border¶

Border used for BorderImage graphics instruction. Used with background_normal and background_down. Can be used for custom backgrounds.
边框,用于BorderImage图形指令。与background_normalbackground_down一起使用。可用于自定义背景。

It must be a list of four values: (bottom, right, top, left). Read the BorderImage instruction for more information about how to use it.
它必须是一个包含四个值的列表:(底部, 右侧, 顶部, 左侧)。要获取更多关于如何使用它的信息,请阅读BorderImage指令的说明。

border is a ListProperty and defaults to (16, 16, 16, 16)
border是一个ListProperty,其默认值为(16, 16, 16, 16)。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1911534.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

c++入门基础篇(上)

目录 前言&#xff1a; 1.c&#xff0b;&#xff0b;的第一个程序 2.命名空间 2.1 namespace的定义 2.2 命名空间使用 3.c&#xff0b;&#xff0b;输入&输出 4.缺省参数 5.函数重载 前言&#xff1a; 我们在之前学完了c语言的大部分语法知识&#xff0c;是不是意…

GraphRAG——一个基于图的检索增强生成的开源项目【送源码】

GraphRAG 最近几天&#xff0c;微软团队开源了GraphRAG&#xff0c;这是一种基于图&#xff08;Graph&#xff09;的检索增强生成方法。 先说说RAG吧&#xff0c;检索增强生成&#xff0c;相当于是从一个给定好的知识库中进行检索&#xff0c;接入LLM模型&#xff0c;让模型生…

数据结构——顺序表【C】

顺序表 1. 顺序表的概念以及结构1.1概念1.2静态顺序表和动态顺序表 2. 顺序表接口模拟实现接口总览2.1 初始化数据和销毁容器 2.2 顺序表的尾插和尾删2.3 头插和头删2.4 任意位置插入和删除数据2.5 查找数据 3. 顺序表的问题 &#xff1a; 1. 顺序表的概念以及结构 1.1概念 顺…

无缝协作:如何实现VMware与Ubuntu虚拟机的剪切板共享!

文章目录 📖 介绍 📖🏡 演示环境 🏡📒 剪贴板共享 📒📝 VMware设置📝 安装VMware Tools或open-vm-tools📝 验证剪贴板共享功能⚓️ 相关链接 🚓️📖 介绍 📖 无缝的剪贴板共享是提高工作效率的关键。在VMware和Ubuntu虚拟机的协同工作中,能够直接在宿…

【鸿蒙学习笔记】属性学习迭代笔记

这里写目录标题 TextImageColumnRow Text Entry Component struct PracExample {build() {Row() {Text(文本描述).fontSize(40)// 字体大小.fontWeight(FontWeight.Bold)// 加粗.fontColor(Color.Blue)// 字体颜色.backgroundColor(Color.Red)// 背景颜色.width(50%)// 组件宽…

arp缓存中毒实验

文章目录 一、相关知识1.什么是arp&#xff08;地址解析协议&#xff09;2.什么是免费arp&#xff08;1&#xff09;简介&#xff08;2&#xff09;主要应用&#xff08;3&#xff09;代码 3.什么是arp缓存中毒&#xff08;1&#xff09;简介&#xff08;2&#xff09;过程&…

ubuntu使用kubeadm搭建k8s集群

一、卸载k8s kubeadm reset -f modprobe -r ipip lsmod rm -rf ~/.kube/ rm -rf /etc/kubernetes/ rm -rf /etc/systemd/system/kubelet.service.d rm -rf /etc/systemd/system/kubelet.service rm -rf /usr/bin/kube* rm -rf /etc/cni rm -rf /opt/cni rm -rf /var/lib/etcd …

第5章-组合序列类型

#全部是重点知识&#xff0c;必须会。 了解序列和索引|的相关概念 掌握序列的相关操作 掌握列表的相关操作 掌握元组的相关操作 掌握字典的相关操作 掌握集合的相关操作1&#xff0c;序列和索引 1&#xff0c;序列是一个用于存储多个值的连续空间&#xff0c;每一个值都对应一…

python实现建议股票计算器

name 无忧传播 stock_price 19.99 stock_code "003032" stock_rise 1.2 day 7print(f"公司&#xff1a;{name},代码&#xff1a;{stock_code},当前股价&#xff1a;{stock_price}")print("增长系数是&#xff1a;%f&#xff0c;经过%d天后&am…

Git本地仓库的搭建与使用

目录 一、前言 二、Linux下搭建 git 仓库 三、Windows下搭建 git 仓库 一、前言 做项目时&#xff0c;我们常常需要将自己的代码进行托管&#xff0c;但有时候 Github 的速度属实叫人流泪。有的人会选择 Gitee 等进行托管代码&#xff0c;这当然是可以的。那如果没有其他代码…

【VUE基础】VUE3第一节—vite创建vue3工程

什么是VUE Vue (发音为 /vjuː/&#xff0c;类似 view) 是一款用于构建用户界面的 JavaScript 框架。它基于标准 HTML、CSS 和 JavaScript 构建&#xff0c;并提供了一套声明式的、组件化的编程模型&#xff0c;帮助你高效地开发用户界面。无论是简单还是复杂的界面&#xff0…

藏汉翻译通作为翻译软件的优势有哪些?

藏汉翻译通作为一款专业的藏汉双语翻译软件&#xff0c;具有以下优势&#xff1a; 人工智能技术应用&#xff1a;藏汉翻译通利用了人工智能翻译和语音识别合成技术&#xff0c;提供智能藏文翻译服务。 高准确率&#xff1a;文字识别准确率可达90%&#xff0c;语音识别转化文字…

IDEA新建项目并撰写Java代码的方法

本文介绍在IntelliJ IDEA软件中&#xff0c;新建项目或打开已有项目&#xff0c;并撰写Java代码的具体方法&#xff1b;Groovy等语言的代码也可以基于这种方法来撰写。 在之前的文章IntelliJ IDEA社区版在Windows电脑中的下载、安装方法&#xff08;https://blog.csdn.net/zheb…

Echarts水球图(liquidFill)添加文字

效果 代码 {type: liquidFill,shape: shapes[0].value,radius: 90%,data: [{name: 独立百货,value: 0}],center: [50%, 50%],color: [{type: linear,x: 0,y: 0,x2: 0,y2: 1,colorStops: [{offset: 0,color: #446bf5},{offset: 1,color: #2ca3e2}],globalCoord: false}],backgro…

混合贪心算法求解地铁线路调度

一、问题描述 城市轨道交通的繁荣发展&#xff0c;带来了车辆资源需求的日益增加。如何兼顾运营服务水平和运营成本&#xff0c;以最少的车底优质地完成运输任务成为一大严峻问题。本题在后续的描述中将由多辆动车和拖车组合而成的车组称为车底。在日常的运营组织中&#xff0…

算力狂飙|WAIC 2024上的服务器

7月7日&#xff0c;2024世界人工智能大会暨人工智能全球治理高级别会议&#xff08;WAIC 2024&#xff09;在上海落下帷幕。这场备受瞩目的AI盛宴与热辣夏日碰撞&#xff0c;吸引了全球科技、产业及学术界的广泛关注&#xff0c;线下参观人数突破30万人次&#xff0c;线上流量突…

DOM(文档对象模型)生命周期事件

前言 DOM 生命周期事件涉及到从创建、更新到销毁 DOM 元素的不同阶段。 ● 我们来看下当HTML文档加载完再执行JavaScript代码 document.addEventListener(DOMContentLoaded, function (e) {console.log(HTML parsed adn DOM tree built!, e); })● 除此之外&#xff0c;浏览…

Linux | 安装lb-toolkits 1.2.4库

Linux | 安装 lb-toolkits 最近又需要下载葵花的数据&#xff0c;之前分享过一次代码。今天发现之前的环境不小心被我删了&#xff0c;而运行相关的代码需要安装lb-toolkits这个库&#xff0c;今天正好记录了一下安装lb-toolkits的过程。 这里安装的版本是1.2.4&#xff0c;别…

【前端从入门到精通:第十二课: JS运算符及分支结构】

JavaScript运算符 算数运算符 关于自增自减运算 自增或者自减运算就是在本身的基础上进行1或者-1的操作 自增或者自减运算符可以在变量前也可以在变量后&#xff0c;但是意义不同 自增自减运算符如果在变量前&#xff0c;是先进行自增或者自减运算&#xff0c;在将变量给别人用…

基于springboot+vue实现的厨艺交流平台(文末源码+Lw)093

93基于SpringBootVue的实现的厨艺交流平台&#xff08;源码数据库万字Lun文流程图ER图结构图演示视频软件包&#xff09; 系统功能&#xff1a; 这次开发的厨艺交流平台功能有个人中心&#xff0c;食材分类管理&#xff0c;用户管理&#xff0c;菜品分类管理&#xff0c;菜谱信…