문제

I'm experimenting with the new ttk Tile enhancements that ship with Python 2.7.

Windows 7: The code below demonstrates how the combobox dropdown shows up BEHIND our root window when the root window is configured as a topmost window ("always on top"). If you comment out the line """ root.attributes( '-topmost', 1 )""" then the combobox dropdown appears within the root window (as expected).

Anyone have any workarounds for this behavior so we can use comboboxes with 'topmost' windows?

# sample code that illustrates problem described above

import Tkinter as tkinter
import ttk

root = tkinter.Tk()

panelCombo = ttk.Frame( root )
panelCombo.pack( side='top', fill='x', padx=12, pady=8 )
valCombo = ( 'cat', 'dog', 'pig' )
varCombo = tkinter.StringVar()
varCombo.set( 'fish' )
cboCombo = ttk.Combobox( panelCombo, values=valCombo, textvariable=varCombo )
cboCombo.pack( side='left', anchor='w', padx=12, pady=8 )

# make our window 'alwaysontop'
root.attributes( '-topmost', 1 )
root.mainloop()
도움이 되었습니까?

해결책

That's a known bug in the Tk toolkit. It was fixed in release 8.5.6. Maybe you just need to wait until that release makes its way into Python.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top