• mcriley821

    @OkieWolf

    hypotenuse = float(v['hypotenuse'].text or 0)
        short = float(v['short'].text or 0)
        long = float(v['long'].text or 0)
        if len([x for x in (hypotenuse, short, long) if x]) != 2: ```
    

    v['short'].text or 0 will choose 0 if the text is "". You won’t hit an exception for a blank textfield. You will get an error if the text is alphabetical though.

    (hypotenuse,short,long) is a tuple and [x for x in (hypotenuse,short,long) if x] is a list comprehension that steps through the tuple
    and makes a list of the values that exist. Then if the length of that list isn’t 2, then you don’t have a correct input

    posted in Pythonista read more
  • mcriley821

    @OkieWolf

    Scratch that, sorry. I was thinking of a label. A textField doesn’t really have a background. It’s background is behind the white layer. What you could do instead is make a red border.

    If you really want the whole thing red, I can write a small bit of code with objc_util

    posted in Pythonista read more
  • mcriley821

    @OkieWolf then it’s not making it to the else statement. What are you inputting to the textfields? Maybe one of them is white space?

    posted in Pythonista read more
  • mcriley821

    @OkieWolf
    To specify hex you have to have a # in front

    red = '#ff0000'
    

    The current hex value you have is mostly white. It’s also too long. 'red' should work too

    posted in Pythonista read more
  • mcriley821

    @OkieWolf this will throw an exception if the string can’t convert to a float. If you suspect that won’t happen, your code is fine. Otherwise my previous code would be more robust

    posted in Pythonista read more
  • mcriley821

    @OkieWolf

    def button3_tapped(sender):
        if v['textfield3'].text and v['textfield4'].text:
            try:
                    sidea = float(v['textfield3'].text)
                    sideb = float(v['textfield4'].text)
            except ValueError:
                    v['textfield5'].text = 'ENTER ALL REQUIRED FIELDS CORRECTLY'
            else:
                    sidec = sidea + sideb
                    v['textfield5'].text = f'sidec = {sidec}'
    

    posted in Pythonista read more
  • mcriley821

    Have you tried connecting through file explorer first? Doing so first may simplify access down to a file path similar to what you’ve tried

    https://appletoolbox.com/use-smb-to-connect-to-your-nas-drive-with-files-in-ipados-or-ios-13/

    posted in Pythonista read more
  • mcriley821

    @Bumbo-Cactoni well which is it, the textField or the console? 😂

    When I say console I mean when you swipe left and go to the screen that has the word “Console” at the top. The input is what you’d usually type on this screen.

    There’s ways to make your own buttons/toolbars and ui stuff on the actual Pythonista app itself, and not on a view you present. I was just trying to clarify.

    I’m glad @mikael answered your question the way you needed though! 😎

    posted in Pythonista read more
  • mcriley821

    What do you mean by input bar? Like the Pythonista console?

    posted in Pythonista read more
  • mcriley821

    @OkieWolf
    try to format your code with the </> button, but from what I can tell, it looks like you’re missing a colon ':' after the conditions of the if statement

    Like so

    if sidea and sideb:#colon right here
        #do stuff
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!