Skip to content

Instantly share code, notes, and snippets.

@Gadgettyke Gadgettyke/cql.py Secret
Created Apr 30, 2018

Embed
What would you like to do?
cql.py
import ui
import time
from time import clock
# initialize timers with default values
stdtime = [120, 30]
timer1=[0,0,0]
timer2=[0,0,0]
seconds=[0,0,0]
start = time.clock()
seconds[0]=(int(start))
# timerx [ on, setval, curval]
timer1[1] = stdtime[0]
timer1[2] = stdtime[0]
timer2[1] = stdtime[1]
timer2[2] = stdtime[1]
print(timer1,timer2)
# update_display()
def how_long(seconds):
seconds[2]=seconds[1]
delta = time.clock()
seconds[1]=int(delta)
def action(sender):
label4=sender.superview['label4']
label5=sender.superview['label5']
confer_button=sender.superview['button1']
pass_button=sender.superview['button2']
reset_button=sender.superview['button3']
title=sender.title
#print(title)
# is it just changing value on screen?
if timer1[0] == 1 or timer2[0] == 1:
label4.text = str(timer1[2])
label5.text = str(timer2[2])
# have they pressed confer button
if title == 'Confer':
if timer1[0]==0:
timer1[0]=1
run_timer1()
label4.text = str(timer1[2])
confer_button.enabled = False
# have they pressed pass button
if title == 'Pass':
if timer2[0]==0:
timer2[0]=1
run_timer2()
label5.text = str(timer2[2])
pass_button.enabled=False
# halt the confer timer and not allow restart
confer_button.enabled=False
timer1[0]=2
# have they pressed reset button
if title == 'Reset':
timer1[0]=0
timer1[2]=timer1[1]
timer2[0]=0
timer2[2]=timer2[1]
label4.text = str(timer1[2])
label5.text = str(timer2[2])
confer_button.enabled=True
pass_button.enabled=True
def label4_update(guide) :
label=guide.superview['label4']
label.text = str(timer1[2])
def label5_update(sender):
label=guide.superview['label5']
label.text = str(timer2[2])
def change_time1(r1):
timer1[1]=int(r1.text)
# print (stdtime)
def change_time2(r2):
timer2[1] = int(r2.text)
# print (stdtime)
def run_timer1():
if timer1[0] != 2:
timer1[2] -= 1
print (timer1[2])
if timer1[2]<=0:
timer1[0]=2
def run_timer2():
if timer2[0] != 2:
timer2[2] -= 1
print (timer2[2])
if timer2[2]<=0:
timer2[0]=2
def timer_update():
if timer1[0]==1:
run_timer1()
if timer2[0]==1:
run_timer2()
def main():
guide=ui.View
#guide.Update_interval(0.5)
while True:
how_long(seconds)
if seconds[1] != seconds[2] and (timer1[0]== 1 or timer2[0]==1):
timer_update()
# try calling a subroutine or two just to update the label values
label4_update(guide)
label5_update(guide)
v = ui.load_view('cql')
#v.update_interval(0.5)
v.background_color='#00ffff'
v.present('sheet')
main()
[
{
"nodes" : [
{
"nodes" : [
],
"frame" : "{{33, 288}, {120, 60}}",
"class" : "Button",
"attributes" : {
"uuid" : "5B3C581B-AB10-4993-BD07-988A808E27EB",
"font_size" : 32,
"corner_radius" : 5,
"background_color" : "RGBA(0.138955,0.714623,0.330844,1.000000)",
"frame" : "{{120, 224}, {80, 32}}",
"tint_color" : "RGBA(0.833333,0.944444,1.000000,1.000000)",
"border_width" : 1,
"title" : "Confer",
"action" : "action",
"class" : "Button",
"name" : "button1",
"flex" : "LRTB"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{177, 288}, {120, 60}}",
"class" : "Button",
"attributes" : {
"uuid" : "D2842675-E521-4CC1-A92E-EE33DC6C193A",
"font_size" : 32,
"corner_radius" : 5,
"background_color" : "RGBA(0.250000,0.500000,1.000000,1.000000)",
"frame" : "{{120, 224}, {80, 32}}",
"tint_color" : "RGBA(0.972222,1.000000,1.000000,1.000000)",
"border_width" : 1,
"title" : "Pass",
"action" : "action",
"class" : "Button",
"name" : "button2",
"flex" : "LRTB"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{33, 376}, {264, 58}}",
"class" : "Button",
"attributes" : {
"border_width" : 1,
"action" : "action",
"frame" : "{{120, 224}, {80, 32}}",
"tint_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)",
"title" : "Reset",
"uuid" : "9158A829-155D-43C8-9927-F545A6D7E463",
"class" : "Button",
"corner_radius" : 6,
"background_color" : "RGBA(1.000000,0.333333,0.333333,1.000000)",
"name" : "button3",
"font_size" : 32
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{223, 6}, {74, 38}}",
"class" : "TextField",
"attributes" : {
"uuid" : "BC832B64-B2CB-409B-A546-C2D49F93EE57",
"font_size" : 24,
"corner_radius" : 6,
"background_color" : "RGBA(0.000000,1.000000,1.000000,1.000000)",
"frame" : "{{60, 224}, {200, 32}}",
"border_width" : 1,
"custom_attributes" : "",
"alignment" : "center",
"autocorrection_type" : "default",
"action" : "change_time1",
"text" : "120",
"font_name" : "<System>",
"spellchecking_type" : "default",
"class" : "TextField",
"name" : "textfield1",
"flex" : "LRTB"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{33, 6}, {182, 38}}",
"class" : "Label",
"attributes" : {
"flex" : "LRTB",
"name" : "label1",
"frame" : "{{85, 224}, {150, 32}}",
"uuid" : "BE60516A-4423-45D5-B81C-35413CA17089",
"class" : "Label",
"alignment" : "center",
"text" : "Confer time",
"background_color" : "RGBA(0.000000,1.000000,1.000000,1.000000)",
"font_size" : 18,
"font_name" : "<System>"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{33, 149}, {182, 36}}",
"class" : "Label",
"attributes" : {
"flex" : "LRTB",
"name" : "label2",
"frame" : "{{85, 224}, {150, 32}}",
"uuid" : "412D5501-643C-46EA-AE51-0A85B34E78EF",
"class" : "Label",
"alignment" : "center",
"text" : "Pass time",
"background_color" : "RGBA(0.000000,1.000000,1.000000,1.000000)",
"font_size" : 18,
"font_name" : "<System>"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{223, 149}, {74, 36}}",
"class" : "TextField",
"attributes" : {
"uuid" : "0556E6BE-8B52-4C4C-BBB9-AD5B0B88519A",
"font_size" : 24,
"corner_radius" : 6,
"background_color" : "RGBA(0.000000,1.000000,1.000000,1.000000)",
"frame" : "{{60, 224}, {200, 32}}",
"border_width" : 1,
"custom_attributes" : "",
"alignment" : "center",
"autocorrection_type" : "default",
"action" : "change_time2",
"text" : "30",
"placeholder" : "",
"font_name" : "<System>",
"spellchecking_type" : "default",
"class" : "TextField",
"name" : "textfield2",
"flex" : "LRTB"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{33, 442}, {264, 32}}",
"class" : "Label",
"attributes" : {
"uuid" : "B30DCCE7-8F66-407F-B51C-51F126C6F4D4",
"font_size" : 14,
"corner_radius" : 29,
"background_color" : "RGBA(1.000000,1.000000,0.617647,1.000000)",
"frame" : "{{85, 224}, {150, 32}}",
"number_of_lines" : 0,
"border_width" : 0,
"alignment" : "center",
"text" : "©️ SRHC Entertainment",
"font_name" : "TimesNewRomanPS-BoldItalicMT",
"class" : "Label",
"name" : "label3",
"flex" : "LRTB"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{33, 52}, {264, 80}}",
"class" : "Label",
"attributes" : {
"font_size" : 72,
"custom_attributes" : "",
"frame" : "{{85, 224}, {150, 32}}",
"uuid" : "A5AE98B5-EEBE-4E4E-AA74-8FAE73A09EE8",
"background_color" : "RGBA(0.000000,1.000000,1.000000,1.000000)",
"class" : "Label",
"alignment" : "center",
"text" : "120",
"name" : "label4",
"font_name" : "<System>"
},
"selected" : false
},
{
"nodes" : [
],
"frame" : "{{33, 193}, {264, 80}}",
"class" : "Label",
"attributes" : {
"name" : "label5",
"frame" : "{{85, 224}, {150, 32}}",
"uuid" : "A94E176D-1571-47DF-B6E3-41BCA4B998B7",
"class" : "Label",
"alignment" : "center",
"text" : "30",
"background_color" : "RGBA(0.000000,1.000000,1.000000,1.000000)",
"font_size" : 72,
"font_name" : "<System>"
},
"selected" : false
}
],
"frame" : "{{0, 0}, {320, 480}}",
"class" : "View",
"attributes" : {
"flex" : "",
"custom_class" : "",
"tint_color" : "RGBA(0.000000,0.478000,1.000000,1.000000)",
"enabled" : true,
"border_color" : "RGBA(0.000000,0.000000,0.000000,1.000000)",
"background_color" : "RGBA(1.000000,1.000000,1.000000,1.000000)",
"name" : "The official CQL Timer"
},
"selected" : false
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.