Skip to content

Commit

Permalink
fix bugs with pyexists and qt path (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
jjstickel authored May 31, 2024
1 parent fe588f4 commit 476e896
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/init.jl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ function find_backend(matplotlib::Py)
return (gui2matplotlib[gui], gui)
end
catch e
@warn(e) # provide information for debugging why a gui was not found
if !isjulia_display[]
@warn("No working GUI backend found for matplotlib")
isjulia_display[] = true
Expand Down
8 changes: 6 additions & 2 deletions src/pygui.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
# global variable to specify default GUI toolkit to use
gui = :default # one of :default, :wx, :qt, :tk, or :gtk

pyexists(mod::AbstractString) = pyconvert(Bool, pyimport("importlib").util.find_spec(mod) != Py(nothing))
# for some reason, `util` is not always imported as an attribute to `importlib`:
#PythonCall.PyException(<py AttributeError("module 'importlib' has no attribute 'util'")>)
pyexists(mod::AbstractString) = pyconvert(Bool, pyimport("importlib.util").find_spec(mod) != Py(nothing))

pygui_works(gui::Symbol) = gui == :default ||
((gui == :wx && pyexists("wx")) ||
Expand Down Expand Up @@ -130,7 +132,9 @@ end

# Qt: (PyQt5, PyQt4, or PySide module)
function qt_eventloop(QtCore::Py, sec::Real=50e-3)
fixqtpath()
# `fixqtpath()` seems to not be working,
# https://github.com/JuliaPy/PythonPlot.jl/issues/17
#fixqtpath()
instance = QtCore.QCoreApplication.instance
AllEvents = QtCore.QEventLoop.AllEvents
processEvents = QtCore.QCoreApplication.processEvents
Expand Down

0 comments on commit 476e896

Please sign in to comment.