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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:22:03+00:00 2026-05-10T23:22:03+00:00

Alright, I’ll preface this with the fact that I’m a GTK and Python newb,

  • 0

Alright, I’ll preface this with the fact that I’m a GTK and Python newb, but I haven’t been able to dig up the information I needed. Basically what I have is a list of Radio Buttons, and based on which one is checked, I need to connect a button to a different function. I tried creating all my radio buttons, and then creating a disgusting if/else block checking for sget_active() on each button. The problem is the same button returns true every single time. Any ideas?

Here’s the code in use:

    #Radio Buttons Center     self.updatePostRadioVBox = gtk.VBox(False, 0)     self.updatePageRadio = gtk.RadioButton(None, 'Updating Page')     self.updatePostRadio = gtk.RadioButton(self.updatePageRadio, 'Updating Blog Post')     self.pageRadio = gtk.RadioButton(self.updatePageRadio, 'New Page')     self.blogRadio = gtk.RadioButton(self.updatePageRadio, 'New Blog Post')     self.addSpaceRadio = gtk.RadioButton(self.updatePageRadio, 'Add New Space')     self.removePageRadio = gtk.RadioButton(self.updatePageRadio, 'Remove Page')     self.removePostRadio = gtk.RadioButton(self.updatePageRadio, 'Remove Blog Post')     self.removeSpaceRadio = gtk.RadioButton(self.updatePageRadio, 'Remove Space')       #Now the buttons to direct us from here     self.returnMainMenuButton = gtk.Button(' Main Menu ')     self.returnMainMenuButton.connect('clicked', self.transToMain)     self.contentManageHBoxBottom.pack_start(self.returnMainMenuButton, False, False, 30)     self.contentProceedButton = gtk.Button('    Proceed    ')     self.contentManageHBoxBottom.pack_end(self.contentProceedButton, False, False, 30)      if self.updatePageRadio.get_active():         self.contentProceedButton.connect('clicked', self.updatePage)      elif self.updatePostRadio.get_active():         self.contentProceedButton.connect('clicked', self.updatePost)      elif self.pageRadio.get_active():         self.contentProceedButton.connect('clicked', self.newPage)      elif self.blogRadio.get_active():         self.contentProceedButton.connect('clicked', self.newBlogPost)      elif self.addSpaceRadio.get_active():         self.contentProceedButton.connect('clicked', self.newSpace)      elif self.removePageRadio.get_active():         self.contentProceedButton.connect('clicked', self.removePage)      elif self.removePostRadio.get_active():         self.contentProceedButton.connect('clicked', self.removeBlogPost)      elif self.removeSpaceRadio.get_active():         self.contentProceedButton.connect('clicked', self.removeSpace) 
  • 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. 2026-05-10T23:22:03+00:00Added an answer on May 10, 2026 at 11:22 pm

    Edit: (since you posted some code), just use:

    active = [r for r in self.updatePageRadio.get_group() if r.get_active()][0] 

    and use that to look up in a dict of functions and call it:

    my_actions[active]() 

    Edit: I totally forgot to mention that this is not a good use-case at all for RadioButtons, regular gtk.Button would be much better in my opinion.


    Your answer is to use the RadioButton ‘groups’ system. It is explained in this document, but here is a small practical example.

    Firstly a group is really just a RadioButton itself that is used to collect a number of other RadioButtons. You specify a group as the first argument to the constructor.

    r1 = gtk.RadioButton(None, label='Cat') # this has no group, it is the first r2 = gtk.RadioButton(r1, label='Mouse') # use the first radio                                         # button as the group argument r3 = gtk.RadioButton(r1, label='Dog')   # again use r1 

    Now all the radio buttons will be synchronised. And the matter of reading them is as easy as:

    active_radios = [r for r in r1.get_group() if r.get_active()] 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 104k
  • Answers 104k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer AFAIK, MetadataTypeAttribute is not supported by XmlSerializer (although it would… May 11, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer Windows CE itself doesn't support the STARTUPINFO structure passed to… May 11, 2026 at 8:36 pm
  • Editorial Team
    Editorial Team added an answer $items = array(); while($row = mysql_fetch_array($result, MYSQL_BOTH)) { $items[] =… May 11, 2026 at 8:36 pm

Related Questions

Alright, I have been doing the following (variable names have been changed): FileInputStream fis
Alright, I'm trying to read a comma delimited file and then put that into
Alright, I know how the fieldset / legend works out in HTML. Say you
Alright. I have a query that looks like this: SELECT SUM(`order_items`.`quantity`) as `count`, `menu_items`.`name`
Alright, I am going to state up front that this question may be too

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.