• Kipekeedev

    @Phuket2

    If I remove the decorator

    @ui.in_background
    

    I get an error:

    TypeError: Cannot show camera from main UI thread
    
    

    posted in Pythonista read more
  • Kipekeedev

    I know this is out of topic but I'm having trouble running this code. It freezes my app:

    @ui.in_background
        def scan_document(self, sender):
            
            img = photos.capture_image()
            console.show_activity()
            if not img:
                return
            with io.BytesIO() as bIO:
                img.save(bIO, 'PNG')
                imgOut = ui.Image.from_data
    

    I don't know if you guys know a lot about the photos module but I can't find any good documentation.

    @ccc do you have a github post on it?

    posted in Pythonista read more
  • Kipekeedev

    Solved it!

    the_action = getattr(self, name + '_action')
    button.action = the_action
    

    posted in Pythonista read more
  • Kipekeedev

    @techteej

    Would this work?

    def scan_view_action(self,sender):
        pass
    
    def make_button(self,name):
        the_action = name + '_action'
        button.action = the_action
    

    Or is there any convenient way to do this to keep it DRY?

    posted in Pythonista read more
  • Kipekeedev

    I'm having a problem concatenating a string to a variable to create a method in my app. It goes something like this:

    # coding: utf-8
    
    import ui
    
    w,h = ui.get_screen_size()
    buttons = ''' Scan_View Show_View '''.split()
    
    class OCRApp(ui.View):
        def __init__(self):
            x,y,w,h = self.bounds
            self.background_color = 'orange'
            self.present()
            for i, button in enumerate(buttons):
                button = str(button).lower()
                self.add_subview(self.make_button(button,i))
            
        def scan_view_action(self, sender):
            scanview = ui.load_view('scanview.pyui')
            scanview.background_color = 'red'
            scanview.present()
            
        def show_view_action(self,sender):
            pass 
        
        def make_button(self,name, i):
            button = ui.Button(title=name)
            **the_action = name
            button.action = the_action()**
            button.center =w/2, (i*60)+(button.height*2)
            self.add_subview(button)
            return button
    
    OCRApp()
        
    

    When I create a string on the variable 'the_action' and call it on 'button.action' I get an error ' TypeError: "str" object is not callable'.

    How do I go about doing this correctly?

    posted in Pythonista read more
  • Kipekeedev

    @JonB

    Great the first option seems pretty easy. I don't know if I can get all the testing done in only 200 request. But the second option seems pretty convenient also. Thanks for the help!

    posted in Pythonista read more
  • Kipekeedev

    Hello. I want to work on something different but I don't know if pythonista supports it so please help. Here it is.
    I want to create a program that takes an image (eg. taking a photo of an image with a large amount of text), reads the text and converts it to a manipulatable string. Does pythonista have this capability? If so, where do I start. Which modules should I import (pythonista or an external module)? I have a pretty good idea but if it's not possible I'll move to something else.

    Thanks

    posted in Pythonista read more
  • Kipekeedev

    @omz

    So simple. But worked perfectly. Thanks

    posted in Pythonista read more
  • Kipekeedev

    @Webmaster4o

    Yes and it gives me and error that the value needs to be a ui.Image

    
    # example url
    url = 'http://is4.mzstatic.com/image/thumb/Music7/v4/53/fc/a2/53fca253-84b1-f2cd-4e17-98be502ec53c/UMG_cvrart_00602547534873_01_RGB72_1500x1500_15UMGIM41882.jpg/55x55bb-85.jpg'
    
    i = urlopen(url)
    b= BytesIO(i.read())
    img = Image.open(b)
    btn = ui.Button()
    btn.image  = img         #<<< TypeError: Expected a ui.Image
    

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!