Python ui.in_background() Examples

The following are 3 code examples of ui.in_background(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module ui , or try the search function .
Example #1
Source File: easy_config.py    From stash with MIT License 5 votes vote down vote up
def show(self):
        """shows the view and starts a thread."""
        self.present(orientations=ORIENTATIONS)
        # launch a background thread
        # we can not use ui.in_background here
        # because some dialogs would not open anymoe
        thr = threading.Thread(target=self.show_messages)
        thr.daemon = True
        thr.start() 
Example #2
Source File: SPLView11.py    From pythonista-scripts with MIT License 5 votes vote down vote up
def printLog():
   ### Pull the contents back into a string and close the stream
   global log_capture_string
   log_contents = log_capture_string.getvalue()
   log_capture_string.close()
   log_capture_string = StringIO()
   logger.handlers[0].stream=log_capture_string
   print(log_contents.lower())


## run a runction in an async thread.  better than ui.in_background for this application, because it is not queued up 
Example #3
Source File: uidir.py    From pythonista-scripts with MIT License 5 votes vote down vote up
def getFile(setter=None,base_dir='.'):
    fv = FileViewer(setter,base_dir)
    fv.height=700
    nv = ui.NavigationView(fv)
    
    def openDocuments(sender,path):
       def setme(fv,value):
       # set and bubble up setters
           fv.src.sel[0]=value
           if fv.src.setter is not None:
              fv.src.setter(value)
       newfv = FileViewer(setter=lambda value:setme(fv,value),base_dir=path)
       nv.push_view(newfv)
       
       
    nv.right_button_items=[
        ui.ButtonItem(title='Documents',
         action=lambda sender:openDocuments(sender,os.path.expanduser('~/Documents'))), 
        ui.ButtonItem(title='Library',
         action=lambda sender:openDocuments(sender,os.path.split(os.__file__)[0]))]
    nv.height=800
    nv.width=500
    nv.name = 'File Selector'
    nv.present('popover')
    ui.in_background(nv.wait_modal)
    nv.wait_modal()
    return fv.src.sel[0]