How to change popup color in kivy(如何在kivy中更改弹出颜色)
问题描述
在 Kivy 中,Popup 显示为灰色,应该更改什么使其变为红色
In Kivy, Popup appears in grey color, what should be changed to make it red color
我的弹出代码:
class MyPopup(Popup):
def show_popup(self):
content = BoxLayout(orientation="vertical")
content.add_widget(Label(text="Game Over", font_size=20))
mybutton_cancel = Button(text="Cancel", size_hint_y=None)
content.add_widget(mybutton_cancel)
mypopup = Popup(content = content,
title = "b29wcw==",
auto_dismiss = False,
size_hint = (.5, .5))
mybutton_cancel.bind(on_release=mypopup.dismiss)
mypopup.open()
我希望,很明显我在谈论弹出颜色,而不是弹出窗口或弹出文本颜色后面的背景屏幕颜色.我说的是弹出矩形的颜色.请指教.
I hope , it is clear that i am talking about popup color and not color of background screen behind popup or popup text color. I am talking about the color of popup rectangle. Please advice.
推荐答案
Popup
作为 ModalView
的子项,有一个名为 StringProperty
的 >background
,它指向来自 atlas 的图像.默认的是 atlas://data/images/defaulttheme/modalview-background
.在这里,我将其更改为默认按钮图像之一:
Popup
as a child of ModalView
has a StringProperty
called background
, which points to an image from at atlas. The default one is atlas://data/images/defaulttheme/modalview-background
. Here I changed it to one of the default button images:
from kivy.app import App
from kivy.uix.button import Button
from kivy.uix.popup import Popup
from kivy.uix.label import Label
class TestApp(App):
def build(self):
return Button(text="show", on_press=self.anim_btn)
def anim_btn(self, *args):
popup = Popup(title="VGVzdCBwb3B1cA==",
content=Label(text='Hello world'),
size_hint=(None, None),
size=(400, 400),
background = 'atlas://data/images/defaulttheme/button_pressed'
).open()
if __name__ == "__main__":
TestApp().run()
此默认主题位于此处:https://github.com/kivy/kivy/blob/master/kivy/data/images/defaulttheme-0.png 为了自定义您的弹出窗口(以及例如按钮),您可以创建自己的图集(http://kivy.org/docs/api-kivy.atlas.html).
This default theme resides here: https://github.com/kivy/kivy/blob/master/kivy/data/images/defaulttheme-0.png In order to customize your popup (and also, for example, buttons) you can create your own atlas (http://kivy.org/docs/api-kivy.atlas.html).
这篇关于如何在kivy中更改弹出颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在kivy中更改弹出颜色


- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01