Skip to content
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

fix bugs with pyexists and qt path #34

Merged
merged 1 commit into from
May 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is it not working, or not necessary? What is the downside of keeping this function call (which may still be needed on some systems)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It somehow breaks the Qt5 backend for me, and apparently others as described in #17 . It isn't necessary for me; I don't even need to set QT_PLUGIN_PATH. After spending a few hours debugging the first problem, I didn't take time to investigate what is going here with qt path.

instance = QtCore.QCoreApplication.instance
AllEvents = QtCore.QEventLoop.AllEvents
processEvents = QtCore.QCoreApplication.processEvents
Expand Down
Loading