예제 #1
0
파일: devices.py 프로젝트: if1live/marika
    def init_ui(self):
        self.parent.title('Fake Device')
        self.style = Style()
        self.style.theme_use('default')

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

        x_scale = Scale(self,
                        from_=self.MIN_X,
                        to=self.MAX_X,
                        command=self.on_scale_x)
        x_scale.place(x=0, y=0)

        y_scale = Scale(self,
                        from_=self.MIN_Y,
                        to=self.MAX_Y,
                        command=self.on_scale_y)
        y_scale.place(x=0, y=20)

        z_scale = Scale(self,
                        from_=self.MIN_Z,
                        to=self.MAX_Z,
                        command=self.on_scale_z)
        z_scale.place(x=0, y=40)

        angle_scale = Scale(self,
                            from_=0,
                            to=math.pi / 2,
                            command=self.on_scale_angle)
        angle_scale.place(x=0, y=80)

        self.x_var = IntVar()
        self.x_label = Label(self, text=0, textvariable=self.x_var)
        self.x_label.place(x=100, y=0)

        self.y_var = IntVar()
        self.y_label = Label(self, text=0, textvariable=self.y_var)
        self.y_label.place(x=100, y=20)

        self.z_var = IntVar()
        self.z_label = Label(self, text=0, textvariable=self.z_var)
        self.z_label.place(x=100, y=40)

        self.angle_var = DoubleVar()
        self.angle_label = Label(self, text=0, textvariable=self.angle_var)
        self.angle_label.place(x=100, y=80)

        self.button = Button(self, text='test', command=self.on_button)
        self.button.place(x=0, y=100)
예제 #2
0
파일: window.py 프로젝트: mavbrace/world
    def initUI(self):
        self.parent.title("WORLD")

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

        self.pack(fill=BOTH, expand=1)  #pack = a geometry manager

        #button
        b = Button(self, text=" GO ", command=self.callback)
        b.pack(side=TOP, padx=15, pady=20)

        #text
        t = Text(self, height=3, width=40)
        t.pack(side=TOP, padx=15)
        t.insert(
            END,
            "Welcome.\nPlease select the number of years\nyou would like to run the Simulation.\n"
        )

        #slider
        slider = Scale(self, from_=0, to=400,
                       command=self.onScale)  #values of slider!
        slider.pack(side=TOP, padx=15)

        self.var = IntVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.pack(side=TOP, padx=15)
예제 #3
0
    def initUI(self):
        self.parent.title("Scale")
        self.style = Style()
        self.style.theme_use("default")

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

        scale = Scale(self, from_=0, to=100, command=self.onScale)
        scale.pack(side=LEFT, padx=15)

        self.var = IntVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.pack(side=LEFT)
예제 #4
0
    def initUI(self):
        self.parent.title("Gripper Demo")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        #scale1 - Gripper Pos
        ScaleGripperPos = Scale(self,
                                from_=0,
                                to=100,
                                orient=HORIZONTAL,
                                length=300,
                                resolution=1,
                                command=self.onScaleGripperPos)
        ScaleGripperPos.grid(row=1, column=2)

        self.label = Label(self, text="Gripper Pos ")
        self.label.grid(row=1, column=1)

        self.GripperPos = IntVar()
        self.labelScaleGripperPos = Label(self,
                                          text=0,
                                          textvariable=self.GripperPos)
        self.labelScaleGripperPos.grid(row=1, column=3)

        #scale2 - X ROTATION
        scaleRotX = Scale(self,
                          from_=0,
                          to=650,
                          orient=HORIZONTAL,
                          length=300,
                          resolution=1,
                          command=self.onScaleXAxisRot)
        scaleRotX.grid(row=2, column=2)
        scaleRotX.set(450)

        self.label = Label(self, text="X Axis Rotation ")
        self.label.grid(row=2, column=1)

        self.labelRotX = Label(self)
        self.labelRotX.grid(row=2, column=3)

        #Entry1 - Force
        self.entryForce = Entry(self)
        self.entryForce.grid(row=3, column=2)
        self.entryForce.insert(0, "50")  #35=700

        #self.forceString = StringVar()
        #self.forceString.set(1023);
        self.labelForce = Label(self)
        self.labelForce.grid(row=3, column=3)
        #self.entryForce.insert(1023,self.force.get())
        #self.entry1.delete(0,END) #delete entry text
        #entry.bind("<Return>", callback) #calls callback function after hit "enter"

        self.label = Label(self, text="Current (A)")
        self.label.grid(row=6, column=1)
        self.labelCurrent = Label(self)
        self.labelCurrent.grid(row=6, column=3)

        #Entry2 - Speed
        self.entrySpeed = Entry(self)
        self.entrySpeed.grid(row=4, column=2)
        self.entrySpeed.insert(0, "4000")
        self.labelSpeed = Label(self)
        self.labelSpeed.grid(row=4, column=3)

        #Entry2 - Active Distance
        self.entryDistance = Entry(self)
        self.entryDistance.grid(row=5, column=2)

        #Entry3 - Send Command
        self.entrySendCommand = Entry(self)
        self.entrySendCommand.grid(row=8, column=2)

        self.activeDistance = IntVar()
        self.activeDistance.set(15)
        self.labelActiveDistance = Label(self)
        self.labelActiveDistance.grid(row=5, column=3)
        self.entryDistance.insert(0, self.activeDistance.get())

        #Button1 - close
        self.button1 = Button(self, text="close", command=self.gripperClose)
        self.button1.grid(row=7, column=1)
        #Button2 - open
        self.button2 = Button(self, text="open", command=self.gripperOpen)
        self.button2.grid(row=7, column=2)
        #Button3 - home
        self.button3 = Button(self,
                              text="home",
                              command=self.gripperHomeRoutine)
        self.button3.grid(row=7, column=3)
        #Button4 - send command
        self.button4 = Button(self, text="send", command=self.sendCommand)
        self.button4.grid(row=8, column=3)
        #Button3
        self.buttonForce = Button(self,
                                  text="forceSetPoint (mg)",
                                  command=self.gripperSetForce)
        self.buttonForce.grid(row=3, column=1)
        #Button4
        self.buttonSpeed = Button(self,
                                  text="speedSetPoint (mseg/close)",
                                  command=self.gripperSetSpeed)
        #80degree each finger = to move 40 degree to close
        self.buttonSpeed.grid(row=4, column=1)
        #Button5
        self.buttonDistance = Button(self,
                                     text="distanceSetPoint (Cm)",
                                     command=self.gripperSetDistance)
        self.buttonDistance.grid(row=5, column=1)
예제 #5
0
    def set_optional_buttons(self, supervoxel_id_path=None):
        """ Set bottoms to quit, change axis, show and hide segmentation, ...
        at the upper row of the main frame.
        """

        _sub_frame1 = Frame(self)
        _sub_frame1.grid(column=0,
                         row=0,
                         padx=10,
                         sticky=['n', 'e', 'w'])

        _sub_sub_frame1 = Frame(_sub_frame1)
        _sub_sub_frame1.grid(column=0,
                             row=0,
                             sticky=['e', 'w'],
                             pady=10)

        ind = 0
        self.button_axis = Button(_sub_sub_frame1,
                                  text="Change axis",
                                  command=self.change_axis)
        self.button_axis.grid(column=0, row=ind, pady=3)
        
        ind += 1
        self.button_axis = Button(_sub_sub_frame1,
                                  text="Mirror Images",
                                  command=self.mirror_image)
        self.button_axis.grid(column=0, row=ind, pady=3)

        ind = 0
        if self.segm is not None:

            _sub_sub_frame2 = Frame(_sub_frame1)
            _sub_sub_frame2.grid(column=0,
                                 row=1,
                                 sticky=['e', 'w'],
                                 pady=10)

            _sub_sub_frame3 = Frame(_sub_frame1)
            _sub_sub_frame3.grid(column=0,
                                 row=2,
                                 sticky=['e', 'w'],
                                 pady=10)

            self.button_supervoxels = Button(_sub_sub_frame2,
                                             text="Show/Hide supervoxels",
                                             command=self.change_supervoxels)
            self.button_supervoxels.grid(column=0,
                                         row=ind,
                                         sticky=['w', 'n', 'e'])

            if supervoxel_id_path is None:
                self.button_supervoxels['state'] = 'disabled'
            ind += 1

            self.tumor_checkbox_label = Label(_sub_sub_frame2,
                                              text="Display tumor type: ",
                                              relief=FLAT)
            self.tumor_checkbox_label.grid(column=0, row=ind)

            ind += 1
            self.tumor_cb = []
            for i in range(len(labels)):
                tumor_button = IntVar()
                this_text = '%s (%s <%s>)' % (labels[i], 
                                              label_colors_d[i], 
                                              label_hot_keys[i+1])
                button = Checkbutton(_sub_sub_frame2,
                                        text=this_text,
                                        variable=tumor_button,
                                        command=lambda arg0=i: self.change_segm(arg0))
                button.grid(column=0, row=ind, sticky=['w', 'n', 'e'])
                self.tumor_cb.append(tumor_button)
                ind += 1
                
            self.all_tumor_bc = IntVar()
            button = Checkbutton(_sub_sub_frame2,
                                    text="All tumors",
                                    variable=self.all_tumor_bc,
                                    command=lambda : self.change_segm(3))
            button.grid(column=0,
                        row=ind,
                        sticky=['w', 'n', 'e'])

            ind += 1
            self.no_tumor_bc = IntVar()
            button = Checkbutton(_sub_sub_frame2,
                                    text="No tumors",
                                    variable=self.no_tumor_bc,
                                    command=lambda : self.change_segm(4))
            button.grid(column=0,
                           row=ind,
                           sticky=['w', 'n', 'e'])

            ind += 1
            alpha_label = Label(_sub_sub_frame2, text="Opacity:")
            alpha_label.grid(column=0, row=ind)
            self.alpha_scale = Scale(_sub_sub_frame2,
                                     from_=0.0,
                                     to=1.0,
                                     command=self.set_alpha,
                                     orient=HORIZONTAL)
            ind += 1
            self.alpha_scale.set(self.alpha)
            self.alpha_scale.grid(column=0,
                                  row=ind,
                                  columnspan=self.image_nb,
                                  sticky=['w', 'n', 'e'])

            ind = 0
            self.button_save_segm = Button(_sub_sub_frame3,
                                           text="Save segmentation",
                                           command=self.save_segm)
            self.button_save_segm.grid(column=0, row=ind, sticky=['w', 'n', 'e'])

            ind += 1
            self.button_open_segm = Button(_sub_sub_frame3,
                                           text="Open segmentation",
                                           command=self.open_segm)
            self.button_open_segm.grid(column=0, row=ind, sticky=['w', 'n', 'e'])
예제 #6
0
    def configure_images(self,
                         pic_frame,
                         image_paths):
        """Create widgets to place images, descriptions and slice scrollers."""

        # create a sub frame to display the images
        self._imagelabel = [None for _ in range(self.image_nb)]
        self._image_view = [None for _ in range(self.image_nb)]
        _descrlabel = [None for _ in range(self.image_nb)]

        # descriptions of the images defaults to their path basenames
        descriptions = [os.path.basename(image_paths[i]) 
                        for i in range(self.image_nb)]

        self.histogram_sliders = []
        for i in range(self.image_nb):

            _sub_pic_frame = Frame(pic_frame)
            _sub_pic_frame.grid(column=int(i%2),
                                row=int(i/2),
                                pady=5)

            # set Label for a description above the images
            _descrlabel[i] = Label(_sub_pic_frame,
                                   text=descriptions[i])
            _descrlabel[i].grid(column=0, row=0)


            # set Label to depict the images
            self._imagelabel[i] = Label(_sub_pic_frame)
            self._imagelabel[i].grid(column=0, row=1)


            # set Scales for the intensity slides
            _sub_sub_frame = Frame(_sub_pic_frame)
            _sub_sub_frame.grid(column=0,
                                row=2)

            min_val = np.min(self.images_original[i])
            max_val = np.max(self.images_original[i])

            intensity_scale1 = Scale(_sub_sub_frame,
                                     from_=min_val,
                                     to=max_val/2,
                                     orient=HORIZONTAL)
            intensity_scale1.set(min_val)
            intensity_scale1.grid(column=0,
                                  row=0,
                                  sticky=['e', 'w', 's'])

            intensity_scale2 = Scale(_sub_sub_frame,
                                     from_=max_val/2,
                                     to=max_val,
                                     orient=HORIZONTAL)
            intensity_scale2.set(max_val)
            intensity_scale2.grid(column=1,
                                  row=0,
                                  sticky=['e', 'w', 's'])

            self.histogram_sliders.append(intensity_scale1)
            self.histogram_sliders.append(intensity_scale2)
            intensity_scale1.bind("<B1-Motion>", self.change_intensity)
            intensity_scale2.bind("<B1-Motion>", self.change_intensity)

            # Attach commands to the image frames
            self._imagelabel[i].bind("<Button-1>", self.click_image)
            self._imagelabel[i].bind("<Button-3>", self.label_dropdown)
            self._imagelabel[i].bind("<Button 4>", self.slice_up)
            self._imagelabel[i].bind("<Button 5>", self.slice_down)
            self._imagelabel[i].bind("<B1-Motion>", self.motion_image)
            self._imagelabel[i].bind("<Double-Button-1>", self.select_connected)
예제 #7
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)
    def initUI(self):

        #Parent Frame
        self.parent.title("Test Stand Control Panel")
        self.style = Style()
        self.style.theme_use("default")

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


        # Frame 1 (top)
        frame1 = Frame(self)
        frame1.pack(fill=X, expand=1)

            #Start motor button
        startButton = Button(frame1, text="Start Motor",
            command=self.startMotor)
        startButton.pack(side=LEFT, padx=5, pady=5)     


            #Throttle slider
        lbl1 = Label(frame1, text="Throttle (0-100):", width=14)
        lbl1.pack(side=LEFT, padx=5, pady=5)
        
        self.scale = Scale(frame1, from_=0, to=100, 
            command=self.onScaleThrottle)
        self.scale.pack(side=LEFT, padx=15)
        
        self.label = Label(frame1, text="throttle", textvariable=self.throttlevar, width=5)        
        self.label.pack(side=LEFT)

            #Throttlesweep checkbutton
        self.autovar = BooleanVar()
        cb = Checkbutton(frame1, text="Throttle Sweep",
            variable=self.autovar, command=self.onClickAuto)
        cb.pack(side=LEFT, padx=15)

            #Com port selection field
        droplbl = Label(frame1, text="Serial Port:", width=10)
        droplbl.pack(side=LEFT, padx=5, pady=5)
        self.selected_s_Port = StringVar()
        self.s_Ports = []
        self.drop = OptionMenu(frame1,self.selected_s_Port,"None",*self.s_Ports)
        self.drop.pack(side=LEFT, padx=5)

            #baudrate selection field (disabled)
##       drop2lbl = Label(frame1, text="Baudrate:", width=9)
##        drop2lbl.pack(side=LEFT, padx=5, pady=5)
##        self.baudrate = StringVar()
##        baudrates = [9600, 19200, 38400, 57600, 115200]
##        drop2 = OptionMenu(frame1,self.baudrate,*baudrates)
##        drop2.pack(side=LEFT, padx=5)

            #Start serial button
        comsButton = Button(frame1, text="Start Serial",
            command=self.startSerial)
        comsButton.pack(side=LEFT, padx=5, pady=5)

            #Stop serial button
        comsStopButton = Button(frame1, text="Stop Serial",
            command=self.stopSerial)
        comsStopButton.pack(side=LEFT, padx=5, pady=5)

        # Frame 2 (second line)
        frame2 = Frame(self)
        frame2.pack(fill=X, expand=1)

            #Amperage entry
        lbl2 = Label(frame2, text="Max Motor Current (A):", width=21)
        lbl2.pack(side=LEFT, padx=5, pady=5)
        
        self.MaxA_Entry = Entry(frame2)
        self.MaxA_Entry.pack(side="left", fill=X, padx=5, expand=False)
        self.MaxA_Entry.insert(0, 10)

            #Voltage entry
        lbl3 = Label(frame2, text="Max Motor Voltage (V):", width=20)
        lbl3.pack(side=LEFT, padx=5, pady=5)
        
        self.MaxV_Entry = Entry(frame2)
        self.MaxV_Entry.pack(side="left", fill=X, padx=5, expand=False)
        self.MaxV_Entry.insert(0, 14)

            #Update button
        updateButton = Button(frame2, text="Update Values",
            command=self.updateValues)
        updateButton.pack(side=LEFT, padx=5, pady=5)
        
        # Graph Frame
        framegraph = Frame(self)
        framegraph.pack(fill=X, expand=1)

            #Init figures
        f = Figure(figsize=(4,4), dpi=100)
        self.a = f.add_subplot(2, 2, 1)
        self.d = f.add_subplot(2, 2, 4)
        self.c = f.add_subplot(2, 2, 3)
        self.b = f.add_subplot(2, 2, 2)
        
        f.set_tight_layout(True)

        self.canvas = matplotlib.backends.backend_tkagg.FigureCanvasTkAgg(f, master=self)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

            #Display Toolbar
        toolbar = NavigationToolbar2TkAgg(self.canvas, framegraph)
        toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        
        # Frame 0 (Bottom text)
        frame0 = Frame(self)
        frame0.pack(side="bottom", fill="x", expand=1)

            #Display text (allows to give user information)
        self.textboxvar = StringVar()
        self.info = Label(frame0, textvariable=self.textboxvar)
        self.info.pack(side=LEFT, padx=5, pady=5)

        # Button Frame (large buttons, near bottom)
        s = Style() #has its own style
        s.configure('My.TFrame',background='#f7edc3') #fancy colors
        framered = Frame(self, style='My.TFrame')
        framered.pack(side="bottom", fill="x", expand=1)
        #used the tk instead of ttk library for this, allows font and color mods

            #Save Button
        self.saveButton = tk.Button(framered, text="Save Data", bg='green', font=('Arial',20,'bold'),
            command=self.saveData)
        self.saveButton.pack(side="left", padx=5, pady=5)

            #Log button
        self.logButton = tk.Button(framered, text="Start Data Logging", bg="blue", font=('Arial',20,'bold'),
            command=self.logData)
        self.logButton.pack(side="left", padx=5, pady=5)

            #Stop button
        self.stopButton = tk.Button(framered, text="Stop Motor", bg='red', font=('Arial',20,'bold'),
            command=self.stopMotor)
        self.stopButton.pack(side="right", padx=5, pady=5)
예제 #9
0
    def initUI(self, parent):
        # initalising some variables
        self.Quality_e = None
        self.scale = None
        self.fmemory_e = None
        self.memory_e = None

        self.style = Style()
        self.style.theme_use("classic")
        Style().configure("TEntry", font='serif 10')
        Style().configure("TLabel", font='serif 10')

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

        fileMenu = Menu(menubar)
        fileMenu.add_command(label="Restart", command=self.re_start)
        menubar.add_cascade(label="Options", menu=fileMenu)

        # creating layout from frames
        self.frame3 = Frame(parent, relief="sunken")
        self.frame3.pack(side="bottom", fill=X)
        self.frame1 = Frame(parent, relief="sunken")
        self.frame1.pack(side="left", fill=Y)
        self.frame2 = Frame(parent,
                            width=gbl.x2 - gbl.x1,
                            height=max(gbl.y2 - gbl.y1, 200),
                            relief="flat",
                            bg="#333")
        self.frame2.pack(side="right", fill="both", expand="True")

        # creating canvas in frame 2
        self.canvas = Canvas(self.frame2)
        self.canvas.pack(fill="both", expand="True")

        # creating save and next Button
        self.b9 = Button(self.frame1,
                         text="Save and Next>>",
                         state="active",
                         font='serif 10',
                         command=self.save_next)
        self.b9.pack(side="bottom", pady=5)
        self.b9.bind('<Return>', self.save_next)
        self.b8 = Button(self.frame1,
                         text="<<Back",
                         state="active",
                         font='serif 10',
                         command=self.go_back)
        self.b8.pack(side="bottom", pady=5)
        self.b8.bind('<Return>', self.go_back)
        self.parent.bind('<Return>', self.save_next)

        # track for editable entries
        self.e1s = StringVar(self.frame1)
        self.e2s = StringVar(self.frame1)
        self.e1s.trace("w", self.check)
        self.e2s.trace("w", self.check)

        # creating editable format and quality entries
        # self.format_e = self.make_entry(gbl.out_format, "Format (Default JPEG)")
        self.format_e = Entry(self.frame1,
                              textvariable=self.e1s,
                              bg="white",
                              bd=4,
                              cursor="xterm",
                              fg="Black",
                              justify="center",
                              relief="ridge")
        self.format_e.insert(0, "JPEG")
        self.format_e.pack(side="top")
        Label(self.frame1, text="Format (Default JPEG)").pack(side="top")

        # self.Quality_e = self.make_entry(gbl.Quality, "Format (Default 80)")
        self.Quality_e = Entry(self.frame1,
                               textvariable=self.e2s,
                               bg="white",
                               bd=4,
                               cursor="xterm",
                               fg="Black",
                               justify="center",
                               relief="ridge")
        self.Quality_e.insert(0, gbl.Quality)
        self.Quality_e.pack(side="top")
        Label(self.frame1, text="Quality (Default 80)").pack(side="top")
        # self.format_e.config(textvariable=self.e1s)
        # self.Quality_e.config(textvariable=self.e2s)

        # creating sliding bar
        self.var = IntVar()
        self.scale = Scale(self.frame1,
                           from_=1,
                           to=100,
                           orient="horizontal",
                           length=168,
                           command=self.onScale)
        self.scale.set(gbl.Quality)
        self.scale.pack(side="top")

        self.l1 = Label(self.frame1, textvariable=self.var)
        self.l1.pack(side="top")
        self.var.set(gbl.Quality)

        # saving and putting PIL.Image in canvas
        self.save_put_image()

        # creating memory entries
        self.fmemory_e = self.set_memory_entry(self.frame1, "Final",
                                               gbl.output_file)
        self.memory_e = self.set_memory_entry(self.frame1, "Initial",
                                              gbl.input_file)

        # creating status bar
        Label(self.frame3, text=gbl.output_file).pack(side="left", anchor="w")
        Label(self.frame3, text=str(gbl.cu_ind) + "/" +
              str(gbl.total_files)).pack(side="right", anchor="e")
    def initUI(self):

        #Parent Frame
        self.parent.title("Test Stand Control Panel")
        self.style = Style()
        self.style.theme_use("default")

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


        # Frame 1 (top)
        frame1 = Frame(self)
        frame1.pack(fill=X, expand=1)

            #Start motor button
        startButton = Button(frame1, text="Start Motor",
            command=self.startMotor)
        startButton.pack(side=LEFT, padx=5, pady=5)     


            #Throttle slider
        lbl1 = Label(frame1, text="Throttle (0-100):", width=14)
        lbl1.pack(side=LEFT, padx=5, pady=5)
        
        scale = Scale(frame1, from_=0, to=100, 
            command=self.onScaleThrottle)
        scale.pack(side=LEFT, padx=15)
        
        self.throttlevar = StringVar()
        self.throttleval = IntVar()
        self.label = Label(frame1, text="throttle", textvariable=self.throttlevar, width=5)        
        self.label.pack(side=LEFT)

            #Throttlesweep checkbutton
        self.autovar = BooleanVar()
        cb = Checkbutton(frame1, text="Throttle Sweep",
            variable=self.autovar, command=self.onClickAuto)
        cb.pack(side=LEFT, padx=15)

            #Com port selection field
        droplbl = Label(frame1, text="Serial Port:", width=10)
        droplbl.pack(side=LEFT, padx=5, pady=5)
        self.selected_s_Port = StringVar()
        self.s_Ports = []
        drop = OptionMenu(frame1,self.selected_s_Port,"None",*self.s_Ports)
        drop.pack(side=LEFT, padx=5)

            #baudrate selection field (disabled)
##        drop2lbl = Label(frame1, text="Baudrate:", width=9)
##        drop2lbl.pack(side=LEFT, padx=5, pady=5)
##        self.baudrate = StringVar()
##        baudrates = [9600, 19200, 38400, 57600, 115200]
##        drop2 = OptionMenu(frame1,self.baudrate,*baudrates)
##        drop2.pack(side=LEFT, padx=5)

            #Start serial button
        comsButton = Button(frame1, text="Start Serial",
            command=self.startSerial)
        comsButton.pack(side=LEFT, padx=5, pady=5)

            #Stop serial button
        comsStopButton = Button(frame1, text="Stop Serial",
            command=self.stopSerial)
        comsStopButton.pack(side=LEFT, padx=5, pady=5)

        # Frame 2 (second line)
        frame2 = Frame(self)
        frame2.pack(fill=X, expand=1)

            #Amperage entry
        lbl2 = Label(frame2, text="Max Motor Current (A):", width=21)
        lbl2.pack(side=LEFT, padx=5, pady=5)
        
        self.MaxA_Entry = Entry(frame2)
        self.MaxA_Entry.pack(side="left", fill=X, padx=5, expand=False)
        self.MaxA_Entry.insert(0, 10)

            #Voltage entry
        lbl3 = Label(frame2, text="Max Motor Voltage (V):", width=20)
        lbl3.pack(side=LEFT, padx=5, pady=5)
        
        self.MaxV_Entry = Entry(frame2)
        self.MaxV_Entry.pack(side="left", fill=X, padx=5, expand=False)
        self.MaxV_Entry.insert(0, 14)

            #Update button
        updateButton = Button(frame2, text="Update Values",
            command=self.updateValues)
        updateButton.pack(side=LEFT, padx=5, pady=5)
        
        # Graph Frame
        framegraph = Frame(self)
        framegraph.pack(fill=X, expand=1)

            #Init figures
        f = Figure(figsize=(4.5,4.5), dpi=100)
        self.a = f.add_subplot(2, 2, 1)
        self.d = f.add_subplot(2, 2, 4)
        self.c = f.add_subplot(2, 2, 3)
        self.b = f.add_subplot(2, 2, 2)
        
        f.set_tight_layout(True)

        self.canvas = matplotlib.backends.backend_tkagg.FigureCanvasTkAgg(f, master=self)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

            #Display Toolbar
        toolbar = NavigationToolbar2TkAgg(self.canvas, framegraph)
        toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

            #Refresh thread function
        def refreshFigure(): #this is threaded and just refreshes the figure (see time.sleep() for refresh rate)
            time.sleep(1)
            while True  and (not exitapp):
                self.a.clear()
                self.b.clear()
                self.c.clear()
                self.d.clear()
                if not serialStatus:
                    self.a.plot([1,2,3,4,5,6,7,8],[0,0,0,0,0,0,0,0])
                    self.b.plot([1,2,3,4,5,6,7,8],[0,0,0,0,0,0,0,0])
                    self.c.plot([1,2,3,4,5,6,7,8],[0,0,0,0,0,0,0,0])
                    self.d.plot([1,2,3,4,5,6,7,8],[0,0,0,0,0,0,0,0])
                else:
                    #debug plotsTimestamp
                    self.a.plot(serialData[-10:]["Timestamp"],serialData[-10:]["Timestamp"])
                    self.b.plot(serialData[-10:]["Timestamp"],serialData[-10:]["raw_temp"])
                    self.c.plot(serialData[-10:]["Timestamp"],serialData[-10:]["conv_temp"])
                    self.d.plot(serialData[-10:]["Timestamp"],serialData[-10:]["Potentiometer"])
                    #final plots
    ##                self.a.plot(serialData[-10:]["Timestamp"],serialData[-10:]["Thrust"])
    ##                self.b.plot(serialData[-10:]["Timestamp"],serialData[-10:]["RPM"])
    ##                self.c.plot(serialData[-10:]["Timestamp"],serialData[-10:]["Current"])
    ##                self.d.plot(serialData[-10:]["Timestamp"],serialData[-10:]["Voltage"])
                    #old demo stuff
    ##                self.a.plot([1,2,3,4,5,6,7,8],[5,6,1,3,self.throttleval.get(),9,3,5])
    ##                self.b.plot([1,2,3,4,5,6,7,8],[3,16,10,30,80,90,30,50])
    ##                self.c.plot([1,2,3,4,5,6,7,8],[8,5,4,(self.throttleval.get())**(0.5),15,15,15,20])
    ##                self.d.plot([1,2,3,4,5,6,7,8],[14,14,13,12,12,11.5,11.2,10.5])

                #set labels for graphs (could make automatic later)
                self.a.set_xlabel('time (s)')
                self.a.set_ylabel('Thrust (N)')
                self.b.set_xlabel('time (s)')
                self.b.set_ylabel('RPM')
                self.c.set_xlabel('time (s)')
                self.c.set_ylabel('Current (A)')
                self.d.set_xlabel('time (s)')
                self.d.set_ylabel('Voltage (V)')

                #try drawing the canvas
                try:
                    self.canvas.draw()
                except:
                    pass #just ignore it, you'll do better next time
                time.sleep(0.1) #refreshrate
        ###END FUNCTION###

            #Start the graphing thread
        plotThread = Thread(target=refreshFigure, args=())
        plotThread.start()
        threads.append(plotThread)
        
        # Frame 0 (Bottom text)
        frame0 = Frame(self)
        frame0.pack(side="bottom", fill="x", expand=1)

            #Display text (allows to give user information)
        self.textboxvar = StringVar()
        self.info = Label(frame0, textvariable=self.textboxvar)
        self.info.pack(side=LEFT, padx=5, pady=5)

        # Button Frame (large buttons, near bottom)
        s = Style() #has its own style
        s.configure('My.TFrame',background='#f7edc3') #fancy colors
        framered = Frame(self, style='My.TFrame')
        framered.pack(side="bottom", fill="x", expand=1)
        #used the tk instead of ttk library for this, allows font and color mods

            #Save Button
        self.saveButton = tk.Button(framered, text="Save Data", bg='green', font=('Arial',20,'bold'),
            command=self.saveData)
        self.saveButton.pack(side="left", padx=5, pady=5)

            #Log button
        self.logButton = tk.Button(framered, text="Start Data Logging", bg="blue", font=('Arial',20,'bold'),
            command=self.logData)
        self.logButton.pack(side="left", padx=5, pady=5)

            #Stop button
        self.stopButton = tk.Button(framered, text="Stop Motor", bg='red', font=('Arial',20,'bold'),
            command=self.stopMotor)
        self.stopButton.pack(side="right", padx=5, pady=5)