Pergunta

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()
Foi útil?

Solução

Try

textvariable = self.variableCombo_value
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top