1

I wrote some code that has a few boolean statements at the beginning, and depending on which ones are True/False different problems are solved, and different plots are created (currently using imshow and some animation).

How would I run the code, have some sort of interactive window (be in a plot or some other way) appear that you can select which of these things would be true or false?

And secondly, I also have some in console inputs that are needed, if I could double dip and have this also in some sort of gui, that would be cool. My programming knowledge is primarily definition based and raw computations, and I'm not very savvy with classes, but am all for learning.

Currently I have these pieces hard coded, and would like to be able to alter them with a GUI.

animate = True
parta   = False                   # This chooses which problem we solve
partb   = True               
if parta and partb == True:
    print 'Code is not set up to run both a and be simultaneously'
    quit()

I also have a bunch of inputs, that get stored into variables in the following style.

xy_values = raw_input('Enter xmin,ymin separated by a comma or [Enter] for 0,0: ')
if xy_values == '':
    a = 0. ; c = 0.
else:
    a,c = [float(x) for x in xy_values.split(",")]

I would love to just have a window appear, where I can have the user input all of this data, and then have the rest of my program run based on that data, and if possible, allow to rerun and rechange the data ( but that last piece is not necessary ). I've done about an hour of digging and haven't found anything that has really made sense or helped me. [ Primarily i've been looking at buttons on plot windows using matplotlib ].

bmu
  • 35,119
  • 13
  • 91
  • 108
KevinShaffer
  • 760
  • 5
  • 14
  • 26

2 Answers2

2

This is called widgets in matplotlib:

http://matplotlib.org/api/widgets_api.html

And here are some examples:

http://matplotlib.org/examples/widgets/index.html

HYRY
  • 94,853
  • 25
  • 187
  • 187
0

If you are looking for an user interface, I advise you to use Tkinter : it is really simple and you can embed matlplotlib graph in it.

Example : Running matplotlib in tkinter

Community
  • 1
  • 1
lucasg
  • 10,734
  • 4
  • 35
  • 57