Gui object has no attribute 'repack'
BrokenSwing opened this issue · comments
Hello, I'm having troubles running an example.
I use :
- glooey 0.1.2
- pyglet 1.3.2
- python 3.6.4
Here's the code causing a crash :
import pyglet
import glooey
def main():
window = pyglet.window.Window(visible=False)
window.set_size(500, 500)
# Initialize window
gui = glooey.Gui(window)
placeholder = glooey.Placeholder()
gui.add(placeholder)
window.set_visible()
pyglet.app.run()
if __name__ == '__main__':
main()
And here's the crash I got :
File "D:/Documents/Python/TileMapper/tilemapper/__main__.py", line 86, in <module>
main()
File "D:/Documents/Python/TileMapper/tilemapper/__main__.py", line 82, in main
pyglet.app.run()
File "D:\Programs\Python\3.6.4\lib\site-packages\pyglet\app\__init__.py", line 138, in run
event_loop.run()
File "D:\Programs\Python\3.6.4\lib\site-packages\pyglet\app\base.py", line 131, in run
self._legacy_setup()
File "D:\Programs\Python\3.6.4\lib\site-packages\pyglet\app\base.py", line 220, in _legacy_setup
window.dispatch_pending_events()
File "D:\Programs\Python\3.6.4\lib\site-packages\pyglet\window\win32\__init__.py", line 631, in dispatch_pending_events
event[0](*event[1:])
File "D:\Programs\Python\3.6.4\lib\site-packages\pyglet\window\win32\__init__.py", line 976, in _event_size
self.dispatch_event('on_resize', self._width, self._height)
File "D:\Programs\Python\3.6.4\lib\site-packages\pyglet\window\__init__.py", line 1232, in dispatch_event
if EventDispatcher.dispatch_event(self, *args) != False:
File "D:\Programs\Python\3.6.4\lib\site-packages\pyglet\event.py", line 357, in dispatch_event
if handler(*args):
File "D:\Programs\Python\3.6.4\lib\site-packages\glooey\root.py", line 118, in on_resize
self.repack()
AttributeError: 'Gui' object has no attribute 'repack'
It seems to come from the window.set_size(500, 500)
because when I delete it, it doesn't crash anymore. Seems to be pretty related to #17 . Thank you for reading
I think the problem is that I haven't made a new release since #17, so the version of glooey on PyPI still has that bug. That's my bad, I kept wanting to get in a few more features before making a release.
I just made a 0.2.0
release now, so pip install --upgrade glooey
should fix the problem. Of course, it might cause other problems, like #29, but I'll try to fix that ASAP.
Ok, it's not crashing anymore with the 0.2.0, but I don't know if it's an expected behavior but the placeholder doesn't fit the window size. With the same code I gave previously I get this :
And if I try to resize the placeholder or the Gui with set_size_hint
, it crashes with an RuntimeError : RuntimeError: Gui(id=14b0) is only 640x480, but its children are 500x500.
Maybe I didn't understand the purpose of this method, if so, I'm sorry.
gui = glooey.Gui(window)
gui.set_size_hint(500, 500)
placeholder = glooey.Placeholder()
placeholder.set_size_hint(500, 500)
gui.add(placeholder)
Can you post the full script you're using? The following seems to work for me, with or without either set_size_hint()
line:
#!/usr/bin/env python3
import pyglet
import glooey
def main():
window = pyglet.window.Window(visible=False)
window.set_size(500, 500)
# Initialize window
gui = glooey.Gui(window)
gui.set_size_hint(500, 500)
placeholder = glooey.Placeholder()
placeholder.set_size_hint(490, 490)
gui.add(placeholder)
window.set_visible()
pyglet.app.run()
if __name__ == '__main__':
main()
Also, you should upgrade to 0.2.1
now; there was a bug in the 0.2.0
release (not related to this, though).