• Brando

    Oops I forgot to explain. I want to have a 64 by 32 pixel image that can either be black or white that can be changed by editing the array's values.

    posted in Pythonista read more
  • Brando

    screen = np.array((0,0)*32*64)*2
    b = np.array(screen, dtype=np.uint8)*255
    print(b)
    img = Image.fromarray(b, 'L')
    img.show()
    

    posted in Pythonista read more
  • Brando

    Thank you both so much, I'm not really understanding fromarray(), does it only accept nested narray's and tuples? I keep getting a tuple index out of range.

    posted in Pythonista read more
  • Brando

    Hello, I'm relatively new to python and I'm trying to figure out how I make my array, full of 1's or 0's, display a black or white pixel graphically. I'm making a chip8 emulator and have searched the forums a little but it doesn't look like my question has come up.

    posted in Pythonista read more
  • Brando

    I get the same error while loading my widget (sometimes). It has to do with the amount of memory allocated, you can try and remove some of the other widgets in your notification bar but I have noticed only a very slight difference.

    posted in Pythonista read more
  • Brando

    Sorry but this is a fantastic app and the $10 goes to providing the developer with money so he can support himself.

    posted in Pythonista read more
  • Brando

    Is there any way to execute code within a program from a URL? I want to put some code on a google sites then execute that code but is there a command to execute a string?

    posted in Pythonista read more
  • Brando

    Yes after creating a label there are many different attributes for it. The help menu was vital for my learning of the ui module. You can use: (labelname).text to set the text of the label and (labelname).name for the name of the label, I'm pretty sure this is read only but it's helpful with button to determine which one is being pressed. Most other helpful parameters can be set within the definition of the label. The ui editor is easier to use, and look at the built-in examples, they are helpful.

    posted in Pythonista read more
  • Brando

    Not sure why the one comment is huge but that is the code, I know it is not efficient and I haven't cleaned anything up yet. Thank you for the help.

    posted in Pythonista read more
  • Brando

    Ok thanks, I'll share the code, I realized memory could be an issue. Just to let you know I took out the URLs because it has personal data on it.

    import urllib.request,ui,appex
    l=0
    from objc_util import *
    UIDevice = ObjCClass('UIDevice')
    device = UIDevice.currentDevice()
    device.setBatteryMonitoringEnabled_(True)
    battery_percent = device.batteryLevel() * 100
    off=True
    hum=0
    tem=0
    #Do not worry about this, this changes my lights but will disable if I'm not at home
    def button_tapped(sender):
        global l
        if sender.name =='+':
            l+=10
        if sender.name =='-':
            l+=-10
        with urllib.request.urlopen(' ' + str(l) ) as response:
            if l>100:
                l=100
            if l<0:
                l=0
            print(str(l))
    
    # Checks if I'm at home, still doesn't work if I take this out
    req = urllib.request.Request(' ')
    try: urllib.request.urlopen(req)
    except urllib.error.URLError :
        tem = '  -- ' 
    
    with urllib.request.urlopen(' ') as response:
        html = response.read()
        info = html
    
    
    
    def main():
        label = ui.View(frame=(0, 0, 320, 64))
        # TEMPERATURE
        t = ui.Label(frame=(1, 0, 100, 0), flex='wh',text_color='white', font=('HelveticaNeue-Light', 15), alignment=ui.ALIGN_LEFT, text = 'Temperature:' + str(info)[3:7] + '°')
        label.add_subview(t)
        # HUMIDITY
        h = ui.Label(frame=(1,0,150,32),flex='wh', text_color='white',font=('HelveticaNeue-Light',15), alignment=ui.ALIGN_LEFT, text = 'Humidity:'+str(info)[11:13] + '%')
        label.add_subview(h)
        
        # LIVING ROOM LIGHTS
        living_title = ui.Label(frame=(320-135,0,130,-20),flex='wh',text_color='white', font=('Monla',15), alignment=ui.ALIGN_RIGHT, text = 'Living Room Lights')
        
        # GREETING (WIP)
        greet='hi'
    
    
        # LIVING ROOM BUTTONS
        plus_btn = ui.Button(name='+', image=ui.Image('iow:ios7_plus_outline_32'), flex='hl', tint_color='#666', action=button_tapped)
        plus_btn.frame = (320-64, 0, 64, 64)
        
        minus_btn = ui.Button(name='-',         image=ui.Image('iow:ios7_minus_outline_32'), flex='hl', tint_color='#666', action=button_tapped)
        minus_btn.frame = (320-64 ,0, -64,64)
        if tem!='  -- ':
            label.add_subview(minus_btn)
            label.add_subview(plus_btn)
            label.add_subview(living_title)
        else:
            # GREETING
            greeting = ui.Label(frame=(320-135,0,130,-20),flex='wh',text_color='white', font=('Monla',15), alignment=ui.ALIGN_RIGHT, text = greet)
            #label.add_subview(greeting)
        
        # BATTERY
        if battery_percent>=85:
            img='iow:battery_full_24'
        if battery_percent<85 and battery_percent>=50:
            img='iow:battery_half_24'
        if battery_percent<50 and battery_percent>=30:
            img='iow:battery_low_24'
        elif battery_percent<30:
            img='iow:battery_empty_24'
        bat = ui.Button(name='batteryl', image=ui.Image(img),flex='hl',tint_color='#00d500',action=button_tapped)
        bat.frame = (320-30,64,32,32)
        label.add_subview(bat)
        
        
        # BACKGROUND COLOR
        label.background_color = '#1a1a1a'
        
        # SETS WIDGET
        appex.set_widget_view(label)
    
    if __name__ == '__main__':
        main()
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!