1. Saving images in a GUI

  • Open the notebook file GUI_command_line.
  • Copy the cell with the %%writefile magic command in it to a cell in your homework notebook.
  • Add a button element (e.g., a checkbox) to the left of the OK button that when checked will save the image to a file named bathymetry.png.
  • Modify the code to allow the user to enter a file name of their choice and save the image to that file name. HINT: If the checkbox element returns the dictionary "values" where the key (set when you first defined the sg.Checkbox() object) is True, then call a function, say, save_fig() that saves fig with a call to the figure object method: fig.savefig('bathymetry.png').

2. Decorating your GUI

  • Change the title of the file browser window to something more meaningful.
  • Move your 'OK' and checkbox elements around so that they are centered at the bottom.
  • Optional Challenge: allow the user to choose a projection of their choice.
In [ ]: