Skip to content

Commit

Permalink
Update to pyqt6
Browse files Browse the repository at this point in the history
Allows getting rid of some 6 pylint warnings.
  • Loading branch information
vmiklos committed Mar 22, 2024
1 parent 7bc6996 commit 0efd85e
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ min-public-methods=0
max-attributes=14

[MASTER]
extension-pkg-whitelist=PyQt5
extension-pkg-whitelist=PyQt6
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ check: check-mypy check-flake8 check-pylint check-unit
@echo "make check: ok"

check-mypy: $(PYTHON_OBJECTS) Makefile requirements.txt
env PYTHONPATH=.:tests mypy --python-version 3.8 --strict --no-error-summary $(PYTHON_OBJECTS) && touch $@
env PYTHONPATH=.:tests mypy --python-version 3.11 --strict --no-error-summary $(PYTHON_OBJECTS) && touch $@

check-flake8: $(patsubst %.py,%.flake8,$(PYTHON_OBJECTS))

Expand Down
60 changes: 25 additions & 35 deletions qged2dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,27 @@

"""Qt-based GUI for ged2dot."""

from typing import cast
import io
import os
import sys
import traceback
import webbrowser

from PyQt5 import QtGui
from PyQt5.QtCore import pyqtBoundSignal
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QCheckBox
from PyQt5.QtWidgets import QComboBox
from PyQt5.QtWidgets import QDialogButtonBox
from PyQt5.QtWidgets import QFileDialog
from PyQt5.QtWidgets import QGridLayout
from PyQt5.QtWidgets import QLabel
from PyQt5.QtWidgets import QLineEdit
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtWidgets import QPushButton
from PyQt5.QtWidgets import QSpinBox
from PyQt5.QtWidgets import QStatusBar
from PyQt5.QtWidgets import QVBoxLayout
from PyQt5.QtWidgets import QWidget
from PyQt6 import QtGui
from PyQt6.QtWidgets import QApplication
from PyQt6.QtWidgets import QCheckBox
from PyQt6.QtWidgets import QComboBox
from PyQt6.QtWidgets import QDialogButtonBox
from PyQt6.QtWidgets import QFileDialog
from PyQt6.QtWidgets import QGridLayout
from PyQt6.QtWidgets import QLabel
from PyQt6.QtWidgets import QLineEdit
from PyQt6.QtWidgets import QMessageBox
from PyQt6.QtWidgets import QPushButton
from PyQt6.QtWidgets import QSpinBox
from PyQt6.QtWidgets import QStatusBar
from PyQt6.QtWidgets import QVBoxLayout
from PyQt6.QtWidgets import QWidget
import pygraphviz # type: ignore

import ged2dot
Expand Down Expand Up @@ -186,8 +184,7 @@ def setup_input(self) -> None:
self.grid_layout.addWidget(self.widgets.input_value, 0, 1)
input_button = QPushButton(self.window)
input_button.setText("Browse...")
# pylint: disable=no-value-for-parameter
cast(pyqtBoundSignal, input_button.clicked).connect(self.widgets.set_input)
input_button.clicked.connect(self.widgets.set_input)
self.grid_layout.addWidget(input_button, 0, 2)

def setup_output(self) -> None:
Expand All @@ -198,8 +195,7 @@ def setup_output(self) -> None:
self.grid_layout.addWidget(self.widgets.output_value, 1, 1)
output_button = QPushButton(self.window)
output_button.setText("Browse...")
# pylint: disable=no-value-for-parameter
cast(pyqtBoundSignal, output_button.clicked).connect(self.widgets.set_output)
output_button.clicked.connect(self.widgets.set_output)
self.grid_layout.addWidget(output_button, 1, 2)

def setup_rootfamily(self) -> None:
Expand All @@ -225,8 +221,7 @@ def setup_imagedir(self) -> None:
self.grid_layout.addWidget(self.widgets.imagedir_value, 4, 1)
imagedir_button = QPushButton(self.window)
imagedir_button.setText("Browse...")
# pylint: disable=no-value-for-parameter
cast(pyqtBoundSignal, imagedir_button.clicked).connect(self.widgets.set_imagedir)
imagedir_button.clicked.connect(self.widgets.set_imagedir)
self.grid_layout.addWidget(imagedir_button, 4, 2)

def setup_nameorder(self) -> None:
Expand Down Expand Up @@ -261,20 +256,15 @@ def main() -> None:
app.layout.addLayout(app.grid_layout)

button_box = QDialogButtonBox()
standard_buttons = cast(
QDialogButtonBox.StandardButtons,
QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel # pylint: disable=no-member
)
standard_buttons = QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel
button_box.setStandardButtons(standard_buttons)
app.layout.addWidget(button_box)
cast(
pyqtBoundSignal,
button_box.button(QDialogButtonBox.StandardButton.Cancel).clicked # pylint: disable=no-member
).connect(sys.exit)
cast(
pyqtBoundSignal,
button_box.button(QDialogButtonBox.StandardButton.Ok).clicked # pylint: disable=no-member
).connect(app.widgets.convert)
cancel_button = button_box.button(QDialogButtonBox.StandardButton.Cancel)
assert cancel_button
cancel_button.clicked.connect(sys.exit)
ok_button = button_box.button(QDialogButtonBox.StandardButton.Ok)
assert ok_button
ok_button.clicked.connect(app.widgets.convert)
app.layout.addWidget(app.widgets.statusbar)
app.widgets.update_status()

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ mypy==1.8.0
pygraphviz==1.12
pyinstaller==6.3.0
pylint==3.0.3
pyqt5==5.15.7
pyqt6==6.6.1
2 changes: 2 additions & 0 deletions tools/ci-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if [ "$GITHUB_JOB" == "macos" ]; then
python3 -c 'import sys; assert sys.version_info.major == 3; assert sys.version_info.minor == 11'
elif [ -n "$GITHUB_JOB" ]; then
sudo apt-get install graphviz graphviz-dev
# for pylint and pyqt6
sudo apt-get install xorg libxkbcommon0
fi

cd tools
Expand Down

0 comments on commit 0efd85e

Please sign in to comment.