kivymd / KivyMD

KivyMD is a collection of Material Design compliant widgets for use with Kivy, a framework for cross-platform, touch-enabled graphical applications. https://youtube.com/c/KivyMD https://twitter.com/KivyMD https://habr.com/ru/users/kivymd https://stackoverflow.com/tags/kivymd
https://kivymd.readthedocs.io
MIT License
2.26k stars 674 forks source link

MDDialog with custom bg color disappears when using @mainthread #1681

Open cdavidson-project-canary opened 7 months ago

cdavidson-project-canary commented 7 months ago

Description of the Bug

When utilizing the @mainthread decorator to open a MDDialog with a custom background color, the dialog background will go transparent when mousing over and then mousing off the dialog without clicking anything.

I found a way to workaround this by overriding the set_properties_widget() method in my custom dialog class that inherits from MDDialog. This overridden method is defined in kivymd/uix/behaviors/state_layer_behavior.py.

Note: the example below is simplified - in my usage a separate thread is invoking the open_dialog_in_mainthread() method.

Code and Logs


from kivy.clock import mainthread

from kivymd.app import MDApp
from kivymd.uix.dialog import MDDialog
from kivymd.uix.screen import MDScreen

class TestApp(MDApp):

    def build(self):
        screen = MDScreen()
        self.dialog = MDDialog(theme_bg_color="Custom", md_bg_color="yellow")
        self.open_dialog_in_mainthread()
        return screen
    #

    #@mainthread
    def open_dialog_in_mainthread(self):
        self.dialog.open()
    #
#

app = TestApp()
app.run()

Versions

HeaTTheatR commented 7 months ago

This is fixed in my local repository