Skip to content

Commit

Permalink
Generate Clock Widget
Browse files Browse the repository at this point in the history
  • Loading branch information
maerkl24 committed Oct 29, 2023
1 parent b219ca3 commit 050c7b3
Show file tree
Hide file tree
Showing 9 changed files with 1,314 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/generation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ jobs:
run: pdm install
- name: Run pyside6-uic and pyside6-rcc
run: |
pdm run pyside6-uic ui/main_window.ui -o hockeygameclock/frontend/ui/main_window.py --from-imports
pdm run pyside6-rcc ui/resources.qrc -o hockeygameclock/frontend/ui/resources_rc.py
pdm run pyside6-uic ui/clock_widget.ui -o hockeygameclock/frontend/generated/clock_widget.py --from-imports
# pdm run pyside6-rcc ui/resources.qrc -o hockeygameclock/frontend/ui/resources_rc.py
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ __pycache__/
/docs/_build/

# Generated Qt user interface Python files
/hockeygameclock/frontend/ui/*.py
!/hockeygameclock/frontend/ui/__init__.py
/hockeygameclock/frontend/generated/*.py
!/hockeygameclock/frontend/generated/__init__.py
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"editor.codeActionsOnSave": {
"source.organizeImports": true,
},
"python.formatting.provider": "black",
"python.formatting.provider": "none",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.linting.mypyEnabled": true,
Expand All @@ -15,4 +15,7 @@
"hockeygameclock"
],
"esbonio.sphinx.confDir": "",
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
},
}
25 changes: 11 additions & 14 deletions docs/developer/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,26 @@ The ``hockeygameclock`` relies on `Qt <https://www.qt.io/>`_ as frontend and the
binding.

The GUI is developed and designed with help of the `Qt Designer <https://doc.qt.io/qt-6/qtdesigner-manual.html>`_. You
can open the Qt Designer with the following commands:
can open the Qt Designer with the following command:

.. code-block:: batch
.. code-block:: shell
:: Activate virtual environment
.venv\Scripts\activate.bat
# Open the Qt Designer
pdm run pyside6-designer
:: Open Qt Designer
pyside6-designer
# Open the Qt Designer for a specific .ui file
pdm run pyside6-designer ui/clock_widget.ui
The Qt Designer works with ``.ui`` files to describe the developed GUI. However, to uses these information in
combination with Python, we have to convert them to Python code. This can be done with the following commands:

.. code-block:: batch
.. code-block:: shell
:: Activate virtual environment
.venv\Scripts\activate.bat
# Convert user interface files to Python
pdm run pyside6-uic ui/clock_widget.ui -o hockeygameclock/frontend/generated/clock_widget.py --from-imports
:: Convert user interface files to Python
pyside6-uic ui/main_window.ui -o hockeygameclock/frontend/ui/main_window.py --from-imports
:: Convert resource file to Python
pyside6-rcc ui/resources.qrc -o hockeygameclock/frontend/ui/resources_rc.py
# Convert resource file to Python
# pdm run pyside6-rcc ui/resources.qrc -o hockeygameclock/frontend/ui/resources_rc.py
Backend
-------
Expand Down
13 changes: 5 additions & 8 deletions hockeygameclock/frontend/clock_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@

from typing import Optional

from PySide6.QtCore import Qt
from PySide6.QtWidgets import QGridLayout, QLabel, QWidget
from PySide6.QtWidgets import QWidget

# pylint: disable-next=import-error,no-name-in-module
from hockeygameclock.frontend.generated.clock_widget import Ui_ClockWidget # type: ignore[reportMissingImports]


class ClockPage(QWidget):
"""Clock page UI."""

def __init__(self, parent: Optional[QWidget] = None) -> None:
super().__init__(parent)
self._layout = QGridLayout(self)
label = QLabel(self)
label.setText("Clock")
label.setStyleSheet('color: rgb(255, 255, 255); font: 700 48pt "Segoe UI";')
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
self._layout.addWidget(label)
Ui_ClockWidget().setupUi(self)
2 changes: 2 additions & 0 deletions hockeygameclock/frontend/generated/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"""generated module.
"""
Empty file added hockeygameclock/py.typed
Empty file.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ line-length = 120
[tool.pylint.main]
load-plugins = ["pylint.extensions.docparams"]
ignored-modules = ["PySide6"]
ignore-paths = ["hockeygameclock/frontend/generated"]
extension-pkg-whitelist = ["PySide6"]

[tool.pylint.format]
Expand All @@ -83,7 +84,7 @@ default-docstring-type = "google"
warn_return_any = true

[[tool.mypy.overrides]]
module = "hockeygameclock.frontend.ui.*"
module = "hockeygameclock.frontend.generated.*"
ignore_missing_imports = true


Expand Down
Loading

0 comments on commit 050c7b3

Please sign in to comment.