当前位置:网站首页>Kivy教程之 更改背景颜色(教程含源码)
Kivy教程之 更改背景颜色(教程含源码)
2022-07-04 03:53:00 【知识大胖】
我们将调整窗口背景颜色。窗口背景(OpenGL 渲染器的“清晰颜色”)是全局Window对象的属性。为了更改它,我们在以下__name__ == 'main’行之后添加此代码main.py:
from kivy.core.window import Window
from kivy.utils import get_color_from_hex
Window.clearcolor = get_color_from_hex('#101216')
实战代码
import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.core.window import Window
from kivy.utils import get_color_from_hex
#Window.clearcolor = [1, 1, 1, 1]
Window.clearcolor = get_color_from_hex("#ffffff")
kvcode = """
#:import C kivy.utils.get_color_from_hex
<[email protected]>:
size_hint: .2, .3
canvas.before:
Color:
rgba: C("#22FFAA")
Rectangle:
pos: self.pos
size: self.size
FloatLayout:
FVerde:
pos_hint:{"x":.4, "y":.4}
"""
class JanelaApp(App):
def build(self):
return Builder.load_string(kvcode)
janela = JanelaApp()
janela.run()
边栏推荐
- [microservices openfeign] two degradation methods of feign | fallback | fallbackfactory
- Emlog user registration plug-in is worth 80 yuan
- Rhcsa 04 - process management
- What does software testing do? Find defects and improve the quality of software
- Emlog用户注册插件 价值80元
- leetcode刷题:二叉树05(翻转二叉树)
- RHCSA 01 - 创建分区与文件系统
- Redis: hash type data operation command
- Redis:有序集合zset类型数据操作命令
- 十字路口通行优先权,十字路口通行规则图解
猜你喜欢
Main applications of TDK lambda power supply
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
What does software testing do? Find defects and improve the quality of software
【微信小程序】好看的轮播图组件
Leetcode skimming: binary tree 07 (maximum depth of binary tree)
Redis:有序集合zset类型数据操作命令
Instructions for LPC interrupt binding under ft2000+
TCP-三次握手和四次挥手简单理解
Unity draws the trajectory of pinball and billiards
戳气球和布尔运算问题(巨难)
随机推荐
C语言双向链表初版
Why use node
Balloon punching and Boolean operation problems (extremely difficult)
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
一位毕业生的自我分享
Exercises in quantum mechanics
博朗与Virgil Abloh于2021年为纪念博朗品牌100周年而联合打造的“功能性艺术”将在博物馆展出Abloh作品期间首次亮相
Emlog user registration plug-in is worth 80 yuan
西部数据绿盘、蓝盘、黑盘、红盘和紫盘有什么区别
两万字带你掌握多线程
Configuration and hot update of nocturnal simulator in hbuildx
leetcode 121 Best Time to Buy and Sell Stock 买卖股票的最佳时机(简单)
领导:谁再用redis过期监听实现关闭订单,立马滚蛋!
普源DS1000Z系列数字示波器在通信原理实验中的应用方案
Leetcode brush questions: binary tree 05 (flip binary tree)
Common methods of threads
统计遗传学:第三章,群体遗传
How to add custom API objects in kubernetes (1)
软件测试是干什么的 发现缺陷错误,提高软件的质量
Leetcode skimming: binary tree 07 (maximum depth of binary tree)