-
Notifications
You must be signed in to change notification settings - Fork 187
Support closing the first (root) window in Tk #591
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
Conversation
src/gui.jl
Outdated
| _tkinter = pyimport("_tkinter") | ||
| end | ||
| flag = _tkinter[:ALL_EVENTS] | _tkinter[:DONT_WAIT] | ||
| root = Tk["_default_root"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just root = PyObject(nothing) since it will get updated in the event loop anyway.
| end | ||
| if root.o != pynothing[] | ||
| pycall(root["update"], PyObject) | ||
| while pycall(root["dooneevent"], Bool, flag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that the correct spelling?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see, it's "do one event"
Note: _tkinter is available both in Python 3 and 2. * https://docs.python.org/3/library/tkinter.html#tkinter-modules * https://docs.python.org/2/library/tkinter.html#tkinter-modules * https://github.com/ipython/ipython/blob/5.8.0/IPython/terminal/pt_inputhooks/tk.py#L45
|
OK. Applied the fix. |
|
Why the change from |
|
Right, I should have left comments. Calling julia> using PyCall, PyPlot
julia> figure(1)
plot([1,2,3])
figure(2)
plot([1,2,3])
root = pyimport("tkinter")["_default_root"]
close(1)
julia> pycall(root["update"], PyObject)
ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/takafumi/.julia/dev/PyCall/src/pyfncall.jl:44 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class '_tkinter.TclError'>
TclError('can\'t invoke "update" command: application has been destroyed')
File "/usr/lib64/python3.7/tkinter/__init__.py", line 1174, in update
self.tk.call('update')I used It seems that So I guess that's why it works even after the |
Maybe fix JuliaPy/PyPlot.jl#316