如何更改kivy中的弹出颜色

How to change popup color in kivy

在Kivy中,Popup显示为灰色,需要修改什么使其变成红色

我的弹窗代码:

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()

我希望很明显,我说的是弹出窗口颜色,而不是弹出窗口后面的背景屏幕颜色或弹出文本颜色。我说的是弹出矩形的颜色。请指教

Popup 因为 ModalView 的 child 有一个 StringProperty 称为 background,它指向来自 atlas 的图像。默认值为 atlas://data/images/defaulttheme/modalview-background。在这里,我将其更改为默认按钮图像之一:

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 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)。