• sendog3c

    Hello here:

    My code is presenting a syntax error. I have done all in possibilities to fix it but have been impossible to find what is happening.

    I appreciate your help.

    Regards

    import ui
    
    #w, h = ui.get_screen_size()
    bw = 0
    bh = 0
    color1 = ''
    equis = 60
    yee = 140
    ancho = 100
    alto = 100
    posicion = equis, yee, ancho, alto
    bg_color1 = '#656ba9'
    
    def button_tapped(sender):
        label.bg_color = sender.bg_color
        label.text = sender.title
        label.text_color = sender.tint_color
        
    
    def make_button(color1, title, posicion):
        button = ui.Button(
            action=button_tapped,
            alignment=ui.ALIGN_CENTER,
            #bg_color=title.lower(),
            background_color = bg_color1,
            border_color='black',
            border_width=1,
            frame=(posicion),
            tint_color='white',
            title=title,
            corner_radius = 5)
            
        # it seems to be necessary to reset the frame
        #button.frame = (screen_x, h - 600, bw, bh)
        return button
    
    
    label = ui.Label(
        alignment=ui.ALIGN_CENTER,
        bg_color='silver',
        background_color='black',
        border_width=1,
        frame=(10, 50, 180, 60),
        name='Label')
    
    button1 = make_button(title ='SUM', background_color='#a93d17', frame=(posicion))
    button2 = make_button(title='SUBS', background_color='#7ca917', frame=(posicion))
    button3 = make_button(title = 'MULT', background_color='#1770a9', frame=(posicion))
    button4 = make_button(title = 'DIV', background_color='#7c17a9', frame=(posicion)
    
    view = ui.View(name='MATHGICIAN', background_color='#7f7f7f', frame=(10,10,400,700))
    view.add_subview(label)
    view.add_subview(button1)
    view.add_subview(button2)
    view.add_subview(button3)
    view.add_subview(button4)
    view.present('screen')```

    posted in Pythonista read more
  • sendog3c

    What I want to know what button was tapped in order to use the correct Math operation (+ - * /) function o whatever that I coding

    posted in Pythonista read more
  • sendog3c

    Thank both. Ben to help understand better the logic and ccc to become pro my code.

    posted in Pythonista read more
  • sendog3c

    I would like to get the button title of my script to decide with math operation do. But I have problem with parameter, data gotten from sender (str, int).

    I check an answer given to newbie (I did not remember exactly the user) an adapt it, but is not working properly. Here is the code.

    Is a simply math app for my kids. In developing of course.

    Thanks

    import ui
    #import console
    
    texto1 = ''
    
    mains=ui.View(frame=(10,10,10,10), background_color='#008000', name='Math for Fun')
    
    mains.present('view')
    
    controls1=ui.View(frame=(0,0,410,200), background_color='#e6ec5f', name='controls1')
    
    def button_tapped(sender):
        #if  button_tapped == b_top1.title('SUM'):
        #itexto1 = 'Hello World'
        texto1 = sender.title
        #else:
        #texto1 = str(300)  
        return texto1
    
    b_top1 = ui.Button()
    b_top1.frame = (20,80,80,50)
    b_top1.title = 'SUM'
    b_top1.font = ('<System-Bold>', 20)
    b_top1.background_color = ('#07b2cc')
    b_top1.border_width = 2
    b_top1.corner_radius = 5
    b_top1.action = button_tapped
    
    b_top2 = ui.Button()
    b_top2.frame = (115,80,80,50)
    b_top2.title = 'SUBS'
    b_top2.font = ('<System-Bold>', 20)
    b_top2.background_color = '#ff8909'
    b_top2.border_width = 2
    b_top2.corner_radius = 5
    b_top1.action = button_tapped
    
    b_top3 = ui.Button()
    b_top3.frame = (215,80,80,50)
    b_top3.title = 'MULT'
    b_top3.font = ('<System-Bold>', 20)
    b_top3.background_color = '#07de1a'
    b_top3.border_width = 2
    b_top3.corner_radius = 5
    b_top1.action = button_tapped
    
    b_top4 = ui.Button()
    b_top4.frame = (310,80,80,50)
    b_top4.title = 'DIV'
    b_top4.font = ('<System-Bold>', 20)
    b_top4.background_color = '#ffd12b'
    b_top4.border_width = 2
    b_top4.corner_radius = 5
    b_top1.action = button_tapped
    
    lb1 = ui.Label(name = 'Label1', bg_color = 'yellow', frame =(80,20,250,50))
    lb1.border_color = 'black'
    lb1.border_width = 1
    lb1.flex = 'RB'
    lb1.alignment=1
    lb1.text = 'VAMOS A JUGAR MATEMATICAS'
    
    txt_field1 = ui.TextField()
    txt_field1.frame = (150,145,100,50)
    txt_field1.border = (50,20,50,50)
    txt_field1.bg_color = (.9, .98, 1.0)
    txt_field1.text = button_tapped()
    
    
    mains.add_subview(controls1)
    controls1.add_subview(b_top1)
    controls1.add_subview(b_top2)
    controls1.add_subview(b_top3)
    controls1.add_subview(b_top4)
    controls1.add_subview(lb1)
    controls1.add_subview(txt_field1)
    

    posted in Pythonista read more
  • sendog3c

    Thank you Maikel let me to digest it 🤭🤭🤭😂😂😂😂😂, before implement

    posted in Pythonista read more
  • sendog3c

    I want to disable a sub view, if I do that automatically all the buttons, textfield will be disable too.

    Thanks.

    posted in Pythonista read more
  • sendog3c

    It works. Thank you very much

    posted in Pythonista read more
  • sendog3c

    Hi forum:

    I need help to understand what is happening that the function does not give a good result.
    Thanks.

    import ui
    
    suma = 0
    suma1 = 0
    
    class Arithmetic():
        pass
    
    a = input("Vamos a Sumar. :")
    type(suma)
    
    def math_ope(a):
        return 2*a
        
        
    resultado = math_ope(a)
    print(resultado)
    a = 0
    
    

    posted in Pythonista read more
  • sendog3c

    Thank you Brumm. I a going to check it.

    posted in Pythonista read more
  • sendog3c

    Thanks again

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!