Skip to content

Commit

Permalink
PR: Restore QtWidgets.QFileDialog.Options access as `QtWidgets.QFil…
Browse files Browse the repository at this point in the history
…eDialog.Option` alias (PyQt6) (#448)
  • Loading branch information
ccordoba12 authored Aug 21, 2023
2 parents bada0d7 + 545d193 commit a5044f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions qtpy/QtWidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ def _directory_to_dir_(*args, **kwargs):
QMenu.exec_ = lambda *args, **kwargs: possibly_static_exec(QMenu, *args, **kwargs)
QLineEdit.getTextMargins = lambda self: (self.textMargins().left(), self.textMargins().top(), self.textMargins().right(), self.textMargins().bottom())

# Map missing flags definitions
QFileDialog.Options = QFileDialog.Option

# Allow unscoped access for enums inside the QtWidgets module
from .enums_compat import promote_enums
promote_enums(QtWidgets)
Expand Down
11 changes: 9 additions & 2 deletions qtpy/tests/test_qtwidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_opengl_imports():
reason="Crashes on macOS with Python 3.7 with 'Illegal instruction: 4'")
@pytest.mark.parametrize("keyword", ["dir", "directory"])
@pytest.mark.parametrize("instance", [True, False])
def test_qfiledialog_compat(tmp_path, qtbot, keyword, instance):
def test_qfiledialog_dir_compat(tmp_path, qtbot, keyword, instance):
"""
This function is testing if the decorators that renamed the dir/directory
keyword are working.
Expand Down Expand Up @@ -229,4 +229,11 @@ def run(self, allow_restart=True):
qtbot.waitUntil(thr.isRunning, timeout=1000)
dlg = QtWidgets.QFileDialog() if instance else QtWidgets.QFileDialog
dlg.getExistingDirectory(**kwargs)
qtbot.waitUntil(thr.isFinished, timeout=3000)
qtbot.waitUntil(thr.isFinished, timeout=3000)


def test_qfiledialog_flags_typedef():
"""
Test existence of `QFlags<Option>` typedef `Options` that was removed from PyQt6
"""
assert QtWidgets.QFileDialog.Options is not None

0 comments on commit a5044f2

Please sign in to comment.