Ejemplo n.º 1
0
    def initUI(self):
      
        self.parent.title("Batch Geocoder")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(x=50, y=50)
        
        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)
        
        scrollbar = Scrollbar(self)
        scrollbar.pack( side = RIGHT, fill=Y)
        
		
        fileMenu = Menu(menubar)
        fileMenu.add_command(label="Run", command=self.onOpen)
        fileMenu.add_command(label="Exit", underline=0, command=self.onExit)
        
        menubar.add_cascade(label="File", menu=fileMenu)
        #menubar.add_command(label="Run", command=self.runScript)
        
        self.txt = Text(self, yscrollcommand = scrollbar.set)
        scrollbar.config( command = self.txt.yview )
        self.txt.pack(fill=BOTH, expand=1)
Ejemplo n.º 2
0
    def initUI(self):
        self.parent.title("Example")
        self.pack(fill=BOTH, expand=1)

        self.style = Style()
        self.style.theme_use("default")

        frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1)
        frame.pack(fill=BOTH, expand=1)

        okButton = Button(self, text="OK")
        okButton.place(x=self.width - 200, y=self.height - 100)

        quitButton = Button(self.parent, text="QUIT")
        quitButton.place(x=self.width - 100, y=self.height - 100)

        scale = 0.75
        self.wow_pic = Image.open("hd_1.jpg")
        self.wow_pic = self.wow_pic.resize(
            (int(self.width * scale), int(self.height * scale)))
        self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic)
        self.label_wow_pic = Label(self, image=self.wow_pic_tk)
        self.label_wow_pic.image = self.wow_pic_tk
        self.label_wow_pic.place(x=10, y=10)

        info_x = int(self.width * scale) + 20

        label_text_area = Tkinter.Label(self, text="Message received:")
        label_text_area.place(x=info_x, y=10)

        self.text_area = Tkinter.Text(self, height=10, width=40)
        self.text_area.place(x=info_x, y=30)
Ejemplo n.º 3
0
 def initUI(self):
   
     self.parent.title("FirstGUI")
     self.pack(fill=BOTH, expand=1)
     
     quitButton = Button(self, text="Quit", command=self.quit)
     quitButton.place(x=100, y=100)
Ejemplo n.º 4
0
    def initUI(self):
        self.parent.title("Example")
        self.pack(fill=BOTH, expand = 1)

        self.style = Style()
        self.style.theme_use("default")

        frame = Frame(self, relief=Tkinter.RAISED, borderwidth=1)
        frame.pack(fill=BOTH, expand=1)
     
        okButton = Button(self, text = "OK")
        okButton.place(x = self.width - 200, y = self.height - 100)

        quitButton = Button(self.parent, text = "QUIT")
        quitButton.place(x = self.width - 100, y = self.height - 100)
       
        scale = 0.75
        self.wow_pic = Image.open("hd_1.jpg")
        self.wow_pic = self.wow_pic.resize((int(self.width*scale), int(self.height*scale)))
        self.wow_pic_tk = ImageTk.PhotoImage(self.wow_pic)
        self.label_wow_pic = Label(self, image = self.wow_pic_tk)
        self.label_wow_pic.image = self.wow_pic_tk
        self.label_wow_pic.place(x = 10, y = 10)

        info_x = int(self.width*scale) + 20

        label_text_area = Tkinter.Label(self, text = "Message received:")
        label_text_area.place(x = info_x, y = 10)

        self.text_area = Tkinter.Text(self, height = 10, width = 40)
        self.text_area.place(x = info_x, y = 30)
Ejemplo n.º 5
0
    def initUI(self):

        self.style = Style().configure("TFrame",
                                       background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)

        # setup labels
        self.Embedded = Label(self,
                              width=15,
                              background=self.sys.win_cfg.cUnknown,
                              text="LED: COM0")
        self.Embedded.place(x=15, y=35)
        self.Stage = Label(self,
                           width=15,
                           background=self.sys.win_cfg.cUnknown,
                           text="Stages: COM0")
        self.Stage.place(x=15, y=60)

        # setup buttons
        configComButton = Button(self,
                                 text="COM Port Setup",
                                 command=self.com_port_search,
                                 width=17)
        configComButton.place(x=15, y=5)

        # close buttons
        closeButton = Button(self,
                             text="Close",
                             command=self.close_window,
                             width=17)
        closeButton.place(x=15, y=90)
Ejemplo n.º 6
0
    def initUI(self):

        self.parent.title("Batch Geocoder")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(x=50, y=50)

        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        scrollbar = Scrollbar(self)
        scrollbar.pack(side=RIGHT, fill=Y)

        fileMenu = Menu(menubar)
        fileMenu.add_command(label="Run", command=self.onOpen)
        fileMenu.add_command(label="Exit", underline=0, command=self.onExit)

        menubar.add_cascade(label="File", menu=fileMenu)
        #menubar.add_command(label="Run", command=self.runScript)

        self.txt = Text(self, yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.txt.yview)
        self.txt.pack(fill=BOTH, expand=1)
Ejemplo n.º 7
0
    def initUI(self):

        self.parent.title("FirstGUI")
        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(x=100, y=100)
    def initUI(self):
        self.parent.title("Image Copy-Move Detection")
        self.style = Style().configure("TFrame", background="#333")
        # self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Open File", command=self.onFilePicker)
        quitButton.place(x=10, y=10)

        printButton = Button(self, text="Detect", command=self.onDetect)
        printButton.place(x=10, y=40)

        self.textBoxFile = Text(self, state='disabled', width=80, height = 1)
        self.textBoxFile.place(x=90, y=10)

        self.textBoxLog = Text(self, state='disabled', width=40, height=3)
        self.textBoxLog.place(x=90, y=40)

        # absolute image widget
        imageLeft = Image.open("resource/empty.png")
        imageLeftLabel = ImageTk.PhotoImage(imageLeft)
        self.labelLeft = Label(self, image=imageLeftLabel)
        self.labelLeft.image = imageLeftLabel
        self.labelLeft.place(x=5, y=100)

        imageRight = Image.open("resource/empty.png")
        imageRightLabel = ImageTk.PhotoImage(imageRight)
        self.labelRight = Label(self, image=imageRightLabel)
        self.labelRight.image = imageRightLabel
        self.labelRight.place(x=525, y=100)

        self.centerWindow()
Ejemplo n.º 9
0
    def initUI(self):

        self.style = Style().configure("TFrame", background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)


        # setup labels
        self.LED1 = Label(self, width=4, background=self.sys.win_cfg.cLEDOff, text="LED1")
        self.LED1.place(x=98, y=45)
        self.LED2 = Label(self, width=4, background=self.sys.win_cfg.cLEDOff, text="LED2")
        self.LED2.place(x=98, y=75)
        self.LED3 = Label(self, width=4, background=self.sys.win_cfg.cLEDOff, text="LED3")
        self.LED3.place(x=98, y=105)
        self.LED4 = Label(self, width=4, background=self.sys.win_cfg.cLEDOff, text="LED4")
        self.LED4.place(x=98, y=135)
        
        # setup entries
        
        titleLabel = Label(self, text=self.sys.win_cfg.sLEDAdvanced,
                             background=self.sys.win_cfg.cBackground,
                             width=12, height=1)
        titleLabel.place(x=5, y=5)
        percentLabel = Label(self, text="0-100 (%)",
                             background=self.sys.win_cfg.cBackground,
                             width=8, height=1)
        percentLabel.place(x=5, y=22)
        self.led1val = Entry(self, width=4, 
                           background=self.sys.win_cfg.cTextBackground)
        self.led1val.place(x=10, y=50-4)
        self.led2val = Entry(self, width=4,
                           background=self.sys.win_cfg.cTextBackground)
        self.led2val.place(x=10, y=80-4)
        self.led3val = Entry(self, width=4,
                           background=self.sys.win_cfg.cTextBackground)
        self.led3val.place(x=10, y=110-4)
        self.led4val = Entry(self, width=4,
                           background=self.sys.win_cfg.cTextBackground)
        self.led4val.place(x=10, y=140)
        
        # setup buttons
        led1onButton = Button(self, text="LED1",
            command=self.led1_on,  width=6)
        led1onButton.place(x=45, y=45)
        led2onButton = Button(self, text="LED2",
            command=self.led2_on,  width=6)
        led2onButton.place(x=45, y=75)
        led3onButton = Button(self, text="LED3",
            command=self.led3_on,  width=6)
        led3onButton.place(x=45, y=105)
        led4onButton = Button(self, text="LED4",
            command=self.led4_on,  width=6)
        led4onButton.place(x=45, y=135)

        # close buttons
        closeButton = Button(self, text="Close",
            command=self.close_window)
        closeButton.place(x=30, y=180)
        
        self.update_duty()
Ejemplo n.º 10
0
 def initUI(self):
   
     self.parent.title("Simple")
     self.pack(fill=BOTH, expand=1)
     self.centerWindow()
     
     quitButton = Button(self, text="Quit", command=self.quit)
     quitButton.place(x=50, y=50)
Ejemplo n.º 11
0
 def initUI(self):
     self.parent.title('Simple')
     self.style = Style()
     self.style.theme_use('default')
     self.pack(fill=BOTH, expand=1)
     # self.centerWindow()
     quitButton = Button(self, text='Quit', command=self.quit)
     quitButton.place(x=50, y=50)
Ejemplo n.º 12
0
Archivo: knn.py Proyecto: tifoit/knn-1
    def init_ui(self):
        self.parent.title("knn - Classification")
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)
        self.center_window()
        quit_button = Button(self, text="Close", command=self.quit)
        quit_button.place(x=50, y=50)
Ejemplo n.º 13
0
Archivo: knn.py Proyecto: tifoit/knn-1
    def init_ui(self):
        self.parent.title("knn - Classification")
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)
        self.center_window()
        quit_button = Button(self, text="Close", command=self.quit)
        quit_button.place(x=50, y=50)
Ejemplo n.º 14
0
    def initUI(self,parent):
        self.parent.title("Quit Button")
        self.style= Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH,expand=1)
        quitbutton=Button(self,text="Quit",command=parent.destroy)
        quitbutton.place(x=50,y=50)
Ejemplo n.º 15
0
    def initUI(self):

        var = IntVar()

        #General stuff
        self.parent.title("I2C Command Manager")
        self.style = Style()
        self.style.theme_use("default")
        #self.pack(fill=BOTH, expand=1)
        self.parent.configure(background=Constants.BG_COL)

        s = Style()
        s.configure('C.TRadiobutton', background=Constants.BG_COL)

        #Quit button
        quitButton = Button(self.parent, text="Quit", command=self.quit)
        quitButton.place(x=Constants.QUIT_X, y=Constants.QUIT_Y)

        #Radiobuttons
        ledRadio = Radiobutton(
            self.parent,
            text="LED Strip",
            variable=var,
            value=1,
            command=lambda: self.instructor.setAddress(0x04),
            style='C.TRadiobutton')
        vertRadio = Radiobutton(
            self.parent,
            text="Vertical Motion",
            variable=var,
            value=2,
            command=lambda: self.instructor.setAddress(0x06),
            style='C.TRadiobutton')
        ledRadio.place(x=Constants.LED_X, y=Constants.LED_Y)
        vertRadio.place(x=Constants.VERT_X, y=Constants.VERT_Y)
        #ledRadio.configure(background = Constants.BG_COL)

        #Label
        sendLabel = Label(self.parent,
                          text="Enter command:",
                          background=Constants.BG_COL)
        sendLabel.place(x=Constants.SENDL_X, y=Constants.SENDL_Y)

        #Address label
        adLabel = Label(self.parent,
                        text="Select address:",
                        background=Constants.BG_COL)
        adLabel.place(x=Constants.ADL_X, y=Constants.ADL_Y)

        #Text entry box
        textBox = Entry(self.parent, bd=2, width=Constants.TEXT_W)
        textBox.place(x=Constants.TEXT_X, y=Constants.TEXT_Y)

        #Send command button
        sendButton = Button(self.parent,
                            text="Send",
                            command=lambda: self.assignCommand(textBox.get()))
        sendButton.place(x=Constants.SENDB_X, y=Constants.SENDB_Y)
Ejemplo n.º 16
0
    def add_button(self, name, func, loc, **kwargs):
        """Adds a button in the desired location of the SubFrame"""

        # set title of button
        print (func, kwargs)
        button = Button(self, text=name, command=func, **kwargs)

        # place the button
        button.place(x=loc[0], y=loc[1])
Ejemplo n.º 17
0
	def initUI(self):
		self.parent.title("Sample Button")
		self.style = Style()
		self.style.theme_use("default")

		self.pack(fill=BOTH, expand=1)

		quitButton = Button(self, text="Quit", command=self.quit)
		quitButton.place(x=50, y=50)
Ejemplo n.º 18
0
    def initUI(self):
        self.parent.title("Quit button")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(x=50, y=50)
Ejemplo n.º 19
0
    def initUI(self):

        self.parent.title("PyPass Manager by adb")
        self.style = Style()
        self.style.theme_use("clam")

        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Exit", command=self.quit)
        quitButton.place(x=50, y=50)
Ejemplo n.º 20
0
    def initUI(self):
        self.parent.title("Quit button")
        
        # Styling the frame 
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit",command=self.quit)
        quitButton.place(x=100, y=100)
Ejemplo n.º 21
0
    def initUI(self):
      
        self.parent.title("We shall eat")
        self.style = Style()
        self.style.theme_use("aqua")

        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="%s" % restaurant,
            command=self.quit)
        quitButton.place(x=50, y=50)
Ejemplo n.º 22
0
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.parent.title("Centered Window with quit button")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()

        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(x=50, y=50)
Ejemplo n.º 23
0
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.parent.title("Centered Window with quit button")
        self.style=Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()

        quitButton = Button(self,text="Quit",command=self.quit)
        quitButton.place(x=50,y=50)
Ejemplo n.º 24
0
    def startButton(self):
	    self.style = Style()
	    self.style.theme_use("default")
	    
	    self.pack(fill=BOTH, expand=1)
	    
	    startButton = Button(self, text="Start   -->", command=startMonitor)

	    # to calculate where to put button
	    x1 = w - w/3 + 10
	    y1 = h/5
	    startButton.place(x=x1, y=y1)
Ejemplo n.º 25
0
    def backButton(self):
	    self.style = Style()
	    self.style.theme_use("default")
	    
	    self.pack(fill=BOTH, expand=1)
	    
	    backButton = Button(self, text="<--   Back", command=callInputWindow)

	    # to calculate where to put button
	    x1 = w/16 - 10
	    y1 = h/5
	    backButton.place(x=x1, y=y1)
Ejemplo n.º 26
0
  def initUI(self):
      self.parent.title("Calendar Entry")
      self.style = Style()
      self.style.theme_use("alt")
      self.pack(fill = BOTH, expand = 1)
      
      quitButton = Button(self, text = "Quit", command = self.quit)
      quitButton.place(x = 425, y = 475)
 # def googleLogin(self):
      entry = Entry(self)
      entry.place(x = 200, y = 70)
      username = entry.get()
Ejemplo n.º 27
0
    def initUI(self):
      
        self.parent.title("Quit button")
        self.style = Style()
        self.style.theme_use("default")

        #Expand the frame to fill the parent window in both directions
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()
        
        #Create a quit button (Stops the program but does not close the window!)
        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(x=50, y=50)
Ejemplo n.º 28
0
    def quitButton(self):
	    
	    self.style = Style()
	    self.style.theme_use("default")
	    
	    self.pack(fill=BOTH, expand=2)
	    
	    quitButton = Button(self, text="Quit", command=quitMonitor)
	    
	    # to calculate where to put button
	    x1 = w/3 + 10
	    y1 = h/5
	    quitButton.place(x=x1, y=y1)
    def initUI(self):
        self.parent.title("Slave Python GUI - Aleix")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit",
                            command=self.OnQuitButtonClick)

        #We use the place geometry manager to position the button in absolute coordinates. 50x50px from the top-left corner of the window.
        quitButton.place(x=140, y=140)

        setupYellowLedOff(root)
        setupRedLedOff(root)
Ejemplo n.º 30
0
    def initUI(self):
        self.parent.title("Tomates")
        self.pack(fill=BOTH, expand=True)
        Style().configure("TFrame", background="#333")
        # self.imagen("inicio.jpg")
        self.salida1("")
        self.salida2("")
        self.salida3("")
        self.estado("")

        AbrirButton = Button(self, text="Abrir")
        AbrirButton.pack(side=RIGHT, padx=5, pady=5)
        AbrirButton.place(x=800, y=25)
        AbrirButton["command"] = self.abrir

        label = Label(self,
                      text="Datos de salida",
                      fg="#F66",
                      bg="#333",
                      font="Helvetica 16 bold italic")
        label.place(x=550, y=60)

        label = Label(self,
                      text="P Salida1:",
                      fg="#FF5",
                      bg="#333",
                      font="Helvetica 16 bold italic")
        label.place(x=500, y=150)

        label = Label(self,
                      text="M Salida2:",
                      fg="#FF5",
                      bg="#333",
                      font="Helvetica 16 bold italic")
        label.place(x=500, y=200)

        label = Label(self,
                      text="V Salida3:",
                      fg="#FF5",
                      bg="#333",
                      font="Helvetica 16 bold italic")
        label.place(x=500, y=250)

        label = Label(self,
                      text="Estado del tomate:",
                      fg="#0040ff",
                      bg="#333",
                      font="Helvetica 16 bold italic")
        label.place(x=500, y=300)
        """
Ejemplo n.º 31
0
    def initUI(self):
        #sets the title of the window  
        self.parent.title("Do you dare to Zlatan?")
        self.style = Style()
        self.style.theme_use("alt")
        #creates an object for the window
        self.pack(fill=BOTH, expand=1)
        #makes buttons
        quitButton = Button(self, text="No, Zlatan sucks",
            command=self.quit)
        quitButton.place(x=30, y=50)

        webbutton = Button(self, text="Yes, #DaretoZlatan", command=self.OpenUrl)
        webbutton.place(x=130, y=50)
Ejemplo n.º 32
0
 def initUI(self):
     self.parent.title("Quit button")
     self.style = Style()
     self.style.theme_use("default")
     #We apply a theme for our widgets. 
     #Some of the supported themes are clam, default, alt or classic.
     self.pack(fill=BOTH, expand=1)
     quitButton = Button(self, text="Quit", command=self.quit)
     #We create an instance of the Button widget. 
     #The parent of this button is the Frame container. 
     #We provide a label for the button and a command. 
     #The command specifies a method that is called when we press the button. 
     #In our case the quit() method is called, which terminates the application.
     quitButton.place(x=50, y=50)
    def initUI(self):
        """Adds a Tkinter canvas element that tracks mouse clicks to select image region for saving"""
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        
        self.canvas = Tkinter.Canvas(self, width = self.image.width(), height = self.image.height())       
        self.canvas.bind("<Button-1>", self.OnMouseDown)
        self.canvas.pack()
        
        nextButton = Button(self, text="Next", command=self.nextButton)
        nextButton.place(x=0, y=0)

        resetButton = Button(self, text="Reset", command=self.reset)
        resetButton.place(x=0, y=22)
Ejemplo n.º 34
0
    def initUI(self):
        self.parent.title("HamPi")
        self.pack(fill=BOTH, expand=2)

        # self.parent.title("Process button")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        processButton = Button(self, text="Process", command=self.run)
        processButton.place(x=60, y=10)

        quitButton = Button(self, text="Quit", command=self.close)
        quitButton.place(x=140, y=10)
Ejemplo n.º 35
0
    def initUI(self):

        #<standard set up>
        self.parent.title("Quit Button")
        self.style = Style()
        self.style.theme_use("default")
        #</standard set up>

        #<assuming we use no or pack manager frame is normal>
        self.pack(fill=BOTH, expand=1)
        
        
        #<adding quit button>
        quitButton = Button(self, text="Quit",command = self.quit)#operation
        quitButton.place(x=50, y=50)#placing
Ejemplo n.º 36
0
	def initUI(self):
		self.parent.title("Demo Program")
		self.style = Style()
		self.style.theme_use("default")

		self.pack(fill=BOTH, expand=1)

		# A real Organelle app would not have a Quit button
		# This is just for debug purposes.
		quitButton = Button(self, text="Quit", command=self.quit)
		quitButton.place(x=50,y=50)

		# A real Organelle app wouldn't use the command line
		# arguments, either. This just gives us a way to use
		# a single demo app to stand in for many apps.
		messageLabel = Label(self, text=sys.argv[1], fg="red", font=("Helvetica", 144))
		messageLabel.place(x=100, y=100)
Ejemplo n.º 37
0
    def initUI(self):
        self.centerWindow()

        self.parent.title("Cursor")
        self.style = Style()
        self.style.theme_use("clam")
        self.style.configure("TFrame")

        self.pack(fill=BOTH, expand=1)

        self.label = Label(self)
        self.label.configure(text="Hold your hand above the device for two seconds...")
        self.label.place(x=50, y=50)

        quitButton = Button(self, text="Quit",
                            command=self.quit)
        quitButton.place(x=50, y=100)
Ejemplo n.º 38
0
    def initUI(self):
        self.parent.title("Proyecto Guardian del Bosque")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)
        self.check_var1 = IntVar()
        self.check_var2 = IntVar()
        self.check_var3 = IntVar()
        self.path_video = StringVar()
        self.path_video1 = StringVar()
        lbl_title = Label(self, text="Proyecto Guardian del bosque")
        lbl_title.place(x=280, y=10)
        image = Image.open("images/img.png")
        photo = ImageTk.PhotoImage(image)
        lbl_image = Label(image=photo)
        lbl_image.image = photo
        lbl_image.place(x=550, y=50)

        image1 = Image.open("images/img1.png")
        photo1 = ImageTk.PhotoImage(image1)
        lbl_image1 = Label(image=photo1)
        lbl_image1.image = photo1
        lbl_image1.place(x=50, y=300)

        lbl_path1 = Label(
            self, text="Ingrese la direccion de la primera imagen(actual): ")
        lbl_path1.place(x=20, y=50)
        entry_path1 = Entry(self, textvariable=self.path_video, width=60)
        entry_path1.place(x=20, y=80)

        lbl_path2 = Label(
            self, text="Ingrese la direccion de la segunda imagen(anterior): ")
        lbl_path2.place(x=20, y=110)

        entry_path2 = Entry(self, textvariable=self.path_video1, width=60)
        entry_path2.place(x=20, y=140)

        button_detect = Button(self,
                               text="Detectar",
                               command=self.detect,
                               width=20)
        button_detect.place(x=60, y=180)

        button_quit = Button(self, text="Salir", command=self.quit, width=20)
        button_quit.place(x=280, y=180)
Ejemplo n.º 39
0
    def initUI(self):
        self.parent.title("Computação Gráfica - UFT")
        self.style = Style()
        self.style.theme_use("default")
        self.pack()  # apenas um teste

        # botao para tracar a reta
        okButton = Button(self, text="OK")
        okButton.place(x=300, y=430)
        okButton.pack()

        # botao para fechar a aplicação
        quitButton = Button(
            self, text="Fechar",
            command=self.quit)  # o titulo do botao deveria ser Sair
        quitButton.place(
            x=300,
            y=460)  # posiciona o botão nas coordenadas aqui especificadas
        quitButton.pack()
Ejemplo n.º 40
0
    def initUI(self):
        self.parent.title("Y.tube Ü.rl L.ist É.xtrapolator")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        global urlList, Stats, Whatsup, whatsup
        Whatsup.set(whatsup)
        stats = "SUCCESS: " + str(len(urlList)) + "\nFAIL: " + str(len(urlBList))
        Stats.set(stats)
        mainLabel = tk.Label(self, textvariable = Stats)
        mainLabel.pack()
        quitButton = Button(self, text="Save & Quit",
            command=self.saveQuit)
        quitButton.place(x=85, y=80)
        goButton = Button(self, command=self.goPher, textvariable = Whatsup)
        goButton.place(x=5, y=80)
        goButton.pack()
	def initUI(self):
		self.parent.title("Facial Expression Recognizer")
		self.style = Style()
		self.style.theme_use("default")
		self.pack(fill=BOTH, expand=1)

		self.file_opt = options = {}
		options['defaultextension'] = '.txt'
		options['filetypes'] = [('all files', '.*'),('JPG', '.jpg'),('GIF','.gif'),('PNG','.png')]
		options['initialdir'] = ''
		options['initialfile'] = ''
		options['parent'] = self.parent
		options['title'] = 'Choose 48x48 Grayscale Image...'
		
		loadButton = Button(self, text="Load",command=self.load_image)
		loadButton.place(x=215, y=265)

		runButton = Button(self, text="Run",command=self.classify)
		runButton.place(x=305, y=265)
Ejemplo n.º 42
0
    def initUI(self):

        self.parent.title("Finger Putty")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        # Logo text
        # logoText = Text(self)

        # OS drop-down button
        variable = StringVar(self)
        variable.set("Linux")

        osDropdownButton = OptionMenu(self, variable, "Choose your OS",
                                      "Linux", "Windows", "Playstation",
                                      "Revert Defaults")
        osDropdownButton.pack()
        osDropdownButton.place(x=50, y=50)

        # Set (OS) fingerprint button
        def fcallback():
            if variable.get() == "Revert Defaults":
                setctl.defaults()
            elif variable.get() != "Choose your OS":
                setctl.control(variable.get())

        changePrintButton = Button(self,
                                   text="Set fingerprint",
                                   command=fcallback)
        changePrintButton.place(x=50, y=80)

        # Launch browser button
        def bcallback():
            useragent.getVersion()
            useragent.launchBrowser()

        launchButton = Button(self,
                              text="Launch browser (new user-agent)",
                              command=bcallback)
        launchButton.place(x=50, y=110)
Ejemplo n.º 43
0
    def initUI(self):
      
        self.parent.title("Finger Putty")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        # Logo text
        # logoText = Text(self)

        # OS drop-down button
        variable = StringVar(self)
        variable.set("Linux")

        osDropdownButton = OptionMenu(self, variable, "Choose your OS", 
                                                      "Linux", 
                                                      "Windows", 
                                                      "Playstation", 
                                                      "Revert Defaults")
        osDropdownButton.pack()
        osDropdownButton.place(x=50, y=50)

        # Set (OS) fingerprint button
        def fcallback():
            if variable.get() == "Revert Defaults":
                setctl.defaults()
            elif variable.get() != "Choose your OS":
                setctl.control(variable.get())

        changePrintButton = Button(self, text="Set fingerprint",
            command=fcallback)
        changePrintButton.place(x=50, y=80)

        # Launch browser button
        def bcallback():
            useragent.getVersion()
            useragent.launchBrowser()

        launchButton = Button(self, text="Launch browser (new user-agent)",
            command=bcallback)
        launchButton.place(x=50, y=110)
Ejemplo n.º 44
0
    def init_ui(self):
        self.parent.title("VV-VolumeViewer")
        self.pack(fill=BOTH, expand=1)

        # Menu stuff
        menu_bar = Menu(self.parent)
        menu = Menu(menu_bar, tearoff=0)
        menu_bar.add_cascade(label="File", menu=menu)
        menu_bar.add_cascade(label="Help", menu=menu)
        self.parent.config(menu=menu_bar)

        # Left frame
        left_frame = Frame(self)
        left_frame.configure(borderwidth=1.5, background='black', width=200)

        # volume frame
        canvas_frame = Frame(self)
        canvas_frame.configure(borderwidth=1.5, background='white')
        self.canvas = Canvas(canvas_frame,
                             highlightthickness=0,
                             background='black')
        self.canvas.bind_all("<Button-4>", self._on_mousewheel)
        self.canvas.bind_all("<Button-5>", self._on_mousewheel)

        test_button = Button(left_frame,
                             text="PrintSize",
                             command=self.print_size,
                             style="TButton")
        self.bind("<Configure>", self.print_size)
        self.canvas.bind("<Configure>", self.render_image)

        # canvas.pack(side = TOP, expand=True, fill=BOTH)
        # canvas.place(x=20, y=10)

        console = Text(self, height=12)

        left_frame.pack(side=LEFT, fill=Y)
        canvas_frame.pack(fill=BOTH, expand=1)
        self.canvas.pack(fill=BOTH, expand=1)
        console.pack(side=BOTTOM, fill=X)
        test_button.pack()
        test_button.place(x=10, y=10)
Ejemplo n.º 45
0
    def init_ui(self):
        self.parent.title("Image enhancement")
        self.pack(fill=BOTH, expand=1)
        self.center_window()

        openFileButton = Button(self, text="Choose image", command=self.open_file)
        openFileButton.place(x=50, y=50)

        self.runButton = Button(self, text="Enhance", command=self.run, state="disabled")
        self.runButton.place(x=200, y=50)

        membershipLabel = Label(text="Membership passes:")
        membershipLabel.place(x=50, y=120)
        self.membershipPassScale = LabeledScale(self, from_=1, to=10)
        self.membershipPassScale.place(x=250, y=100)

        intensifyLabel = Label(text="1st intensify passes:")
        intensifyLabel.place(x=50, y=170)
        self.intensifyPassScale = LabeledScale(self, from_=1, to=10)
        self.intensifyPassScale.place(x=250, y=150)

        convolveLabel = Label(text="Convolve:")
        convolveLabel.place(x=50, y=220)
        self.convolveCheckbutton = Checkbutton(self)
        self.convolveCheckbutton.place(x=250, y=220)
        self.convolveCheckbutton.invoke()

        secondIntensifyLabel = Label(text="2nd intensify passes:")
        secondIntensifyLabel.place(x=50, y=270)
        self.secondIntensifyPassScale = LabeledScale(self, from_=1, to=10)
        self.secondIntensifyPassScale.place(x=250, y=250)

        thresholdLabel = Label(text="Threshold:")
        thresholdLabel.place(x=50, y=320)
        self.thresholdScale = LabeledScale(self, from_=1, to=10)
        self.thresholdScale.place(x=250, y=300)
        self.thresholdScale.scale.set(5)

        powerLabel = Label(text="Power:")
        powerLabel.place(x=50, y=370)
        self.powerScale = LabeledScale(self, from_=2, to=5)
        self.powerScale.place(x=250, y=350)
Ejemplo n.º 46
0
    def initUI(self):
        w = self.parent.winfo_screenwidth() / 2
        h = self.parent.winfo_screenheight() / 2

        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()

        x = (sw - w) / 2
        y = (sh - h) / 2

        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))

        self.parent.title("myApp")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(x=w / 2, y=h / 2)
Ejemplo n.º 47
0
    def initUI(self):
        w = self.parent.winfo_screenwidth()/2
        h = self.parent.winfo_screenheight()/2

        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()

        x = (sw - w)/2
        y = (sh - h)/2

        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))

        self.parent.title("myApp")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self, text="Quit",
            command=self.quit)
        quitButton.place(x=w/2, y=h/2)
Ejemplo n.º 48
0
Archivo: gui.py Proyecto: OzTamir/oZip
 def initUI(self):
     ''' Create the UI '''
     # Name the window
     self.parent.title("oZip")
     self.pack(fill=BOTH, expand=1)
     
     # 'Add File' button
     addFileButton = Button(self, text="Add File",
         command=self.onOpen)
     addFileButton.place(x=225, y=30)
     
     # 'Go' button
     goButton = Button(self, text="Go",
         command=self.onClick)
     goButton.place(x=225, y=100)
     
     # 'Quit' button
     quitButton = Button(self, text="Quit",
         command=self.quit)
     quitButton.place(x=225, y=160)
     
     # Decompression checkbox
     self.cb = Checkbutton(self, text="Should decompress",
         command=self.checkboxClick)
     self.cb.place(x=20, y=195)
     
     # Selected files list
     lb = Listbox(self)
     self.lb = lb   
     lb.place(x=20, y=20)
Ejemplo n.º 49
0
    def initUI(self):

        self.style = Style().configure("TFrame", background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)
        
        titleLabel = Label(self, text=self.sys.win_cfg.sFileinfo,
                             background=self.sys.win_cfg.cBackground,
                             width=12, height=1)
        titleLabel.place(x=5, y=5)

        # file function buttons
        browseButton = Button(self, text="Browse",
            command=self.browse_folder, width=12)
        browseButton.place(x=15, y=40)
        
        netButton = Button(self, text="Net",
            command=self.net_check, width=8)
        netButton.place(x=125, y=40)
    
        chipIDLabel = Label(self, text="Chip ID: ",
                             background=self.sys.win_cfg.cBackground,
                             width=8, height=1)
        chipIDLabel.place(x=10, y=80)
        self.chipIDEntry = Entry(self, width=15,
                           background=self.sys.win_cfg.cTextBackground)
        self.chipIDEntry.place(x=85, y=80)
        
        self.chipIDEntry.insert(0, self.instant_chip_id())
        
        # close buttons
        closeButton = Button(self, text="Close",
            command=self.close_window, width=17)
        closeButton.place(x=15, y=140)
    def initUI(self):
        
        photo = ImageTk.PhotoImage(file='icon/main_bg_4.jpg')
        w = Tkinter.Label(self,image=photo)
        w.photo = photo 
        w.place(x=0, y=0, relwidth=1, relheight=1)
        #ackground_label.pack()
        
        
        self.api = IntVar()
        self.parent.title("Face Recognition System")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)
        
        faceplus = Radiobutton(self, text="Face++", variable=self.api, value=1)
        faceplus.place(x=50, y=40)
        
        facer = Radiobutton(self, text="FaceR Animetrics", variable=self.api, value=2)
        facer.place(x=200, y=40)

        start = Button(self, text="Start Recognition",
            command=self.startRecognition)
        start.place(x=100, y=80)
        
        helpButton = Button(self, text="Help",
            command=self.giveHelp)
        helpButton.place(x=100, y=110)
    
        quitButton = Button(self, text="Quit",
            command=self.quitGUI)
        quitButton.place(x=100, y=140)
Ejemplo n.º 51
0
    def initUI(self):

        self.style = Style().configure("TFrame",
                                       background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)

        # setup labels
        self.LED1 = Label(self,
                          width=10,
                          background=self.sys.win_cfg.cLEDOff,
                          text="LED1")
        self.LED1.place(x=30, y=10)

        #duty cycle

        # setup buttons
        ledonButton = Button(self, text="LED On", command=self.led_on)
        ledonButton.place(x=30, y=40)
        ledoffButton = Button(self, text="LED Off", command=self.led_off)
        ledoffButton.place(x=30, y=70)
        serialButton = Button(self,
                              text="Serial",
                              command=self.led_serial_status)
        serialButton.place(x=30, y=100)
        #ledstatusButton = Button(self, text="Status",
        #    command=self.led_status)
        #ledstatusButton.place(x=30, y=130)
        ledAdvButton = Button(self, text="Advanced", command=self.led_advanced)
        ledAdvButton.place(x=30, y=130)
        self.ledstatusLabel = Label(self,
                                    width=15,
                                    background=self.sys.win_cfg.cBackground,
                                    text="LED: Status: X")
        self.ledstatusLabel.place(x=15, y=158)

        # close buttons
        closeButton = Button(self, text="Close", command=self.close_window)
        closeButton.place(x=30, y=180)
Ejemplo n.º 52
0
    def initUI(self):

        self.style = Style().configure("TFrame",
                                       background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)

        # setup labels
        self.Vacuum = Label(self,
                            width=16,
                            background=self.sys.win_cfg.cLEDOff,
                            text="Idle")
        self.Vacuum.place(x=20, y=10)

        #duty cycle

        # setup buttons
        vacuumButton = Button(self,
                              text="Toggle Vacuum",
                              command=self.vacuum_toggle,
                              width=15)
        vacuumButton.place(x=30, y=40)
        valveutton = Button(self,
                            text="Toggle Valve",
                            command=self.valve_toggle,
                            width=15)
        valveutton.place(x=30, y=70)
        pressureButton = Button(self,
                                text="Measure Pressure",
                                command=self.measure_pressure,
                                width=15)
        pressureButton.place(x=30, y=100)

        self.statusLabel = Label(self,
                                 width=15,
                                 background=self.sys.win_cfg.cBackground,
                                 text="")
        self.statusLabel.place(x=15, y=130)

        # close buttons
        closeButton = Button(self,
                             text="Close",
                             command=self.close_window,
                             width=15)
        closeButton.place(x=30, y=160)
Ejemplo n.º 53
0
    def initUI(self):

        self.style = Style().configure("TFrame",
                                       background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)

        titleLabel = Label(self,
                           text=self.sys.win_cfg.sFocus,
                           background=self.sys.win_cfg.cBackground,
                           width=12,
                           height=1)
        titleLabel.place(x=5, y=5)

        # file function buttons
        coarseFocusButton = Button(self,
                                   text="Coarse",
                                   command=self.coarse_focus,
                                   width=17)
        coarseFocusButton.place(x=15, y=40)

        fineFocusButton = Button(self,
                                 text="Fine",
                                 command=self.fine_focus,
                                 width=17)
        fineFocusButton.place(x=15, y=80)

        halfButton = Button(self,
                            text="Center Corner",
                            command=self.center_corner,
                            width=17)
        halfButton.place(x=15, y=120)

        # close buttons
        closeButton = Button(self,
                             text="Close",
                             command=self.close_window,
                             width=17)
        closeButton.place(x=15, y=160)
Ejemplo n.º 54
0
class NGA_Window_LowMag(Frame):


    #homePos = [-10,0,2]
    homePos = [0,0,0]
    
    scanMirror = [2.3,-20,0] #for Dry

    options = [
        "NSF AIR - 90nm",
        "NV16 - 30nm",
        "NV10 - 90nm",
        "NV10B - 60nm",
        "NV16B - 60nm",
        "NV16B (dry) - 60nm"
    ]
    # Chip Modes: (*** note: ask Dave to make cooler chip names ***)
    #   1. NSF AIR - 90nm
    #   2. NV16 - 30nm
    #   3. NV10 - 90nm
    #   4. NV10B - 60nm
    #   5. NV16B - 60nm

    zoff = 0 #when stages are misaligned
    scanNSFAIR_1 = [-0.5,-18.1,-1+zoff]
    scanNSFAIR_2 = [-0.5,-18.1,-1+zoff]
    scanNV16_1 = [1.1,-18.1,-1+zoff] 
    scanNV16_2 = [1.1,-18.1,-1+zoff]
    scanNV10_1 = [2.3,-20,0+zoff] 
    scanNV10_2 = [2.3,-20,0+zoff] 
    scanNV10B_1 = [2.3,-20,0+zoff] 
    scanNV10B_2 = [2.3,-20,0+zoff] 
    scanNV16B_1 = [4.5,-20,0+zoff] 
    scanNV16B_2 = [4.5,-20,0+zoff]

    # Old modes commented out rather than deleted, for sanity.
    #scan90_1 = [1.0,-13.6,-1.4-1.8] #for Dry
    #scan90_2 = [1.0,-13.6,-1.85-1.8] #for Dry
    #scan60_1 = [1.0,-13.6,-1.2-1.8] #for Dry
    #scan60_2 = [1.0,-13.6,-1.85-1.8] #for Dry
    #scan30_1 = [2.6,-13.6,-1.4-1.8] #for Liquid
    #scan30_2 = [2.6,-13.6,-1.85-1.8] #for Liquid
    #scan60Long_1 = [4.0,-13.6,-1.2-1.8] #for Dry Long
    #scan60Long_2 = [4.0,-13.6,-1.85-1.8] #for Dry Long
     

    def __init__(self,parent,sys):
        Frame.__init__(self,parent)

        self.parent = parent
        self.sys = sys

        self.sys.c_lowmag = self

        self.parent.geometry(self.sys.win_cfg.wLowMag)
        self.parent.title(self.sys.win_cfg.sLowMag)
        
        self.sys.c_cam.setup_camera()
        self.sys.c_led.led_serial_status()
        if(self.sys.c_led.status == ":0"):
                self.sys.c_stage.home_stages()
                        
        self.longchip = 0
        
        self.initUI()

    def initUI(self):

        self.style = Style().configure("TFrame", background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)

        titleLabel = Label(self, text=self.sys.win_cfg.sLowMag,
                            background="light blue",
                            width=15, height=1)
        titleLabel.place(x=5, y=5)

        prefixLabel= Label(self, text="File Prefix",
                                   background = self.sys.win_cfg.cBackground,width=9, height=1)
        prefixLabel.place(x=5, y=60)

        self.prefixEntry = Entry(self, width=30,background=self.sys.win_cfg.cTextBackground)
        self.prefixEntry.place(x=10, y=85)

        self.prefixEntry.insert(0,"CHIP")

        numberLabel= Label(self, text="Chip #",
                                   background = self.sys.win_cfg.cBackground,width=9, height=1)
        numberLabel.place(x=5, y=110)

        self.numberEntry = Entry(self, width=10,
                                         justify="center",background=self.sys.win_cfg.cTextBackground)
        self.numberEntry.place(x=10, y=135)

        self.numberEntry.insert(0,"1")
        
        if (self.checkIm(str(1)) == True):
            self.numberEntry.config(background="green")
        else:
            self.numberEntry.config(background="red")

        self.numDownButton = Button(self, text="prev",command=self.numDown, width=5)
        self.numDownButton.place(x=80, y=120)

        self.numUpButton = Button(self, text="next",command=self.numUp, width=5)
        self.numUpButton.place(x=80, y=145)

        self.deleteButton = Button(self, text="Delete",command=self.deleteIm, width = 10)
        self.deleteButton.place(x=125, y = 130)

        #self.stitchButton = Button(self, text="Stitch",command=self.stitch, width = 10)
        #self.stitchButton.place(x=125, y = 5)

        

        

        self.acquireButton = Button(self, text="Acquire",command=self.acquire, width = 20)
        self.acquireButton.place(x=5,y=180)

        self.mirrorButton = Button(self, text="Mirror",command=self.mirrorBtn, width = 5)
        self.mirrorButton.place(x=150,y=180)

        self.loadButton = Button(self, text="Unload",command=self.unload, width = 8)
        self.loadButton.place(x=130, y=30)   
        self.autoUnload = IntVar()
        self.autoUnload.set(1)

        self.autoUnloadCheck = Checkbutton(self, text = "Auto-Unload", variable = self.autoUnload, \
                                            onvalue = 1, offvalue = 0, height=1, \
                                            width = 10)
        self.autoUnloadCheck.place(x=90, y=60)

        self.v = IntVar()

        self.v.set(0)

        # Setting up the option box for the chip version
        self.chipMode = StringVar()
        self.chipMode.set(self.options[3]) # Default value
        self.chipSelect = OptionMenu(self,self.chipMode,*self.options)
        self.chipSelect.place(x=5, y=30)
        
        #self.modeDryV2 = Radiobutton(self, text="60", variable=self.v, value=0)
        #self.modeDryV2.place(x=5, y=30)
        #self.modeDry = Radiobutton(self, text="90", variable=self.v, value=1)
        #self.modeDry.place(x=45, y=30)
        #self.modeWet = Radiobutton(self, text="30", variable=self.v, value=2)
        #self.modeWet.place(x=85, y=30)

        #self.longCheck = Radiobutton(self, text="60-Long", variable=self.v, value=3)
        #self.longCheck.place(x=125, y = 5)

    def numUp(self):
        num = self.numberEntry.get()
        num = str(int(num)+1);
        self.numberEntry.delete(0, END)
        self.numberEntry.insert(0,str(int(num)))
        if (self.checkIm(num) == True):
            self.numberEntry.config(background="green")
        else:
            self.numberEntry.config(background="red")


    def numDown(self):
        num = self.numberEntry.get()
        if(int(num) > 1):
            num = str(int(num)-1);
            self.numberEntry.delete(0, END)
            self.numberEntry.insert(0,str(int(num)))
            if (self.checkIm(num) == True):
                self.numberEntry.config(background="green")
            else:
                self.numberEntry.config(background="red")


    def deleteIm(self):
            today = date.today()
            todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"/"
            todaystr = time.strftime("%Y-%m-%d") + "/"
            prefix = self.prefixEntry.get() + "_"
            num = self.numberEntry.get()
            os.remove("../data/" + todaystr + prefix + num.zfill(3)+"_1.png") 
            os.remove("../data/" + todaystr + prefix + num.zfill(3)+"_2.png")
            if (self.checkIm(num) == True):
                    self.numberEntry.config(background="green")
            else:
                    self.numberEntry.config(background="red")

    def mirrorBtn(self):
        self.mirror()
        #self.focus()
        
    def dataMirrorFiles(self):
        runMore = 0
        mirror_exists = self.mirror_exists()
        if (mirror_exists == False ):
            proceed = self.checkMirrorFiles()
            if (proceed == 0): #mirror is not old
                self.mirror_copy()
                runMore = 1
            elif (proceed == 1): # take new mirror
                runMore = 0
            elif (proceed == 2): #use old mirror
                self.mirror_copy()
                runMore = 1
        else:
            runMore = 1
        return runMore
            
    def checkMirrorFiles(self):
        proceed = 0
        mirror_fn1 = "../data/mirror/MIRROR_01.png"
        mirror_fn2 = "../data/mirror/MIRROR_02.png"
        
        mir_fold = "../data/mirror/"

        
        mirror_date = time.strftime("%Y-%m-%d",time.gmtime(os.path.getmtime(mirror_fn1)))
        days_since = self.days_between(mirror_date,time.strftime("%Y-%m-%d",time.gmtime()))
        if (days_since > 6):
            result = tkMessageBox.askyesno("Mirror File","It has been %d days since you took a mirror, would you like to take a new mirror before scanning?" % days_since)
            if (result == True):
                proceed = 1 #"Take new mirror"
            else:
                proceed = 2 #"Use existing mirror"
            
        return proceed
    
    def days_between(self,d1, d2):
        d1b = datetime.strptime(d1, "%Y-%m-%d")
        d2b = datetime.strptime(d2, "%Y-%m-%d") 
        return abs((d2b - d1b).days)
    
    def focus(self, focus_point = 1, led_color = 1):
            '''
            mode = self.v.get() 
            if(mode == 2): #30 nm
                if (led_color == 1):
                    scanPos = self.scan30_1
                elif (led_color == 2):
                    scanPos = self.scan30_2
            elif(mode == 1): #90 nm
                if (led_color == 1):
                    scanPos = self.scan90_1
                elif (led_color == 2):
                    scanPos = self.scan90_2
            elif(mode == 0): #30 nm
                if (led_color == 1):
                    scanPos = self.scan60_1
                elif (led_color == 2):
                    scanPos = self.scan60_2        
            elif(mode == 3): #60 long
                if (led_color == 1):
                    scanPos = self.scan60Long_1
                elif (led_color == 2):
                    scanPos = self.scan60Long_2             
            '''
            mode = self.chipMode.get()
            if(mode == self.options[0]):
                if(led_color == 1):
                    scanPos = self.scanNSFAIR_1
                elif(led_color == 2):
                    scanPos = self.scanNSFAIR_2
            elif(mode == self.options[1]):
                if(led_color == 1):
                    scanPos = self.scanNV16_1
                elif(led_color == 2):
                    scanPos = self.scanNV16_2
            elif(mode == self.options[2]):
                if(led_color == 1):
                    scanPos = self.scanNV10_1
                elif(led_color == 2):
                    scanPos = self.scanNV10_2
            elif(mode == self.options[3]):
                if(led_color == 1):
                    scanPos = self.scanNV10B_1
                elif(led_color == 2):
                    scanPos = self.scanNV10B_2
            elif(mode == self.options[4]):
                if(led_color == 1):
                    scanPos = self.scanNV16B_1
                elif(led_color == 2):
                    scanPos = self.scanNV16B_2
            elif(mode == self.options[5]):
                if(led_color == 1):
                    scanPos = self.scanNV16B_1
                elif(led_color == 2):
                    scanPos = self.scanNV16B_2
            
            
            self.sys.c_cam.close_realtime()
            oldfrms = self.sys.hw.cam.frms
            self.sys.hw.cam.frms = str(1)
            scores = []
            zpos = []
            for x in range(-50, 30, 5):
                offsetval = x/100
                self.sys.hw.stg.move_z(scanPos[2]+offsetval)
                z_status = self.sys.hw.stg.status_z()
                while ( (z_status['axis_moving'] == True)):
                    time.sleep(0.05)
                    z_status = self.sys.hw.stg.status_z()
                self.sys.hw.cam.dog_image(1)
                scores.append(float(self.sys.hw.cam.dog_score))
                #print scanPos[2]+offsetval
                zpos.append(scanPos[2]+offsetval)
            
            self.sys.hw.cam.frms = oldfrms
            
            # set focus to max change of slope
            y = numpy.gradient(scores)
            zs = numpy.argmax(y)
            zs2 = numpy.argmax(scores)
            zsmin = numpy.argmin(scores)
            
            if (focus_point == 0): # middle of slope
                focus_z = zs
            elif (focus_point == 1): #max of score
                focus_z = zs2
            elif (focus_point == 2): #min of score
                focus_z = zsmin
                    
            if (0):
                plt.interactive(True) #need to add this or program freezes while plotting
                plt.plot(zpos,scores)
                plt.show()               
                fig2 = plt.figure()
                zero_crossings = numpy.where(numpy.diff(numpy.sign(y)))[0]
                #print zero_crossings
                plt.plot(zpos,y)
                plt.plot(zpos[focus_z],y[focus_z],'gx')
                plt.show()
            
            ## move to z
            print(zpos[focus_z])
            print "Focus: " + str(focus_point)  + " - " + str(zpos[focus_z])
            self.sys.hw.stg.move_z(zpos[focus_z])
            z_status = self.sys.hw.stg.status_z()
            while ( (z_status['axis_moving'] == True)):
                time.sleep(0.05)
                z_status = self.sys.hw.stg.status_z()
            
            
    def moveAndCheck(self, x, y):
        self.sys.hw.stg.move_x(x)
        self.sys.hw.stg.move_y(y)
        x_status = self.sys.hw.stg.status_x()
        while ( (x_status['axis_moving'] == True)):
                time.sleep(0.05)
                x_status = self.sys.hw.stg.status_x()
        
        y_status = self.sys.hw.stg.status_y()
        while ( (y_status['axis_moving'] == True)):
                time.sleep(0.05)
                y_status = self.sys.hw.stg.status_y()
                
    def read_pgm(self, filename, byteorder='>'):
        #"""Return image data from a raw PGM file as numpy array.
    #
     #   Format specification: http://netpbm.sourceforge.net/doc/pgm.html
    

        with open(filename, 'rb') as f:
            buffer = f.read()
        try:
            header, width, height, maxval = re.search(
                b"(^P5\s(?:\s*#.*[\r\n])*"
                b"(\d+)\s(?:\s*#.*[\r\n])*"
                b"(\d+)\s(?:\s*#.*[\r\n])*"
                b"(\d+)\s(?:\s*#.*[\r\n]\s)*)", buffer).groups()
        except AttributeError:
            raise ValueError("Not a raw PGM file: '%s'" % filename)
        return numpy.frombuffer(buffer,
                                dtype='u1' if int(maxval) < 256 else byteorder+'u2',
                                count=int(width)*int(height),
                                offset=len(header)
                                ).reshape((int(height), int(width)))
                                       
    def mirror(self):
        start_time = time.time()
        self.mirror1()
        self.mirror2()
        self.mirror_copy()
        elapsed_time = time.time() - start_time
        str_cap = "Mirror Time: {0:.2f} s.".format(elapsed_time)
        print str_cap
    
    def mirror2(self):
            self.disableButtons()
            
            #self.backup_mirror() #make copy of mirror before replacing
            
            today = date.today()
            #todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"\\"
            folder = "../data/mirror/" # + todaystr
            image = []
            for i in range(0,9):
                fn1 = folder + "MIRROR_01_" + str(i) + ".pgm"
                image.append(self.read_pgm(fn1, byteorder='>'))
                os.remove(fn1)
                #plt.imshow(image)
                #plt.show()
                
            #d = numpy.array([image[0],image[1],image[2],image[3],image[4],image[5],image[6],image[7],image[8]])
            e = numpy.median(image, axis=0)
   
            fn1 = folder + "MIRROR_01" + ".png"
            f = open(fn1, 'wb')      # binary mode is important
            w = png.Writer(len(e[0]), len(e), greyscale=True, bitdepth=16)
            w.write(f, e)
            f.close()
            
            image = []
            for i in range(0,9):
                fn2 = folder + "MIRROR_02_" + str(i) + ".pgm"
                image.append(self.read_pgm(fn2, byteorder='>'))
                os.remove(fn2)
                #plt.imshow(image)
                #plt.show()
                
            #d = numpy.array([image[0],image[1],image[2],image[3],image[4],image[5],image[6],image[7],image[8]])
            e = numpy.median(image, axis=0)
   
            fn2 = folder + "MIRROR_02" + ".png"
            f = open(fn2, 'wb')      # binary mode is important
            w = png.Writer(len(e[0]), len(e), greyscale=True, bitdepth=16)
            w.write(f, e)
            f.close()
            self.enableButtons()
#             if (len(filename2) > 0):
#                 imgA = mpimg.imread(filename2,cv2.IMREAD_GRAYSCALE)
#                 img2A = cv2.resize(imgA, (0,0), fx=0.5, fy=0.5)
#                 heightA, width1A, channelsA = img2A.shape
#                 
#                 blue_image = img2A[:,:,1]
#                 red_image = img2[:,:,1]
#                     
#                 blank_image = 255*numpy.ones((height,width1,3), numpy.uint8)
#                 blank_image[:,:,0] = blank_image[:,:,0]-red_image
#                 blank_image[:,:,2] = blank_image[:,:,2]-blue_image
# 
#                 plt.imshow(blank_image)

    def backup_mirror(self):
        mir_fold = "../data/mirror/"
        
        og_fn1 = mir_fold + "MIRROR_01" + ".png"
        og_fn2 = mir_fold + "MIRROR_02" + ".png"
        
        mirror_date = time.strftime("%Y-%m-%d",time.gmtime(os.path.getmtime(og_fn1)))

        folder = "../data/mirror/" + mirror_date + "/"
        fn1 = folder + "MIRROR_01" + ".png"
        fn2 = folder + "MIRROR_02" + ".png"
        
        if(os.path.isdir(folder) == False):
                os.mkdir(folder)
        
        copyfile(og_fn1, fn1)
        copyfile(og_fn2, fn2)
        os.remove(og_fn1)
        os.remove(og_fn2)
        
    def mirror_exists(self):
        today = date.today()        
        todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"/"
        todaystr = time.strftime("%Y-%m-%d") + "/"
        folder = "../data/" + todaystr
        fn1 = folder + "MIRROR_01" + ".png"
        fn2 = folder + "MIRROR_02" + ".png"
        
        file1 = os.path.isfile(fn1)
        file2 = os.path.isfile(fn2) 
        
        return (file1 and file2)
        
    def mirror_copy(self): #copy mirror to data folder
        today = date.today()
        todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"/"

        todaystr = time.strftime("%Y-%m-%d") + "/"
        folder = "../data/" + todaystr
        fn1 = folder + "MIRROR_01" + ".png"
        fn2 = folder + "MIRROR_02" + ".png"
        
        mir_fold = "../data/mirror/"
        
        if(os.path.isdir(folder) == False):
                os.mkdir(folder)
        
        og_fn1 = mir_fold + "MIRROR_01" + ".png"
        og_fn2 = mir_fold + "MIRROR_02" + ".png"
        
        copyfile(og_fn1, fn1)
        copyfile(og_fn2, fn2)
        
    def mirror1(self):
            
            self.load()
            self.disableButtons()
            today = date.today()
            #todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"\\"
            folder = "../data/mirror/" # + todaystr
            if(os.path.isdir(folder) == False):
                os.mkdir(folder)
            #self.sys.c_cam.close_realtime()

            xoffsets = [-0.512, -0.512, -0.512, 0, 0, 0, 0.512, 0.512, 0.512]
            yoffsets = [-0.512, 0, 0.512, -0.512, 0, 0.5, -0.512, 0, 0.512]
            
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED1_ON)
            self.focus(1) #max peak
            
            for i in range(0,9):
                xpos = self.scanMirror[0] + xoffsets[i]
                ypos = self.scanMirror[1] + yoffsets[i]
                self.moveAndCheck(xpos, ypos)
                fn1 = folder + "MIRROR_01_" + str(i)
                self.sys.hw.cam.fn = fn1
                self.sys.hw.cam.imagePGM()
                
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED2_ON)
            self.focus(1) #max peak
            
            for i in range(0,9):
                xpos = self.scanMirror[0] + xoffsets[i]
                ypos = self.scanMirror[1] + yoffsets[i]
                self.moveAndCheck(xpos, ypos)
                fn2 = folder + "MIRROR_02_" + str(i)
                self.sys.hw.cam.fn = fn2
                self.sys.hw.cam.imagePGM()
            
    
            self.enableButtons()
            
            aunload = self.autoUnload.get()

            if (aunload > 0):
                self.unload()  
            
            
    def acquire(self):
        run = self.dataMirrorFiles() #check for mirror first
        if (run == 1):
            self.acquire_data() #acquire data
        
    def acquire_data(self):
            #mode = self.v.get()
            mode = self.chipMode.get()
            start_time = time.time()
            self.load()
            self.disableButtons()
            today = date.today()
            todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"/"
            todaystr = time.strftime("%Y-%m-%d") + "/"
            folder = "../data/" + todaystr
            if(os.path.isdir(folder) == False):
                os.mkdir(folder)
            #self.sys.c_cam.close_realtime()
            
            num = self.numberEntry.get().zfill(3)
            
            ## LED1
            ledn = 1
            fn1 = folder + self.prefixEntry.get()+"_"+num + "_1"
            self.sys.hw.cam.fn = fn1
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED1_ON)

            print("before focus 1. mode = " + mode)

            '''
            if (mode == 2): #30
                self.focus(1,ledn) #min score
            elif (mode == 1): #90
                self.focus(0,ledn) #max slope
            elif (mode == 0): #60
                self.focus(1,ledn) #max score
            '''
            if(mode == self.options[0]):
                self.focus(0,ledn)
            elif(mode == self.options[1]):
                self.focus(1,ledn)
            elif(mode == self.options[2]):
                self.focus(0,ledn)
            elif(mode == self.options[3]):
                self.focus(1,ledn)
            elif(mode == self.options[4]):
                self.focus(1,ledn)
            elif(mode == self.options[5]):
                self.focus(1,ledn)
            print('done with first focus')
            self.sys.hw.cam.image()
            print('done with first image')
            ## LED 2
            ledn = 2
            fn2 = folder + self.prefixEntry.get()+"_"+num + "_2"
            self.sys.hw.cam.fn = fn2
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED2_ON)
            '''
            if (mode == 2): #30
                self.focus(2,ledn) #min score
            elif (mode == 1): #90
                self.focus(1,ledn) #max score
            elif (mode == 0): #60
                self.focus(1,ledn) #max score
            '''
            print('before focus 2')
            if(mode == self.options[0]):
                self.focus(0,ledn)
            elif(mode == self.options[1]):
                self.focus(1,ledn)
            elif(mode == self.options[2]):
                self.focus(0,ledn)
            elif(mode == self.options[3]):
                self.focus(1,ledn)
            elif(mode == self.options[4]):
                self.focus(1,ledn)
            elif(mode == self.options[5]):
                self.focus(1,ledn)                
            print('second focus complete')
            
            self.sys.hw.cam.image()
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED1_ON)
            if (self.checkIm(num) == True):
                    self.numberEntry.config(background="green")
            else:
                    self.numberEntry.config(background="red")
            self.showimhist(fn1+".png", fn2+".png")
            self.enableButtons()
            
            aunload = self.autoUnload.get()

            if (aunload > 0):
                self.unload()
                
            self.numUp()    
            
            elapsed_time = time.time() - start_time
            str_cap = "Capture Time: {0:.2f} s.".format(elapsed_time)
            print str_cap

            # Editing the first pixel
            print('about to edit pixel...')
            point = (0,0)

            reader = png.Reader(filename=fn1+'.png')
            w, h, pixels, metadata = reader.read_flat()

            ## set chip version in first pixel
            if(mode == self.options[0]):
                pixels[0] = 1
            elif(mode == self.options[1]):
                pixels[0] = 2
            elif(mode == self.options[2]):
                pixels[0] = 3
            elif(mode == self.options[3]):
                pixels[0] = 4
            elif(mode == self.options[4]):
                pixels[0] = 5
            elif(mode == self.options[5]):
                pixels[0] = 6
                
            output = open(fn1+'.png', 'wb')
            writer = png.Writer(w, h, **metadata)
            writer.write_array(output, pixels)
            output.close()
            print('done')
            
            #self.sys.c_cam.real_time()

    def stitch(self):
            # preserve old values
            old90_1 = self.scan90_1
            old90_2 = self.scan90_2
            old60_1 = self.scan60_1
            old60_2 = self.scan60_2
            old30_1 = self.scan30_1
            old30_2 = self.scan30_2

            # Offset the x
            self.scan90_1[0] -= 3
            self.scan90_2[0] -= 3
            self.scan60_1[0] -= 3
            self.scan60_2[0] -= 3
            self.scan30_1[0] -= 3
            self.scan30_2[0] -= 3
        
            mode = self.v.get()
            start_time = time.time()
            self.load()
            self.disableButtons()
            today = date.today()
            todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"/"
            todaystr = time.strftime("%Y-%m-%d") + "/"
            folder = "../data/" + todaystr
            if(os.path.isdir(folder) == False):
                os.mkdir(folder)
            #self.sys.c_cam.close_realtime()
            
            num = self.numberEntry.get().zfill(3)
            
            ## LED1
            ledn = 1
            fn1 = folder + self.prefixEntry.get()+"_"+num + "_1a"
            self.sys.hw.cam.fn = fn1
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED1_ON)
            
            if (mode == 2): #30
                self.focus(1,ledn) #min score
            elif (mode == 1): #90
                self.focus(0,ledn) #max slope
            elif (mode == 0): #60
                self.focus(1,ledn) #max score
            self.sys.hw.cam.image()
            
            ## LED 2
            ledn = 2
            fn2 = folder + self.prefixEntry.get()+"_"+num + "_2a"
            self.sys.hw.cam.fn = fn2
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED2_ON)
            if (mode == 2): #30
                self.focus(2,ledn) #min score
            elif (mode == 1): #90
                self.focus(1,ledn) #max score
            elif (mode == 0): #60
                self.focus(1,ledn) #max score
            self.sys.hw.cam.image()
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED1_ON)
            if (self.checkIm(num) == True):
                    self.numberEntry.config(background="green")
            else:
                    self.numberEntry.config(background="red")
            self.showimhist(fn1+".png", fn2+".png")
            self.enableButtons()
            


            ### MOVE THE STAGE
                        # Offset the x
            self.scan90_1[0] += 6
            self.scan90_2[0] += 6
            self.scan60_1[0] += 6
            self.scan60_2[0] += 6
            self.scan30_1[0] += 6
            self.scan30_2[0] += 6

            self.load()
            
            ## LED1
            ledn = 1
            fn1 = folder + self.prefixEntry.get()+"_"+num + "_1b"
            self.sys.hw.cam.fn = fn1
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED1_ON)
            
            if (mode == 2): #30
                self.focus(1,ledn) #min score
            elif (mode == 1): #90
                self.focus(0,ledn) #max slope
            elif (mode == 0): #60
                self.focus(1,ledn) #max score
            self.sys.hw.cam.image()
            
            ## LED 2
            ledn = 2
            fn2 = folder + self.prefixEntry.get()+"_"+num + "_2b"
            self.sys.hw.cam.fn = fn2
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED2_ON)
            if (mode == 2): #30
                self.focus(2,ledn) #min score
            elif (mode == 1): #90
                self.focus(1,ledn) #max score
            elif (mode == 0): #60
                self.focus(1,ledn) #max score
            self.sys.hw.cam.image()
            self.sys.hw.led.command(NGA_Interface_LED.LED_OFF)
            self.sys.hw.led.command(NGA_Interface_LED.LED1_ON)
            if (self.checkIm(num) == True):
                    self.numberEntry.config(background="green")
            else:
                    self.numberEntry.config(background="red")
            self.showimhist(fn1+".png", fn2+".png")
            self.enableButtons()
            
            aunload = self.autoUnload.get()

            if (aunload > 0):
                self.unload()
                
            self.numUp()    
            
            elapsed_time = time.time() - start_time
            str_cap = "Capture Time: {0:.2f} s.".format(elapsed_time)
            print str_cap
            #self.sys.c_cam.real_time()

            # preserve old values
            #self.scan90_1 = old90_1
            #self.scan90_2 = old90_2
            #self.scan60_1 = old60_1
            #self.scan60_2 = old60_2
            #self.scan30_1 = old30_1
            #self.scan30_2 = old30_2
            self.scan90_1[0] -= 3
            self.scan90_2[0] -= 3
            self.scan60_1[0] -= 3
            self.scan60_2[0] -= 3
            self.scan30_1[0] -= 3
            self.scan30_2[0] -= 3


            

    def disableButtons(self):
            self.setButtons(DISABLED)

    def enableButtons(self):
            self.setButtons('normal')
    
    def setButtons(self,btnState):
            self.prefixEntry.config(state=btnState)
            self.numberEntry.config(state=btnState)
            self.numDownButton.config(state=btnState)
            self.numUpButton.config(state=btnState)
            self.deleteButton.config(state=btnState)
            self.acquireButton.config(state=btnState)
            self.loadButton.config(state=btnState)
            #self.modeDry.config(state=btnState)
            #self.modeWet.config(state=btnState)
            self.autoUnloadCheck.config(state=btnState)
            self.mirrorButton.config(state=btnState)
            
            
            #self.focusButton.config(state=DISABLED)
            self.parent.update()
        
    def checkIm(self, num):
        today = date.today()
        todaystr = str(today.year) +"-"+str(today.month) +"-"+str(today.day) +"/"
        todaystr = time.strftime("%Y-%m-%d") + "/"
        prefix = self.prefixEntry.get() + "_"
        return (os.path.isfile("../data/" + todaystr + prefix + num.zfill(3)+"_1.png") 
            & os.path.isfile("../data/" + todaystr + prefix + num.zfill(3)+"_2.png"))

    def load(self):
            self.disableButtons()
            self.loadButton["text"] = "Loading..."

            '''
                mode = self.v.get()
                if(mode == 2):
                    scanPos = self.scan30_1
                    #print str(scanPos[0])+" "+str(scanPos[1])+" "+str(scanPos[2])
                elif(mode == 1):
                    scanPos = self.scan90_1
                elif(mode == 0):
                    scanPos = self.scan60_1
                    #print str(scanPos[0])+" "+str(scanPos[1])+" "+str(scanPos[2])
                elif(mode==3):
                    scanPos = self.scan60Long_1
            '''
            
            mode = self.chipMode.get()
            print("Mode: " + mode)
            scanPos = [0, 0, 0]
            if(mode == self.options[0]):
               scanPos = self.scanNSFAIR_1
            elif(mode == self.options[1]):
               scanPos = self.scanNV16_1
            elif(mode == self.options[2]):
               scanPos = self.scanNV10_1
            elif(mode == self.options[3]):
               scanPos = self.scanNV10B_1
            elif(mode == self.options[4]):
               scanPos = self.scanNV16B_1
            elif(mode == self.options[5]):
               scanPos = self.scanNV16B_1
               
            print(scanPos)
            self.sys.hw.stg.move_z(scanPos[2])
            self.sys.c_stage.update_pos_x_y_z()
            self.sys.hw.stg.move_x(scanPos[0])
            self.sys.hw.stg.move_y(scanPos[1])
            self.sys.c_stage.update_pos_x_y_z()
            self.loadButton["text"] = "Unload"
            self.loadButton["command"] = self.unload
            self.enableButtons()

    def unload(self): 
            self.disableButtons()
            self.loadButton["text"] = "Unloading..."
            if self.sys.hw.led.led_on[0] == False:
                    self.sys.c_led.led_on()
            #self.sys.c_cam.real_time()
            self.sys.hw.stg.move_x(self.homePos[0])
            self.sys.hw.stg.move_y(self.homePos[1])
            self.sys.c_stage.update_pos_x_y_z()
            self.sys.hw.stg.move_z(self.homePos[2])
            self.sys.c_stage.update_pos_x_y_z()
            self.loadButton["text"] = "Load"
            self.loadButton["command"] = self.load
            self.enableButtons()

    def showimhist(self, filename, filename2 = ""):
            plt.interactive(True) #need to add this or program freezes while plotting
            #print filename
            img = mpimg.imread(filename,cv2.IMREAD_GRAYSCALE)
            img2 = cv2.resize(img, (0,0), fx=0.5, fy=0.5)
            height, width1, channels = img2.shape
            try:
                plt.close(0)
            except:
                pass #this will error out if window hasn't loaded yet, that's ok
            plt.figure(0)
            plt.imshow(img2)
            
#             if (len(filename2) > 0):
#                 imgA = mpimg.imread(filename2,cv2.IMREAD_GRAYSCALE)
#                 img2A = cv2.resize(imgA, (0,0), fx=0.5, fy=0.5)
#                 heightA, width1A, channelsA = img2A.shape
#                 
#                 blue_image = img2A[:,:,1]
#                 red_image = img2[:,:,1]
#                     
#                 blank_image = 255*numpy.ones((height,width1,3), numpy.uint8)
#                 blank_image[:,:,0] = blank_image[:,:,0]-red_image
#                 blank_image[:,:,2] = blank_image[:,:,2]-blue_image
# 
#                 plt.imshow(blank_image)
                
            hist = cv2.calcHist(img,[0],None,[256],[0,256])
            maxhist = max(hist)
            y = [((x/maxhist)*-1*height*.3) for x in hist]
            N = len(y)
            xold = range(N)
            x = [(x/(N-1))*width1 for x in xold]
            width = (1/N)*width1
            plt.bar(x, y, width, color="blue", bottom=height)
            plt.axis([0,width1,height,0])
            plt.title(filename)
            plt.show()
Ejemplo n.º 55
0
    def initUI(self):

        #self.parent.title("SP-IRIS Main")
        self.parent.iconbitmap(default=r"../resources/nga.ico")
        self.style = Style().configure("TFrame", background="#FFFFFF")
        #self.style.theme_use("default")

        bard = Image.open(r"../resources/nexgen_logo_80.png")
        bardejov = ImageTk.PhotoImage(bard)
        label1 = Label(self, image=bardejov)
        label1.image = bardejov
        label1.place(x=20, y=20)

        self.pack(fill=BOTH, expand=1)

        quitButton = Button(self,
                            text="Quit",
                            command=self.endProgram,
                            width=12)
        quitButton.place(x=20, y=140)

        if (self.enable_panel_config):
            configButton = Button(self,
                                  text="Config Panel",
                                  command=self.panel_config,
                                  width=15)
            configButton.place(x=150, y=20)

        if (self.enable_panel_led):
            ledButton = Button(self,
                               text="LED Panel",
                               command=self.panel_led,
                               width=15)
            ledButton.place(x=150, y=60)

        if (self.enable_panel_camera):
            camButton = Button(self,
                               text="Camera Panel",
                               command=self.panel_cam,
                               width=15)
            camButton.place(x=150, y=100)

        if (self.enable_panel_stage):
            stageButton = Button(self,
                                 text="Stage Panel",
                                 command=self.panel_stage,
                                 width=15)
            stageButton.place(x=150, y=140)

        if (self.enable_panel_file):
            ## 2nd column
            fileinfoButton = Button(self,
                                    text="File Panel",
                                    command=self.panel_fileinfo,
                                    width=16)
            fileinfoButton.place(x=270, y=20)

        if (self.enable_panel_process):
            processButton = Button(self,
                                   text="Process Panel",
                                   command=self.panel_process,
                                   width=16)
            processButton.place(x=270, y=60)

        if (self.enable_panel_focus):
            focusButton = Button(self,
                                 text="Focus Panel",
                                 command=self.panel_focus,
                                 width=16)
            focusButton.place(x=270, y=100)
        if (self.enable_panel_pneumatics):
            pneumaticsButton = Button(self,
                                      text="Pneumatics Panel",
                                      command=self.panel_pneumatics,
                                      width=16)
            pneumaticsButton.place(x=270, y=140)

        if (self.enable_panel_lowmag):
            lowmagButton = Button(self,
                                  text="Low Mag Panel",
                                  command=self.panel_lowmag,
                                  width=16)
            lowmagButton.place(x=270, y=20)

        # Config Panel
        if (self.enable_panel_config):
            self.w_Config = Toplevel(self.parent)
            self.c_Config = NGA_Window_Config(self.w_Config, self.sys)

        # LED Panel
        if (self.enable_panel_led):
            self.w_LED = Toplevel(self.parent)
            self.c_LED = NGA_Window_LED(self.w_LED, self.sys)

        # Camera Panel
        if (self.enable_panel_camera):
            self.w_Cam = Toplevel(self.parent)
            self.c_Cam = NGA_Window_Camera(self.w_Cam, self.sys)

        # Stage Panel
        if (self.enable_panel_stage):
            self.w_Stage = Toplevel(self.parent)
            self.c_Stage = NGA_Window_Stage(self.w_Stage, self.sys)

        # FileInfo Panel
        if (self.enable_panel_file):
            self.w_Fileinfo = Toplevel(self.parent)
            self.c_Fileinfo = NGA_Window_FileInfo(self.w_Fileinfo, self.sys)

        # Process Panel
        if (self.enable_panel_process):
            self.w_Process = Toplevel(self.parent)
            self.c_Process = NGA_Window_Process(self.w_Process, self.sys)

        # Focus Panel
        if (self.enable_panel_focus):
            self.w_Focus = Toplevel(self.parent)
            self.c_Focus = NGA_Window_Focus(self.w_Focus, self.sys)

        # Pneumatics Panel
        if (self.enable_panel_pneumatics):
            self.w_Pneumatics = Toplevel(self.parent)
            self.c_Pneumatics = NGA_Window_Pneumatics(self.w_Pneumatics,
                                                      self.sys)

        # Testing Panel
        if (self.enable_panel_testing):
            self.w_Testing = Toplevel(self.parent)
            self.c_Testing = NGA_Window_Testing(self.w_Testing, self.sys)

        #Low Mag Panel
        if (self.enable_panel_lowmag):
            self.w_LowMag = Toplevel(self.parent)
            self.c_LowMag = NGA_Window_LowMag(self.w_LowMag, self.sys)

        if (self.load_other_w == False):
            if (self.enable_panel_config):
                self.c_Config.close_window()
            if (self.enable_panel_led):
                self.c_LED.close_window()
            if (self.enable_panel_camera):
                self.c_Cam.close_window()
            if (self.enable_panel_stage):
                self.c_Stage.close_window()
            if (self.enable_panel_file):
                self.c_Fileinfo.close_window()
            if (self.enable_panel_process):
                self.c_Process.close_window()
            if (self.enable_panel_focus):
                self.c_Focus.close_window()
            if (self.enable_panel_pneuamtics):
                self.c_Pneumatics.close_window()
Ejemplo n.º 56
0
    def initUI(self):

        self.parent.title("Captura de datos")
        self.style = Style()
        self.pack(fill=BOTH, expand=1)

        BotonIncX = Button(self, text="+", command=IncX)
        BotonIncX.place(x=300, y=150)
        label1 = Label(self, text="Incrementar X:")
        label1.place(x=150, y=150)
        global texto1, texto2, x, y
        x = 0
        y = 0
        texto1 = StringVar()
        texto1.set(x)
        label10 = Label(self, textvariable=texto1, width=5, relief="solid")
        label10.place(x=250, y=175)
        BotonDecX = Button(self, text="-", command=DecX)
        BotonDecX.place(x=300, y=200)
        label2 = Label(self, text="Decrementar X:")
        label2.place(x=150, y=200)
        BotonIncY = Button(self, text="+", command=IncY)
        BotonIncY.place(x=300, y=250)
        label3 = Label(self, text="Incrementar Y:")
        label3.place(x=150, y=250)
        texto2 = StringVar()
        texto2.set(y)
        label101 = Label(self, textvariable=texto2, width=5, relief="solid")
        label101.place(x=250, y=275)
        BotonDecY = Button(self, text="-", command=DecY)
        BotonDecY.place(x=300, y=300)
        label4 = Label(self, text="Decrementar Y:")
        label4.place(x=150, y=300)
        Grabar = Button(self, text="Grabar Registro", command=GrabarRegistro)
        Grabar.place(x=150, y=340)
        global ListaMACs
        ListaMACs = Listbox(self, bd=2, relief="solid", height=4, width=82)
        ListaMACs.place(x=50, y=50)

        Scan = Button(self, text="Escanear RSSI en MAC", command=ScanMAC)
        Scan.place(x=350, y=340)
Ejemplo n.º 57
0
    def initUI(self):

        self.style = Style().configure("TFrame", background=self.sys.win_cfg.cBackground)
        self.pack(fill=BOTH, expand=1)
        
        titleLabel = Label(self, text=self.sys.win_cfg.sProcess,
                             background=self.sys.win_cfg.cBackground,
                             width=12, height=1)
        titleLabel.place(x=5, y=5)

        # setup labels
        self.processResult = Label(self, width=12,
                                      background=self.sys.win_cfg.cUnknown, text="            ")
        self.processResult.place(x=20, y=170)
        self.countResult = Label(self, width=8,
                                      background=self.sys.win_cfg.cUnknown, text="0")
        self.countResult.place(x=120, y=170)
        self.extraInfoResult = Label(self, width=22,
                                      background=self.sys.win_cfg.cUnknown, text="")
        self.extraInfoResult.place(x=20, y=200)
        
        # setup buttons
        '''
        contrastLabel = Label(self, text="Contrast: ",
                             background=self.sys.win_cfg.cBackground,
                             width=9, height=1)
        contrastLabel.place(x=10, y=20)
        self.contrastEntry = Entry(self, width=5,
                           background=self.sys.win_cfg.cTextBackground)
        self.contrastEntry.place(x=85, y=20)

        gaussianLabel = Label(self, text="Gaussian: ",
                             background=self.sys.win_cfg.cBackground,
                             width=9, height=1)
        gaussianLabel.place(x=10, y=50)
        self.gaussianEntry = Entry(self, width=5,
                           background=self.sys.win_cfg.cTextBackground)
        self.gaussianEntry.place(x=85, y=50)
        '''
        self.fileListVariable = StringVar(self)
        self.fileListVariable.set("one") # default value
        self.fileListOptionMenu = OptionMenu(self, self.fileListVariable, "one", "two", "three")
        self.fileListOptionMenu.place(x=20, y=90)
        self.populate_file_list()
        
        processButton = Button(self, text="Process",
            command=self.process, width=14)
        processButton.place(x=20, y=130)


        viewResultsButton = Button(self, text="...",
            command=self.view_process_image, width=6)
        viewResultsButton.place(x=120, y=130)

        lowMagButton = Button(self, text="Low Mag",
            command=self.process_low_mag, width=12)
        lowMagButton.place(x=20, y=250)

        spotFinderButton = Button(self, text="Spot Finder",
            command=self.spotfind_low_mag, width=12)
        spotFinderButton.place(x=20, y=280)
        
        # close buttons
        closeButton = Button(self, text="Close",
            command=self.close_window, width=14)
        closeButton.place(x=20, y=350)
Ejemplo n.º 58
0
    def initUI(self):

        self.parent.title("Quit button")
        self.style = Style()
        self.style.theme_use("default")

        self.pack(fill=BOTH, expand=1)

        #first fig
        fig1 = matplotlib.figure.Figure()
        ax1 = fig1.add_subplot(111)
        self.thisImg1 = np.eye(256)
        self.fig1Drawing = ax1.imshow(self.thisImg1)
        self.canvas1 = FigureCanvasTkAgg(fig1, master=self.parent)
        self.canvas1.show()
        self.canvas1.get_tk_widget().place(relx=0, rely=0,\
                                           relheight=0.7, \
                                           relwidth=0.3)
        #second fig
        fig2 = matplotlib.figure.Figure()
        ax2 = fig2.add_subplot(111)
        self.thisImg2 = np.eye(256)
        self.fig2Drawing = ax2.imshow(self.thisImg2)
        self.canvas2 = FigureCanvasTkAgg(fig2, master=self.parent)
        self.canvas2.show()
        self.canvas2.get_tk_widget().place(relx=0.33, rely=0, \
                                           relheight=0.7, \
                                           relwidth=0.3)
        #Thrid fig
        fig3 = matplotlib.figure.Figure()
        ax3 = fig3.add_subplot(111)
        self.thisImg3 = np.eye(256)
        self.fig3Drawing = ax3.imshow(self.thisImg3)
        self.canvas3 = FigureCanvasTkAgg(fig3, master=self.parent)
        self.canvas3.show()
        self.canvas3.get_tk_widget().place(relx=0.66, rely=0, \
                                           relheight=0.7, \
                                           relwidth=0.3)

        cid1 = self.canvas1.mpl_connect('button_press_event', self.firstUpdate)
        cid2 = self.canvas2.mpl_connect('button_press_event',
                                        self.secondUpdate)
        cid3 = self.canvas3.mpl_connect('button_press_event', self.thirdUpdate)

        cid4 = self.canvas1.mpl_connect('key_press_event', self.writeRoi2)
        cid4 = self.canvas2.mpl_connect('key_press_event', self.writeRoi2)
        cid5 = self.canvas3.mpl_connect('key_press_event', self.writeRoi2)

        #Make the sliders
        self.rowSlider = Scale(self, \
                                   command=self.updateRow, \
                                   orient=tk.HORIZONTAL, \
                                   from_=0, \
                                   to=500)
        self.rowSlider.place(relx=0.8, rely=0.8)
        self.colSlider = Scale(self, \
                                   command=self.updateCol, \
                                   orient=tk.HORIZONTAL, \
                                   from_=0, \
                                   to=500)
        self.colSlider.place(relx=.4, rely=0.8)
        self.sliceSlider = Scale(self, \
                                     command=self.updateSlice, \
                                     orient=tk.HORIZONTAL, \
                                   from_=0, \
                                   to=500)
        self.sliceSlider.place(relx=0.0, rely=0.8)

        openButton = Button(self, text="Open", command=self.pickFile)
        openButton.place(relx=0, rely=.9)

        loadButton = Button(self, text="Load", command=self.loadNifti)
        loadButton.place(relx=.4, rely=.9)

        quitButton = Button(self, text="Quit", command=self.quit)
        quitButton.place(relx=.8, rely=.9)
Ejemplo n.º 59
0
Mafenetre = Tk()
style = ttk.Style()
style.configure('TButton', foreground="blue", relief="RAISED")
bgimg = PhotoImage(file="bg.gif")
bg = Label(Mafenetre, image=bgimg)
bg.place(x=0, y=0, relwidth=1, relheight=1)
Mafenetre.title('Capitator')
Mafenetre.geometry('500x500+400+400')

Texte = StringVar()
NouveauLance()
LabelResultat = Label(Mafenetre,
                      textvariable=Texte,
                      fg='red',
                      font=("Helvetica", 12))
LabelResultat.pack(side=TOP, padx=5, pady=15)

BoutonQuitter = Button(Mafenetre, text='Quitter', command=Mafenetre.destroy)
BoutonQuitter.pack(side=BOTTOM, padx=5, pady=5)

BoutonOui = Button(Mafenetre, text='Oui', command=Oui)
BoutonOui.place(x=205, y=145)
BoutonPEOui = Button(Mafenetre, text='Peu etre que oui', command=PEOui)
BoutonPEOui.place(x=197, y=175)
BoutonJNSP = Button(Mafenetre, text='Je ne sais pas', command=JNSP)
BoutonJNSP.place(x=203, y=205)
BoutonPENon = Button(Mafenetre, text='Peu etre que non', command=PENon)
BoutonPENon.place(x=195, y=235)
BoutonNon = Button(Mafenetre, text='Non', command=Non)
BoutonNon.place(x=205, y=265)
Mafenetre.mainloop()