• Vertec

    Unfortunately for me I'm a little green for yours answers. Been coding for a total of 8 weeks and only in 1hr byte sessions.

    At this point I'm only using the custom gui module and adding references to drag and dropped elements.

    As a beginner I find this manageable and am slowly learning the code as I wrote and rewrite little apps borrowing sections of code from here and the examples.

    I can easily make a digital clock. Or customise the analogue clock. What I can't do is make two and count them backwards.

    Ideally I'd like to reference ui.labels in the module for clock displays simply because it's at "my level" of understanding.

    Thanks again all

    posted in Pythonista read more
  • Vertec

    #using ui module
    import ui
    from time import time,sleep,strftime,localtime,gmtime

    #t = time()

    def reset_action(sender):
    v = sender.superview
    '@type sender: ui.Button'
    global t
    t = time()
    start_time = 0.0
    stop_time = 0.0

    @ui.in_background
    def update_time():
    while True:
    sleep(1)
    v['countdown_timer'].text = strftime('%M:%S', gmtime(time()-t))
    start_time = 0.0
    stop_time = 0.0

    #ts = time()

    def reset_action2(sender):
    v = sender.superview
    '@type sender: ui.Button'
    global ts
    ts = time()
    start_time = 0.0
    stop_time = 0.0

    @ui.in_background
    def update_time2():
    while True:
    #sleep(1)
    v['countdown_timer2'].text = strftime('%M%S', gmtime(time()-ts))
    start_time = 0.0
    stop_time = 0.0

    v = ui.load_view('Chessclock')
    reset_action(v['reset_button'])
    reset_action2(v['reset_button2'])
    update_time()
    update_time2()

    v.present(orientations=['portrait'])

    posted in Pythonista read more
  • Vertec

    I'm trying to develop a simple chess clock - first I'm just having trouble running two instances of time - then I need to figure out how to rotate a label and have them count backwards still a total beginner

    posted in Pythonista read more
  • Vertec

    Hi guys

    I'm very new to this so please forgive.

    Can someone tell me please assist me.

    I need to save switch positions and label texts to json. In a UI designed in pythonista ui-builder (not code built)

    Also need to update a label text based on a incremental switch created from a segment control. Ie -/+ updates label text.
    Label text becoming a value to feed another label.

    posted in Pythonista read more
  • Vertec

    Off Topic : my two cents and Freudian babble

    Sharing information is everything.

    I work in the events industry. Over 20 years as a vision tech, live audio engineer and more recently TD and production manager.

    For at least 15 of those years I've fought against the tendency of some professionals to want to hoard knowledge and not impart skills.

    All this achieves is bad practice across all sectors (hobby programming included) and eventually when one needs assistance one can't find skilled help as you get peers that don't have the skills to be supportive.

    Any argument that imparting knowledge disadvantages the teacher is based on nothing more than fear.

    I order to stay at the top of our game we must research and improve eternally. If we all strive to build on our skill-sets then naturally we will always be ahead of those newer to the game and behind those with more years of service than us. This is how it's meant to be.

    I shouldn't complain. Three months ago after a life changing event (ruptured aneurysm) I left the events production industry for a permanent job at a University working as a trainer. Now I get to choose how knowledge is imparted every day.

    I've got time to breathe and time to learn all those things I'd been putting off. Like Python...

    posted in Pythonista read more
  • Vertec

    Hi guys

    I can't find if I can send an image here so I'll try to describe ui in text

    Text.field (displays slider value)

    Slider (updates textfield taking multiplier value from which of three switches is active)

    Switch 1(makes text field display slider in metres)
    Switch 2(displays in feet)
    Switch 3(displays in milliseconds/ speed of sound)

    Label(displays value of active switch and changes text colour to match switch Color)

    posted in Pythonista read more
  • Vertec

    # coding: utf-8
    import ui
    import clipboard
    import decimal
    from random import random
    from console import hud_alert
    
    def switch_action1(sender):
        '@type sender: ui.Switch'
        v = sender.superview
        sw1 = v['switch1'].value 
        sw2 = v['switch2']
        sw3 = v['switch3']
        if (sw1):
            value = 1
            sw2.value = False
            sw3.value = False
            
    def switch_action2(sender):
        '@type sender: ui.Switch'
        v = sender.superview
        sw1 = v['switch1']
        sw2 = v['switch2'].value
        sw3 = v['switch3']
        if (sw2):
            value = 1
            sw1.value = False
            sw3.value = False
            
    def switch_action3(sender):
        '@type sender: ui.Switch'
        v = sender.superview
        sw1 = v['switch1']
        sw2 = v['switch2']
        sw3 = v['switch3'].value
        if (sw3):
            value = 1
            sw1.value = False
            sw2.value = False
    
    def slider_action(sender):
        v = sender.superview
        numbers = v['slider1'].value
        v['numberval'].text = '%.fm' % (numbers*100.00)
        v['mval'].text = '%.2fm' % (numbers*100.00)
        v['msval'].text = '%.3fms' % (numbers*2.92*100)
        v['ftval'].text = '%.2fft' % (numbers*3.37*100)
        sw1 = v['switch1'].value
        sw2 = v['switch2'].value
        sw3 = v['switch3'].value
        metres = v['mval'].text
        msecs = v['msval'].text
        feet = v['ftval'].text
        if sw1:
            value = 1
            v['mfield'].text = metres
            v['numberval'].text = metres
            v['numberval'].text_color = 'd25050'
            v['slider1'].tint_color = 'd25050'
        if sw2:
            value = 1
            v['mfield'].text = msecs
            v['numberval'].text = msecs
            v['numberval'].text_color = '6bc68b'
            v['slider1'].tint_color = '6bc68b'
        if sw3:
            value = 1
            v['mfield'].text = feet
            v['numberval'].text = feet
            v['numberval'].text_color = '6a93fb'
            v['slider1'].tint_color = '6a93fb'
            
    v = ui.load_view('VertecAxUi')
    slider_action(v['slider1'])
    switch_action1(v['switch1'])
    switch_action2(v['switch2'])
    switch_action3(v['switch3'])
    
    if ui.get_screen_size()[1] >= 768:
        v.present('popover')
    else:
        v.present()
    

    posted in Pythonista read more
  • Vertec

    Hi guys thank you for you help. May have gone over my head- my explanation is also lacking. Forgive me - I'm very new to this:
    There are two things I'd like to happen in this script.

    1. When I flick either of the three switches I would like the textfield at top left to update to metres, feet or milliseconds (/speed of sound) - at present I have to flick switch and move slider prior to field updating.

    2. I would like to have the slider position update based on text input (numeric only) and relative to which switch is active.

    Next two forum posts are my code and ui

    posted in Pythonista read more
  • Vertec

    Is it possible to make a numeric entry field drive a slider position?

    I have made a converter that converts feet to metres and also milliseconds (speed of sound) to calculate PA system delay times between speaker arrays. It currently works but I would love to add numeric entry to the slider.

    Also at this time you move the slider and can activate feet/metres/milliseconds by turning on switches. How would I make it so the label that displays the output will update with a flock of a switch. (Ie change metres to feet) at present it doesn't update until you put your finger back on the slider

    posted in Pythonista read more
  • Vertec

    I'm still having trouble with this. I just want to use an image already sitting in the images folder in pythonista.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!