Building a GUI in Python
For this assignment, you will create a graphical user interface [GUI] using python and the Tkinter library. We'll go over the main concepts in class, but they're also laid out for you here. You'll be building your system on top of this program throughout the semester, so take time to comment the code and make sure you understand it.
Each of you should do the first two programming tasks individually so you understand the code and the system. When you write up the assignment, just make a brief wiki page on your own to describe your work.
Tasks 3 and 4 you should do with your group. Make a single wiki page for your group for this part of project. You will be expanding this page over the course of the next few assignments. Make sure each member of your group can contribute to the group wiki page.
Before you begin, download the skeleton python file for creating a window and menus using the Tkinter package. Rename the file to display.py or something you like. To run the program, open a Terminal and type the following command.
If you're not yet comfortable with Python, there are python books in the Safari Online collection. Work through a few examples so you get a sense for how it works.
There are a number of useful tutorials and documentation sites on Tkinter. You should go through a few of them before continuing with the rest of the assignment.
The basic functionality of the skeleton application is that if the user clicks with the right mouse button it draws an oval in that location and adds it to a list. If the user clicks and drags with the first mouse button, it moves all of the points to follow the mouse. Look at the code and make sure you understanding.
Using the three menu options in the command menu, give the user the
ability to select the shape drawn when they click in the window. For
example, you could let the user select between a circle, a square, and
a cross. You will need a state variable that is modified by the menu
functions and you will need to edit the handleButton1 function so that
it draws a different shape depending upon the current shape selection.
Make sure the scrolling with button 1 still works after you have implemented this capability.
The Open... command in the file menu asks the user to select a file,
but does nothing with it. Using this file,
have your program put a shape at each location given in the file,
where the shape is determined by the current shape option variable you
defined in the first task. Each row has two numbers on it that are
the x and y coordinates for where to draw the circle.
Make sure the scrolling with button 1 still works after you implement this capability.
With your partner/group, pick a data set from the available projects
on campus. The current list of choices includes, but is not limited
to, the following.
Colby Alumni Giving data
Contact: Lisa Burton
Bird migration data
Contact: Prof. Herb Wilson
Purple Finch banding data
Contact: Prof. Herb Wilson
Student survey data
Contact: Prof. Mike Donihue
Elemental concentrations in fossil soil layers
Contact: Cassi Knight, Prof. Robert Gastaldo
Maine lake temperature and elemental concentration data
Contact: Prof. Whitney King
Colby web access data
Contact: Robert Clockedile
Data on Atheletes in Maine
Contact: Prof. Paul Berkner
- Colby Alumni Giving data
Organize a 30-45 minute meeting with your potential client. Listen to
what they would like to visualize or discover from the data. Ask
questions until you have a good understanding of what the most
important issues are. If you don't already have the data, work with
your client to get access to it. Take appropriate safeguards if the
data is valuable or needs to have limited circulation.
Some questions you may want to ask include the following.
- What is the form of the data?
- What meta-data is available?
- How was the data collected?
- If the data was collected using a sensor, does the client have information about the amount of noise in the sensor?
- What visualizations would be helpful?
- What kind of computer system will the client be using?
- Are there dependent variables?
- Is there missing data? How is it represented in the data set?
- What options would the client want in visualizations?
- Does the client want interactive visualizations?
- What are the questions the data is/will be used to answer?
- Figure out how to create and integrate a dialog box with radio buttons into your application. Let the user select the current shape using the dialog box.
- Figure out how to create and integrate a dialog box with a text box into your application. Use the dialog box text to let the user input a caption on the window or to set the window title.
- Write a standalone python script that is capable of reading your chosen data set and putting it into the form of a list of lists. Each data point should be its own list within a larger list that is the data set. If you want to push this further, integrate this capability into your TK application using the file dialog box.
- Start creating a mock-up application that has all of the interface elements the user wants or needs.
As noted, make a brief individual writeup of your TK coding. Don't worry about pictures unless they're really cool.
With your group, make a home wiki page for your data project. All members should have access to this, although it will live in one member's wiki space. For this week's writeup, make two child pages from the main data project page.
- One child page should contain all meta-data for the project. This should include a description of the raw data format.
- The second child page should contain a summary of your first meeting with your client. Include the main goals of the project and a discussion of the most important features of the project.
Once you have written up your assignment, give the page the label:
Put your code in the COMP/CS251 folder on fileserver1/Academics.