From 8dcfb1c3d237e97bacff963d155a504904b5e905 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 10 Mar 2023 13:33:48 -0500 Subject: [PATCH 1/2] protect against Tk not having `_default_root` attr --- .gitignore | 2 ++ src/pygui.jl | 14 ++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0e8c587 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Manifest.toml +.CondaPkg diff --git a/src/pygui.jl b/src/pygui.jl index b719d45..2ef88d3 100644 --- a/src/pygui.jl +++ b/src/pygui.jl @@ -191,12 +191,14 @@ function Tk_eventloop(sec::Real=50e-3) flag = _tkinter.ALL_EVENTS | _tkinter.DONT_WAIT root = pynothing = Py(nothing) install_doevent(sec) do async - new_root = Tk._default_root - if pyconvert(Bool, new_root != pynothing) - root = new_root - end - if pyconvert(Bool, root != pynothing) - while pyconvert(Bool, root.dooneevent(flag)) + if pyhasattr(Tk, "_default_root") + new_root = Tk._default_root + if pyconvert(Bool, new_root != pynothing) + root = new_root + end + if pyconvert(Bool, root != pynothing) + while pyconvert(Bool, root.dooneevent(flag)) + end end end end From e1c8ba8c4331973735c1c5d4a21359c020f22b91 Mon Sep 17 00:00:00 2001 From: Ian Date: Fri, 10 Mar 2023 15:11:18 -0500 Subject: [PATCH 2/2] debug --- src/pygui.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pygui.jl b/src/pygui.jl index 2ef88d3..2776c86 100644 --- a/src/pygui.jl +++ b/src/pygui.jl @@ -191,6 +191,7 @@ function Tk_eventloop(sec::Real=50e-3) flag = _tkinter.ALL_EVENTS | _tkinter.DONT_WAIT root = pynothing = Py(nothing) install_doevent(sec) do async + @show typeof(Tk) if pyhasattr(Tk, "_default_root") new_root = Tk._default_root if pyconvert(Bool, new_root != pynothing)