Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8133941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:49:26+00:00 2026-06-06T09:49:26+00:00

The following code (without showing it all) is my first attempt at using classes.

  • 0

The following code (without showing it all) is my first attempt at using classes. I’m trying to mainly pass the variable box as I wish to retrieve the values from the Entry widgets in Tkinter.

I seem to have possibly made the class work but I’m having difficulties calling the definitions from inside by the ‘command’ in the Tkinter widgets.

If someone could explain where my badly written class code is going wrong and whether or not getting the box values is possible I would be very happy.

I apologise if this is a repeat of any previous questions.

class Start():
    def ChoiceBox(self, choice):


        column = 0
        if choice == "Fixed":
            choice_frame.grid_forget()      
            tkMessageBox.showinfo("Message", "No optimisation, value fixed.")
        elif choice == "List":
            i = [0, 1, 2, 3]

            for i in i:
                choice_title = Label(choice_frame, text='Value %g'% float(i+1), bg='white', borderwidth=0, width=0)
                choice_title.grid(row=0, column=column+i, sticky="nsew", padx=1, pady=1)

                self.box = Entry(choice_frame, bg='white', borderwidth=0, width=0)
                self.box.grid(row=1, column=column+i, sticky="ew", padx=1, pady=1)

                tkMessageBox.showinfo("Message", "Please fill in list values.")


        elif choice == "Interval" or "Optimisation":
            i = [0, 1]
            choice_title1 = Label(choice_frame, text='Min Value', bg='white', borderwidth=0, width=0)
            choice_title1.grid(row=0, column=column, sticky="nsew", padx=1, pady=1)
            choice_title2 = Label(choice_frame, text='Max Value', bg='white', borderwidth=0, width=0)
            choice_title2.grid(row=0, column=column+1, sticky="nsew", padx=1, pady=1)
            for i in i:
                box = Entry(choice_frame, bg='white', borderwidth=0, width=0)
                box.grid(row=1, column=column+i, sticky="nsew", padx=1, pady=1)
                tkMessageBox.showinfo("Message", "Enter Min/Max values.")


    def StartBut(self):
    if self.box.get() == "":
            pass
        else:
            value = self.box.get()

list1 = OptionMenu(frame_table, variablelist, 'Fixed', 'List', 'Interval', 'Optimisation', command=Start.ChoiceBox)

but1 = Button(frame_but, text='Start', command=Start.StartBut)

UPDATE: Error I am now getting: ‘unbound method ‘ChoiceBox()’ must be called with Start instance as first argument (got str instance instead).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:49:29+00:00Added an answer on June 6, 2026 at 9:49 am

    def ChoiceBox(choice): this should be def ChoiceBox(self, choice):

    read more about how python classes work here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In following code the issue is, that I cannot test dao.add() without using dao.list().size()
Im trying to get debugging working without an app.config. I have the following code:
I'm using following peace of code to output an array: echo ======output without array_unique=====;
Given the following code without considering friendship between two classes: class OutSideClass { ...
The following code is making my app crash at line 3 without an error
The following code uploads file to the server display progressdialog with percentage without any
One recommends me the following code apparently only in .zshrc without explaining its purpose
I have written a following code to get just the file name without extension
I have the following code: var bool:String = true; Without an if block or
Consider the following code: int main() { int *p; ++((int){5}); //compile without err/warning &((int){5});

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.