1

I am facing a problem creating a Tkinter-application under Windows, using python 2.7. Basically, when I create an OptionMenu, its right corner (where a down button indicates that something happens when you click there) is truncated in the middle.

The following code reproduces the issue:

from Tkinter import Tk, StringVar
from ttk import OptionMenu

root = Tk()

options = list('ABC')
var = StringVar(value='A')
om = OptionMenu(root, var, var.get(), *options)
om.config(width=25)
om.pack()

root.mainloop()

The result looks on my computer like this:

Example of a truncated option menu

I have played around with the padx and ipadx keywords of the packing layout manager and also tried a grid layout instead. None of them lets me see the down-arrow completely.

I appreciate your helpful comments on this issue.

Gregor
  • 1,333
  • 9
  • 16
  • works perfect when I run it Windows with py 3.3 – W1ll1amvl Aug 13 '14 at 04:20
  • Works fine here too, Python 2.7 on Windows XP. I can check on Windows 7 this afternoon when I get home. – fhdrsdg Aug 13 '14 at 07:26
  • Thank you for trying it out. I'm using Windows 7, if this works for you, too, I'll maybe check how I can update my versions of tkinter and ttk. – Gregor Aug 13 '14 at 09:04
  • Okay, I am using Tcl/Tk in version 8.5.2, seems not too old. – Gregor Aug 13 '14 at 09:26
  • Yes, I have the same problem on Windows 7 and Tk 8.5. I also found [this](http://sourceforge.net/p/tktoolkit/bugs/2883/), which indicates it should be fixed in Tk 8.5.8. Updating Tcl/Tk seems to be [very complicated](http://stackoverflow.com/questions/14740857/how-to-update-tcl-tk-in-python) though – fhdrsdg Aug 13 '14 at 17:00
  • Okay, thanks a lot for your time and help. Why don't you post this as an answer, together with the link. – Gregor Aug 13 '14 at 20:17

2 Answers2

1

The same happens to me on Windows 7 but not on XP, both using Python 2.7. I have found a bug report which states is should be fixed in Tk 8.5.8. Updating Tcl/Tk in Python seems to be very complicated though

Community
  • 1
  • 1
fhdrsdg
  • 10,297
  • 2
  • 41
  • 62
  • Thanks again. I can live with that bug. I will not update right now, I am quite comforted already that I haven't overread anything particular about the OptionMenu packing etc. – Gregor Aug 14 '14 at 10:40
1

The fix in question is for one of the script files shipped in the tk library. You could modify your local copy of vistaTheme.tcl to match this. In later versions I think it does actually request the size from the system properly but this should work if you are forced to use an older version of Tk.

You can find the path using:

from Tkinter import Tk
tk = Tk()
tk.eval("set tk_library")

and then edit the /ttk/vistaTheme.tcl file. I've got python3 here and it seems to have come with Tk 8.6.1 so has this fixed already.

patthoyts
  • 32,320
  • 3
  • 62
  • 93
  • Hi, this seems like an affordable effort, although I consider fiddling with the distribution libraries as undesirable. I haven't tried it out yet, but I give you a +1 for digging into this issue. – Gregor Aug 16 '14 at 18:12