Skip to content

Commit

Permalink
Move designer files to their own directory
Browse files Browse the repository at this point in the history
Clean up the repo structure by keeping designer files (.ui and generated .py) separate from the interface window class definitions
  • Loading branch information
Simon Ho committed Sep 25, 2016
1 parent 86ad8a7 commit 7ff45de
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 23 deletions.
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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...
Expand Down
19 changes: 19 additions & 0 deletions designer/README.md
Original file line number Diff line number Diff line change
@@ -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.
Empty file added designer/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 17 additions & 14 deletions interface/README.md
Original file line number Diff line number Diff line change
@@ -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.
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
2 changes: 1 addition & 1 deletion about_dialog.py → interface/about_dialog.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion settings_window.py → interface/settings_window.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
6 changes: 2 additions & 4 deletions run_battery.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit 7ff45de

Please sign in to comment.