def select_start_options(self):
    '''
    popup box to select side and difficulty levels
    '''
    print 'select game start options'

    popup = Toplevel(self.gui, width=300, height=110)
    popup.title('Choose Game Side and Level')

    # stays on top of the game canvass
    popup.transient(self.gui)
    popup.grab_set()

    # bind window close events
    popup.bind('<Escape>', lambda e: self.not_selected_start_options(popup))
    popup.protocol("WM_DELETE_WINDOW", lambda : self.not_selected_start_options(popup))

    # choose side
    label1 = Label(popup, text="Side", height=30, width=50)
    label1.place(x=10, y=5, height=30, width=50)

    val1 = IntVar()

    bt_north = Radiobutton(popup, text="White", variable=val1, value=1)
    bt_north.place(x=60, y=10)
    bt_south = Radiobutton(popup, text="Black", variable=val1, value=2)
    bt_south.place(x=120, y=10)

    # by default, human plays first, meaning play the north side
    if self.choose_side == 'north':
      bt_north.select()
    else:
      bt_south.select()

    # choose difficulty level
    label2 = Label(popup, text="Level", height=30, width=50)
    label2.place(x=10, y=35, height=30, width=50)

    val2 = IntVar()

    bt_level1 = Radiobutton(popup, text="Dumb", variable=val2, value=1)
    bt_level1.place(x=60, y=40)
    bt_level2 = Radiobutton(popup, text="Smart", variable=val2, value=2)
    bt_level2.place(x=120, y=40)
    bt_level3 = Radiobutton(popup, text="Genius", variable=val2, value=3)
    bt_level3.place(x=180, y=40)

    # by default, the game is medium level
    if self.choose_level == 1:
      bt_level1.select()
    elif self.choose_level == 2:
      bt_level2.select()
    elif self.choose_level == 3:
      bt_level3.select()

    button = Button(popup, text='SET', \
              command=lambda: self.selected_start_options(popup, val1, val2))

    button.place(x=70, y=70)
Exemple #2
0
 def show_about():
     t = Toplevel(master)
     t.title("About")
     t.transient(master)
     t.resizable(False, False)
     Label(t, image=self.img_logo).grid(column=0, row=0, sticky=(E, W))
     Label(t, text="Context %s" % VERSION, anchor=CENTER).grid(column=0, row=1, sticky=(E, W))
     Label(t, text="(c) 2011-2014 Shish", anchor=CENTER).grid(column=0, row=2, sticky=(E, W))
     Button(t, text="Close", command=t.destroy).grid(column=0, row=3, sticky=(E,))
     win_center(t)
Exemple #3
0
class LBChoice(object):
    '''This is a listbox for returning projects to be unarchived.'''
    def __init__(self, list_=None, master=None, title=None):
        '''Must have master, title is optional, li is too.'''
        self.master = master
        if self.master is not None:
            self.top = Toplevel(self.master)
        else:
            return
        self.v = None
        if list_ is None or not isinstance(list_, list):
            self.list = []
        else:
            self.list = list_[:]
        self.top.transient(self.master)
        self.top.grab_set()
        self.top.bind("<Return>", self._choose)
        self.top.bind("<Escape>", self._cancel)
        if title:
            self.top.title(title)
        lf = Frame(self.top)         #Sets up the list.
        lf.pack(side=TOP)
        scroll_bar = Scrollbar(lf)
        scroll_bar.pack(side=RIGHT, fill=Y)
        self.lb = Listbox(lf, selectmode=SINGLE)
        self.lb.pack(side=LEFT, fill=Y)
        scroll_bar.config(command=self.lb.yview)
        self.lb.config(yscrollcommand=scroll_bar.set)
        self.list.sort()
        for item in self.list:
            self.lb.insert(END, item)     #Inserts items into the list.
        bf = Frame(self.top)
        bf.pack(side=BOTTOM)
        Button(bf, text="Select", command=self._choose).pack(side=LEFT)
        Button(bf, text="New", command=self._new).pack(side=LEFT)
        Button(bf, text="Cancel", command=self._cancel).pack(side=LEFT)

    def _choose(self, event=None):
        try:
            first = self.lb.curselection()[0]
            self.v = self.list[int(first)]
        except IndexError:
            self.v = None
        self.top.destroy()

    def _new(self, event=None):
        self.v = "NEW"
        self.top.destroy()

    def _cancel(self, event=None):
        self.top.destroy()

    def return_value(self):
        self.master.wait_window(self.top)
        return self.v
Exemple #4
0
class LBChoice(object):
    '''This is a listbox for returning projects to be unarchived.'''
    def __init__(self, list_=None, master=None, title=None):
        '''Must have master, title is optional, li is too.'''
        self.master = master
        if self.master is not None:
            self.top = Toplevel(self.master)
        else:
            return
        self.v = None
        if list_ is None or not isinstance(list_, list):
            self.list = []
        else:
            self.list = list_[:]
        self.top.transient(self.master)
        self.top.grab_set()
        self.top.bind("<Return>", self._choose)
        self.top.bind("<Escape>", self._cancel)
        if title:
            self.top.title(title)
        lf = Frame(self.top)  #Sets up the list.
        lf.pack(side=TOP)
        scroll_bar = Scrollbar(lf)
        scroll_bar.pack(side=RIGHT, fill=Y)
        self.lb = Listbox(lf, selectmode=SINGLE)
        self.lb.pack(side=LEFT, fill=Y)
        scroll_bar.config(command=self.lb.yview)
        self.lb.config(yscrollcommand=scroll_bar.set)
        self.list.sort()
        for item in self.list:
            self.lb.insert(END, item)  #Inserts items into the list.
        bf = Frame(self.top)
        bf.pack(side=BOTTOM)
        Button(bf, text="Select", command=self._choose).pack(side=LEFT)
        Button(bf, text="New", command=self._new).pack(side=LEFT)
        Button(bf, text="Cancel", command=self._cancel).pack(side=LEFT)

    def _choose(self, event=None):
        try:
            first = self.lb.curselection()[0]
            self.v = self.list[int(first)]
        except IndexError:
            self.v = None
        self.top.destroy()

    def _new(self, event=None):
        self.v = "NEW"
        self.top.destroy()

    def _cancel(self, event=None):
        self.top.destroy()

    def return_value(self):
        self.master.wait_window(self.top)
        return self.v
Exemple #5
0
    def __init__(self, master, main_window):
        self.master = master
        self.main_window = main_window

        top = Toplevel(master)
        top.title(_("Global Options"))
        top.transient(master)
        top.protocol('WM_DELETE_WINDOW', self.close_dlg)

        top.geometry('%+d%+d' %
                     (master.winfo_rootx() + 100, master.winfo_rooty() + 100))

        self.top = top
        self.build_dlg()
Exemple #6
0
    def __init__(self, master, main_window):
	self.master = master
	self.main_window = main_window

	top = Toplevel(master)
	top.title(_("Global Options"))
	top.transient(master)
	top.protocol('WM_DELETE_WINDOW', self.close_dlg)

	top.geometry('%+d%+d' % (master.winfo_rootx() + 100,
				 master.winfo_rooty() + 100))

	self.top = top
	self.build_dlg()
Exemple #7
0
 def edit(self, obj):
     if obj is None:
         return
     editor = self._editors.get(obj)
     if editor is not None:
         editor.toplevel.deiconify()
         editor.toplevel.lift()
         editor.toplevel.focus()
     else:
         toplevel = Toplevel()
         toplevel.transient(self.parent)
         self._editors[obj] = editor = self.editor_factory(obj, toplevel)
         def on_editor_close():
             editor.toplevel.withdraw()
         editor.toplevel.protocol("WM_DELETE_WINDOW", on_editor_close)
Exemple #8
0
def getDlg(root, title):
    """Create a dialog
    
    Arguments
    root -- dialog parent
    title -- dialog title
    
    """
    dlg = Toplevel(root)
    dlg.title(title)
    dlg.root = root
    
    dlg.grab_set()
    dlg.transient(root)
    dlg.resizable(False, False)
    return dlg
Exemple #9
0
 def show_license():
     t = Toplevel(master)
     t.title("Context Licenses")
     t.transient(master)
     scroll = Scrollbar(t, orient=VERTICAL)
     tx = Text(
         t,
         wrap=WORD,
         yscrollcommand=scroll.set,
     )
     scroll['command'] = tx.yview
     scroll.pack(side=RIGHT, fill=Y, expand=1)
     tx.pack(fill=BOTH, expand=1)
     tx.insert("0.0", b64decode(data.LICENSE).replace("\r", ""))
     tx.configure(state="disabled")
     tx.focus_set()
     win_center(t)
Exemple #10
0
    def help_about(self):

        """Shows an 'about' modal dialog.

        Callback method called by tk.

        """

        about_win = Toplevel(self.root)

        # Set up dialog

        lbl = Label(about_win, text="Video Poker")
        lbl.grid(row=0, column=0, padx=10, pady=(10, 0), sticky=W + N)
        lbl = Label(about_win, text="by Paul Griffiths")
        lbl.grid(row=1, column=0, padx=10, pady=(0, 7), sticky=W + N)
        lbl = Label(about_win, text="Written in Python, with tkinter.")
        lbl.grid(row=2, column=0, padx=10, pady=7, sticky=W + N)
        lbl = Label(about_win, text="Copyright 2013 Paul Griffiths")
        lbl.grid(row=4, column=0, padx=10, pady=(7, 0), sticky=W + N)
        lbl = Label(about_win, text="Email: [email protected]")
        lbl.grid(row=5, column=0, padx=10, pady=(0, 21), sticky=W + N)
        lbl = Label(about_win, text="This program is free software: you can " +
            "redistribute it and/or modify it under the terms")
        lbl.grid(row=6, column=0, columnspan=2,
                 padx=10, pady=0, sticky=W + N)
        lbl = Label(about_win, text="of the GNU General Public License as " +
            "published by the Free Software Foundation, either")
        lbl.grid(row=7, column=0, columnspan=2,
                 padx=10, pady=(0, 0), sticky=W + N)
        lbl = Label(about_win, text="version 3 of the License, or " +
            "(at your option) any later version.")
        lbl.grid(row=8, column=0, columnspan=2,
                 padx=10, pady=(0, 21), sticky=W + N)
        lbl = Label(about_win, text="This program is distributed in " +
            "the hope that it will be useful, but WITHOUT ANY WARRANTY;")
        lbl.grid(row=9, column=0, columnspan=2,
                 padx=10, pady=0, sticky=W + N)
        lbl = Label(about_win, text="without even the implied " +
            "warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR")
        lbl.grid(row=10, column=0, columnspan=2,
                 padx=10, pady=(0, 0), sticky=W + N)
        lbl = Label(about_win, text="PURPOSE. See the " +
            "GNU General Public License for more details.")
        lbl.grid(row=11, column=0, columnspan=2,
                 padx=10, pady=(0, 21), sticky=W + N)
        lbl = Label(about_win, text="You should have received a " +
            "copy of the GNU General Public License along with this")
        lbl.grid(row=12, column=0, columnspan=2,
                 padx=10, pady=(0, 0), sticky=W + N)
        lbl = Label(about_win, text="program. If not, see " +
            "<http://www.gnu.org/licenses/>.")
        lbl.grid(row=13, column=0, columnspan=2,
                 padx=10, pady=(0, 21), sticky=W + N)
        img = PhotoImage(file="{0}27.gif".format(self.gifdir))
        lbl = Label(about_win, image=img)
        lbl.grid(row=0, column=1, rowspan=5, padx=10, pady=10, sticky=N + E)

        btn = Button(about_win, text="OK", command=about_win.quit)
        btn.grid(row=14, column=0, columnspan=2,
                 padx=0, pady=(0, 10), ipadx=30, ipady=3)

        # Show dialog

        about_win.transient(self.root)
        about_win.parent = self.root
        about_win.protocol("WM_DELETE_WINDOW", about_win.destroy)
        about_win.geometry("+{0}+{1}".format(self.root.winfo_rootx() + 50,
                                           self.root.winfo_rooty() + 50))
        about_win.title("About Video Poker")
        about_win.focus_set()
        about_win.grab_set()
        about_win.mainloop()
        about_win.destroy()
Exemple #11
0
    def select_start_options(self):
        '''
    popup box to select side and difficulty levels
    '''
        print 'select game start options'

        popup = Toplevel(self.gui, width=300, height=110)
        popup.title('Choose Game Side and Level')

        # stays on top of the game canvass
        popup.transient(self.gui)
        popup.grab_set()

        # bind window close events
        popup.bind('<Escape>',
                   lambda e: self.not_selected_start_options(popup))
        popup.protocol("WM_DELETE_WINDOW",
                       lambda: self.not_selected_start_options(popup))

        # choose side
        label1 = Label(popup, text="Side", height=30, width=50)
        label1.place(x=10, y=5, height=30, width=50)

        val1 = IntVar()

        bt_north = Radiobutton(popup, text="White", variable=val1, value=1)
        bt_north.place(x=60, y=10)
        bt_south = Radiobutton(popup, text="Black", variable=val1, value=2)
        bt_south.place(x=120, y=10)

        # by default, human plays first, meaning play the north side
        if self.choose_side == 'north':
            bt_north.select()
        else:
            bt_south.select()

        # choose difficulty level
        label2 = Label(popup, text="Level", height=30, width=50)
        label2.place(x=10, y=35, height=30, width=50)

        val2 = IntVar()

        bt_level1 = Radiobutton(popup, text="Dumb", variable=val2, value=1)
        bt_level1.place(x=60, y=40)
        bt_level2 = Radiobutton(popup, text="Smart", variable=val2, value=2)
        bt_level2.place(x=120, y=40)
        bt_level3 = Radiobutton(popup, text="Genius", variable=val2, value=3)
        bt_level3.place(x=180, y=40)

        # by default, the game is medium level
        if self.choose_level == 1:
            bt_level1.select()
        elif self.choose_level == 2:
            bt_level2.select()
        elif self.choose_level == 3:
            bt_level3.select()

        button = Button(popup, text='SET', \
                  command=lambda: self.selected_start_options(popup, val1, val2))

        button.place(x=70, y=70)
Exemple #12
0
    def help_about(self):

        """Shows an 'about' modal dialog.

        Callback method called by tk.

        """

        about_win = Toplevel(self.root)

        # Set up dialog

        lbl = Label(about_win, text="Video Poker")
        lbl.grid(row=0, column=0, padx=10, pady=(10, 0), sticky=W + N)
        lbl = Label(about_win, text="by Charles Raymond Smith")
        lbl.grid(row=1, column=0, padx=10, pady=(0, 7), sticky=W + N)
        lbl = Label(about_win, text="Adapted from video poker by Paul Griffiths")
        lbl.grid(row=2, column=0, padx=10, pady=(0, 7), sticky=W + N)
        lbl = Label(about_win, text="Written in Python, with tkinter.")
        lbl.grid(row=3, column=0, padx=10, pady=7, sticky=W + N)
        lbl = Label(about_win, text="Copyright 2017 Charles Raymond Smith")
        lbl.grid(row=4, column=0, padx=10, pady=(7, 0), sticky=W + N)
        lbl = Label(about_win, text="Email: [email protected]")
        lbl.grid(row=5, column=0, padx=10, pady=(0, 21), sticky=W + N)
        lbl = Label(about_win, text="This program is free software: you can " +
            "redistribute it and/or modify it under the terms")
        lbl.grid(row=6, column=0, columnspan=2,
                 padx=10, pady=0, sticky=W + N)
        lbl = Label(about_win, text="of the GNU General Public License as " +
            "published by the Free Software Foundation, either")
        lbl.grid(row=7, column=0, columnspan=2,
                 padx=10, pady=(0, 0), sticky=W + N)
        lbl = Label(about_win, text="version 3 of the License, or " +
            "(at your option) any later version.")
        lbl.grid(row=8, column=0, columnspan=2,
                 padx=10, pady=(0, 21), sticky=W + N)
        lbl = Label(about_win, text="This program is distributed in " +
            "the hope that it will be useful, but WITHOUT ANY WARRANTY;")
        lbl.grid(row=9, column=0, columnspan=2,
                 padx=10, pady=0, sticky=W + N)
        lbl = Label(about_win, text="without even the implied " +
            "warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR")
        lbl.grid(row=10, column=0, columnspan=2,
                 padx=10, pady=(0, 0), sticky=W + N)
        lbl = Label(about_win, text="PURPOSE. See the " +
            "GNU General Public License for more details.")
        lbl.grid(row=11, column=0, columnspan=2,
                 padx=10, pady=(0, 21), sticky=W + N)
        lbl = Label(about_win, text="You should have received a " +
            "copy of the GNU General Public License along with this")
        lbl.grid(row=12, column=0, columnspan=2,
                 padx=10, pady=(0, 0), sticky=W + N)
        lbl = Label(about_win, text="program. If not, see " +
            "<http://www.gnu.org/licenses/>.")
        lbl.grid(row=13, column=0, columnspan=2,
                 padx=10, pady=(0, 21), sticky=W + N)
        img = PhotoImage(file="{0}27.gif".format(self.gifdir))
        lbl = Label(about_win, image=img)
        lbl.grid(row=0, column=1, rowspan=5, padx=10, pady=10, sticky=N + E)

        btn = Button(about_win, text="OK", command=about_win.quit)
        btn.grid(row=14, column=0, columnspan=2,
                 padx=0, pady=(0, 10), ipadx=30, ipady=3)

        # Show dialog

        about_win.transient(self.root)
        about_win.parent = self.root
        about_win.protocol("WM_DELETE_WINDOW", about_win.destroy)
        about_win.geometry("+{0}+{1}".format(self.root.winfo_rootx() + 50,
                                           self.root.winfo_rooty() + 50))
        about_win.title("About Video Poker")
        about_win.focus_set()
        about_win.grab_set()
        about_win.mainloop()
        about_win.destroy()
Exemple #13
0
class ListBoxChoice(object):
	def __init__(self, master=None, title=None, message=None, clist=[], newmessage=None):
		self.master = master
		self.value = None
		self.newmessage = newmessage
		self.list = clist[:]
		
		self.modalPane = Toplevel(self.master)

		self.modalPane.transient(self.master)
		self.modalPane.grab_set()

		self.modalPane.bind("<Return>", self._choose)
		self.modalPane.bind("<Escape>", self._cancel)

		if title:
			self.modalPane.title(title)

		if message:
			Label(self.modalPane, text=message).pack(padx=5, pady=5)

		listFrame = Frame(self.modalPane)
		listFrame.pack(side=TOP, padx=5, pady=5)
		
		scrollBar = Scrollbar(listFrame)
		scrollBar.pack(side=RIGHT, fill=Y)
		self.listBox = Listbox(listFrame, selectmode=SINGLE)
		self.listBox.pack(side=LEFT, fill=Y)
		scrollBar.config(command=self.listBox.yview)
		self.listBox.config(yscrollcommand=scrollBar.set)
		self.list.sort()
		for item in self.list:
			self.listBox.insert(END, item)

		if newmessage is not None:
			newFrame = Frame(self.modalPane)
			newFrame.pack(side=TOP, padx=5)
			Label(newFrame, text=newmessage).pack(padx=5, pady=5)
			self.entry = Entry(newFrame, width=30)
			self.entry.pack(side=TOP, padx=5)
			self.entry.bind("<Return>", self._choose_entry)


		buttonFrame = Frame(self.modalPane)
		buttonFrame.pack(side=BOTTOM)

		chooseButton = Button(buttonFrame, text="Choose", command=self._choose_entry)
		chooseButton.pack()

		cancelButton = Button(buttonFrame, text="Cancel", command=self._cancel)
		cancelButton.pack(side=RIGHT)

	def _choose_entry(self, event=None):
		if self.newmessage is None:
			self._choose()
			return
		
		v = self.entry.get().strip()
		if v == None or v == "":
			self._choose()
			return

		self.value = v
		self.modalPane.destroy()
		
	def _choose(self, event=None):
		try:
			firstIndex = self.listBox.curselection()[0]
			self.value = self.list[int(firstIndex)]
		except IndexError:
			self.value = None
		self.modalPane.destroy()

	def _cancel(self, event=None):
		self.modalPane.destroy()
		
	def returnValue(self):
		self.master.wait_window(self.modalPane)
		return self.value
Exemple #14
0
class Docview:
    def __init__(self, master, fn, **kwargs):

        self.file = fn
        self.widget = None
        self.text = Text()
        self.frame = master
        self.location = kwargs.get('location', None)
        self.wait = kwargs.get('wait', None)
        self.find = kwargs.get('find', None)
        self.delete_img = PhotoImage(file='delete.pbm')
        self.up_img = PhotoImage(file='1uparrow.pbm')
        self.down_img = PhotoImage(file='1downarrow.pbm')
        self.upbutn = Button()
        self.dnbutn = Button()
        self.deletebutn = Button()
        self.entry = None
        self.doc = ''

    def Search(self, pattern):
        '''
        normal top-down search
        :param pattern:
        :return:
        '''
        try:
            self.text.tag_remove('hilight', '1.0', 'end')
            ind = self.text.search(pattern,
                                   '1.0',
                                   stopindex="end",
                                   nocase=True)
            self.text.mark_set("insert", ind)
            self.text.see("insert")
            nchar = len(pattern)
            self.text.tag_add('hilight', ind, ind + "+{}c".format(nchar))

        except:
            pass

    def RecursiveSearch(self, pattern, upward=False):
        '''
        Search forward from current position.  Search backward if upward is True.
        :param pattern: search pattern
        :param upward: reverse search if true
        :return: Null
        '''
        if len(pattern) == 0:
            ind = '1.0' if upward else 'end'
            self.text.mark_set("insert", ind)
            self.text.see("insert")
            return
        try:

            insert = self.text.index("insert")
            if upward:
                point = insert + "-1c"
                ind = self.text.search(pattern,
                                       point,
                                       stopindex="1.0",
                                       backwards=True,
                                       nocase=True)
            else:
                point = insert + "+1c"
                ind = self.text.search(pattern,
                                       point,
                                       stopindex="end",
                                       nocase=True)

            self.text.mark_set("insert", ind)
            self.text.see("insert")
            self.text.tag_remove('hilight', '1.0', 'end')
            nchar = len(pattern)
            self.text.tag_add('hilight', ind, ind + "+{}c".format(nchar))
            self.text.update()
        except:
            pass

    def SearchUp(self):
        pattern = str(self.entry.get())
        self.RecursiveSearch(pattern, True)

    def SearchDn(self):
        pattern = str(self.entry.get())
        self.RecursiveSearch(pattern, False)

    def FindEntry(self, event):
        '''triggered by keyrelease event in find entry box'''
        pattern = str(self.entry.get())
        nchar = len(pattern)
        self.text.tag_remove('hilight', '1.0', 'end')
        if nchar == 0:
            return
        try:
            ind = self.text.search(pattern,
                                   "1.0",
                                   stopindex="end",
                                   nocase=True)
            self.text.mark_set("insert", ind)
            self.text.see("insert")
            self.text.tag_add('hilight', ind, ind + "+{}c".format(nchar))
            self.text.update()
        except:
            pass

    def DeleteSearch(self):
        self.entry.delete(0, 'end')
        self.text.tag_remove('hilight', '1.0', 'end')

    def Popup(self):

        if not self.doc:
            with open(self.file, 'r') as fh:
                self.doc = fh.read()

        if self.widget:  # widget already open
            if self.frame:
                self.widget.lift(aboveThis=self.frame)
            return

        #print 'length of doc ', len(self.doc)

        self.widget = Toplevel()
        if self.find:
            self.sframe = Frame(self.widget)
            self.sframe.pack()
            self.upbutn = Button(self.sframe,
                                 width=17,
                                 command=self.SearchUp,
                                 image=self.up_img)
            self.upbutn.pack(side='left')
            self.dnbutn = Button(self.sframe,
                                 width=17,
                                 command=self.SearchDn,
                                 image=self.down_img)
            self.dnbutn.pack(side='left')
            self.entry = Entry(self.sframe, width=50)
            self.entry.bind('<KeyRelease>', self.FindEntry)
            self.entry.pack(side='left')
            self.deletebutn = Button(self.sframe,
                                     width=17,
                                     command=self.DeleteSearch)
            self.deletebutn.config(image=self.delete_img)
            self.deletebutn.pack(side='left')

        width = max([len(line) for line in self.doc.split('\n')])
        height = min([self.doc.count('\n') + 1, 40])
        self.text = Text(self.widget, width=width, height=height)
        self.text.tag = self.text.tag_configure('hilight',
                                                background='#ffff00')
        self.text.insert("1.0", self.doc)
        self.text.pack()

        if self.location and self.frame:
            dx, dy = self.location
            w = self.text.winfo_width()
            h = self.text.winfo_height()
            x = self.frame.winfo_x()
            y = self.frame.winfo_y()
            loc = "%dx%d+%d+%d" % (600, 400, x + dx, y + dy)
            self.widget.geometry(loc)

        if self.wait:
            self.widget.focus_set()
            self.widget.grab_set()
            if self.frame:
                self.widget.transient(master=self.frame)
            self.widget.wait_window(self.widget)

        if self.frame:
            self.widget.lift(aboveThis=self.frame)

        self.widget.protocol("WM_DELETE_WINDOW", self.Kill)

    def Kill(self):
        self.widget.destroy()
        self.widget = None