Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ComboBox not present in TK

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.

like image 293
qwerty_so Avatar asked Oct 27 '25 18:10

qwerty_so


1 Answers

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 *
like image 110
Dartmouth Avatar answered Oct 30 '25 08:10

Dartmouth