Bianca
Bianca

Reputation: 21

When importing a kivymd module in a python script, a blank window appears

This is the offending python script, stored in file.py:

from kivymd.uix.tab import MDTabsBase

That's it. Nothing else.

When I run it using this command:

python file.py

A blank window opens shortly, then disappears.

I've read the kivymd.uix.tab source file, called tab.py, and can't see any code that's run outside of class definitions.

The version of kivymd I'm using is from the github master branch downloaded a few days ago.

I don't see why this blank window should even appear before I called App().run().

I'd appreciate your help.

Upvotes: 2

Views: 166

Answers (1)

inclement
inclement

Reputation: 29488

Kivy automatically creates a Window when you import kivy.core.window. This is an old design mistake that's never been fixed because it mostly doesn't matter and would break a lot of apps that happen to rely on it, although we've talked about how to correct it recently.

So, this is probably what kivymd is ultimately importing, and there may be no simple way around it.

One workaround that might work, depending on what you need, would be to build kivy headless so that it doesn't make a window. That would mean your script could never make a window though.

Upvotes: 1

Related Questions