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

  • Home
  • SEARCH
  • 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 8214407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:27:09+00:00 2026-06-07T11:27:09+00:00

what i am trying to do is setup if statements to check if a

  • 0

what i am trying to do is setup if statements to check if a checkbuttons value is on or off

what i was thinking was something like this

from Tkinter import *

def checkbutton_value():
    #If statement here
    #is their something like 

    #if checkbox_1.onvalue == True:
    #   checkbox_2.deselect()

    #if checkbox_1.varible == checkbox_1.onvalue:
    #   checkbox_2.deselect()

    print 'Need Help on lines 7-8 or 10-11'

root=Tk()

checkbox_1 = Checkbutton(root, text='1   ', command=checkbutton_value).pack()
checkbox_2 = Checkbutton(root, text='2   ', command=checkbutton_value).pack()

checkbox_3 = Checkbutton(root, text='QUIT', command=quit).pack()

root.mainloop()
  • 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-07T11:27:11+00:00Added an answer on June 7, 2026 at 11:27 am

    First, do not create and pack a widget on one line. pack returns None, so in your code above, checkbox_1 is None. Instead:

    checkbox_1 = Checkbutton(root, text='1   ', command=checkbutton_value)
    checkbox_1.pack()
    

    Now, to get the value of the checkbutton:

    def checkbutton_value1():
        if(var1.get()):
           var2.set(0)
    
    def checkbutton_value2():
        if(var2.get()):
           var1.set(0)
    
    var1=IntVar()
    checkbox_1 = Checkbutton(root, text='1   ', variable=var1, command=checkbutton_value1)
    checkbox_1.pack()
    var2=IntVar()
    checkbox_2 = Checkbutton(root, text='2   ', variable=var2, command=checkbutton_value2)
    checkbox_2.pack()
    

    It is often desireable to create your own checkbutton class for things like this:

    class MyCheckButton(CheckButton):
        def __init__(self,*args,**kwargs):
            self.var=kwargs.get('variable',IntVar())
            kwargs['variable']=self.var
            Checkbutton.__init__(self,*args,**kwargs)
    
        def is_checked(self):
            return self.var.get()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to setup my asp.net mvc page like the following image: The header
I'm trying to setup the application server part of C2DM push messaging using this
Not sure how to describe what I'm trying to get from this question, but
Possible Duplicate: Check iPhone iOS Version I am trying to setup some code that
Trying to setup a personal image upload/downloader webpage. I've viewed the msdn article on
Trying to setup a CodeIgniter based project for local development (LAMP stack), and once
Trying to setup some validation on the add to cart button for the dropdown
Trying to setup and get going with the RestKit library for a cocoa project
I have been trying to setup git for our web development team unsuccessfully. Some
I'm trying to setup a system to minimize complexity for people updating the site

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.