From 7ff45deed15491a267a0acef7386f1416aa025e3 Mon Sep 17 00:00:00 2001 From: Simon Ho Date: Sun, 25 Sep 2016 05:37:27 -0700 Subject: [PATCH] Move designer files to their own directory Clean up the repo structure by keeping designer files (.ui and generated .py) separate from the interface window class definitions --- README.md | 5 ++- designer/README.md | 19 ++++++++++++ designer/__init__.py | 0 {interface => designer}/about_dialog_qt.py | 0 {interface => designer}/battery_window_qt.py | 0 {interface => designer}/settings_window_qt.py | 0 .../ui}/about_dialog_qt.ui | 0 .../ui}/battery_window_qt.ui | 0 .../designer => designer/ui}/convertUI.bat | 0 .../ui}/settings_window_qt.ui | 0 interface/README.md | 31 ++++++++++--------- about_dialog.py => interface/about_dialog.py | 2 +- .../settings_window.py | 2 +- run_battery.py | 6 ++-- 14 files changed, 42 insertions(+), 23 deletions(-) create mode 100644 designer/README.md create mode 100644 designer/__init__.py rename {interface => designer}/about_dialog_qt.py (100%) rename {interface => designer}/battery_window_qt.py (100%) rename {interface => designer}/settings_window_qt.py (100%) rename {interface/designer => designer/ui}/about_dialog_qt.ui (100%) rename {interface/designer => designer/ui}/battery_window_qt.ui (100%) rename {interface/designer => designer/ui}/convertUI.bat (100%) rename {interface/designer => designer/ui}/settings_window_qt.ui (100%) rename about_dialog.py => interface/about_dialog.py (93%) rename settings_window.py => interface/settings_window.py (98%) diff --git a/README.md b/README.md index 5e419c6..eff92b2 100644 --- a/README.md +++ b/README.md @@ -102,7 +102,7 @@ An instance of the class is spawned in `run_battery.py`, near the end of the returned dataframe is saved to file. You'll then need to update the QT Designer UI file -(`/interface/designer/battery_window_qt.ui`) by adding your task to the list. +(`/designer/ui/battery_window_qt.ui`) by adding your task to the list. Rebuild using the included `convertUI.bat` script. **Note**: It is better to modify the UI file using QT Designer and then @@ -125,8 +125,7 @@ method 6. Update the QT Designer UI file and rebuild using the conversion script Consider making a pull request. However, I will only add tasks that are -using a standard implementation, without major deviations, and have a -journal reference. +using a standard implementation and have a journal reference. ##TODO In no particular order... diff --git a/designer/README.md b/designer/README.md new file mode 100644 index 0000000..6c06b9c --- /dev/null +++ b/designer/README.md @@ -0,0 +1,19 @@ +#Designer Files + +The `/ui` directory contains `.ui` files used by QT Designer to create +the various windows and dialogs of the application. Edit those in QT Designer +if you want to make changes to the user interface. + +After making changes in QT Designer, you'll need to convert the `.ui` files to +Python modules. `/ui/convertUI.bat` is a Windows batch script for converting +(using `pyuic`) the QT Designer UI files to Python modules that can be +imported by the main script. + +The Python `.py` files in this directory are the modules generated by the +batch script above. These are used to set up the UI elements and window logic +elsewhere (see `../interface/`) + +**Note**: Do not manually edit the `.py` files in this directory. While it +might be tempting to add/change UI elements directly in the Python file, +any changes you make will be overwritten by the `.ui -> .py` conversion +process. \ No newline at end of file diff --git a/designer/__init__.py b/designer/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/interface/about_dialog_qt.py b/designer/about_dialog_qt.py similarity index 100% rename from interface/about_dialog_qt.py rename to designer/about_dialog_qt.py diff --git a/interface/battery_window_qt.py b/designer/battery_window_qt.py similarity index 100% rename from interface/battery_window_qt.py rename to designer/battery_window_qt.py diff --git a/interface/settings_window_qt.py b/designer/settings_window_qt.py similarity index 100% rename from interface/settings_window_qt.py rename to designer/settings_window_qt.py diff --git a/interface/designer/about_dialog_qt.ui b/designer/ui/about_dialog_qt.ui similarity index 100% rename from interface/designer/about_dialog_qt.ui rename to designer/ui/about_dialog_qt.ui diff --git a/interface/designer/battery_window_qt.ui b/designer/ui/battery_window_qt.ui similarity index 100% rename from interface/designer/battery_window_qt.ui rename to designer/ui/battery_window_qt.ui diff --git a/interface/designer/convertUI.bat b/designer/ui/convertUI.bat similarity index 100% rename from interface/designer/convertUI.bat rename to designer/ui/convertUI.bat diff --git a/interface/designer/settings_window_qt.ui b/designer/ui/settings_window_qt.ui similarity index 100% rename from interface/designer/settings_window_qt.ui rename to designer/ui/settings_window_qt.ui diff --git a/interface/README.md b/interface/README.md index 779aa7b..2fef709 100644 --- a/interface/README.md +++ b/interface/README.md @@ -1,18 +1,21 @@ -#Designer Files +#Interface Files -The `/designer` directory contains `.ui` files used by QT Designer to create -the various windows and dialogs of the application. Edit those in QT Designer -if you want to make changes to the user interface. +This directory contains class definitions for the different windows and dialog +boxes. These are imported by the main script as modules and used to +create/display the different application windows. -After making changes in QT Designer, you'll need to convert the `.ui` files to -Python modules. `convertUI.bat` is a Windows batch script for converting -(using `pyuic`) the QT Designer UI files into Python modules that can be -imported by the main script. +Each module here uses the generated Python files (`../designer/*.py`) to +determine the layout for each window -The Python `.py` files in this directory are the modules generated by the -batch script above. These are used by the main script to setup the UI elements. +The process as a whole: -**Note**: Do not manually edit the `.py` files in this directory. While it -might be tempting to add/change UI elements directly in the Python file, -any changes you make will be overwritten by the `.ui -> .py` conversion -process. \ No newline at end of file +1. `.ui` files are created for each window using QT Designer. These can be +found in `../designer/ui/` +2. `.ui` files are converted to `.py` using `../designer/ui/convertUI.bat`. +These are just Python versions of the `.ui` files and contain the layout and +structure of all window elements. They can be found in `../designer/` +3. The Python modules in this directory define classes for each application +window, using the layout from files generated in Step #2 and adding the +logic for each window +4. Finally, these classes are instantiated in the main script to create and +display the windows when needed \ No newline at end of file diff --git a/about_dialog.py b/interface/about_dialog.py similarity index 93% rename from about_dialog.py rename to interface/about_dialog.py index 792638c..d5714dd 100644 --- a/about_dialog.py +++ b/interface/about_dialog.py @@ -1,7 +1,7 @@ import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui -from interface import about_dialog_qt +from designer import about_dialog_qt class AboutDialog(QtGui.QDialog, about_dialog_qt.Ui_Dialog): diff --git a/settings_window.py b/interface/settings_window.py similarity index 98% rename from settings_window.py rename to interface/settings_window.py index 6c37063..45f82dd 100644 --- a/settings_window.py +++ b/interface/settings_window.py @@ -1,7 +1,7 @@ import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui -from interface import settings_window_qt +from designer import settings_window_qt class SettingsWindow(QtGui.QDialog, settings_window_qt.Ui_SettingsDialog): diff --git a/run_battery.py b/run_battery.py index 85de2bf..5107fdf 100644 --- a/run_battery.py +++ b/run_battery.py @@ -6,10 +6,8 @@ import PyQt4.QtCore as QtCore import PyQt4.QtGui as QtGui -import about_dialog -import settings_window - -from interface import battery_window_qt +from designer import battery_window_qt +from interface import about_dialog, settings_window from tasks import ant, mrt, sart, ravens, digitspan_backwards