Reputation: 36295
According to the docs there should be a ComboBox
operation in TK, but I can't find it. dir(tk)
shows
['ACTIVE', 'ALL', 'ANCHOR', 'ARC', 'At', 'AtEnd', 'AtInsert', 'AtSelFirst', 'AtSelLast', 'BASELINE', 'BEVEL', 'BOTH', 'BOTTOM', 'BROWSE', 'BUTT', 'BaseWidget', 'BitmapImage', 'BooleanType', 'BooleanVar', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'Button', 'CASCADE', 'CENTER', 'CHAR', 'CHECKBUTTON', 'CHORD', 'COMMAND', 'CURRENT', 'CallWrapper', 'Canvas', 'Checkbutton', 'ClassType', 'CodeType', 'ComplexType', 'DISABLED', ...
The version is
import Tkinter as tk
tk.__version__
'$Revision: 81008 $'
on my Mac (latest OS X 10.11.6). No brewery for python whatsoever.
Upvotes: 4
Views: 14794
Reputation: 1089
There is no ComboBox
widget in tkinter
, what you are looking for is tkinter.ttk
(in Python 3, in Python 2 it's just called ttk
), which provides themed tk widgets. Docs for tkinter.ttk
, and subsection for ComboBox.
You can use this code to import ttk and use its widgets rather than standard tkinter
ones (note the different capitalization between 2 and 3!):
Python 2
from Tkinter import *
from ttk import *
Python 3:
from tkinter import *
from tkinter.ttk import *
Upvotes: 11
Reputation: 1
Started to learn tkinter (on python 2.7) just now, I ran into this problem and I read the first person's reply it didnt make sense at first so I had to go through the docs.
Combobox is part of ttk
comboBox_example = ttk.Combobox(window, width, textvariable)
wont work and will throw an error but if you give the library an alias
import ttk as TTK
or something, then
comboBox_example = TTK.Combobox(window, width, textvariable)
will work w/o a hitch
Upvotes: 0