Skip to content

Commit bf492ed

Browse files
committed
cleaned it up
1 parent 340c881 commit bf492ed

File tree

1 file changed

+5
-18
lines changed

1 file changed

+5
-18
lines changed

examples/GUI/plotter.py

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def __init__(self, parent):
8383
self.frame_buttons.pack(fill=Tk.BOTH, expand=1)
8484

8585
self.plot_button = Tk.Button(self.frame_buttons, text='Plot',
86-
command=self._plot, font=myfont)
86+
command=self._plot, font=myfont)
8787
self.plot_button.pack(side=Tk.BOTTOM)
8888

8989
self.clear_button = Tk.Button(self.frame_buttons, text='Clear',
@@ -98,28 +98,15 @@ def __init__(self, parent):
9898
self.clear_button.pack(side=Tk.LEFT, padx=5, pady=5)
9999
self.quit_button.pack(side=Tk.RIGHT)
100100

101-
def _plot1(event=None): # define plot function inside this class so
102-
f_str = self.func.get() # self.func.bind can call it
103-
f = str_to_f(f_str)
104101

105-
xm = float(self.xmin.get())
106-
xM = float(self.xmax.get())
107-
108-
xv = np.linspace(xm, xM, 1000)
109-
fv = f(xv)
110-
111-
self.a.plot(xv, fv)
112-
self.a.set_xlim([xm, xM])
113-
self.canvas.show()
114-
115-
self.func.bind('<Return>', _plot1)
116-
self.xmin.bind('<Return>', _plot1)
117-
self.xmax.bind('<Return>', _plot1)
102+
self.func.bind('<Return>', self._plot)
103+
self.xmin.bind('<Return>', self._plot)
104+
self.xmax.bind('<Return>', self._plot)
118105
# this allows the use of the enter key to plot the function as well
119106
# while the cursor is in any one of the three text-entry fields
120107

121108

122-
def _plot(self):
109+
def _plot(self, event=None):
123110
f_str = self.func.get()
124111
f = str_to_f(f_str)
125112

0 commit comments

Comments
 (0)