CESG505 - Class Project | A Qt GUI for Illustrating a Traffic Network of Intersections, Roads, Features, and Road Names
A basic demonstration of the app: https://youtu.be/E-N1DbndH1o
This project is an app developed for a class project (CESG505). The app is a Qt GUI that connects to a .db file (sql) chosen from a file dialog. This database has information regarding intersection nodes, roads between the nodes, the road names, and installed features on the intersections namely, traffic lights and crosswalks. The app has checkboxes to select which layers the user wants to view and then it plots them inside a QGraphicsView
widget. The user can also export the figures (which are matplotlib objects) to .png and .pdf. Thie UI also has a menu bar for connecting/disconnecting to and from the database and buttons to view the list of intersections and roads in a table format.
The GUI was designed in Qt Designer and then brought into Python using the following command: pyuic5 -x app.ui -o appui.py
. The buttons and format were designed in accordance to the project description. The menu's ‘connect’ and ‘disconnect’ buttons connect to a local .db
file (which the user selects from a dialog box) and the data for each of the tables is put into a pandas dataframe
located inside the self
function of the app. Certain measures were put into order that error messages should pop up if the selected file is not a .db file or if no file is selected.
After the connect buttons, the list of intersection and road tables were developed using QTableView
and QSqlDatabase
. Again, there are measures put in place that error messages pop up if the user selects to view the table of intersections without having connected the database first.
The maps were created in Jupyter Notebook at first by using the pandas dataframes
from the sql
database. Seven different maps are plotted for all the different layers which are selected through the checkboxes. For instance: fig_i
is for viewing Intersections only, fig_s
is for Streets only, fig_sn
is for Streets and street Names only, fig_sin
is for Streets and Intersections and Names, etc. Afterwards, the code of these maps was brought into appui.py
and embedded inside a QGraphicsView
object in the Qt app.
The export button functions were developed at last. The way the export works is that the app actually exports the matplotlib
objects and not a screenshot of the app. Clicking the buttons generates a save file dialog and when the user selects the location of the file, that is where the matplotlib figure object saves the plot using savefig. The dpi is selected to be 500 so that when the figures are exported, the quality is relatively good. You can zoom into the pictures and see all the street names, etc.