Make True or False a variable
If I have the following snippet of code (from a larger section):
Code:
if self.generator.MS == "S":
self.lockSpouseBoxes(True)
else:
self.lockSpouseBoxes(False)
def lockSpouseBoxes(self):
self.ui.lineEdit1.setEnabled(variable for True or False)
How do I modify either/both the top part and the bottom function to carry the True or False from the top part to the function (there will be many line edits to setEnabled true or false). Stated another way, if MS == "S", I want to set a bunch of line edits to "setEnabled(True)" and vice versa. I'm new and not quite sure how to phrase the question.
Re: Make True or False a variable
Your "lockSpousesBoxes" needs a parameter for the boolean value
Code:
def lockSpousesBoxes(self, enable):
self.ui.lineEdit1.setEnabled(enable)
Cheers,
_
Re: Make True or False a variable
Quote:
Originally Posted by
anda_skoa
Your "lockSpousesBoxes" needs a parameter for the boolean value
Code:
def lockSpousesBoxes(self, enable):
self.ui.lineEdit1.setEnabled(enable)
Cheers,
_
'
thanks for your response, but it does not work. I do not understand how the variable 'enable' receives a value of True or False from the code (the "if" statement) above the function? By the way, the code above the function is contained in another function. Sorry, I forgot to mention that.
Re: Make True or False a variable
Quote:
I do not understand how the variable 'enable' receives a value of True or False from the code
What do you think this line of code does?
Code:
self.lockSpouseBoxes(True)
If you don't know, then you really need to learn something about the Python language before you try to write programs using it.
You also need to be very careful about indenting in Python. An indented section in Python is the same as code enclosed in curly braces "{}" in C / C++ - it defines the scope for that section of code. So if your code is really indented the way you pasted it, then I don't have any idea how Python interprets the scope of the lockSpouses function.