def body(self, master): """Put the contents of the dialog box in here by overriding @param master - where to draw the widgets""" # create dialog body. return widget that should have # initial focus. this method should be overridden self.cwd = os.getcwd().split('/') self.cwd[0] = '/' self.current_folder = StringVar() self.current_folder.set(self.cwd[-1]) myOptionMenu(master,self.current_folder,*self.cwd).pack(side="left") Button(master,text='Up').pack(side='left') Button(master,text='New Folder').pack(side='left')
def body(self,master): self.maxscalelength = 200 f0 = Frame(master,background=_CHROME_COLOR) self.scl = Scale(f0, from_=1, to=self.n, tickinterval=self.n/5, resolution=1, orient='horizontal', length=self.maxscalelength, bd=1, troughcolor="gray80", activebackground=_HIGHLIGHT_COLOR, background=_CHROME_COLOR) self.scl.pack(fill=X,expand=1) f0.pack(fill=X,expand=1,anchor=N) f1 = Frame(master,background=_CHROME_COLOR) Button(f1,text='show',command=self.report,bd=1,activebackground=_HIGHLIGHT_COLOR, background=_CHROME_COLOR).pack(side=LEFT) Button(f1,text='jump',command=self.jump,bd=1,activebackground=_HIGHLIGHT_COLOR, background=_CHROME_COLOR).pack(side=LEFT) a = myOptionMenu(f1,self._scaletype,'histeq','99.5','zscale', command=self.scale) a.config(bd=1,background=_CHROME_COLOR,activebackground=_HIGHLIGHT_COLOR) a.pack(side=LEFT) self.SaveB = Button(f1,text="Save",command=self.save,bd=1, activebackground=_HIGHLIGHT_COLOR,background=_CHROME_COLOR) self.SaveB.pack(side=LEFT) self.plotB = Button(f1,text='plot',command=self.plot,bd=1, background=_CHROME_COLOR,activebackground=_HIGHLIGHT_COLOR) self.plotB.pack(side=LEFT) if not _plotFlag: self.plotB.config(state=DISABLED) self.plotB.config(fg="gray") f1.pack(anchor=N) header="wave flux dflux" f2=Frame(master,background=_CHROME_COLOR) Label(f2,text=header,anchor=W,background=_CHROME_COLOR).pack(anchor=W) self.scrollbar = Scrollbar(f2,orient=VERTICAL,troughcolor="gray80",bd=1, activebackground=_THEME_COLOR,background=_CHROME_COLOR) self.listbox = Listbox(f2,width=50,height=self.numframes,bg="White",bd=1, yscrollcommand=self.scrollbar.set,selectbackground='White', selectborderwidth=0,background=_CHROME_COLOR) self.scrollbar.config(command=self.listbox.yview) self.scrollbar.pack(side=RIGHT,fill=Y) self.listbox.pack(fill=BOTH,expand=1) f2.pack(fill=BOTH,expand=1,anchor=N) self.update(self.idx) return None
def body(self,master): """Make GUI widgets for showall dialog master - the window where widgets should be drawn""" self.color=StringVar() self.color.set(_circlecolor) self.delete = IntVar() self.number = IntVar() self.reset = IntVar() self.size=StringVar() self.size.set(_circsize) Label(master,text="Region Color:",background=_CHROME_COLOR).grid(row=0,column=0,sticky=W) self.x=myOptionMenu(master,self.color,'black','white','red','green',\ 'blue','cyan','magenta','yellow') self.x.grid(row=0,column=1,sticky=W) self.x.config(bd=1,highlightcolor=_THEME_COLOR,background=_CHROME_COLOR, activebackground=_HIGHLIGHT_COLOR) Label(master,text="Circle Size(''):",background=_CHROME_COLOR).grid(row=1,column=0,sticky=W) self.y=Entry(master,textvariable=self.size,width=5,bd=1, selectborderwidth=0,highlightcolor=_THEME_COLOR, selectbackground=_THEME_COLOR,background=_CHROME_COLOR, selectforeground="Black") self.y.config(bg="White") self.y.grid(row=1,column=1,sticky=W) Checkbutton(master,text="Delete old regions in frames?",\ variable=self.delete,bd=1,selectcolor=_THEME_COLOR, activebackground=_HIGHLIGHT_COLOR,background=_CHROME_COLOR).grid(row=2,column=0,columnspan=2) Checkbutton(master,text="Show numbers?",\ variable=self.number,bd=1,selectcolor=_THEME_COLOR, activebackground=_HIGHLIGHT_COLOR,background=_CHROME_COLOR).grid(row=3,column=0, columnspan=2,sticky=W) Checkbutton(master,text="Reset Frame?",variable=self.reset,bd=1, selectcolor=_THEME_COLOR,activebackground=_HIGHLIGHT_COLOR, background=_CHROME_COLOR).grid(row=4,column=0,columnspan=2,stick=W) return self.x
def start(infile,window,numframes): """Creates the main p6_ds9 window. infile - input filename. Defaults to "" window - string name of the ds9 window numframes - number of frames in ds9 window""" global _fitsimgs def load(): """Create the loadimages class""" if _numframes.get() not in range(1,_maxframe+1): showwarning("Numframes Warning","You must have between 1 and %d frames." %_maxframe) else: start = len(_fitsimgs) for i in range(start,_numframes.get()): _fitsimgs.append('%s/???' %_fitscwd) x=loadimages(root,window,_numframes.get()) def startshowall(): """Calls the showall function""" if _all is not None and _all.num > 0: x=showall(root,window,_numframes.get()) else: msg="You must input a file before using show all." msg=msg+" Click on the browse button to load a file." showwarning("Show All warning",msg) def startpan(): """Starts the panner function""" if os.path.exists("%s/ds9.reg" %_cwd): ans = askokcancel('File exists!',"Overwrite ds9.reg?") if ans: panner(root,window,_numframes.get()) else: panner(root,window,_numframes.get()) def startvcr(): """Starts the vcr function.""" if _all is not None and _all.num > 0: if os.path.exists("%s/vcr_%s.dat" %(_cwd,window)): ans = askokcancel('File exists!', "Overwrite vcr_%s.dat?" %window) if ans: x=vcr(root,_cwd,_numframes.get(),window) else: x=vcr(root,_cwd,_numframes.get(),window) else: msg="You must input a file before starting the vcr." msg=msg+" Click on the browse button to load a file." showwarning("VCR warning",msg) root = Tk() root.title("p6 ds9 - %s" %window) root.config(background=_CHROME_COLOR) _numframes=IntVar() _numframes.set(numframes) fileformats = readin.AllowedTypes f0 = Frame(root,background=_CHROME_COLOR) r = readdata(f0,window) r.grid(row=0,column=0,columnspan=3,sticky=E) Label(f0,text="# Frames",background=_CHROME_COLOR).grid(row=2,column=0) a = myOptionMenu(f0,_numframes,*range(1,_maxframe+1)) a.grid(row=2,column=1) a.config(bd=1,activebackground=_HIGHLIGHT_COLOR) Button(f0,text="Load",command=load,bd=1,activebackground=_HIGHLIGHT_COLOR).grid(row=2,column=2,sticky=E) f0.pack(pady=5,padx=5) f1 = Frame(root,background=_CHROME_COLOR) Button(f1,text="VCR",command=startvcr,bd=1,activebackground=_HIGHLIGHT_COLOR).pack(side=LEFT,padx=5) Button(f1,text="Show All",command=startshowall,bd=1,activebackground=_HIGHLIGHT_COLOR).pack(side=LEFT,padx=5) Button(f1,text="Pan",command=startpan,bd=1,activebackground=_HIGHLIGHT_COLOR).pack(side=LEFT,padx=5) f1.pack(pady=5) if infile is not None: temp = os.path.abspath(infile) temp = os.path.split(temp) r.dir.set(temp[0]) r.name.set(temp[1]) r.dostuff() root.mainloop()
# code to make GUI root = Tk() root.title("Danube %s" % ds9WindowName) # Image frame image = LabelFrame(root, text="Image") ds9ImageColorMap = StringVar() ds9ImageScale = StringVar() ds9ImageLimits = StringVar() ds9ImageMin = DoubleVar() ds9ImageMax = DoubleVar() ds9ImageInvert = IntVar() _sf1 = Frame(image) myOptionMenu(_sf1, ds9ImageColorMap, command=cmdImageColorMap, *_lvlsColorMap).pack(side="left", padx=1) myOptionMenu(_sf1, ds9ImageScale, command=cmdImageScale, *_lvlsScale).pack(side="left", padx=1) myOptionMenu(_sf1, ds9ImageLimits, command=cmdImageLimits, *_lvlsLimits).pack(side="left", padx=1) _sf2 = Frame(image) Checkbutton(_sf2, text="Invert Colormap", variable=ds9ImageInvert, command=cmdImageInvert, bd=1).pack(side="left") _sf3 = Frame(image) Label(_sf3, text="min:").pack(side="left", padx=1) Entry(_sf3, textvariable=ds9ImageMin, bg="white", width=10, bd=1).pack(side="left", padx=1) Label(_sf3, text="max:").pack(side="left", padx=1) Entry(_sf3, textvariable=ds9ImageMax, bg="white", width=10, bd=1).pack(side="left", padx=1) Button(_sf3, text="set", bd=1, command=cmdSetImageLimits).pack(side="left", padx=1) _sf4 = Frame(image) Button(_sf4, text="Open Single", command=cmdImageOpen, bd=1).pack(side=LEFT, padx=2.5)