def __init__(self, master, title): Toplevel.__init__(self, master) self.transient(master) self.title(title) self.bar = tkExtra.ProgressBar(self, width=200, height=24, background="DarkGray") self.bar.pack(side=TOP, expand=YES, fill=X) self.label = Label(self, width=60) self.label.pack(side=TOP, expand=YES, fill=BOTH) b = Button(self, text="Stop", foreground="Darkred", command=self.stop) b.pack(side=BOTTOM, fill=X, pady=2) self.ended = False self.bind("<Escape>", self.stop) self.protocol("WM_DELETE_WINDOW", self.stop) self.wait_visibility() self.update_idletasks() self.grab_set() x = master.winfo_rootx() + (master.winfo_width() - self.winfo_width()) / 2 y = master.winfo_rooty() + (master.winfo_height() - self.winfo_height()) / 2 self.geometry('+%d+%d' % (x, y)) self.lastTime = time.time() self.refreshInterval = 0.25
def main_interface(self): """Generate main interface widgets moved from __main__.py """ # --- Ribbon --- OCV.RIBBON = Ribbon.TabRibbonFrame(self) OCV.RIBBON.pack(side=Tk.TOP, fill=Tk.X) # Main frame self.paned = Tk.PanedWindow(self, orient=Tk.HORIZONTAL) self.paned.pack(fill=Tk.BOTH, expand=Tk.YES) # Status bar frame = Tk.Frame(self) frame.pack(side=Tk.BOTTOM, fill=Tk.X) OCV.STATUSBAR = tkExtra.ProgressBar(frame, height=20, relief=Tk.SUNKEN) OCV.STATUSBAR.pack(side=Tk.LEFT, fill=Tk.X, expand=Tk.YES) OCV.STATUSBAR.configText(fill="DarkBlue", justify=Tk.LEFT, anchor=Tk.W) self.statusz = Tk.Label(frame, foreground="DarkRed", relief=Tk.SUNKEN, anchor=Tk.W, width=10) self.statusz.pack(side=Tk.RIGHT) self.statusy = Tk.Label(frame, foreground="DarkRed", relief=Tk.SUNKEN, anchor=Tk.W, width=10) self.statusy.pack(side=Tk.RIGHT) self.statusx = Tk.Label(frame, foreground="DarkRed", relief=Tk.SUNKEN, anchor=Tk.W, width=10) self.statusx.pack(side=Tk.RIGHT) # Buffer bar OCV.BUFFERBAR = tkExtra.ProgressBar(frame, height=20, width=40, relief=Tk.SUNKEN) OCV.BUFFERBAR.pack(side=Tk.RIGHT, expand=Tk.NO) OCV.BUFFERBAR.setLimits(0, 100) tkExtra.Balloon.set(OCV.BUFFERBAR, _("Controller buffer fill")) # --- Left side --- self.Lframe = Tk.Frame(self.paned) self.paned.add(self.Lframe) #, minsize=340) self.pageframe = Tk.Frame(self.Lframe) self.pageframe.pack(side=Tk.TOP, expand=Tk.YES, fill=Tk.BOTH) OCV.RIBBON.setPageFrame(self.pageframe) # Command bar cmd_f = Tk.Frame(self.Lframe) cmd_f.pack(side=Tk.BOTTOM, fill=Tk.X) self.cmdlabel = Tk.Label(cmd_f, text=_("Command:")) self.cmdlabel.pack(side=Tk.LEFT) OCV.CMD_W = Tk.Entry(cmd_f, relief=Tk.SUNKEN, background="White") OCV.CMD_W.pack(side=Tk.RIGHT, fill=Tk.X, expand=Tk.YES) tkExtra.Balloon.set( OCV.CMD_W, _("MDI Command line: Accept g-code commands or macro " \ "commands (RESET/HOME...) or editor commands " \ "(move,inkscape, round...) [Space or Ctrl-Space]")) # --- Right side --- self.Rframe = Tk.Frame(self.paned) self.paned.add(self.Rframe) # --- Canvas --- OCV.CANVAS_F = CNCCanvas.CanvasFrame(self.Rframe, self) OCV.CANVAS_F.pack(side=Tk.TOP, fill=Tk.BOTH, expand=Tk.YES) self.linebuffer = Tk.Label(self.Rframe, background="khaki") self.proc_line = Tk.StringVar() self.linebuffer.configure(height=1, anchor=Tk.W, textvariable=self.proc_line) self.linebuffer.pack(side=Tk.BOTTOM, fill=Tk.X) # fist create Pages self.pages = {} for cls in (ControlPage, EditorPage, FilePage, ProbePage, TerminalPage, ToolsPage): page = cls(OCV.RIBBON, self) self.pages[page.name] = page # then add their properties (in separate loop) errors = [] for name, page in self.pages.items(): for page_name in IniFile.get_str(OCV.PRG_NAME, "{0}.ribbon".format( page.name)).split(): try: page.addRibbonGroup(page_name) except KeyError: errors.append(page_name) for page_name in IniFile.get_str(OCV.PRG_NAME, "{0}.page".format(page.name)).split(): last = page_name[-1] try: if last == "*": page.addPageFrame(page_name[:-1], fill=Tk.BOTH, expand=Tk.TRUE) else: page.addPageFrame(page_name) except KeyError: errors.append(page_name) if errors: tkMessageBox.showwarning( "OKKCNC configuration", "The following pages \"{0}\" are found in " \ "your <HOME>/.OKKCNC initialization file, " \ "which are either spelled wrongly or " \ "no longer exist in OKKCNC".format(" ".join(errors)), parent=self)