当前位置:网站首页>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()
边栏推荐
- JS realizes the effect of text scrolling marquee
- Rhcsa 03 - Basic permissions for documents
- Flink learning 7: application structure
- [microservice openfeign] @feignclient detailed explanation
- (pointer) write a function to compare the size of strings by yourself, which is similar to StrCmp.
- Configuration and hot update of nocturnal simulator in hbuildx
- B. All Distinct
- leetcode刷题:二叉树09(二叉树的最小深度)
- Three years of graduation, half a year of distance | community essay solicitation
- Longest increasing subsequence problem (do you really know it)
猜你喜欢
随机推荐
Configuration and hot update of nocturnal simulator in hbuildx
R语言中如何查看已安装的R包
(pointer) write a function to compare the size of strings by yourself, which is similar to StrCmp.
Why use node
EventBridge 在 SaaS 企业集成领域的探索与实践
十字路口通行优先权,十字路口通行规则图解
Redis:集合Set类型数据的操作命令
Flink learning 8: data consistency
[microservice openfeign] @feignclient detailed explanation
Leetcode skimming: binary tree 07 (maximum depth of binary tree)
沃博联结束战略评估,决定保留表现优异的博姿业务
leetcode刷题:二叉树05(翻转二叉树)
Operation of ES6
网络 - VXLAN
批处理初识
Emlog用户注册插件 价值80元
MIN_RTO 对话
Architecture training graduation design + summary
Three years of graduation, half a year of distance | community essay solicitation
TCP-三次握手和四次挥手简单理解