def callback1(self, instance):
global day = self.user1.text
global day_type = self.user2.text
global split = self.user3.text
current_day = ExcelEdit.split_def_start(day, day_type)
Workout_app.screen_manager.current = "Input"
#The error is (global day = self.user1.text) SyntaxError: invalid syntax. #I have all three variables defined outside of the class yet I am unable to update them
CodePudding user response:
You are assigning these values to the variables and then creating a global variable on the same line, which doesn't seem to be valid Python syntax. You will have to write it as:
global day
global day_type
global split
day = self.user1.text
day_type = self.user2.text
split = self.user3.text
CodePudding user response:
The hint is in invalid syntax.
You cannot say global <var> = <val>
you have to "define" the global variable in one line and then assign to it in the next.
Here is a tiny working example of how it should look
day = 1
day_type = 2
split = 4
class Test:
def callback1(self):
global day
global day_type
global split
day = 10
day_type = 20
split = 3
if __name__ == "__main__":
print("Day: {}".format(day))
print("Day Type: {}".format(day_type))
print("Split: {}".format(split))
a = Test()
a.callback1()
print("")
print("")
print("Day: {}".format(day))
print("Day Type: {}".format(day_type))
print("Split: {}".format(split))
Thereby your code should look like this:
def callback1(self, instance):
global day
global day_type
global split
day = self.user1.text
day_type = self.user2.text
split = self.user3.text
current_day = ExcelEdit.split_def_start(day, day_type)
Workout_app.screen_manager.current = "Input"