def refresh_window(object, format, label_list): msg = "<Device_Info id=\"1\" />\n" newmsg = handleCommand.sendCommand(object, msg, True) global taglist data = xmlParser.ParseXML(newmsg, "device_info", "none", taglist) placeValues(object, data, format, label_list) object.topwin.after(5, lambda: refresh_window(object, format, label_list))
def refresh_dataFrame(self): self.measuring = False send = "<Object_List />\n" rec = handleCommand.sendCommand(self, send, True) names = [] objinfo = xmlParser.ParseXML(rec, "object", "object", names) for widget in self.dataFrame.winfo_children(): widget.destroy() objectIndex = self.parsedList.index(objinfo[-1]) self.objectDetails(objectIndex) if self.isOOT == True: self.listboxFrame.objects.itemconfig(objectIndex, bg="red") else: self.listboxFrame.objects.itemconfig(objectIndex, bg="green") self.listboxFrame.objects.selection_clear(0, END) self.listboxFrame.objects.selection_set(objectIndex) self.listboxFrame.objects.activate(objectIndex) try: if self.top.winfo_exists(): if objinfo[-1] != objinfo[-2]: for widget in self.top.winfo_children(): widget.destroy() self.showResults() else: self.update_rro() except AttributeError: #do nothing, no window None
def objectDetails(self, num): sender = "<Inspect_Object_Info id=\"" + str(num) + "\" />\n" received = handleCommand.sendCommand(self, sender, False) taglist = [ "name", "nominal", "measured", "deviation", "tolmin", "tolmax" ] self.objectList = xmlParser.ParseXML(received, "property", "none", taglist) self.placeResults(num)
def getPlans(self): Label(text="Active Plan").place(x=0, y=50) sender = "<Inspect_Plan_List />\n" received = handleCommand.sendCommand(self, sender, True) self.Plans = xmlParser.ParseXML(received, "plan", "id", None) if len(self.Plans) == 0: self.Plans.append("No Plans") # CREATE DROP DOWN self.selected = StringVar() menu = ttk.Combobox(self, values=[*self.Plans], textvariable=self.selected) menu.current(0) menu.place(x=0, y=80) menu.bind("<<ComboboxSelected>>", self.userSelection) self.planDetails(0)
def checkOOT(self, num): indexOOT = [] for i in range(0, num): isOOT = False sender = "<Inspect_Object_Info id=\"" + str(i) + "\" />\n" received = handleCommand.sendCommand(self, sender, False) taglist = [ "name", "nominal", "measured", "deviation", "tolmin", "tolmax" ] list = xmlParser.ParseXML(received, "property", "none", taglist) for items in list: if items['measured'] == 0: isOOT = None break elif items['deviation'] > items['tolmax'] or items[ 'deviation'] < items['tolmin']: isOOT = True break indexOOT.insert(i, isOOT) return indexOOT
def planDetails(self, planNumber): try: send = "<Inspect_Plan_Load id=\"" + str(planNumber) + "\" />\n" received = handleCommand.sendCommand(self, send, True) send = "<Inspect_Plan_Info id = \"" + str(planNumber) + "\" />\n" received = handleCommand.sendCommand(self, send, True) self.parsedList = xmlParser.ParseXML(received, "plan_object", "object_id", None) # CREATE DROP DOWN self.listboxFrame.scrollbar = Scrollbar(self.listboxFrame, orient="vertical") self.listboxFrame.scrollbar.pack(side=RIGHT, fill=Y) self.listboxFrame.objects = Listbox(self.listboxFrame, height=20) self.listboxFrame.objects.pack(side=LEFT, expand=True, fill=Y) self.listboxFrame.objects.config( yscrollcommand=self.listboxFrame.scrollbar.set) self.listboxFrame.objects.bind("<<ListboxSelect>>", self.ObjectSelect) self.listboxFrame.scrollbar.config( command=self.listboxFrame.objects.yview) x = 1 for items in self.parsedList: self.listboxFrame.objects.insert(END, items) x += 1 ranger = len(self.parsedList) isOOT = self.checkOOT(ranger) x = 0 for i in isOOT: if i == True: self.listboxFrame.objects.itemconfig(x, bg="red") elif i == None: self.listboxFrame.objects.itemconfig(x, bg="white") else: self.listboxFrame.objects.itemconfig(x, bg="green") x += 1 except: showinfo("No data", "Selected plan has no objects.")
def msmtFrameLayout(self): menu = ttk.Combobox(self.msmtFrame, values=[ 'Point', 'Line', 'Circle', 'Ellipse', 'Slot', 'Plane', 'Sphere', 'Cylinder', 'Spline', 'Cone' ], textvariable=self.objType) menu.pack() menu.current(0) menu.bind("<<ComboboxSelected>>", self.selection) modes = [("Single Point", "0"), ("Continuous", "1"), ("Average Point", "2")] ptMode = handleCommand.sendCommand(self, "<Measure_Get_Point_Mode />\n", True) nolist = [] ptMode = xmlParser.ParseXML(ptMode, "data", "data", nolist) self.v = StringVar() self.v.set(ptMode[0]) for text, mode in modes: b = Radiobutton(self.msmtFrame, text=text, variable=self.v, value=mode, justify=LEFT, command=self.ptMode, indicatoron=0) b.pack(anchor=W) msmtBtn = Button(self.msmtFrame, text="Measure", command=lambda: handleCommand.sendCommand( self, "<Measure_Trigger />\n", True), height=1, width=15) msmtBtn.pack()
def dispDevice(object): # get data msg = "<Build />\n" rmsg = handleCommand.sendCommand(object, msg, True) if rmsg == None: return msg = "<Device_Info id=\"1\" />\n" rmsg = handleCommand.sendCommand(object, msg, True) global taglist data = xmlParser.ParseXML(rmsg, "device_info", "none", taglist) # set up interface object.font1 = font.Font(object.master, family="Helvetica", size=10, weight="bold") object.topwin = Toplevel(master=None, relief="sunken") object.topwin.title("Device Read Out") for x in range(0, 5): object.topwin.grid_rowconfigure(x, weight=1) object.topwin.grid_columnconfigure(x, weight=1) xpads = 10 ypads = 10 widthnum = 5 items = data[0] setup = ["X", "Y", "Z", "3D"] rownum = 1 for labels in setup: lbl = Label(object.topwin, text=labels, font=object.font1) lbl.grid(row=rownum, column=0) lbl.grid_configure(sticky="nsew") lbl.grid_rowconfigure(0, weight=1) lbl.grid_columnconfigure(0, weight=1) rownum += 1 setup = ["Nom", "Meas", "Dev"] colnum = 1 for labels in setup: lbl = Label(object.topwin, text=labels, font=object.font1, anchor=E) lbl.grid(row=0, column=colnum) lbl.grid_configure(sticky="nsew") lbl.grid_rowconfigure(0, weight=1) lbl.grid_columnconfigure(0, weight=1) colnum += 1 format = ['PX', 'PY', 'PZ', 'X', 'Y', 'Z', 'DX', 'DY', 'DZ'] rownum = 1 colnum = 1 label_list = [] for names in format: if rownum == 4: colnum += 1 rownum = 1 object.newLabel = Label(object.topwin, text="{:.3f}".format(items[names]), font=object.font1, anchor=E, width=widthnum) object.newLabel.grid(row=rownum, column=colnum, padx=xpads, pady=ypads, sticky="nsew") label_list.append(object.newLabel) rownum += 1 object.dev3D = Label(object.topwin, text="{:.3f}".format(items['D3']), font=object.font1, anchor=E, width=widthnum) object.dev3D.grid(row=4, column=3, padx=xpads, pady=ypads, sticky="nsew") object.dev3D.grid_columnconfigure(1, weight=1) object.dev3D.grid_rowconfigure(0, weight=1) object.update() object.topwin.bind('<Configure>', object.resize_top) placeValues(object, data, format, label_list) object.topwin.after(5, lambda: refresh_window(object, format, label_list))