omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular
    1. Home
    2. Kipekeedev

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    • Profile
    • Following 1
    • Followers 0
    • Topics 4
    • Posts 18
    • Best 0
    • Controversial 0
    • Groups 0

    Thomas Roberts

    @Kipekeedev

    0
    Reputation
    941
    Profile views
    18
    Posts
    0
    Followers
    1
    Following
    Joined Last Online
    Location Crestline Age 29

    Kipekeedev Unfollow Follow

    Latest posts made by Kipekeedev

    • RE: Python string object as callable method

      @Phuket2

      If I remove the decorator

      @ui.in_background
      

      I get an error:

      TypeError: Cannot show camera from main UI thread
      
      
      posted in Pythonista
      Kipekeedev
      Kipekeedev
    • RE: Python string object as callable method

      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
      Kipekeedev
      Kipekeedev
    • RE: Python string object as callable method

      Thanks @ccc

      posted in Pythonista
      Kipekeedev
      Kipekeedev
    • RE: Python string object as callable method

      Solved it!

      the_action = getattr(self, name + '_action')
      button.action = the_action
      
      posted in Pythonista
      Kipekeedev
      Kipekeedev
    • RE: Python string object as callable method

      @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
      Kipekeedev
      Kipekeedev
    • Python string object as callable method

      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
      Kipekeedev
      Kipekeedev
    • RE: Is pythonista capable of this?

      @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
      Kipekeedev
      Kipekeedev
    • Is pythonista capable of this?

      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
      Kipekeedev
      Kipekeedev
    • RE: Button image from URL

      @omz

      So simple. But worked perfectly. Thanks

      posted in Pythonista
      Kipekeedev
      Kipekeedev
    • RE: Button image from URL

      @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
      Kipekeedev
      Kipekeedev