在 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 = "oops",
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='Test popup',
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中更改弹出颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!