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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:27:56+00:00 2026-05-27T21:27:56+00:00

I have a small program with many widgets like checkboxes, textctrls, statictexts,… The values

  • 0

I have a small program with many widgets like checkboxes, textctrls, statictexts,…

The values of all my widgets are stored in a dictionary. I’m saving the settings, e.g. this dictionary in a csv file. When I’m importing the settings from this file and update my dictionary, all my widgets should be enabled or disabled depending on the value in the dictionary by calling “def enable_controls”. But the widgets are always enabled, even if the value is “False”.

Here is the code snippet:

def enable_controls(self):
    self.Checkbox1.SetValue(bool(config.StartValues['Checkbox1']))
    self.Checkbox1TextCtrl.Enable(bool(config.StartValues['Checkbox1']))
    self.Checkbox1StaticText.Enable(bool(config.StartValues['Checkbox1']))

    self.Checkbox2.SetValue(bool(config.StartValues['Checkbox2']))
    self.Checkbox2TextCtrl.Enable(bool(config.StartValues['Checkbox2']))
    self.Checkbox2StaticText.Enable(bool(config.StartValues['Checkbox2']))

When I don’t assign the value dynamically, it works:

def enable_controls(self):
    self.Checkbox1.SetValue(False)
    self.Checkbox1TextCtrl.Enable(False)
    self.Checkbox1StaticText.Enable(False)

    self.Checkbox2.SetValue(False)
    self.Checkbox2TextCtrl.Enable(False)
    self.Checkbox2StaticText.Enable(False)

Am I doing the type conversion to bool correctly?

Edit: This is how I write and read from my csv file:

def onButtonSave(self, event):
    import csv
    getValues(self, StartValues)
    writer = csv.writer(open('Test.csv', 'wb'))
    for key, value in sorted(config.StartValues.items()):
        writer.writerow([key, value])

def onButtonLoad(self, event):
    import csv
    reader = csv.reader(open('Test.csv', 'rb'))
    config.StartValues = dict(x for x in reader)
    enable_controls(self)
  • 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-27T21:27:56+00:00Added an answer on May 27, 2026 at 9:27 pm

    As I said up in the comments, don’t use bool(config.StartValues['Checkbox2']) to do the data conversion. bool returns True for anything that does not evaluate to 0, 0.0 or an empty sequence or map. In this case, strings like "True" and "False" will both evaluate to True

    Using string comparison or similar would be better, but beware of user-introduced typos if you let them edit the files!

    Edit: use example…

    def evalBooleans(value):
        """Assumes we're getting either booleans or strings!"""
        return (value if isinstance(value, bool)
                    else value.lower() == "true")
    
    cb2 = evalBooleans(config.StartValues['Checkbox2'])
    self.Checkbox2.SetValue(cb2)
    self.Checkbox2TextCtrl.Enable(cb2)
    self.Checkbox2StaticText.Enable(cb2)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java program that runs many small simulations. It runs a genetic
I currently have a small Java program which I would like to run both
I have a small program to build a house. A house will have many
I have a small program to order and sort email messages, outputting to a
I have a small program <350ish lines of code on 5 forms>. It works
i have a small program where an element is draged and dropped, when the
I have a small program to do in Java. I have a 2D array
I have a small program I want to execute to test something #include <map>
I have a small server program that accepts connections on a TCP or local
I have a small Python program, which uses a Google Maps API secret key.

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.