当前位置:网站首页>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()
边栏推荐
- A beautiful API document generation tool
- leetcode刷题:二叉树04(二叉树的层序遍历)
- Pytest基础自学系列(一)
- Select function variable column name in dplyr of R language
- Leetcode skimming: binary tree 07 (maximum depth of binary tree)
- 2020 Bioinformatics | TransformerCPI
- Restore the subtlety of window position
- Redis:哈希hash类型数据操作命令
- Leetcode skimming: binary tree 04 (sequence traversal of binary tree)
- (指针)编写函数void fun(int x,int *pp,int *n)
猜你喜欢

Main applications of TDK lambda power supply

Wechat brain competition answer applet_ Support the flow main belt with the latest question bank file

MySQL JDBC编程

【愚公系列】2022年7月 Go教学课程 001-Go语言前提简介

I.MX6U-ALPHA开发板(C语言版本LED驱动实验)

Restore the subtlety of window position

资深开发人员告诉你,怎样编写出优秀的代码?

Redis:集合Set类型数据的操作命令

毕业设计项目

How to telecommute more efficiently | community essay solicitation
随机推荐
C language bidirectional linked list first edition
leetcode刷题:二叉树06(对称二叉树)
【云原生】那些看起来很牛X,原理却很简单的一行代码
VIM add interval annotation correctly
Unity draws the trajectory of pinball and billiards
Architecture training graduation design + summary
(pointer) write a function to compare the size of strings by yourself, which is similar to StrCmp.
【微服务|openfeign】@FeignClient详解
[microservice openfeign] @feignclient detailed explanation
The interactive solution of JS and app in the H5 page embedded in app (parameters can be transferred and callbacks can be made)
JS realizes the effect of text scrolling marquee
Distributed system: what, why, how
Imitation of "game bird" source code, mobile game issue evaluation, open service, open test collection, game download website template
Emlog用户注册插件 价值80元
ROS2中CMake编译选项的设置
Redis: hash type data operation command
MySQL JDBC编程
Graduation project
微信脑力比拼答题小程序_支持流量主带最新题库文件
DP83848+网线热拔插