In this assignment you’ll create a simple desktop GUI for the Humane Society.
This is an individual assignment.
Collaboration at a reasonable level will not result in substantially similar code. Students may only collaborate with fellow students currently taking CS 2316, the TA’s and the lecturer. Collaboration means talking through problems, assisting with debugging, explaining a concept, etc. You should not exchange code or write code for others.
Notes:
You work for the Humane Society and are tasked with creating a desktop GUI application to nicely view the profiles of pets in the shelters.
Write a program in humanexgui.py
that reads data from a Humane Society database, shows pet information in a table, and shows information for each pet, possibly including a picture of the pet. The database will use the schema created by humanex-schema.sql. Note the x
in the name to distinguish this extended version of the Humane Society database we’ve seen before. You may wish to populate your database with humanex-data.sql to test your application.
DbLoginDialog
Your program should start by displaying a database login dialog like the one in mysql_browser.py to get correct login credentials. After successful database connection, the MainWindow
should be displayed. If the user supplies incorrect credentials or the database connection failes for some other reason, exit and print an error message to the console.
host
– the hostname of the MySQL server to which to connect, should default to localhost
user
– the username of a MySQL user on host
that can read the humanex
database, should default to root
password
– the password of user
, should default to `` (empty string)database
– the name of the humanex
database, should default to humanex
Your DbLoginDialog
should look something like this when it is first displayed:
ManWindow
After successfully connecting to the database your program should read the contents of the pet
and shelter
tables and display Shelter Name
, Pet Name
and Breed
in a QTableView
. Note that you’ll need to join the shelter
and pet
tables.
PetDetailsDialog
showing the details of the pet selected in the table (more below).
SimpleTableModel
class found in scripters_gui.pytable_view.setSelectionMode(QAbstractItemView.SelectRows)
Your MainWindow
should look something like this (note that you may have scroll bars):
PetDetails
DialogYour PetDetailsDialog
should look something like this:
In the PetDetailsDialog
, display pet’s picture, if available. The file name of the picture is available in the pic_url
column of the pet
table in the database. Note that the header in the table should be “Picture URL”.
Display shelter information.
Below the “Pet Details …” button on the MainWindow
display a “Shelter Details …” button that, when clicked, displays the details for the shelter at which the selected pet is housed. The button should be disabled if no pet is selected in the table.
ShelterDetailsDialog
should show the shelter name and list all the pets and workers at the shelter. Buttons for pet details and worker details should display information in dialogs (see grading section below).Start your code with the contents of scripters_gui.py, then add the DbLoginDialog
from mysql_browser.py, and replace the code in scripters_gui.py that loads data from a CSV file with code that loads data from a MySQL database connection that you get from DbLoginDialog
(Slide 6).
Useful downloads:
DbLoginDialog
contains default values.MainWindow
after entering db login details and clicking “OK”.MainWindow
contains table showing pet data.
pet
table.shelter
table.MainWindow
has “Pet Details…” button.
PetDetailsDialog
.PetDetailsDialog
is a modal dialog showing some information.
Bonus (these will require additional database queries):
MainWindow
has “Shelter Details…” button.
ShelterDetailsDialog
.ShelterDetailsDialog
shows some shelter details.
PetDetailsDialog
.WorkerScheduleDialog
WorkerScheduleDialog
shows some worker schedule information
Yes, there are 200 points available on this homework.
Submit your humanexgui.py
file on Canvas as an attachment. When you’re ready, double-check that you have submitted and not just saved a draft.
Practice safe submission! Verify that your HW files were truly submitted correctly, the upload was successful, and that your program runs with no syntax or runtime errors. It is solely your responsibility to turn in your homework and practice this safe submission safeguard.
This procedure helps guard against a few things.