Tkinter button doesn't appear in OS X

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • crystalattice

    Tkinter button doesn't appear in OS X

    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(sel f):
    """Allows modification of a database entry.

    Called by modifyInven Button"""

    try: #see if a selection was made
    self.getSelecti on = self.listBox.cu rselection() #get index
    of selection
    self.selectedEn try = self.listBox.ge t(self.getSelec tion)
    #get tuple from selection
    (self.prodnum, self.descrip, self.colors, self.cost,
    self.price,
    self.quan) = self.selectedEn try #unpack tuple

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

    #---Edit product window widgets
    Label(self.edit Window, text = "Product Number").grid(r ow =
    0, column = 0)
    Label(self.edit Window, text = "Description"). grid(row = 0,
    column = 1)
    Label(self.edit Window, text = "Color").grid(r ow = 0, column
    = 2)
    Label(self.edit Window, text = "Unit cost").grid(row = 0,
    column = 3)
    Label(self.edit Window, text = "Sell price").grid(ro w = 0,
    column = 4)
    Label(self.edit Window, text = "Quantity").gri d(row = 0,
    column = 5)

    self.oldNum = Entry(self.edit Window, name = "prodNum")
    self.oldNum.gri d(row = 1, column = 0)
    self.oldDescrip = Entry(self.edit Window, name = "descrip")
    self.oldDescrip .grid(row = 1, column = 1)
    self.oldColor = Entry(self.edit Window, name = "color")
    self.oldColor.g rid(row = 1, column = 2)
    self.oldCost = Entry(self.edit Window, name = "cost")
    self.oldCost.gr id(row = 1, column = 3)
    self.oldPrice = Entry(self.edit Window, name = "price")
    self.oldPrice.g rid(row = 1, column = 4)
    self.oldQuan = Entry(self.edit Window, name = "quan")
    self.oldQuan.gr id(row = 1, column = 5)

    self.update = Button(self.edi tWindow, text = "Update
    product",
    command = self.updateProd uct).grid(row = 2, column = 2)
    self.cancel = Button(self.edi tWindow, text = "Cancel",
    command = self.cancelProd uct).grid(row = 2, column = 3)


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

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

  • Kevin Walzer

    #2
    Re: Tkinter button doesn't appear in OS X

    crystalattice wrote:
    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).
    >
    What version of Tk are you running? I've seen this bug on old versions
    of Tk (i.e. 8.4.7) but not recently.

    --
    Kevin Walzer
    Code by Kevin

    Comment

    • crystalattice

      #3
      Re: Tkinter button doesn't appear in OS X


      Kevin Walzer wrote:
      >
      What version of Tk are you running? I've seen this bug on old versions
      of Tk (i.e. 8.4.7) but not recently.
      >
      --
      Kevin Walzer
      Code by Kevin
      http://www.codebykevin.com
      I'm using Python 2.4.2, which I believe is the default version for OS
      X. How do I check the Tk version? Can I force my programs to use a
      different version of Python, e.g. if I installed Python 2.5?

      Comment

      • Kevin Walzer

        #4
        Re: Tkinter button doesn't appear in OS X

        crystalattice wrote:
        Kevin Walzer wrote:
        >What version of Tk are you running? I've seen this bug on old versions
        >of Tk (i.e. 8.4.7) but not recently.
        >>
        >--
        >Kevin Walzer
        >Code by Kevin
        >http://www.codebykevin.com
        >
        I'm using Python 2.4.2, which I believe is the default version for OS
        X. How do I check the Tk version? Can I force my programs to use a
        different version of Python, e.g. if I installed Python 2.5?
        >
        When you run your program on OS X, there should be a menu item next to
        the Apple menu that says "about Tcl/Tk," which you access from the
        "Python" menu item. That will give you the version number.

        Python 2.3.5 and Tcl/Tk 8.4.7 ship with OS X 10.4. Python 2.4.2 is a
        separate installation, but probably accesses the system Tcl/Tk unless
        you have installed a more recent version. Using the official Mac build
        of Python 2.5 will update your Python, but not Tcl/Tk--you'll need to
        install something more recent.

        You can install ActiveTcl for a "batteries-included" distro of
        Tcl/Tk--it has the latest and greatest of everything. Or, you can
        install a slightly older (8.4.13) version of Tcl/Tk at
        http://tk-components.sourceforge.net. (This is a version of Tcl/Tk Aqua
        that I use in my own programs and I made the build available for others
        to use.)

        Hope that helps,
        Kevin

        --
        Kevin Walzer
        Code by Kevin

        Comment

        • crystalattice

          #5
          Re: Tkinter button doesn't appear in OS X


          Kevin Walzer wrote:
          When you run your program on OS X, there should be a menu item next to
          the Apple menu that says "about Tcl/Tk," which you access from the
          "Python" menu item. That will give you the version number.
          >
          Python 2.3.5 and Tcl/Tk 8.4.7 ship with OS X 10.4. Python 2.4.2 is a
          separate installation, but probably accesses the system Tcl/Tk unless
          you have installed a more recent version. Using the official Mac build
          of Python 2.5 will update your Python, but not Tcl/Tk--you'll need to
          install something more recent.
          >
          You can install ActiveTcl for a "batteries-included" distro of
          Tcl/Tk--it has the latest and greatest of everything. Or, you can
          install a slightly older (8.4.13) version of Tcl/Tk at
          http://tk-components.sourceforge.net. (This is a version of Tcl/Tk Aqua
          that I use in my own programs and I made the build available for others
          to use.)
          >
          Hope that helps,
          Kevin
          >
          --
          Kevin Walzer
          Code by Kevin
          http://www.codebykevin.com
          Thanks for the info. It looks like it should work. I wasn't aware
          that OS X is so "compartmentali zed"; makes it a pain in the butt to
          develop on sometimes.

          Comment

          • crystalattice

            #6
            Re: Tkinter button doesn't appear in OS X

            I downloaded your file and got it working. Thanks for the hint and the
            code. I really appreciate it.

            Comment

            Working...