Search code examples
python-3.xpycharmkivysublimetext3

Why does a borderless Kivy Window shift content down and to the right?


Using Kivy, I want to remove the default border from the App window (removing the close, minimize and maximize buttons). Based on the Kivy docs, I want to set the borderless value of my Window to True. However, doing so moves the content of my window down and to the right, exposing the black background color on the top and left sides of the window.

Screenshot of Window with borderless=False

Screenshot of Window with borderless=True

In the above images, the white within the window is coming from the Window.clearcolor, and the black in the borderless=True image is what I want to remove, or overlay with the rest of my content.

In the following snippet I have removed all the code that makes up the inner widgets of the kivy App, replacing them with an empty GridLayout to show where the content will be.

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.core.window import Window

class MyApp(App):
    def build(self):
        self.title = 'My App'
        Window.clearcolor = (1, 1, 1, 1)
        Window.size = (300, 430)
        Window.borderless = True # This is what is being changed
        return GridLayout()

if __name__ == '__main__':
    MyApp().run()

I have read the answers to similar questions regarding removing the default Kivy window border and how to position a borderless Kivy window.

Can anyone help diagnose how to shift the contents of my window back to the upper left corner when borderless is set to True?

Note: This is my first Stackoverflow question, please let me know how to improve it if need be!


Solution

  • Well, I'm not sure what the exact issue was, but after troubleshooting several different things within PyCharm (where my original project files were held), on a whim I tried opening the same project with Sublime and the issue is no longer present. When I run the identical code in Sublime, I get the intended result:

    enter image description here

    Beautiful! Just how I wanted it. =) I'm sure I somehow goofed up the Kivy settings in Pycharm somehow without realizing it, maybe something with the builder strings? I'm honestly at a loss. But I suppose if by any off chance someone else comes across this, switch up your IDE for a clean slate and give it another go.