Python Forum

Full Version: Windows 10: AttributeError: 'WM_PenProvider' object has no attribute 'hwnd'
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello, when I execute my kivy program I get the following error message:
Quote:AttributeError: 'WM_PenProvider' object has no attribute 'hwnd'

Small description on how my app works.
My app starts with a login screen which works properly. After I have logged in, my app crashes with the above error message. At first, as usual the build method gets executed after running the run method of my custom app class (i.e. CustomClass().run()). As you can see below I have created two classes LoginScreen and MainScreen which handle different kind of things like displaying a table, statistics etc. Each of these screens are determined by the screen_to_load variable. Every time I switch from one kv file to the other, first I unload the previous one and then load the next one. To switch to the next screen I am executing in the login and logout methods accordingly self.__app.run(), which works on Ubuntu 20.04. LTS but not on my Windows 10 system (as depicted with #---->). I am not quite sure if this methodology is the right one, because by running again the run method of the app it is like initializing the application from the beginning. I have searched for this problem via google, but only 2-4 results where found, which didn't help me. I hope you guys can help me out, because I'm struggling with this issue a week. The wired thing is that on Ubuntu it works properly but on Windows (this is the OS I need to run the app) it doesn't work.

Build method in kivy_app.py
def build(self):
        screen = None

        # Loads the login screen
        if self.screen_to_load == 'login':
            self.theme_cls.theme_style = "Light"
            self.theme_cls.primary_palette = "Indigo"
            
            Builder.unload_file("kv/main_screen.kv")
            Builder.load_file("kv/login_screen.kv")
            screen = LoginScreen(self)

        # Loads the main screen
        elif self.screen_to_load == 'main':            
            # Loads the main screen
            self.theme_cls.primary_palette = "BlueGray"
            Builder.unload_file("kv/login_screen.kv")
            Builder.load_file("kv/main_screen.kv")
            
            self.use_kivy_settings = False
            self.settings_cls = SettingsWithSidebar
            screen = MainScreen(self)
            
        return screen
login_screen.py
class LoginScreen(Screen):
    ...
    def login(self):
        if self.ids.user.text == "user" and self.ids.password.text == "pass":
            self.__app.screen_to_load = 'main'
            self.__app.run() #----> When executing this line, the crash occurs
    ...
main_screen.py
class MainScreen(Screen):
    ...         
    def logout(self):
        self.hide_widgets()
        self.__app.screen_to_load = 'login'
        self.__app.run()
    ...
More error trace would be helpful. Also helpful is making a small example that demonstrates the problem. A small peek into the code with no roadmap for the error is not going to get an replies.