Tkinter button doesn't appear in OS X

crystalattice crystalattice at gmail.com
Sun Dec 10 19:49:18 EST 2006


I'm creating a shelve interface using Tkinter.  I have a button that
allows the user to modify an existing entry; when the button is
clicked, a new TopLevel window appears with Entry boxes holding the
selected entry.  Below the Entry boxes are two buttons, one that saves
the changes to the database and the other is simply a Cancel button.

Under Linux, both buttons appear correctly.  However, in OS X the
Cancel button is invisible unless the window is resized or you click in
the area where the Cancel button is located.  I believe it works
correctly under Windows (it's been a few days since I was able to check
it on a Windows machine).

Is there something special about OS X and Tkinter that I need to know
about or is it just a glitch I'll have to work around?  Below is the
relevant code block:
------------------------------------------------------
def changeInven(self):
        """Allows modification of a database entry.

        Called by modifyInven Button"""

        try:    #see if a selection was made
            self.getSelection = self.listBox.curselection() #get index
of selection
            self.selectedEntry = self.listBox.get(self.getSelection)
#get tuple from selection
            (self.prodnum, self.descrip, self.colors, self.cost,
self.price,
                self.quan) = self.selectedEntry    #unpack tuple

            #---New 'edit product' window
            self.editWindow = Toplevel()
            self.editWindow.title("Edit selected entry")

            #---Edit product window widgets
            Label(self.editWindow, text = "Product Number").grid(row =
0, column = 0)
            Label(self.editWindow, text = "Description").grid(row = 0,
column = 1)
            Label(self.editWindow, text = "Color").grid(row = 0, column
= 2)
            Label(self.editWindow, text = "Unit cost").grid(row = 0,
column = 3)
            Label(self.editWindow, text = "Sell price").grid(row = 0,
column = 4)
            Label(self.editWindow, text = "Quantity").grid(row = 0,
column = 5)

            self.oldNum = Entry(self.editWindow, name = "prodNum")
            self.oldNum.grid(row = 1, column = 0)
            self.oldDescrip = Entry(self.editWindow, name = "descrip")
            self.oldDescrip.grid(row = 1, column = 1)
            self.oldColor = Entry(self.editWindow, name = "color")
            self.oldColor.grid(row = 1, column = 2)
            self.oldCost = Entry(self.editWindow, name = "cost")
            self.oldCost.grid(row = 1, column = 3)
            self.oldPrice = Entry(self.editWindow, name = "price")
            self.oldPrice.grid(row = 1, column = 4)
            self.oldQuan = Entry(self.editWindow, name = "quan")
            self.oldQuan.grid(row = 1, column = 5)

            self.update = Button(self.editWindow, text = "Update
product",
                command = self.updateProduct).grid(row = 2, column = 2)
            self.cancel = Button(self.editWindow, text = "Cancel",
                command = self.cancelProduct).grid(row = 2, column = 3)


            #---Edit product data
            self.oldNum.insert(END, self.prodnum)
            self.oldDescrip.insert(END, self.descrip)
            self.oldColor.insert(END, self.colors)
            self.oldCost.insert(END, self.cost)
            self.oldPrice.insert(END, self.price)
            self.oldQuan.insert(END, self.quan)

        except TclError:    #tell user to make a selection first
            showerror(title = "Error!", message = "You must make a
selection first!")




More information about the Python-list mailing list