Hi Trevor,
Thus spoketh Trevor J Christensen <[email protected]>
unto us on Tue, 06 Sep 2011 18:07:49 -0600 (MDT):
> How could/would one programmatically open/close a ttk combobox (i.e.
> present/hide the list of values) without requiring the user to click on
> combobox down arrow?
>
> In other words, I want to programmatically change focus (from where
> ever it is) to the combobox and have the combobox list of values
> displayed (just as if I had clicked on the combobox down arrow
> control). I fiddled around with setting state (['pressed'] and
> ['focus']) but didn't succeed accomplishing this.
there seems to be no "post()" method or something like that for the
ttk.Combobox, but what you want can be done with a little trickery:
from Tkinter import *
import ttk
class ComboBox(ttk.Combobox):
def __init__(self, *args, **kw):
ttk.Combobox.__init__(self, *args, **kw)
def post(self, event=None):
self.update_idletasks()
x, y = self.winfo_x(), self.winfo_y()
self.event_generate('<1>', x=x+self.winfo_width()-3, y=y+3)
root = Tk()
c = ComboBox(root, values=('foo', 'bar', 'baz'))
c.set('foo')
c.pack(padx=50, pady=50)
e = Entry(root)
e.pack(pady=(0,50))
e.focus()
root.bind('<F1>', c.post)
root.mainloop()
I hope this helps
Michael
.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.
No one can guarantee the actions of another.
-- Spock, "Day of the Dove", stardate unknown
_______________________________________________
Tkinter-discuss mailing list
[email protected]
http://mail.python.org/mailman/listinfo/tkinter-discuss