New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GoogleMap fails when nested in new window #228

Closed
gh0st42 opened this Issue Aug 25, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@gh0st42

gh0st42 commented Aug 25, 2017

I tried to implement a subwindow that displays a map with some markers. My platform is Ubuntu 16.04, python 2.7 and appJar installed via pip (0.07)

The following code will trigger the error:

from appJar import gui

def showGmap(btn):
    app = gui()
    app.addGoogleMap("m1")
    app.setGoogleMapSize("m1", "300x500")    
    app.go()

g = gui()
g.addButton("Map", showGmap)
g.go()

This will produce an error:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1540, in __call__
    return self.func(*args)
  File "/home/user/.local/lib/python2.7/site-packages/appJar/appjar.py", line 2724, in <lambda>
    return lambda: funcName(param)
  File "mapfail.py", line 6, in showGmap
    app.addGoogleMap("m1")
  File "/home/user/.local/lib/python2.7/site-packages/appJar/appjar.py", line 4404, in addGoogleMap
    gMap = GoogleMap(self.getContainer())
  File "/home/user/.local/lib/python2.7/site-packages/appJar/appjar.py", line 10617, in __init__
    self.image_on_canvas = self.canvas.create_image(1, 1, image=imgObj, anchor=NW)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2318, in create_image
    return self._create('image', args, kw)
  File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 2309, in _create
    *(args + self._options(cnf, kw))))
TclError: image "pyimage1" doesn't exist

@gh0st42 gh0st42 changed the title from GoogleMap fails when nested in subwindow to GoogleMap fails when nested in new window Aug 25, 2017

@gh0st42

This comment has been minimized.

Show comment
Hide comment
@gh0st42

gh0st42 Aug 25, 2017

When using startSubwindow() this does not happen which is probably the correct way to implement a subwindow. But the bug still hints at something not encapsulated correctly in the appJar instance object.

gh0st42 commented Aug 25, 2017

When using startSubwindow() this does not happen which is probably the correct way to implement a subwindow. But the bug still hints at something not encapsulated correctly in the appJar instance object.

@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Aug 25, 2017

Owner

Hi @gh0st42 - the initial problem is definitely caused by creating two instances of gui() - they will each create an instance of Tk() which breaks things like vars & images.

In this case an image (pyimage1) has been created, but it exists in the first Tk (don't know why or how, this is a tkinter thing) - so tkinter can't find it in the new instance of Tk

There's nothing I can do to fix this. However, you're not the first person to attempt to create multiple windows by making multiple instances of gui(). So, I will investigate how to prevent people form instantiating more than one gui object at a time, and try to make the documentation more obvious.

Owner

jarvisteach commented Aug 25, 2017

Hi @gh0st42 - the initial problem is definitely caused by creating two instances of gui() - they will each create an instance of Tk() which breaks things like vars & images.

In this case an image (pyimage1) has been created, but it exists in the first Tk (don't know why or how, this is a tkinter thing) - so tkinter can't find it in the new instance of Tk

There's nothing I can do to fix this. However, you're not the first person to attempt to create multiple windows by making multiple instances of gui(). So, I will investigate how to prevent people form instantiating more than one gui object at a time, and try to make the documentation more obvious.

jarvisteach added a commit that referenced this issue Aug 25, 2017

Added singleton style attribute #228
appJar attempts to prevent more than one instance of gui being created.

Also, tidied up comments #127

jarvisteach added a commit that referenced this issue Aug 26, 2017

@jarvisteach jarvisteach added this to the 0.08 milestone Aug 26, 2017

jarvisteach added a commit that referenced this issue Aug 26, 2017

Updated docs for SubWindows #228
Moved SubWindows docs to their own page: MultipleWindows
@jarvisteach

This comment has been minimized.

Show comment
Hide comment
@jarvisteach

jarvisteach Aug 26, 2017

Owner

Hopefully this won't catch people out anymore :)

Owner

jarvisteach commented Aug 26, 2017

Hopefully this won't catch people out anymore :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment