what is the global name of combo box?
Answers
Explanation:
Stack Overflow
sign up log in
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Questions Jobs Tags Users Badges Ask
Up vote
3
Down vote
Python, Tkinter: NameError: global name 'Combobox' is not defined
python tkinter ttk
I have created a combobox for my gui application in Python but I have been getting this error when declaring my combobox in my init function:
TypeError: 'Combobox' object is not callable
Here is the code I am using for this:
class ProgramingPractice(Tk):
def __init__(self):
super(ProgramingPractice, self).__init__()
self.variableCombo_value = StringVar()
self.variableCombo = ttk.Combobox()
def questionVariables(self):
self.variableCombo_value = StringVar()
self.variableCombo(self.formSize, textvariable = self.variableCombo, state = 'readonly')
self.variableCombo['values'] = ('Month', 'Year', 'Age', 'Day')
self.variableCombo.pack()
I have tried different solutions to this problem but I have either got an Attibute error or a name error.
Does anyone know of a solution to this problem?
This is the smallest I can make the code while still getting the error:
import sys
from tkinter import *
from tkinter import ttk
class ProgramingPractice(Tk):
def __init__(self):
super(ProgramingPractice, self).__init__()
self.formSize()
self.variableCombo_value = StringVar()
self.variableCombo = ttk.Combobox()
def formSize(self):
self.geometry("700x450+200+200") # Sets the size of the gui
def questionVariables(self):
self.variableCombo_value = StringVar()
self.variableCombo.configure(self.formSize, textvariable = self.variableCombo_value, state = 'readonly')
self.variableCombo['values'] = ('Month', 'Year', 'Age', 'Day')
self.variableCombo.pack()
pp = ProgramingPractice()
pp.questionVariables()
share improve this question follow
asked
Mar 28 '14 at 14:43
Tumbler
188●11 silver badge●1010 bronze badges edited
Mar 29 '14 at 11:44
What exactly is ttk, how did you import it? Also, Python 2 or 3? – tobias_k Mar 28 '14 at 14:47
ttk is the tkinter themed widget set, from tkinter import ttk – Tumbler Mar 28 '14 at 14:50
You do not get the error in __init__, but in the 2nd line of questionVariables. Try self.variableCombo.configure(stuff). Also, the textvariable parameter should probably be the StringVar, not the combobox itself... – tobias_k Mar 28 '14 at 14:50
@tobias_k By using the self.variableCombo.configure(stuff) I know get the error AttributeError: 'function' object has no attribute 'items' I am not sure what 'items' is. – Tumbler Mar 28 '14 at 15:05
Where you do self.variableCombo(....) you are trying to use the widget as a callable - you probably want self.variableCombo.configure(width=self.formsize, textvariable.....) – patthoyts Mar 28 '14 at 16:10
show 4 more comments
1 Answer
order by
votes
Up vote
2
Down vote
Accepted
Try
textvariable = self.variableCombo_value
share improve this answer follow
answered
Mar 28 '14 at 19:38
User
12.5k●11 gold badge●3030 silver badges●5555 bronze badges
Your Answer
Body
Add picture
OR
Name
By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy
meta chat tour help blog privacy policy legal contact us full site
2021 Stack Exchange, Inc. user contributions under cc by-sa
Means youfjdjfjdjdfjjffjfjfjfkfkgkfkfkckcjfjfjdjdjdkskslwkekedk