KIVY Button¶

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.mfbz.cn/a/787714.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

HTML【详解】表格 table 标签(table的属性,语义化表格,简易表格,合并单元格)

html 中的表格 <table> 由行 <tr> 组成&#xff0c;每行由单元格 <td> 组成。 所以表格是由行组成&#xff08;行由列组成&#xff09;&#xff0c;而不是由行和列组成。 table 标签 display: table &#xff0c;属于块级元素。 table 的属性 border&#…

基于Java+SpringMvc+Vue技术的智慧校园系统设计与实现

博主介绍&#xff1a;硕士研究生&#xff0c;专注于信息化技术领域开发与管理&#xff0c;会使用java、标准c/c等开发语言&#xff0c;以及毕业项目实战✌ 从事基于java BS架构、CS架构、c/c 编程工作近16年&#xff0c;拥有近12年的管理工作经验&#xff0c;拥有较丰富的技术架…

5G(NR) NTN 卫星组网架构

5G(NR) NTN 卫星组网架构 参考 3GPP TR 38.821 5G NTN 技术适用于高轨、低轨等多种星座部署场景&#xff0c;是实现星地网络融合发展的可行技术路线。5G NTN 网络分为用户段、空间段和地面段三部分。其中用户段由各种用户终端组成&#xff0c;包括手持、便携站、嵌入式终端、车…

uniapp内置组件uni.navigateTo跳转后页面空白问题解决

文章目录 导文空白问题 导文 在h5上跳转正常 但是在小程序里面跳转有问题 无任何报错 页面跳转地址显示正确&#xff0c;但页面内容为空 空白问题 控制台&#xff1a; 问题解决&#xff1a; 方法1&#xff1a; 可能是没有注册的问题&#xff0c;把没注册的页面 注册一下。 方…

互助学习平台小程序的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;学生管理&#xff0c;课程信息管理&#xff0c;课程分类管理&#xff0c;课程评价管理&#xff0c;学习计划管理&#xff0c;留言板管理 微信端账号功能包括&#xff1a;系统首页&#xff0c;课程信息…

离线运行Llama3:本地部署终极指南_liama2 本地部署

4月18日&#xff0c;Meta在官方博客官宣了Llama3&#xff0c;标志着人工智能领域迈向了一个重要的飞跃。经过笔者的个人体验&#xff0c;Llama3 8B效果已经超越GPT-3.5&#xff0c;最为重要的是&#xff0c;Llama3是开源的&#xff0c;我们可以自己部署&#xff01; 本文和大家…

智能眼镜火热发展 AI+AR或将成为主流趋势?

日前&#xff0c;The Verge 发布消息称&#xff0c;AI 智能音频眼镜 Ray-Ban Meta 的销量可能已突破 100 万。Meta 在博客中也指出&#xff0c;Ray-Ban Meta 取得了超预期的市场表现&#xff0c;眼镜的销售速度比生产速度还要快&#xff0c;目前团队正着手于推出更多新款式。Ra…

产品推荐| 立錡低耗电器件:线性稳压器、Buck 和 Boost 转换器

想让电池用得更久、利用好它的每一份电力&#xff1f;低静态电流的电源转换器是你的必然选择。立錡深谙电源管理之道&#xff0c;为你备好了低耗电的各种产品&#xff0c;其中包括低压差线性稳压器、Buck 转换器和 Boost 转换器&#xff0c;最低消耗仅有 360nA&#xff0c;是无…

Linux多进程和多线程(八)多线程

多线程 线程定义线程与进程线程资源 线程相关命令 pidstat 命令 top 命令ps 命令常见的并发方案 1. 多进程模式2. 多线程模式 创建线程 1. pthread_create() 示例:创建一个线程 2. pthread_exit() 退出线程3. pthread_join() 等待线程结束 示例: 线程分离 创建多个线程 示例 1:…

构造二进制字符串

目录 LeetCode3221 生成不含相邻零的二进制字符串 #include <iostream> #include <vector> using namespace std;void dfs(string s,int n,vector<string>& res){if(s.size()n){res.push_back(s);return;}dfs(s"0",n,res);dfs(s"1"…

Invoice OCR

Invoice OCR 发票识别 其他类型ORC&#xff1a; DIPS_YTPC OCR-CSDN博客

前端面试题31(TCP与UDP区别)

TCP (Transmission Control Protocol) 和 UDP (User Datagram Protocol) 是两种在网络通信中常用的传输层协议&#xff0c;它们在多个方面存在显著差异&#xff0c;主要体现在以下几个方面&#xff1a; 连接方式&#xff1a; TCP 是面向连接的协议。在数据传输开始之前&#xf…

怎么将图片旋转30度?旋转图片的几种方法推荐

怎么将图片旋转30度&#xff1f;在创作过程中&#xff0c;我们常常需要处理图片的镜像效果&#xff0c;确保其视觉效果和构图都达到最佳状态。镜像效果的合理运用不仅可以解决视觉单调的问题&#xff0c;还能在艺术作品中吸引观者的注意力。此外&#xff0c;镜像可以有效地调整…

【LeetCode刷题笔记】LeetCode.11.盛最多水的容器

创作不易&#xff0c;本篇文章如果帮助到了你&#xff0c;还请点赞 关注支持一下♡>&#x16966;<)!! 主页专栏有更多知识&#xff0c;如有疑问欢迎大家指正讨论&#xff0c;共同进步&#xff01; 更多算法知识专栏&#xff1a;算法分析&#x1f525; 给大家跳段街舞感谢…

JavaScript 作用域 与 var、let、const关键字

目录 一、JavaScript 作用域 1、全局作用域 2、函数作用域 3、块级作用域 4、综合示例 5、总结 二、var、let、const 1、var 关键字 2、let 关键字 3、const 关键字 4、总结 5、使用场景 一、JavaScript 作用域 在JavaScript中&#xff0c;作用域是指程序中可访问…

【堆 (优先队列) 扫描线】218. 天际线问题

本文涉及知识点 堆 &#xff08;优先队列) 扫描线 LeetCode218. 天际线问题 城市的 天际线 是从远处观看该城市中所有建筑物形成的轮廓的外部轮廓。给你所有建筑物的位置和高度&#xff0c;请返回 由这些建筑物形成的 天际线 。 每个建筑物的几何信息由数组 buildings 表示&…

面经-计算机网络-数据结构-堆

1.什么是堆 堆是一种满足以下条件的树&#xff1a; 堆中的每一个节点值都大于等于&#xff08;或小于等于&#xff09;子树中所有节点的值。或者说&#xff0c;任意一个节点的值都大于等于&#xff08;或小于等于&#xff09;所有子节点的值。 2.堆的用途 当我们只关心所有数…

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

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

python破解密码·筛查和选择

破解密码时可能遇到的几种情况 ① 已知密码字符&#xff0c;破排序 ② 已知密码位数&#xff0c;破字符 ③ 已知密码类型&#xff0c;破字位 ④ 已知部分密码&#xff0c;破未知 ⑤ 啥都不知道&#xff0c;盲破&#xff0c;玩完 ⑥ 已知位数、字符、类型、部分密码中的几个&am…

python-23-零基础自学python open()和replace()函数运用

学习内容&#xff1a;《python编程&#xff1a;从入门到实践》第二版练习10-2 知识点&#xff1a; 打开文件&#xff0c;replace()替换文件内容&#xff0c;open(), 练习内容&#xff1a; 练习10-2:C语言学习笔记 可使用方法replace()将字符串中的特定单词都替换为另一个单…