如何在猕猴桃中删除弹出标题

Tak*_*sui 1 python kivy

我一直在想是否有办法删除弹出窗口的标题栏:

由此

对此

提前致谢!

编辑:代码参考以供将来使用:

<MyPopup@Popup>:
size_hint: None, None
size: 300, 200
title: 'Close'
title_color: 0.7, 0, 0, 0.9
separator_color: 0.4, 0.4, 0.4, 1
title_align: 'center'
BoxLayout:
    orientation: 'vertical'
    padding: 5, 5, 5, 5
    cols: 2
    Label:
        color: 0.7, 0, 0, 0.9
        center_x: root.center_x
        center_y: root.center_y
        text: 'Are you sure you want to exit?'
    BoxLayout:
        size_hint: 1, 0.6
        Button:
            color: 0.7, 0, 0, 0.9
            background_color: 0.4, 0.4, 0.4, 0.05
            text: 'Yes'
            on_release: exit()
        Button:
            color: 0.7, 0, 0, 0.9
            background_color: 0.4, 0.4, 0.4, 0.05
            text: 'No'
            on_release: root.dismiss()
Run Code Online (Sandbox Code Playgroud)

FJS*_*lla 6

您只需将title属性设置为""并将separator_height属性设置为0

例子:

from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.popup import Popup
from kivy.lang import Builder


Builder.load_string("""

<NoTitleDialog>:
    title: ""                 # <<<<<<<<
    separator_height: 0       # <<<<<<<<
    size_hint: None, None
    size: 400, 200

    BoxLayout:
        orientation: "vertical"
        Label:
            text: "Are you sure you want to exit?"
        BoxLayout: 
            size_hint_y: 0.3   
            Button:
                text: "Yes"
            Button:
                text: "No"

""")


class MainWindow(BoxLayout):
    def __init__(self, **kwargs):
        super(MainWindow, self).__init__(**kwargs)
        self.dialog = NoTitleDialog()
        self.dialog.open()


class NoTitleDialog(Popup):
    pass


class Example(App):
    def build(self):
        return MainWindow()

if __name__ == '__main__':
    Example().run()
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述


inc*_*ent 5

请改用ModalView。这是弹出式行为的基类,弹出式是带有标题的ModalView。