-
janAaron
I made a program that spits out hello + some numbers, and it makes a really cool animation. I tried to make it so that when the random number reaches 20, it changes the color of the console output, but it didn't work. What's wrong?
import console console.set_color() a = 1 while 100: print ("hello "+ str(a+a)) a +=a if a == 20: console.set_color(1.00, 0.00, 0.00)
Thank you!
-
janAaron
I've (with a lot of help) made this basic tic tac toe game. Right now when you tap on one of the clocks it turns into an "X", but I want to make it so that every other click the clock turns into an "O"; that way two people can play. How would I do that?
Here's the code:
#coding: utf-8 import ui def pressed (sender): sender.tint_color = 1.00, 0.00, 0.00 button1.background_image = ui.Image.named('ionicons-close-24') def jumbo (sender): button2.background_image = ui.Image.named('ionicons-close-round-24') def pretzel (sender): button3.background_image = ui.Image.named('ionicons-close-24') def turkey (sender): button4.background_image = ui.Image.named('ionicons-close-round-24') def yoohoo (sender): button5.background_image = ui.Image.named('ionicons-close-24') def domino (sender): button6.background_image = ui.Image.named('ionicons-close-24') def tubs (sender): button7.background_image = ui.Image.named('ionicons-close-24') def oops (sender): button8.background_image = ui.Image.named('ionicons-close-24') def ager (sender): button9.background_image = ui.Image.named('ionicons-close-24') # view established view = ui.View() view.name = "tic tac toe" view.background_color = 0.90, 0.90, 0.90 view.present("sheet") view.background_color = 0.00, 1.00, 1.00 # first button button1 = ui.Button() button1.background_image = ui.Image.named('ionicons-clock-24') button1.flex = "LRTB" button1.action = pressed view.add_subview(button1) button1.center = (view.width * 0.4, view.height * 0.1) button1.size_to_fit() #second button button2 = ui.Button() button2.background_image = ui.Image.named('ionicons-clock-24') button2.flex = "LRTB" button2.action = jumbo view.add_subview(button2) button2.center = (view.width * 0.7, view.height * 0.1) button2.size_to_fit() # third button button3 = ui.Button() button3.background_image = ui.Image.named('ionicons-clock-24') button3.flex = "LRTB" button3.action = pretzel view.add_subview(button3) button3.center = (view.width * 0.2, view.height * 0.1) button3.size_to_fit() # fourth button button4 = ui.Button() button4.background_image = ui.Image.named('ionicons-clock-24') button4.flex = "LRTB" button4.action = turkey view.add_subview(button4) button4.center = (view.width * 0.2, view.height * 0.4) button4.size_to_fit() # fifth button button5 = ui.Button() button5.background_image = ui.Image.named('ionicons-clock-24') button5.flex = "LRTB" button5.action = yoohoo view.add_subview(button5) button5.center = (view.width * 0.4, view.height * 0.4) button5.size_to_fit() # sixth button button6 = ui.Button() button6.background_image = ui.Image.named('ionicons-clock-24') button6.flex = "LRTB" button6.action = domino view.add_subview(button6) button6.center = (view.width * 0.7, view.height * 0.4) button6.size_to_fit() # seventh button button7 = ui.Button() button7.background_image = ui.Image.named('ionicons-clock-24') button7.flex = "LRTB" button7.action = tubs view.add_subview(button7) button7.center = (view.width * 0.2, view.height * 0.7) button7.size_to_fit() # eighth button button8 = ui.Button() button8.background_image = ui.Image.named('ionicons-clock-24') button8.flex = "LRTB" button8.action = oops view.add_subview(button8) button8.center = (view.width * 0.4, view.height * 0.7) button8.size_to_fit() # ninth button button9 = ui.Button() button9.background_image = ui.Image.named('ionicons-clock-24') button9.flex = "LRTB" button9.action = ager view.add_subview(button9) button9.center = (view.width * 0.7, view.height * 0.7) button9.size_to_fit()
-
-
-
janAaron
This is a program I wrote which is supposed to change a button's image from a smiley face to an ant when the face is touched. When I ran it, it did change, but also kept the face image. How do I get it so that it gets rid of the face when the image is touched?
Here's the code:
#coding: utf-8 import ui def pressed (sender): sender.tint_color = 1.00, 0.00, 0.00 button1.background_image = ui.Image.named('Ant') view = ui.View() view.name = "tic tac toe" view.background_color = 0.90, 0.90, 0.90 view.present("sheet") button1 = ui.Button(title = "😄") button1.flex = "LRTB" button1.action = pressed view.add_subview(button1) button1.center = (view.width *0.5,view.height *0.5) button1.font = ('AmericanTypewriter-Condensed', 60) button1.size_to_fit()
Thanks!
-
-
janAaron
Hi everyone!
I wrote this ui code, but the button isnt showing up. What's up?
Here's the code:
import ui def pressed (sender): sender.tint_color = 1.00, 0.00, 0.00 view = ui.View() view.name = "tic tac toe" view.background_color = 0.90, 0.90, 0.90 view.present("sheet") button = ui.Button() button.flex = "LRTB" button.action = pressed view.add_subview(button) button.center = (view.width *0.5,view.height *0.5) button.title = "nothing" button.background_image = ui.Image('Ant')
-
-
janAaron
Hi!
I'm trying to write a program where you can flip a switch, and it changes the color of the switch flipped. I made a GUI with three switches, and put the action as switch, but I don't know what code to put in the defined method switch to change the switches color once pressed.
Thanks!
import ui def switch (sender): print "hi" ui.load_view("tic tac toe.pyui").present("sheet")
-
janAaron
I switched it from 3 switches to three buttons, and re-wrote the code as this:
# coding: utf-8 import speech import ui view = ui.View() def switch (sender): speech.say("hello") ui.View().tint_color = 1.00, 0.00, 0.00 ui.load_view("tic tac toe.pyui").present("sheet")
Is that what you meant, because nothing happened.