Application spawning parent tk window even though layout has a top level.
When running the application, a smaller tk parent window is created.
Steps to reproduce the behavior:
- Start new project
- Save the layout
- Run app loading layout
- See the error
It is not using the parent object, which is set, but instead spawning a new tk parent and shouldn't be.
- OS: Windows
-
formationVersion 0.6.1 - Python version: 3.11.0
- tk version: 8.6
app.py
from formation import AppBuilder
app = AppBuilder(path="test.xml")
app.mainloop()
test.xml
<?xml version='1.0' encoding='utf-8'?>
<tkinter.Toplevel xmlns:attr="http://www.hoversetformationstudio.com/styles/" xmlns:layout="http://www.hoversetformationstudio.com/layouts/" name="toplevel_1" attr:layout="place" layout:width="1170" layout:height="858" layout:x="30" layout:y="30"><meth name="title"><arg value="title" /></meth><meth name="geometry"><arg value="1170x825+0+0" /></meth><meta major="6" minor="1" name="version" /></tkinter.Toplevel>
I noticed the last PR states there are fixes to top level. I tried installing both for PyPI and directly from GH, but the issue seems present for me in both.
For the time being, just grabby the child Destroy and killing the app after a withdraw on the root. Probably not the best way to do this.
from formation import AppBuilder
import tkinter as tk
import sys
# TODO Remove this one the bug is fixed in the library
def kill_app(*args):
sys.exit()
root = tk.Tk()
root.withdraw()
app = AppBuilder(app=root, path="layout.xml")
app.connect_callbacks(globals())
app.mainloop()
and <event sequence="<Destroy>" handler="kill_app" add="True" />
@seth-c-stenzel Normally if you use Toplevel as your root widget tkinter spawns a Tk widget to act as the default root. To solve this make sure your root widget is a Tk object not a Toplevel. Your test.xml should be
<?xml version='1.0' encoding='utf-8'?>
<tkinter.Tk xmlns:attr="http://www.hoversetformationstudio.com/styles/" xmlns:layout="http://www.hoversetformationstudio.com/layouts/" name="toplevel_1" attr:layout="place" layout:width="1170" layout:height="858" layout:x="30" layout:y="30"><meth name="title"><arg value="title" /></meth><meth name="geometry"><arg value="1170x825+0+0" /></meth><meta major="6" minor="1" name="version" /></tkinter.Tk>
In the designer, you can delete your root widget which is probably a Toplevel object and then instead drag a Tk object to the designer.