Esempio n. 1
0
    def __init__(self, variable, editor, iid):
        Toplevel.__init__(self)
        self.protocol("WM_DELETE_WINDOW", self.quit)
        self.attributes('-topmost', 'true')
        self.grab_set()
        self.variable = variable
        self.editor = editor
        self.iid = iid

        self.winfo_toplevel().minsize(200, 100)
        self.resizable(False, False)
        self.wm_title("Variable")

        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        content = Frame(self)
        content.grid(row=0, column=0, padx=10, pady=10, sticky=(N, S, E, W))

        content.columnconfigure(0, weight=1)
        content.rowconfigure(0, weight=1)
        content.rowconfigure(1, weight=1)

        #Action

        self.varFrame = self.variable.display(content)

        self.varFrame.columnconfigure(0, weight=1)
        self.varFrame.rowconfigure(0, weight=1)

        self.varFrame.grid(row=0, column=0, pady=(0, 5), sticky=(N, S, E, W))

        optionsFrame = Frame(content)
        optionsFrame.grid(row=1, column=0, sticky=(S, E))

        optionsFrame.columnconfigure(0, weight=1)
        optionsFrame.columnconfigure(1, weight=1)
        optionsFrame.rowconfigure(0, weight=1)

        acceptFrame = Frame(optionsFrame, width=50, height=25)
        acceptFrame.grid(row=0, column=0, sticky=(E), padx=(0, 5))
        acceptFrame.grid_propagate(0)
        acceptFrame.columnconfigure(0, weight=1)
        acceptFrame.rowconfigure(0, weight=1)
        self.acceptButton = Button(acceptFrame,
                                   text="Accept",
                                   command=self.accept)
        self.acceptButton.grid(row=0, column=0, sticky=(N, S, E, W))

        cancelFrame = Frame(optionsFrame, width=50, height=25)
        cancelFrame.grid(row=0, column=1, sticky=(E))
        cancelFrame.grid_propagate(0)
        cancelFrame.columnconfigure(0, weight=1)
        cancelFrame.rowconfigure(0, weight=1)
        cancel = Button(cancelFrame, text="Cancel", command=self.quit)
        cancel.grid(row=0, column=0, sticky=(N, S, E, W))

        ToplevelObserver.add_element(self)
Esempio n. 2
0
    def do_action(self):
        """ Scan a specified area of the screen for an image and store the location in a variable """

        try:
            img = Image.open(self.screenshot)
        except:
            if (self.screenshot is None):
                s = "No image selected in detect image action"
            else:
                s = "Image " + self.screenshot + " Not Found."
            messagebox.showinfo("Image Not Found",
                                s,
                                parent=ToplevelObserver.top())
            return False

        width, height = img.size
        pt = imgsearch.imagesearcharea(self.screenshot,
                                       self.scanPoint.x,
                                       self.scanPoint.y,
                                       self.scanPoint.x + self.scanWidth,
                                       self.scanPoint.y + self.scanHeight,
                                       precision=(float(self.precision) /
                                                  100.0))
        point = POINT(int(pt[0] + (width / 2) + self.scanPoint.x),
                      int(pt[1] + (height / 2 + self.scanPoint.y)))
        if (pt[0] is -1):
            if (self.failOption.get() == 'Set Default Value'):
                point = self.failDefaultValue
            elif (self.failOption.get() == 'Retry'):
                timer = time.time()
                while (pt[0] is -1
                       and (time.time() - timer) < self.retryTimer):
                    pt = imgsearch.imagesearcharea(
                        self.screenshot,
                        self.scanPoint.x,
                        self.scanPoint.y,
                        self.scanPoint.x + self.scanWidth,
                        self.scanPoint.y + self.scanHeight,
                        precision=(float(self.precision) / 100.0))
                if pt[0] is -1:
                    s = "Image not found after retry, stopping."
                    messagebox.showinfo("Image Not Found",
                                        s,
                                        parent=ToplevelObserver.top())
                    return False
                point = POINT(int(pt[0] + (width / 2) + self.scanPoint.x),
                              int(pt[1] + (height / 2 + self.scanPoint.y)))
            else:
                s = "Image not found, stopping."
                messagebox.showinfo("Image Not Found",
                                    s,
                                    parent=ToplevelObserver.top())
                return False

        s = str(point.x) + " " + str(point.y)
        VariableList.set(self.storeVariable.get(), point)
        return True
Esempio n. 3
0
    def stop(self):
        """ Stop the application """

        self.stopped = True
        self._elapsedtime = 0.0
        self.pauseTime = 0
        self.set_time(self._elapsedtime)
        self.playing = False
        self.stateFrame1.config(bg="#eeefff")
        self.stateFrame2.config(bg="#eeefff")
        ToplevelObserver.enable_all()
        if self.minimize.get():
            ToplevelObserver.show_all()
Esempio n. 4
0
    def play(self):
        """ Play/Pause the application """

        # If already playing, pause the app
        if (self.playing):
            # Pause
            self.playing = False
            self.playButton.config(image=self.play_img)
            self.playButton.image = self.play_img
            self.stateFrame1.config(bg="#eeefff")
            self.stateFrame2.config(bg="#ffdf7f")
            self.pauseTime = time.time()
            elapsedtime = time.time() - self._start
            self.set_time(elapsedtime)
            if self.minimize.get():
                ToplevelObserver.show_all()
        else:
            # Play
            # If starting, commit the changes
            if (self.stopped):
                # Start
                if not self.tree.is_playable():
                    return
                self.cycles = self._cyclesVal.get()
                if (self.cycles == 0):
                    self.stop()
                    return
                self.cycles = self.cycles - 1
                self._start = time.time()
                self.reset(self.tree.get_start())
                VariableList.commit()

            if self.minimize.get():
                ToplevelObserver.hide_all()

            self.playButton.config(image=self.pause_img)
            self.playButton.image = self.pause_img

            self.stateFrame1.config(bg="#32bf07")
            self.stateFrame2.config(bg="#eeefff")

            if self.pauseTime > 0:
                self._start = self._start + (time.time() - self.pauseTime)
            self.playing = True
            ToplevelObserver.disable_all()
            self.stopped = False

            self.thread = threading.Thread(target=self.run,
                                           args=(),
                                           daemon=True)
            self.thread.start()
Esempio n. 5
0
    def add(self):
        """ Add a new item at the end of the variable list """

        name = self.nameEntry.get()
        if len(name) > 0:
            if VariableList.contains(name):
                if messagebox.askokcancel("Overwrite",
                                          "Overwrite Variable " + name + "?",
                                          parent=ToplevelObserver.top()):
                    self.delete(name)
                else:
                    return

            variable = VariableList.create_variable(self.variableType.get(),
                                                    name)
            VariableList.add_element(variable)
            index = len(self.tree.get_children())

            data = variable.get_data()

            iid = self.add_tree_item(index, data)
            self.treeItems[name] = iid
            self.tree.selection_set(iid)
            self.update_options()
Esempio n. 6
0
 def quit(self, *args):
     ToplevelObserver.remove_element(self)
     self.destroy()
Esempio n. 7
0
 def quit(self, *args):
     ToplevelObserver.remove_element(self)
     VariableList.editor = None
     self.destroy()
Esempio n. 8
0
    def __init__(self):
        Toplevel.__init__(self)
        self.protocol("WM_DELETE_WINDOW", self.quit)
        self.attributes('-topmost', 'true')
        self.grab_set()
        self.winfo_toplevel().minsize(200, 100)
        self.resizable(False, False)
        self.wm_title("Variable Editor")

        VariableList.editor = self

        self.treeItems = {}
        self.running = False
        self._add = None
        self._delete = None
        self._edit = None
        self.tree = None
        self.action = None

        content = Frame(self)
        content.grid(row=0, column=0, sticky=(N, S, E, W))
        content.columnconfigure(0, weight=1)
        content.rowconfigure(0, weight=1)
        content.rowconfigure(1, weight=1)

        #Top

        topFrame = Frame(content)
        topFrame.grid(row=0, column=0, sticky=(N, S, E, W))

        topFrame.columnconfigure(0, weight=1)
        topFrame.rowconfigure(0, weight=1)

        border = Frame(topFrame)
        border.grid(row=0, column=0, padx=10, pady=10, sticky=(N, S, E, W))

        border.columnconfigure(0, weight=1)
        border.columnconfigure(1, weight=1)
        border.rowconfigure(0, weight=1)
        border.rowconfigure(1, weight=1)

        self.variableType = StringVar()
        choices = ['Point']
        self.variableType.set('Point')

        variableChoiceFrame = Frame(border)

        variableChoiceFrame.columnconfigure(0, weight=0)
        variableChoiceFrame.columnconfigure(1, weight=1)
        variableChoiceFrame.columnconfigure(2, weight=1)
        variableChoiceFrame.rowconfigure(0, weight=1)

        lblV = Label(variableChoiceFrame, text='Variable:')
        lblV.grid(row=0, column=0, padx=(0, 10), sticky=(W))

        varChoice = Frame(variableChoiceFrame, width=120, height=30)
        varChoice.grid_propagate(0)
        varChoice.columnconfigure(0, weight=1)
        varChoice.rowconfigure(0, weight=1)
        variable = OptionMenu(varChoice, self.variableType, *choices)
        variable.grid(row=0, column=0, sticky=(N, S, E, W))
        varChoice.grid(row=0, column=1, sticky=(E))

        self.nameEntry = Entry(variableChoiceFrame)
        self.nameEntry.grid(row=0, column=2, sticky=(E))

        variableChoiceFrame.grid(row=0, column=0, sticky=(N, E, W))

        treeBorderFrame = Frame(border, relief="ridge", borderwidth=2)
        treeBorderFrame.grid(row=1, column=0, sticky=(N, S, E, W))

        treeBorderFrame.columnconfigure(0, weight=1)
        treeBorderFrame.rowconfigure(0, weight=1)

        treeFrame = Frame(treeBorderFrame)
        treeFrame.pack(side=TOP, fill=BOTH, expand=Y)

        treeFrame.rowconfigure(0, weight=1)
        treeFrame.columnconfigure(0, weight=1)
        treeFrame.columnconfigure(1, weight=0)

        # create the tree and scrollbars
        dataCols = ('Type', 'Value')
        displayCols = ('Type', 'Value')
        self.tree = ttk.Treeview(treeFrame,
                                 selectmode="browse",
                                 columns=dataCols,
                                 displaycolumns=displayCols)

        ysb = ttk.Scrollbar(treeFrame,
                            orient=VERTICAL,
                            command=self.tree.yview)
        self.tree['yscroll'] = ysb.set

        # setup column headings
        self.tree.heading('#0', text='Name', anchor=W)
        self.tree.heading('Type', text='Type', anchor=W)
        self.tree.heading('Value', text='Value', anchor=W)

        self.tree.column('#0', stretch=0, width=100)
        self.tree.column('Type', stretch=0, width=100)
        self.tree.column('Value', stretch=1, width=120)

        # add tree and scrollbars to frame
        self.tree.grid(row=0, column=0, sticky='NSEW')
        ysb.grid(row=0, column=1, sticky='NSE')

        self.tree.bind("<Double-1>", self.handle_double_click)
        self.tree.bind('<<TreeviewSelect>>', self.update_options)
        self.tree.bind('<Button-1>', self.handle_click)

        self.rightFrame = Frame(border)
        self.rightFrame.grid(row=1, column=1, sticky=(N, E), padx=(10, 0))

        self.rightFrame.columnconfigure(0, weight=0)
        for i in range(0, 3):
            self.rightFrame.rowconfigure(i, weight=0, uniform="MiddleRight")

        dimensions = [70, 35]

        self._addFrame = Frame(self.rightFrame,
                               width=dimensions[0],
                               height=dimensions[1])
        self._addFrame.grid(row=0, column=0, sticky=())
        self._addFrame.grid_propagate(0)
        self._addFrame.columnconfigure(0, weight=1)
        self._addFrame.rowconfigure(0, weight=1)
        self._add = Button(self._addFrame, text="Add", command=self.add)
        self._add.grid(row=0, column=0, sticky=(N, S, E, W))

        self._deleteFrame = Frame(self.rightFrame,
                                  width=dimensions[0],
                                  height=dimensions[1])
        self._deleteFrame.grid(row=1, column=0, sticky=(), pady=3)
        self._deleteFrame.grid_propagate(0)
        self._deleteFrame.columnconfigure(0, weight=1)
        self._deleteFrame.rowconfigure(0, weight=1)
        self._delete = Button(self._deleteFrame,
                              text="Delete",
                              command=self.delete_selected)
        self._delete.grid(row=0, column=0, sticky=(N, S, E, W))

        self._editFrame = Frame(self.rightFrame,
                                width=dimensions[0],
                                height=dimensions[1])
        self._editFrame.grid(row=2, column=0, sticky=())
        self._editFrame.grid_propagate(0)
        self._editFrame.columnconfigure(0, weight=1)
        self._editFrame.rowconfigure(0, weight=1)
        self._edit = Button(self._editFrame, text="Edit", command=self.edit)
        self._edit.grid(row=0, column=0, sticky=(N, S, E, W))

        #Bottom

        optionsFrame = Frame(content)
        optionsFrame.grid(row=1, column=0, padx=10, pady=10, sticky=(S, E))

        optionsFrame.columnconfigure(0, weight=1)
        optionsFrame.columnconfigure(1, weight=1)
        optionsFrame.rowconfigure(0, weight=1)

        acceptFrame = Frame(optionsFrame, width=50, height=25)
        acceptFrame.grid(row=0, column=0, sticky=(E), padx=(0, 5))
        acceptFrame.grid_propagate(0)
        acceptFrame.columnconfigure(0, weight=1)
        acceptFrame.rowconfigure(0, weight=1)
        self.acceptButton = Button(acceptFrame,
                                   text="Accept",
                                   command=self.accept)
        self.acceptButton.grid(row=0, column=0, sticky=(N, S, E, W))

        cancelFrame = Frame(optionsFrame, width=50, height=25)
        cancelFrame.grid(row=0, column=1, sticky=(E))
        cancelFrame.grid_propagate(0)
        cancelFrame.columnconfigure(0, weight=1)
        cancelFrame.rowconfigure(0, weight=1)
        cancel = Button(cancelFrame, text="Cancel", command=self.quit)
        cancel.grid(row=0, column=0, sticky=(N, S, E, W))

        self.populate_tree()

        ToplevelObserver.add_element(self)
Esempio n. 9
0
    def create_widgets(self):
        """ Create widgets for the main containers """

        # Top Frame

        top = Frame(self.content)
        top.grid(row=0, column=0, sticky=(N, E, W))

        top.columnconfigure(0, weight=0)
        top.columnconfigure(1, weight=0)
        top.columnconfigure(2, weight=1)
        top.rowconfigure(0, weight=0)

        playpath = resource_path("play.png")
        self.play_img = PhotoImage(file=playpath)
        self.play_img = self.play_img.subsample(10)

        pausepath = resource_path("pause.png")
        self.pause_img = PhotoImage(file=pausepath)
        self.pause_img = self.pause_img.subsample(10)

        stoppath = resource_path("stop.png")
        self.stop_img = PhotoImage(file=stoppath)
        self.stop_img = self.stop_img.subsample(10)

        buttonFrame = Frame(top)
        buttonFrame.columnconfigure(0, weight=1)
        buttonFrame.columnconfigure(1, weight=1)
        buttonFrame.rowconfigure(0, weight=1)
        buttonFrame.grid(row=0, column=0, sticky=(W))

        self.playButton = Button(buttonFrame,
                                 image=self.play_img,
                                 width="20",
                                 height="20",
                                 command=self.play)
        self.playButton.image = self.play_img
        self.playButton.grid(row=0, column=0, padx=(0, 5), sticky=(W))

        self.stopButton = Button(buttonFrame,
                                 image=self.stop_img,
                                 width="20",
                                 height="20",
                                 command=self.stop)
        self.stopButton.image = self.stop_img
        self.stopButton.grid(row=0, column=1, sticky=(W))

        stateFrame = Frame(top, width=50, heigh=20)
        stateFrame.place(relx=.50, rely=0.40, anchor=CENTER)
        stateFrame.grid_propagate(0)

        stateFrame.columnconfigure(0, weight=1)
        stateFrame.columnconfigure(1, weight=1)
        stateFrame.rowconfigure(0, weight=1)

        self.stateFrame1 = Frame(stateFrame,
                                 width=20,
                                 heigh=20,
                                 relief="ridge",
                                 borderwidth=2)
        self.stateFrame1.grid(row=0, column=0, padx=(0, 10), sticky=(W))
        self.stateFrame1.grid_propagate(0)

        self.stateFrame2 = Frame(stateFrame,
                                 width=20,
                                 heigh=20,
                                 relief="ridge",
                                 borderwidth=2)
        self.stateFrame2.grid(row=0, column=1, sticky=(W))
        self.stateFrame2.grid_propagate(0)

        self.stateFrame1.config(bg="#eeefff")
        self.stateFrame2.config(bg="#eeefff")

        runtimeFrame = Frame(top)
        runtimeFrame.columnconfigure(0, weight=1)
        runtimeFrame.columnconfigure(1, weight=1)
        runtimeFrame.rowconfigure(0, weight=1)
        runtimeFrame.grid(row=0, column=2, sticky=(E))

        runtimelbl = Label(runtimeFrame, text="Runtime:")
        runtimelbl.grid(row=0, column=0, padx=(0, 5), sticky=(W))

        self.runtimeval = Label(runtimeFrame, text="0:00")
        self.runtimeval.grid(row=0, column=1, sticky=(W))

        # Middle Frame/Tree

        self.tree = Tree()
        treeFrame = self.tree.display(self.content)
        treeFrame.grid(row=1, column=0, pady=(10, 0), sticky=(N, S, E, W))

        # Bottom Frame

        self._bottomFrame = Frame(self.content)
        self._bottomFrame.grid(row=2, column=0, sticky=(N, S, E, W))

        self._bottomFrame.columnconfigure(0, weight=1)
        self._bottomFrame.columnconfigure(1, weight=1)
        self._bottomFrame.rowconfigure(0, weight=0)

        # Bottom Left Frame

        bottomLeft = Frame(self._bottomFrame)
        bottomLeft.grid(row=0, column=0, sticky=(N, S, W))
        bottomLeft.columnconfigure(0, weight=1)
        bottomLeft.rowconfigure(0, weight=0)

        bottomLeftBorder = Frame(bottomLeft, relief=GROOVE, borderwidth=2)
        bottomLeftBorder.grid(row=0, column=0, pady=(20, 0), sticky=(N, W))

        bottomLeftBorder.columnconfigure(0, weight=1)
        bottomLeftBorder.rowconfigure(0, weight=1)

        bottomLeftFrame = Frame(bottomLeftBorder)
        bottomLeftFrame.grid(row=0, column=0, padx=10, pady=10, sticky=(N, W))

        bottomLeftFrame.columnconfigure(0, weight=1)
        bottomLeftFrame.columnconfigure(1, weight=1)
        bottomLeftFrame.columnconfigure(2, weight=1)
        bottomLeftFrame.columnconfigure(3, weight=1)
        bottomLeftFrame.rowconfigure(0, weight=0)
        bottomLeftFrame.rowconfigure(1, weight=0)

        Label(bottomLeft, text='Keybinds').place(relx=.08, rely=0.20, anchor=W)

        Label(bottomLeftFrame, text="Play/Pause:", width=8,
              anchor="w").grid(row=0, column=0, sticky="w", padx=(0, 10))
        self.playKeyEntry = KeyEntry(bottomLeftFrame, 10)
        self.playKeyEntry.grid(row=0, column=1, sticky="ew", padx=(0, 5))
        self.playKeySet = Button(bottomLeftFrame,
                                 text="Set",
                                 width=8,
                                 command=self.set_play_keybind)
        self.playKeySet.grid(row=0, column=2, sticky=(E), padx=(0, 5))
        self.playKeyClear = Button(bottomLeftFrame,
                                   text="Clear",
                                   width=8,
                                   command=self.clear_play_keybind)
        self.playKeyClear.grid(row=0, column=3, sticky=(E))

        Label(bottomLeftFrame, text="Stop:", width=8,
              anchor=(W)).grid(row=1, column=0, sticky=(W), padx=(0, 10))
        self.stopKeyEntry = KeyEntry(bottomLeftFrame, 10)
        self.stopKeyEntry.grid(row=1, column=1, sticky=(E, W), padx=(0, 5))
        self.stopKeySet = Button(bottomLeftFrame,
                                 text="Set",
                                 width=8,
                                 command=self.set_stop_keybind)
        self.stopKeySet.grid(row=1, column=2, sticky=(E), padx=(0, 5))
        self.stopKeyClear = Button(bottomLeftFrame,
                                   text="Clear",
                                   width=8,
                                   command=self.clear_stop_keybind)
        self.stopKeyClear.grid(row=1, column=3, sticky=(E))

        # Bottom Right Frame

        self._bottomRightFrame = Frame(self._bottomFrame)
        self._bottomRightFrame.grid(row=0,
                                    column=1,
                                    pady=(10, 0),
                                    sticky=(N, S, E))

        self._bottomRightFrame.columnconfigure(0, weight=1)
        self._bottomRightFrame.columnconfigure(1, weight=1)
        self._bottomRightFrame.rowconfigure(0, weight=1)
        self._bottomRightFrame.rowconfigure(1, weight=0)
        self._bottomRightFrame.rowconfigure(2, weight=0)

        check = Checkbutton(self._bottomRightFrame,
                            text="Mininmize on start",
                            variable=self.minimize)
        check.grid(row=0, column=0, columnspan=2, pady=(0, 5), sticky=(S, E))

        self._lblCycles = Label(self._bottomRightFrame, text="Program Cycles:")
        self._lblMouse = Label(self._bottomRightFrame, text='Mouse Position:')

        self._cyclesVal = NumberEntry(self._bottomRightFrame, 9, 9, '1')

        pos = MouseTools.queryMousePosition()
        self._mouse = Label(self._bottomRightFrame, text=pos, width=8)

        self._lblCycles.grid(row=1,
                             column=0,
                             padx=(0, 10),
                             pady=(0, 5),
                             sticky=(S, W))
        self._lblMouse.grid(row=2, column=0, padx=(0, 10), sticky=(S, W))
        self._cyclesVal.grid(row=1, column=1, pady=(0, 5), sticky=(S, E))
        self._mouse.grid(row=2, column=1, sticky=(S, E))

        ToplevelObserver.add_element(self)
Esempio n. 10
0
 def quit(self, *args):
     self.action.quit()
     ToplevelObserver.remove_element(self)
     self.destroy()
Esempio n. 11
0
    def __init__(self, action, tree, iid):
        Toplevel.__init__(self)
        self.protocol("WM_DELETE_WINDOW", self.quit)
        self.attributes('-topmost', 'true')
        self.grab_set()
        self.action = action
        self.loopType = StringVar()
        self.tree = tree
        self.iid = iid
        top = ToplevelObserver.top()
        loc = '+' + str(top.winfo_x()) + '+' + str(top.winfo_y())
        self.geometry(loc)

        self.winfo_toplevel().minsize(250, 100)
        self.resizable(False, False)
        self.wm_title(action.actionType)

        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        content = Frame(self)
        content.grid(row=0, column=0, padx=10, pady=10, sticky=(N, S, E, W))

        content.columnconfigure(0, weight=1)
        content.rowconfigure(0, weight=1)
        content.rowconfigure(1, weight=1)

        #Action

        self.actionFrame = self.action.display(content)

        self.actionFrame.columnconfigure(0, weight=1)
        self.actionFrame.rowconfigure(0, weight=1)

        self.actionFrame.grid(row=0, column=0, pady=(0, 5), sticky=(N, W))

        optionsFrame = Frame(content)
        optionsFrame.grid(row=1, column=0, sticky=(S, E))

        optionsFrame.columnconfigure(0, weight=1)
        optionsFrame.columnconfigure(1, weight=1)
        optionsFrame.rowconfigure(0, weight=1)

        acceptFrame = Frame(optionsFrame, width=50, height=25)
        acceptFrame.grid(row=0, column=0, sticky=(E), padx=(0, 5))
        acceptFrame.grid_propagate(0)
        acceptFrame.columnconfigure(0, weight=1)
        acceptFrame.rowconfigure(0, weight=1)
        self.acceptButton = Button(acceptFrame,
                                   text="Accept",
                                   command=self.accept)
        self.acceptButton.grid(row=0, column=0, sticky=(N, S, E, W))

        cancelFrame = Frame(optionsFrame, width=50, height=25)
        cancelFrame.grid(row=0, column=1, sticky=(E))
        cancelFrame.grid_propagate(0)
        cancelFrame.columnconfigure(0, weight=1)
        cancelFrame.rowconfigure(0, weight=1)
        cancel = Button(cancelFrame, text="Cancel", command=self.quit)
        cancel.grid(row=0, column=0, sticky=(N, S, E, W))

        ToplevelObserver.add_element(self)