def pingServer(self): """ Checks if server is correctly connected @rtype: None @return: None """ self.serverConnected = self.interface.ping() if self.serverConnected: self.cropped_np = tab_tools.get_image( 'assets/classify_instructions.jpg') else: self.cropped_np = tab_tools.get_image('assets/server_error.jpg')
def noPreviousRaw(self): """ Checks if server is correctly connected @rtype: None @return: None """ self.serverConnected = self.interface.ping() if self.serverConnected: self.org_np = tab_tools.get_image('assets/noPreviousRaw.jpg') else: self.org_np = tab_tools.get_image('assets/server_error.jpg') self.t1c2r6b.configure(text="N/A",foreground="#636363") self.t1c2r1b.configure(text="N/A")
def noNextCropped(self): """ Checks if server is correctly connected @rtype: None @return: None """ self.serverConnected = self.interface.ping() if self.serverConnected: self.cropped_np = tab_tools.get_image('assets/noNextCropped.jpg') self.t2c2lr48b.configure(text='N/A', foreground='#636363') else: self.cropped_np = tab_tools.get_image('assets/server_error.jpg') self.t2c2lr48b.configure(text='N/A', foreground='#636363')
def __init__(self,master,notebook): # itialize variables self.version_num = "Version 0.1.8.1" self.master = master self.n = notebook self.initialized = False #self.default_host = '127.0.0.1' # host if running on own machine self.default_host = '192.168.1.10' self.default_port = '5000' self.default_idnum = 9999 self.default_debug = False self.interface = client_rest.ImagingInterface(host=self.default_host,port=self.default_port,numIdsStored=self.default_idnum,isDebug=self.default_debug) self.resize_counter_tab0 = time.time() # Tab 0: SETTINGS ------------------------------------------------------ self.tab0 = ttk.Frame(self.n) self.n.add(self.tab0, text='Settings') # makes resizing possible for x in range(6): tk.Grid.columnconfigure(self.tab0,x,weight=1) for y in range(10): tk.Grid.rowconfigure(self.tab0,y,weight=1) # Left Column self.t0c0r0 = ttk.Label(self.tab0, anchor=tk.CENTER, text=' ') self.t0c0r0.grid(row=0,column=0,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c1r0 = ttk.Label(self.tab0, anchor=tk.CENTER, text=' ') self.t0c1r0.grid(row=0,column=1,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) # Middle Column self.logo_np = tab_tools.get_image('assets/logo.png') self.logo_im = tab_tools.np2im(self.logo_np) self.logo_width,self.logo_height = self.logo_im.size self.logo_tk = tab_tools.im2tk(self.logo_im) self.t0c2r0 = ttk.Label(self.tab0, anchor=tk.CENTER,image=self.logo_tk) self.t0c2r0.image = self.logo_tk self.t0c2r0.grid(row=0,column=2,rowspan=5,columnspan=2,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c2r5 = ttk.Label(self.tab0, anchor=tk.E, text='Host:') self.t0c2r5.grid(row=5,column=2,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c3host = tk.StringVar() self.t0c3host.set(self.default_host) self.t0c3r5 = ttk.Entry(self.tab0,textvariable=self.t0c3host) self.t0c3r5.grid(row=5,column=3,sticky=tk.N+tk.S+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c2r6 = ttk.Label(self.tab0, anchor=tk.E, text='Port:') self.t0c2r6.grid(row=6,column=2,sticky=tk.N+tk.E+tk.S+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c3port = tk.StringVar() self.t0c3port.set(self.default_port) self.t0c3r6 = ttk.Entry(self.tab0,textvariable=self.t0c3port) self.t0c3r6.grid(row=6,column=3,sticky=tk.N+tk.S+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c2r7 = ttk.Label(self.tab0, anchor=tk.E, text='Number of IDs Stored:') self.t0c2r7.grid(row=7,column=2,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c3ids = tk.StringVar() self.t0c3ids.set(self.default_idnum) self.t0c3r7 = ttk.Entry(self.tab0,textvariable=self.t0c3ids) self.t0c3r7.grid(row=7,column=3,sticky=tk.N+tk.S+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c2r8 = ttk.Label(self.tab0, anchor=tk.E, text='Debug Mode:') self.t0c2r8.grid(row=8,column=2,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c3debug = tk.IntVar() self.t0c3r8 = ttk.Radiobutton(self.tab0,text='True',value=0,variable=self.t0c3debug) self.t0c3r8.grid(row=8,column=3,sticky=tk.N+tk.S+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c3r8b = ttk.Radiobutton(self.tab0,text='False',value=1,variable=self.t0c3debug) self.t0c3r8b.grid(row=8,column=3,sticky=tk.N+tk.S,padx=5,pady=5,ipadx=5,ipady=5) if not self.default_debug: self.t0c3debug.set(1) self.t0c2r9 = ttk.Button(self.tab0, text="Apply Settings",command=self.updateSettings) self.t0c2r9.grid(row=9,column=2,columnspan=2,sticky=tk.N+tk.S,padx=5,pady=5,ipadx=5,ipady=5) # Right Column self.t0c4r0 = ttk.Label(self.tab0, anchor=tk.CENTER, text=' ') self.t0c4r0.grid(row=0,column=4,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c5r0 = ttk.Label(self.tab0, anchor=tk.CENTER, text=' ') self.t0c5r0.grid(row=0,column=5,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c4r6 = ttk.Label(self.tab0, anchor=tk.S, text=self.version_num) self.t0c4r6.grid(row=6,column=4,columnspan=2,sticky=tk.N+tk.S+tk.E+tk.W,padx=5,pady=5,ipadx=5,ipady=5) self.t0c4r7 = ttk.Button(self.tab0, text=" Save Database ",command=self.saveDatabase) self.t0c4r7.grid(row=7,column=4,columnspan=2,sticky=tk.N+tk.S,padx=5,pady=5,ipadx=5,ipady=5) self.t0c4r8 = ttk.Button(self.tab0, text=" Load Database ",command=self.loadDatabase) self.t0c4r8.grid(row=8,column=4,columnspan=2,sticky=tk.N+tk.S,padx=5,pady=5,ipadx=5,ipady=5) if not self.default_debug: self.t0c4r8.configure(state=tk.DISABLED) self.t0c4r9 = tk.Button(self.tab0, text="Delete Database",command=self.deleteDatabase, \ bg='red',fg='white',bd=2) self.t0c4r9.grid(row=9,column=4,columnspan=2,sticky=tk.N+tk.S,padx=5,pady=5,ipadx=5,ipady=5) if not self.default_debug: self.t0c4r9.configure(state=tk.DISABLED) # Done with initialization self.initialized = True
def __init__(self, master, notebook, interface): self.master = master self.n = notebook self.interface = interface self.initialized = False self.resize_counter_tab2 = time.time() self.pingServer() self.cropped_im = tab_tools.np2im(self.cropped_np) self.cropped_width, self.cropped_height = self.cropped_im.size self.cropped_tk = tab_tools.im2tk(self.cropped_im) # Tab 2 variables self.t2_functional = False # prevent self.t2_entry_focus = False # TAB 2: CLASSIFICATION ------------------------------------------------ self.tab2 = ttk.Frame(self.n) # second page self.n.add(self.tab2, text='Classification') for x in range(16): tk.Grid.columnconfigure(self.tab2, x, weight=1) for y in range(50): tk.Grid.rowconfigure(self.tab2, y, weight=1) # Column One self.t2c1title = ttk.Label(self.tab2, anchor=tk.CENTER, text=' ') self.t2c1title.grid(row=0, column=0, columnspan=4, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) # Column Two self.t2sep12 = ttk.Separator(self.tab2, orient=tk.VERTICAL) self.t2sep12.grid(row=0, column=4, rowspan=50, sticky=tk.N + tk.S + tk.E + tk.W, pady=5) self.t2c2title = ttk.Label(self.tab2, anchor=tk.CENTER, text='Classification') self.t2c2title.grid(row=0, column=4, columnspan=8, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2i1 = ttk.Label(self.tab2, anchor=tk.CENTER, image=self.cropped_tk) self.t2c2i1.image = self.cropped_tk self.t2c2i1.grid(row=2, column=4, rowspan=38, columnspan=8, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l1 = ttk.Label(self.tab2, anchor=tk.CENTER, text='Shape') self.t2c2l1.grid(row=40, column=4, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) shape_options = ('circle', 'semicircle', 'quarter_circle', 'triangle', 'square', 'rectangle', 'trapezoid', 'pentagon', 'hexagon', 'heptagon', 'octagon', 'star', 'cross') self.t2c2l2_var = tk.StringVar(self.master) self.t2c2l2 = ttk.OptionMenu(self.tab2, self.t2c2l2_var, shape_options[0], *shape_options) self.t2c2l2.grid(row=42, column=4, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l3 = ttk.Label(self.tab2, anchor=tk.CENTER, text='Alphanumeric') self.t2c2l3.grid(row=40, column=6, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l4_var = tk.StringVar(self.master) alphanumericValidateCommand = self.master.register( self.alphanumericValidate) self.t2c2l4 = ttk.Entry(self.tab2, textvariable=self.t2c2l4_var, validate=tk.ALL, validatecommand=(alphanumericValidateCommand, '%d', '%P')) self.t2c2l4.grid(row=42, column=6, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l5 = ttk.Label(self.tab2, anchor=tk.CENTER, text='Orientation') self.t2c2l5.grid(row=40, column=8, columnspan=4, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) orientation_options = ('N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW') self.t2c2l6_var = tk.StringVar(self.master) self.t2c2l6 = ttk.OptionMenu(self.tab2, self.t2c2l6_var, orientation_options[0], *orientation_options) self.t2c2l6.grid(row=42, column=8, columnspan=4, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l9 = ttk.Label(self.tab2, anchor=tk.CENTER, text='Background Color') self.t2c2l9.grid(row=44, column=4, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) color_options = ('white', 'black', 'gray', 'red', 'blue', 'green', 'yellow', 'purple', 'brown', 'orange') self.t2c2l10_var = tk.StringVar(self.master) self.t2c2l10 = ttk.OptionMenu(self.tab2, self.t2c2l10_var, color_options[0], *color_options) self.t2c2l10.grid(row=46, column=4, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l11 = ttk.Label(self.tab2, anchor=tk.CENTER, text='Alphanumeric Color') self.t2c2l11.grid(row=44, column=6, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l12_var = tk.StringVar(self.master) self.t2c2l12 = ttk.OptionMenu(self.tab2, self.t2c2l12_var, color_options[0], *color_options) self.t2c2l12.grid(row=46, column=6, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l13 = ttk.Label(self.tab2, anchor=tk.CENTER, text='Target Type') self.t2c2l13.grid(row=44, column=8, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l14_var = tk.StringVar(self.master) target_options = ('standard', 'emergent', 'off_axis') self.t2c2l14 = ttk.OptionMenu(self.tab2, self.t2c2l14_var, target_options[0], *target_options) self.t2c2l14.grid(row=46, column=8, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l14_var.trace("w", self.disableEmergentDescription) self.t2c2l15 = ttk.Label(self.tab2, anchor=tk.CENTER, text='Emergent Description') self.t2c2l15.grid(row=44, column=10, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l16_var = tk.StringVar() self.t2c2l16_var.set(None) self.t2c2l16 = ttk.Entry(self.tab2, textvariable=self.t2c2l16_var) self.t2c2l16.grid(row=46, column=10, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2r48a = ttk.Label(self.tab2, anchor=tk.E, text='Submission Status: ') self.t2c2r48a.grid(row=48, column=4, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2lr48b = ttk.Label(self.tab2, anchor=tk.W, text='N/A') self.t2c2lr48b.grid(row=48, column=6, columnspan=2, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.t2c2l17 = ttk.Button(self.tab2, text="Submit Classification", command=self.submitClassification) self.t2c2l17.grid(row=48, column=8, columnspan=4, rowspan=2, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.disableEmergentDescription() # Column Three self.t2sep23 = ttk.Separator(self.tab2, orient=tk.VERTICAL) self.t2sep23.grid(row=0, column=12, rowspan=50, sticky=tk.N + tk.S + tk.E + tk.W, pady=5) self.t2c3title = ttk.Label(self.tab2, anchor=tk.CENTER, text=' ') self.t2c3title.grid(row=0, column=12, columnspan=4, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) t2c2i1_np = tab_tools.get_image('assets/compass.jpg') self.t2c3i1_im = tab_tools.np2im(t2c2i1_np) self.t2c3i1_default_width, self.t2c3i1_default_height = self.t2c3i1_im.size self.t2c3i1_tk = tab_tools.im2tk(self.t2c3i1_im) # place image self.t2c3i1 = ttk.Label(self.tab2, anchor=tk.CENTER, image=self.t2c3i1_tk) self.t2c3i1.image = self.t2c3i1_tk self.t2c3i1.grid(row=2, column=12, rowspan=38, columnspan=4, sticky=tk.N + tk.S + tk.E + tk.W, padx=5, pady=5, ipadx=5, ipady=5) self.initialized = True