2

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.

Bianca
  • 21
  • 2
  • **Oh, Gods.** I too just stumbled headlong into this nonsensical UIX wall. In my case, I merely imported `from kivymd.uix.toolbar import MDTopAppBar` as the very first statement of a new IPython3 session – only to be assaulted by a contentless popup window. At least this explains why the KivyMD app I'm building out starts up with... *a contentless popup window.* You actually need to defer your first import from either the `kivymd` or `kivy` packages until immediately before instantiating your main `MDApp` subclass. So infuriating, honestly. `` – Cecil Curry May 19 '22 at 04:55

1 Answers1

1

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.

inclement
  • 29,124
  • 4
  • 48
  • 60
  • **Please for the love of StackOverflow fix this** if you are a Kivy dev with repository push permissions. This abhorrent behaviour absolutely *does* matter. The UIX community already perceives Kivy as harmful. I disagreed with that consensus until I actually built a Kivy app. Now, I reluctantly agree. Backward compatibility is no excuse for preserving broken functionality. It's broken. It needs to be fixed. Full-stop. – Cecil Curry May 19 '22 at 04:48