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 6707089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:35:51+00:00 2026-05-26T07:35:51+00:00

I have used the line of code below to input a variable for BAI_var1

  • 0

I have used the line of code below to input a variable for “BAI_var1” in a multiple choice command line software.

BAI_var1 = input ("Please enter 0 for not at all, 1 for somewhat, 2 for moderatly or 3 for a lot:")

Here is my Graphic User Interface:

from Tkinter import *
import time

    class App:
        def __init__(self, master):
            w = Label(master, text="1. Anxiety, nervousness, worry or fear")
            w.pack()

            v = IntVar()
            Radiobutton(master, text="0 for not at all", variable=v, value=1).pack(side=TOP, anchor="w")
            Radiobutton(master, text="1 for somewhat", variable=v, value=2).pack(side=TOP, anchor="w")
            Radiobutton(master, text="2 for moderatly", variable=v, value=3).pack(side=TOP, anchor="w")
            Radiobutton(master, text="3 for a lot", variable=v, value=4).pack(side=TOP, anchor="w")

            self.button = Button(master, text="BACK", fg="red", command=self.button6)
            self.button.pack(side=BOTTOM)
            self.button = Button(master, text="NEXT", fg="red", command=self.button5)
            self.button.pack(side=BOTTOM)


        def button6(self):
            print "Sam is awesome!GAJONGA" 

        def button5(self):
            print "PYTHON FOR THE WIN! GIAN SAYS PYTHON = FILTHY" 

    master = Tk()
    app = App(master)
    master.mainloop()

My problem is that I don’t know how to use a Radiobutton to input a set integer to a variable.

  • 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-05-26T07:35:51+00:00Added an answer on May 26, 2026 at 7:35 am

    Use a dictionary to map the integer values to the strings they represent:

    choices = {
        1: "not at all",
        2: "somewhat",
        3: "moderately",
        4: "a lot"
    }
    

    You can then use this to create the UI:

    for (i in sorted(choices.keys())):
        label = "%s - %s" % (i, choices[i])
        rb=Radiobutton(master, text=label, variable=v, value=i)
        rb.pack(side=TOP, anchor="w")
    

    When you need to fetch the values, obviously it’s just a simple dictionary lookup using the value of the variable as the key.

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

Sidebar

Related Questions

I have used this code for extracting urls from web page.But in the line
I have used this below code before and was working perfectly. When I use
I have used traditional version control systems to maintain source code repositories on past
I have used IPC in Win32 code a while ago - critical sections, events,
I have used an update command to update the whole table in an Sql
In the below code, I have a corrupt hello.bz2 which has stray characters beyond
I have some rrdcgi scripts with HTML code which are used to show graphs
Edit: Answered my own question. See below. -_- I have a variable defined in
I have an error message coming up with the following code I have used.
Background In a C# command-line app I'm writing, several of the parameters have yes

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.