Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Task 3 was to make a popup window that has options for random distribution in the x and y axes. Using an outline the task linked to, I made two listboxes in the body method, and packed them into the window vertically. Then, I inserted "uniform" and "gaussian" as selectable options in both. In the apply method, which hitting "ok" triggers, I changed the fields for the current x and y distribution options to match the currently active selection in their respective listboxes. I passed in the displayApp class for this reason. Then, when creating the points, I check the strings associated with the x and y distribution fields, and use a different random function depending on their values. This is shown here:

For my first extension, making the current distribution settings saved as the defaults when opening the window to change them, I simply used the activate method in the body method of the DistSelection class. I passed in the currently selected index by checking the fields of the displayApp class. I also used the select_set method of the listboxes in the same way to make the currently active distribution highlighted for clarity.


And this is where I decided what to draw when placing points:

Below are two pictures of my program's functionality. The blue is Gaussian in its x axis, is more sparse than the red, and is is square. Meanwhile, there is a lot of red, which takes diamond form, and has gaussian distribution in both axes. The effect of Gaussian distribution can be seen in the center-clumping we can see in the red. The distribution makes it more likely for points to be near the center, and less likely to be farther away, based on the standard deviation provided. The blue, which has Gaussian distribution on its x axis, shows this trend horizontally, but vertically, one can see that it does not go down into the middle of the y axis very much.


This project familiarized me with important tkinter features, and I was able to problem-solve when doing the extensions. I learned how to trigger popup windows, read, use, and display selection feedback, make buttons, manipulate different shapes on the canvas, and how to use the gaussian random method, for example. It wasn't that difficult getting back into python because of Jan Plan, and I appreciated how I could "pack" widgets into the window instead of manually placing everything like in pygame. Tkinter seems more user-friendly.