Skip to content

Commit

Permalink
Added discrete and stepsize option but in unstable stage
Browse files Browse the repository at this point in the history
  • Loading branch information
realsdx committed Feb 8, 2018
1 parent ae34c4c commit f1e2144
Showing 1 changed file with 37 additions and 24 deletions.
61 changes: 37 additions & 24 deletions gui_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __init__(self, top=None):
self.line_style = '-'
self.file_path = ''
root.configure(background=_lightwindowbackground)
self.pvalue1=StringVar() #To store enrty values from popup winodw
self.pvalue2=StringVar()

self.Canvas1 = Canvas(top)
self.Canvas1.place(relx=0.04, rely=0.05, relheight=0.70, relwidth=0.69)
Expand Down Expand Up @@ -166,9 +168,9 @@ def __init__(self, top=None):
self.ypoints.configure(state="normal")))
self.chkvar=StringVar()
self.Check= Checkbutton(top,variable=self.chkvar)
self.Check.place(relx=0.40, rely=0.76, relheight=0.05, relwidth=0.24)
self.Check.place(relx=0.40, rely=0.76, relheight=0.05, relwidth=0.245)
self.Check.configure(text='''Options for Function''',background=_bgcolorlight,onvalue='options', offvalue='nooptions')
self.Check.configure(command = lambda : self.functionOptions(self.chkvar.get()))
self.Check.configure(command = lambda : self.functionOptions(self.chkvar.get()),state="disabled")


self.Label1 = Label(top)
Expand Down Expand Up @@ -209,7 +211,7 @@ def __init__(self, top=None):
self.bt_plot = Button(top)
self.bt_plot.place(relx=0.67, rely=0.85, height=26, width=47)
self.bt_plot.configure(activebackground=_activebgcolordark)
self.bt_plot.configure(command=lambda : self.toPlot(self.radiovar.get()))
self.bt_plot.configure(command=lambda : (self.toPlot(self.radiovar.get()),print(self.radiovar.get())))
self.bt_plot.configure(cursor="left_ptr")
self.bt_plot.configure(text='''Plot''')
self.bt_plot.configure(width=47)
Expand Down Expand Up @@ -276,23 +278,30 @@ def __init__(self, top=None):
self.bt_themeswitch.configure(fg=_fgcolorlight)

def toPlot(self,radiovar):
global pvalue1
global pvalue2
if radiovar=="func":
# print("FUNC")
gui_support.Plot(self.fx.get(),range(int(self.x_lower.get()),
int(self.x_upper.get())),
self.color_input.get(),
self.theme,
self.Canvas1, self.line_style, self.file_path)

if radiovar=="func_discrete":
xpoints=list(map(float, self.pentry1.get().split(',')))
xpoints=list(map(float, self.pvalue1.split(',')))
gui_support.Plot(self.fx.get(),xpoints,
self.color_input.get(),
self.theme,
self.Canvas1, self.line_style, self.file_path,True)

if radiovar=="func_stepsize":
gui_support.Plot(self.fx.get(),range(int(self.x_lower.get()),
int(self.x_upper.get()),int(self.pvalue2)),
self.color_input.get(),
self.theme,
self.Canvas1, self.line_style, self.file_path)

if radiovar=="line":
# print("LINE")
gui_support.Plot_line(toArray(self.xpoints.get(),self.ypoints.get()),
self.color_input.get(),
self.theme,
Expand All @@ -304,49 +313,42 @@ def popOptionsWin(self):
This function holds all the gui for this purpose"""
global root
pwin=self.pwin=Toplevel(root)
pwin.geometry("700x160+408+220")
pwin.geometry("420x340+470+200")
pwin.title("Options for Function Plotting")
pwin.configure(background= _lightwindowbackground)

#Entry for Discrete Option
self.pentry1=Entry(pwin)
self.pentry1.place(relx=0.05, rely=0.45, relheight=0.14, relwidth=0.40)
self.pentry1.place(relx=0.15, rely=0.20, relheight=0.08, relwidth=0.70)
self.pentry1.configure(width=374,cursor="xterm",background=_bgcolorlight)
self.pentry1.configure(state="disabled")

#Entry for Stepsize Option
self.pentry2=Entry(pwin)
self.pentry2.place(relx=0.55, rely=0.45, relheight=0.14, relwidth=0.40)
self.pentry2.place(relx=0.15, rely=0.50, relheight=0.08, relwidth=0.70)
self.pentry2.configure(width=374,cursor="xterm",background=_bgcolorlight)
self.pentry2.configure(state="disabled")

# self.plabel1 = Label(pwin)
# self.plabel1.place(relx=0.05, rely=0.30, height=18, width=120)
# self.plabel1.configure(text=" Add discrete points ",fg= _fgcolorlight,background= _lightwindowbackground)
# self.plabel1.configure()

# self.plabel2 = Label(pwin)
# self.plabel2.place(relx=0.53, rely=0.30, height=18, width=120)
# self.plabel2.configure(text=" Add step size ",fg= _fgcolorlight,background= _lightwindowbackground)
# self.plabel2.configure()

self.pchkvar=StringVar()
self.pcheck1= Checkbutton(pwin,variable=self.pchkvar)
self.pcheck1.place(relx=0.05, rely=0.30, relheight=0.15, relwidth=0.40)
self.pcheck1.place(relx=0.30, rely=0.10, relheight=0.10, relwidth=0.37)
self.pcheck1.configure(text='''Add Discrete Points''',background=_lightwindowbackground,onvalue='discrete', offvalue='nodiscrete')
self.pcheck1.configure(command = lambda : self.popupOptionsManager(self.pchkvar.get()))

# self.pchkvar2=StringVar()
self.pcheck2= Checkbutton(pwin,variable=self.pchkvar)
self.pcheck2.place(relx=0.55, rely=0.30, relheight=0.15, relwidth=0.40)
self.pcheck2.place(relx=0.30, rely=0.40, relheight=0.10, relwidth=0.37)
self.pcheck2.configure(text='''Add Step Size''',background=_lightwindowbackground,onvalue='stepsize', offvalue='nostepsize')
self.pcheck2.configure(command = lambda : self.popupOptionsManager(self.pchkvar.get()))


self.bt_submit = Button(pwin)
self.bt_submit.place(relx=0.465, rely=0.75, height=30, width=50)
self.bt_submit.place(relx=0.42, rely=0.75, height=35, width=60)
self.bt_submit.configure(activebackground=_activebgcolordark,background=_bgcolorlight,fg=_fgcolorlight)
self.bt_submit.configure(text= '''Submit''',cursor= "left_ptr",width= 47)
self.bt_submit.configure(command=lambda : self.toPlot(self.radiovar.get()))
self.bt_submit.configure()
self.bt_submit.configure(command=lambda : (self.popupInputManager(self.pchkvar.get()),
self.pwin.destroy()))
# self.bt_submit.configure(command=lambda : self.pwin.withdraw())


def popupOptionsManager(self,chkbtnvar):
Expand All @@ -362,6 +364,17 @@ def popupOptionsManager(self,chkbtnvar):
if chkbtnvar=='nostepsize':
self.pentry2.configure(state="disabled")

def popupInputManager(self,chkbtnvar):
# global pvalue1
# global pvalue2
if chkbtnvar=="discrete":
self.radiovar.set("func_discrete")
self.pvalue1=self.pentry1.get()

if chkbtnvar=="stepsize":
self.radiovar.set("func_stepsize")
self.pvalue2=self.pentry2.get()



def functionOptions(self,chkbtnvar):
Expand Down

0 comments on commit f1e2144

Please sign in to comment.