-
-
Notifications
You must be signed in to change notification settings - Fork 473
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
basic PySide2 support in examples/qt.py #438 #490
Merged
+22
−3
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
PYQT4 = False | ||
PYQT5 = False | ||
PYSIDE = False | ||
PYSIDE2 = False | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a new line to the "Tested configurations" section at the top of the file. |
||
if "pyqt4" in sys.argv: | ||
PYQT4 = True | ||
|
@@ -47,11 +48,24 @@ | |
from PySide.QtGui import * | ||
# noinspection PyUnresolvedReferences | ||
from PySide.QtCore import * | ||
elif "pyside2" in sys.argv: | ||
PYSIDE2 = True | ||
# noinspection PyUnresolvedReferences | ||
import PySide2 | ||
# noinspection PyUnresolvedReferences | ||
from PySide2 import QtCore | ||
# noinspection PyUnresolvedReferences | ||
from PySide2.QtGui import * | ||
# noinspection PyUnresolvedReferences | ||
from PySide2.QtCore import * | ||
# noinspection PyUnresolvedReferences | ||
from PySide2.QtWidgets import * | ||
else: | ||
print("USAGE:") | ||
print(" qt.py pyqt4") | ||
print(" qt.py pyqt5") | ||
print(" qt.py pyside") | ||
print(" qt.py pyside2") | ||
sys.exit(1) | ||
|
||
# Fix for PyCharm hints warnings when using static methods | ||
|
@@ -107,6 +121,9 @@ def check_versions(): | |
elif PYSIDE: | ||
print("[qt.py] PySide {v1} (qt {v2})".format( | ||
v1=PySide.__version__, v2=QtCore.__version__)) | ||
elif PYSIDE2: | ||
print("[qt.py] PySide2 {v1} (qt {v2})".format( | ||
v1=PySide2.__version__, v2=QtCore.__version__)) | ||
# CEF Python version requirement | ||
assert cef.__version__ >= "55.4", "CEF Python v55.4+ required to run this" | ||
|
||
|
@@ -126,6 +143,8 @@ def __init__(self): | |
self.setWindowTitle("PyQt5 example") | ||
elif PYSIDE: | ||
self.setWindowTitle("PySide example") | ||
elif PYSIDE2: | ||
self.setWindowTitle("PySide2 example") | ||
self.setFocusPolicy(Qt.StrongFocus) | ||
self.setupLayout() | ||
|
||
|
@@ -147,7 +166,7 @@ def setupLayout(self): | |
frame.setLayout(layout) | ||
self.setCentralWidget(frame) | ||
|
||
if PYQT5 and WINDOWS: | ||
if (PYSIDE2 or PYQT5) and WINDOWS: | ||
# On Windows with PyQt5 main window must be shown first | ||
# before CEF browser is embedded, otherwise window is | ||
# not resized and application hangs during resize. | ||
|
@@ -156,7 +175,7 @@ def setupLayout(self): | |
# Browser can be embedded only after layout was set up | ||
self.cef_widget.embedBrowser() | ||
|
||
if PYQT5 and LINUX: | ||
if (PYSIDE2 or PYQT5) and LINUX: | ||
# On Linux with PyQt5 the QX11EmbedContainer widget is | ||
# no more available. An equivalent in Qt5 is to create | ||
# a hidden window, embed CEF browser in it and then | ||
|
@@ -204,7 +223,7 @@ def focusOutEvent(self, event): | |
self.browser.SetFocus(False) | ||
|
||
def embedBrowser(self): | ||
if PYQT5 and LINUX: | ||
if (PYSIDE2 or PYQT5) and LINUX: | ||
# noinspection PyUnresolvedReferences | ||
self.hidden_window = QWindow() | ||
window_info = cef.WindowInfo() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Navigation bar icons don't work, see screenshot:
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.
I wasn't able to reproduce this - the buttons appear normally and work correctly in:
CentOS7
Ubuntu 18.10
Kubuntu 18.04
macOS High Sierra
I tested with py2 and py3 and pyqt5 and pyside2 on all the above. All the Python and PySide/PyQt stuff was from miniconda.
I also tested with PySide2 from apt on Ubuntu 18.10 with no button issues.
(I did see sporadic #284 type problems on all these platforms).
Can you please tell me more about your environment?