jarvisteach / appJar

Simple Tkinter GUIs in Python
http://appJar.info
Other
615 stars 68 forks source link

WITH indendation doesn't work with function calls #513

Closed robertmlinden closed 6 years ago

robertmlinden commented 6 years ago

I'm not sure if this is by design, but here's an example of what's breaking.

If I want to split the code for creating a page within a pagedWindow into a separate function, I can't. Here's an example:

with app.pagedWindow(paged_window_title):
        app.create_page(pos)

def create_page(pos, […]):
        with app.page():
                […]

The error I receive is ...line 5257, in stopFrame self._getContainerProperty('type')) Exception: ("Can't stop a FRAME, currently in:", 44)

jarvisteach commented 6 years ago

What you're doing should work - the pagedWindow wouldn't get closed until the function returns.

So there must be something else in your code, that hasn't closed a container properly?

This seems to work fine:

from appJar import gui 

def create_page(pos):
    with app.page(sticky='news', stretch='both'):
        app.label(pos, bg=app.RANDOM_COLOUR())

with gui(font=20) as app:
    with app.pagedWindow('title'):
        for i in range(10):
            create_page(i)
robertmlinden commented 6 years ago

Ok, that's quite odd since when I changed syntax to start/stop it began to work. I'll play around with it more.

jarvisteach commented 6 years ago

Closing this, as don't think it's an issue.