KivyMD icon indicating copy to clipboard operation
KivyMD copied to clipboard

MDDialog with custom bg color disappears when using @mainthread

Open cdavidson-project-canary opened this issue 4 months ago • 1 comments

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

  • OS: Windows 11 Enterprise
  • Python: 3.10.11
  • Kivy: 2.3.0
  • KivyMD: 2.0.1.dev0