def default_display(self): add_button = Button(self, text="+", anchor="center", bg="orange", fg="white", font="bold", command=lambda: self.choose_widget()) add_button.place(width=30, height=30, x=self.width // 2 - 15 - self.bw, y=self.height // 2 - 15 - self.bw) CreateToolTip(add_button, "Add New Widget", c_off=20) self.disp_widgets.append(add_button) self.update()
def __init__(self, root, text, *args, **kwargs): super(InfoHover, self).__init__(root, *args, **kwargs) label = Label(self, text=" \u2139\uFE0F", bg="dodgerblue4", font="none 8", pady=0, borderwidth=0, fg="white") label.place(x=0, y=0, width=10, height=10) CreateToolTip(label, text)
def load_display(self): ta = 0 max_slots = 0 aisle_empty_filled = [] # type: List[Set[Aisle, int, int]] for aisle in self.warehouse: reserves = aisle.get_reserve_slots() if len(reserves) > 0: e = 0 for slot in reserves: if not slot.stock_records: e += 1 f = len(reserves) - e aisle_empty_filled.append((aisle, e, f)) if e + f > max_slots: max_slots = e + f ta += 1 aisle_empty_filled.sort(key=lambda x: x[0].spot_id) x_val = 0 y_val = 20 w = self.winfo_reqwidth() // ta h = self.winfo_reqheight() - 42 for aisle, empty_n, filled_n in aisle_empty_filled: t = empty_n + filled_n t_ratio = ((t / max_slots) * (h - 1)) // 1 f_ratio = ((filled_n / max_slots) * (h - 1)) // 1 frame = Frame(self, bg=self.bg, relief="solid") frame.place(x=x_val + 1, y=y_val + h - t_ratio - 1, width=w - 2, height=t_ratio + 2) border = Label(frame, bg=self.bg, relief="solid") border.place(x=0, y=0, width=w - 2, height=t_ratio + 2) background = Label(frame, bg=self.bg, relief="flat") background.place(x=1, y=1, width=w - 4, height=t_ratio) filled_graphic = Label(frame, bg=self.fg, relief="flat") filled_graphic.place(x=1, y=(t_ratio - f_ratio) + 1, width=w - 4, height=f_ratio) text = Label(self, text=aisle.aisle, relief="groove") text.place(x=x_val, y=h + 20 + 2, width=w, height=20) CreateToolTip(frame, "{} / {}".format(filled_n, t), c_off=(-15 + w)) x_val += w
def __init__(self, master, warehouse, controller, height=50, width=200, *args, **kwargs): super().__init__(master, *args, **kwargs) self.warehouse = warehouse self.width = width self.height = height self.h = height self.y_val = 0 self.x_val = 0 self.configure(width=width, height=height) self.title = Label(self, text="Best Aisles PickSlot Display", bg="CadetBlue1", relief="groove") self.title.place(x=0, y=0, width=self.width, height=20) self.h -= 40 self.y_val += 20 hits = [] best = 0 for aisle in self.warehouse: hit = aisle.get_average_hits() if hit > 0: hits.append((aisle.aisle, hit)) if hit > best: best = hit hits.sort(key=lambda x: x[0]) self.w = (self.width/len(hits))//1 for hit in hits: filled_ratio = (hit[1] / best * self.h) // 1 OldRange = (best - 0) NewRange = (255 - 0) NewValue = (((hit[1] - 0) * NewRange) / OldRange) // 1 self.color = HexColour(255, 255 - int(NewValue), 0) tempLabel = Label(self, bg=str(self.color), relief="groove") tempLabel.place(x=self.x_val, y=self.y_val+self.h-filled_ratio, width=self.w, height=filled_ratio) CreateToolTip(tempLabel, "avg hits / day: {}".format(round(hit[1], 3)), c_off=(-15 + self.w)) text = Label(self, text=hit[0], relief="groove") text.place(x=self.x_val, y=self.h + 20, width=self.w, height=20) self.x_val += self.w
def __init__(self, master, window, **kwargs): """ Icon for opening a task bar app in MGSS :param master: master window :param img: icon image :param window: window that icon opens :param kwargs: style arguments """ super(AppIcon, self).__init__(master) # initialize keyword argument values bg = kwargs['bg'] if kwargs.get('bg') is not None else 'dark grey' name = kwargs['name'] if kwargs.get('name') is not None else 'testing' width = kwargs['width'] if kwargs.get('width') is not None else 25 height = kwargs['height'] if kwargs.get('height') is not None else 25 self.img = kwargs['img'] if kwargs.get('img') is not None else None # check value types if not isinstance(width, int): raise TypeError("width must be of type Integer") if not isinstance(height, int): raise TypeError("height must be of type Integer") if not isinstance(name, str): raise TypeError("name must be of type String") if not isinstance(bg, str): raise TypeError("bg must be of type String") if self.img is not None: self.img = Image.open(self.img).resize((width - 5, width - 5), Image.ANTIALIAS) self.img = ImageTk.PhotoImage(self.img) osa = Button(self, image=self.img, anchor="n", bg=bg, bd=1, command=lambda: self.open_window(window)) self.configure(width=width, height=height) osa.configure(width=width - 5, height=height - 5) osa.place(x=0, y=0) CreateToolTip(osa, name, c_off=width - 15)
def disp_wid(self, type=None): if type is not None: self.current_widget_type = type.__name__ self.current_type = type while len(self.disp_widgets) > 0: temp = self.disp_widgets.pop() temp.destroy() widget = self.current_type(self, warehouse=self.controller.warehouse, controller=self.controller, width=self.width-4, height=self.height-4) widget.place(x=0, y=0) self.close_button = Button(self, text="X", bg="coral1", command=self.clean, relief="groove") self.close_button.place(width=20, height=20, x=self.width-24, y=0) CreateToolTip(self.close_button, "Close", c_off=10) widget.title.bind('<Double-Button-1>', lambda e: self.full_screen()) if not self.fullscreen: widget.title.unbind_all("<Escape>") else: widget.title.bind_all("<Escape>", self.full_screen) self.disp_widgets.append(widget) self.disp_widgets.append(self.close_button)
def load_display(self): ta = 0 max_slots = 0 empty = [] aisles = [] for area in self.controller.areas.values(): e = len(dayxhits_sort_1_4(area)) if e > 0: empty.append(e) aisles.append(area) ta += 1 if e > max_slots: max_slots = e x_val = 0 y_val = 20 if ta == 0: return w = self.winfo_reqwidth() // ta h = self.winfo_reqheight() - 42 for _ in range(len(empty)): e = empty[_] t_ratio = ((e / max_slots) * (h - 1)) // 1 border = Label(self, relief="solid") border.place(x=x_val + 1, y=y_val + h - t_ratio - 1, width=w - 2, height=t_ratio + 2) background = Label(self, relief="flat", bg="light blue") background.place(x=x_val + 2, y=y_val + h - t_ratio, width=w - 4, height=t_ratio) CreateToolTip(background, "{}".format(e), c_off=(-15 + w)) text = Label(self, text=aisles[_].area_name, relief="groove") text.place(x=x_val, y=h + 20 + 2, width=w, height=20) x_val += w
def load_display(self): """ load window display :return: None """ self.area_dict = {} self.file_path = None for aisle in self.controller.warehouse: if len(aisle.get_reserve_slots()) > 0: self.area_dict[str(aisle.aisle)] = aisle settings = Button(self, text="\u2699\uFE0F", bg="light grey", fg="grey25", font="bold 16", command=lambda: GroundConSettings(self, self.controller)) settings.place(x=10, y=70, height=40, width=40) CreateToolTip(settings, "change consolidation\n settings", c_off=30) self.output = WinOutput(self, width=870, height=self.controller.wig_height - 80, x=self.controller.wig_width - 870 - 20, y=70, wrap=WORD, bg="snow", font="none 10", relief="groove") values = [*self.area_dict.keys()] values.sort() self.combo_options = [key for key in values] self.start_val = StringVar(self) self.start_val.set(self.combo_options[0]) bg = Label(self) sort_area = Frame(self) sort_area.place(x=60, y=70, width=210, height=100) sort_area.grid_rowconfigure((0, 1, 2), weight=2) sort_area.grid_columnconfigure(1, weight=0) sort_area.grid_columnconfigure(0, weight=1) gc_label = Label(sort_area, text="Ground Con", bg="cornflower blue", font="bold 10") gc_label.grid(row=0, column=0, columnspan=2, sticky=NSEW) combo_title = Label(sort_area, text="Aisle", bg="light grey", font="bold 10") combo_title.grid(row=1, column=0, sticky=NSEW) sort_button = Button(sort_area, text="Consolidate", relief="groove", bg="maroon1", font="bold 10", command=lambda: self.ground_con(self.area_dict[self.start_val.get()])) sort_button.grid(row=1, column=1, sticky=NSEW) self.combo = Combobox(sort_area, values=self.combo_options, textvariable=self.start_val, font="bold 10", state="readonly") self.combo.grid(row=2, column=0, sticky=NSEW) open_button = Button(sort_area, text="Open", relief="groove", bg="chartreuse2", font="bold 10", command=lambda: self.open_file()) open_button.grid(row=2, column=1, sticky=NSEW) sort_area.update() bg.place(x=sort_area.winfo_x() - 2, y=sort_area.winfo_y() - 2, width=sort_area.winfo_width() + 4, height=sort_area.winfo_height() + 4) bg2 = Label(self) warehouse_reports = Frame(self) warehouse_reports.place(x=sort_area.winfo_x(), y=sort_area.winfo_y() + sort_area.winfo_height() + 10, width=sort_area.winfo_width(), height=90) warehouse_reports.grid_columnconfigure(0, weight=1) warehouse_reports.grid_rowconfigure(0, weight=1) warehouse_reports.grid_rowconfigure(1, weight=2) if True: title = Label(warehouse_reports, text="Get Warehouse Report", bg="cornflower blue", font="bold 10") title.grid(row=0, column=0, sticky=NSEW) sort_button = Button(warehouse_reports, text="Print Report", relief="groove", bg="maroon1", command=lambda: self.ground_report(), font="bold 10") sort_button.grid(row=1, column=0, sticky=NSEW) pass warehouse_reports.update() bg2.place(x=warehouse_reports.winfo_x() - 2, y=warehouse_reports.winfo_y() - 2, width=warehouse_reports.winfo_width() + 4, height=warehouse_reports.winfo_height() + 4) pass