Created
September 4, 2016 02:42
-
-
Save Mr-Coxall/386a792f47f0c2ea11a388b67a621c54 to your computer and use it in GitHub Desktop.
global_variables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Created by: Mr. Coxall | |
# Created on: Sep 2016 | |
# Created for: ICS3U | |
# This program shows the difference between local and global variables | |
import ui | |
variableX = 25 | |
def local_button_touch_up_inside(sender): | |
# shows what happen with local variable | |
variableX = 10 | |
variableY = 30 | |
variableZ = variableX + variableY | |
view['local_answer_label'].text = str(variableZ) | |
def global_button_touch_up_inside(sender): | |
# shows what happen with global variable | |
global variableX | |
variableY = 30 | |
variableZ = variableX + variableY | |
view['global_answer_label'].text = str(variableZ) | |
view = ui.load_view() | |
view.present('full_screen') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"selected" : false, | |
"frame" : "{{0, 0}, {1024, 768}}", | |
"class" : "View", | |
"nodes" : [ | |
{ | |
"selected" : false, | |
"frame" : "{{47, 50}, {140, 32}}", | |
"class" : "Button", | |
"nodes" : [ | |
], | |
"attributes" : { | |
"action" : "local_button_touch_up_inside", | |
"frame" : "{{472, 368}, {80, 32}}", | |
"title" : "Local Variable", | |
"uuid" : "1BF98976-693A-4EFD-9433-28132C5618CB", | |
"class" : "Button", | |
"name" : "local_button", | |
"font_size" : 15 | |
} | |
}, | |
{ | |
"selected" : true, | |
"frame" : "{{47, 115}, {140, 32}}", | |
"class" : "Button", | |
"nodes" : [ | |
], | |
"attributes" : { | |
"action" : "global_button_touch_up_inside", | |
"frame" : "{{472, 368}, {80, 32}}", | |
"title" : "Global Variable", | |
"uuid" : "BF9A9062-6CBC-4B4C-8D68-6F7AF0CAD032", | |
"class" : "Button", | |
"name" : "global_button", | |
"font_size" : 15 | |
} | |
}, | |
{ | |
"selected" : false, | |
"frame" : "{{222, 50}, {150, 32}}", | |
"class" : "Label", | |
"nodes" : [ | |
], | |
"attributes" : { | |
"font_name" : "<System>", | |
"frame" : "{{437, 368}, {150, 32}}", | |
"uuid" : "3C90D0DA-0BF0-4C96-A486-3A420365B947", | |
"class" : "Label", | |
"alignment" : "left", | |
"text" : "Answer:", | |
"name" : "local_answer_label", | |
"font_size" : 18 | |
} | |
}, | |
{ | |
"selected" : false, | |
"frame" : "{{222, 115}, {150, 32}}", | |
"class" : "Label", | |
"nodes" : [ | |
], | |
"attributes" : { | |
"font_name" : "<System>", | |
"frame" : "{{437, 368}, {150, 32}}", | |
"uuid" : "8862EC39-2A90-4013-824E-845E8F58941D", | |
"class" : "Label", | |
"alignment" : "left", | |
"text" : "Answer:", | |
"name" : "global_answer_label", | |
"font_size" : 18 | |
} | |
} | |
], | |
"attributes" : { | |
"enabled" : true, | |
"background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)", | |
"tint_color" : "RGBA(0.000000,0.478000,1.000000,1.000000)", | |
"border_color" : "RGBA(0.000000,0.000000,0.000000,1.000000)", | |
"flex" : "" | |
} | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment