Beispiel #1
0
 def __init__(self,parent,cwd,numframes,window):
    self._scaletype = StringVar()
    self._scaletype.set("zscale")
    self.n = _all.num
    self.cwd = cwd
    self.numframes = numframes # number of ds9 frames
    self.window = window       # string name of ds9 window
    self.idx_on_stack = None   # Family ID number of current family on stack
    self.idx = 0               # family ID of family being shown
    
    self.fp=open("%s/vcr_%s.dat" %(self.cwd,self.window),"w")
    _all.writeHeader(self.fp)
    self.fp.close()
    
    os.system('xpaset -p %s regions format ds9' %self.window)
    ds9.setNumFrames(numframes)
    ds9.init(self.window)
    ds9.scaleAll(self.window,self._scaletype.get()) # start on zscale
    
    Toplevel.__init__(self, parent,background=_CHROME_COLOR)
    self.transient(parent)
    self.title('VCR')
    self.parent = parent
    body = Frame(self,background=_CHROME_COLOR)
    self.initial_focus = self.body(body)
    body.pack(padx=5, pady=5,fill=BOTH,expand=1)
    self.buttonbox()
    self.grab_set()
    if not self.initial_focus:
       self.initial_focus = self
    self.protocol("WM_DELETE_WINDOW", self.cancel)
    self.initial_focus.focus_set()
    self.wait_window(self)
Beispiel #2
0
def panner(root,window,numframes):
   """Create four simple buttons to pan up,down,left and right"""

   def changedelta():
      """Customize the amount of shift in x and y when panning.  Default is
         delta x = 600, delta y = 300"""
      getdeltaxy(top)

   def save(event=None):
      os.system('xpaset -p %s regions save %s/ds9.reg' %(window,_cwd))

   def dopan(event=None):
      """Pan up/down/left/right"""
      os.system('xpaset -p %s pan %s' %(window,direction))

   def panup(event=None):
      dopan("0 %d" %_DELTA_Y)

   def panleft(event=None):
      dopan("-%d 0" %_DELTA_X)

   def panright(event=None):
      dopan("%d 0" %_DELTA_X)

   def pandown(event=None):
      dopan("0 -%d" %_DELTA_Y)

   def scale(event=None):
      ds9.scaleAll(window,_scaletype.get())

   def switchscale(event=None):
      """Switch current scaling to another option (zscale or hist eq)"""

      temp = _scaletype.get()
      if temp =='99.5':
         _scaletype.set('zscale')
         a.config(text="99.5")
      elif temp =='zscale':
         _scaletype.set('99.5')
         a.config(text="zscale")
      ds9.scaleAll(window,_scaletype.get())

   def cancel(event=None):

      save()
      blah = ds9.getRegion(window).split('\n')
      if len(blah) <= 3:
         os.remove('%s/ds9.reg' %_cwd)
      root.focus_set()
      top.destroy()

   top = Toplevel(root,background=_CHROME_COLOR)
   top.transient(root)
   top.grab_set()
   top.title("Panner")
   top.bind("<Escape>",cancel)
   top.bind("<Right>",panright)
   top.bind("<Left>",panleft)
   top.bind("<Up>",panup)
   top.bind("<Down>",pandown)
   top.bind("<Return>",save)
   top.bind("<space>",switchscale)
   top.geometry("%dx%d" %(120,150))
   top.focus_set()
   top.protocol("WM_DELETE_WINDOW", cancel)
   _scaletype = StringVar()
   _scaletype.set('zscale')
   ds9.setNumFrames(numframes)
   f0 = Frame(top,background=_CHROME_COLOR)
   Button(f0,text='delta',command=changedelta,bd=1,activebackground=_HIGHLIGHT_COLOR).pack(side=LEFT)
   Button(f0,text="save",command=save,bd=1,activebackground=_HIGHLIGHT_COLOR).pack(side=LEFT)
   f0.pack(pady=5)
   f1 = Frame(top,background=_CHROME_COLOR)
   Button(f1,text="^",command=panup,bd=1,activebackground=_HIGHLIGHT_COLOR).grid(row=0,column=1)
   Button(f1,text="<",command=panleft,bd=1,activebackground=_HIGHLIGHT_COLOR).grid(row=1,column=0)
   Button(f1,text=">",command=panright,bd=1,activebackground=_HIGHLIGHT_COLOR).grid(row=1,column=2)
   Button(f1,text="v",command=pandown,bd=1,activebackground=_HIGHLIGHT_COLOR).grid(row=2,column=1)
   f1.pack()
   f2 = Frame(top,background=_CHROME_COLOR)
   a = Button(f2,text="99.5",command=switchscale,bd=1,activebackground=_HIGHLIGHT_COLOR)
   a.pack()
   f2.pack(pady=5)
   ds9.scaleAll(window,_scaletype.get())
   os.system('xpaset -p %s mode pointer' %window)
   top.mainloop()