• robertiii

    I think I’m starting to follow. Sorry I do enough programming to understand little. HAHA

    posted in Pythonista read more
  • robertiii

    So I think I should somehow be able to use Transform..... but.... It only scales the view inside the Popup not the bounds of the the Popup itself.

    posted in Pythonista read more
  • robertiii

    def menuButton(sender):
        pv = ui.load_view('menuPopOver')
        pv.name = 'Menu'
        pv.frame = (0,0,400,149)
    #   x = sender.x + sender.width/2
    #   y = sender.superview.titlebar_height + sender.y + sender.height/2
        pv.present('popover',popover_location = (44.5,50))  
    

    posted in Pythonista read more
  • robertiii

    So I have it presented with an arrow pointing to a menu bar buttonitem.

    posted in Pythonista read more
  • robertiii

    I am presenting a view as a popover. I want to resize the popover and add a tableview. The problem is not adding a tableview but how to go about resizing a view that is already being presented? Any work around or ideas. I would include code but I really haven’t got any! Hee Hee

    posted in Pythonista read more
  • robertiii

    I found this code somewhere on the internet heehee.

    def menuButton(sender):
        pv = ui.View()
        pv.name = 'popover'
        pv.frame = (0,0,200,200)
        x = sender.x + sender.width/2
        y = sender.superview.titlebar_height + sender.y + sender.height/2
        pv.present('popover',popover_location = (x,y))  
    

    However this doesn’t work with navbar buttons as they don’t have the location information. How can I get the location info?

    posted in Pythonista read more
  • robertiii

    Or make detail cell multiple lines of text?

    posted in Pythonista read more
  • robertiii

    How do I move the text label to x=0 y=0 of the cell?

    posted in Pythonista read more
  • robertiii

    How can I get a multi line label?

    posted in Pythonista read more
  • robertiii

    Mikael you’re a genius!

    posted in Pythonista read more
  • robertiii

    I cannot get the second table to reload with data from the first tableview on did select.

    
    import ui
    import json
    import time
            
    songList = []
    
    libraryData = []
    serviceData = []
    previewData = []
    liveData = []
    
    def getJsonSongs():
        with open('songs.json') as in_file:
            new_dict = json.load(in_file)
        for song in new_dict:
            songList.append(song)
            
    def setLibrarySongs():
        for song in songList:
            libraryData.append(song)
    
    getJsonSongs()
    setLibrarySongs()
    
    class libraryTable(object): #also acts as the data_source.  Can be separate, but this is easier.  
        def __init__(self,items):   
            self.items = items
            self.currentNumLines = len(items)
            self.currentTitle = None
            self.currentRow = None
            
        def tableview_did_select(self, tableview, section, row):
            # Called when a row was selected.
            serviceData.append(self.items[row])
            servTable.reload()
            tableview.reload()
        def tableview_did_deselect(self, tableview, section, row):
            # Called when a row was de-selected (in multiple selection mode).
            pass
    
        def tableview_title_for_delete_button(self, tableview, section, row):
            # Return the title for the 'swipe-to-***' button.
            return 'Delete' # or 'bye bye' or 'begone!!!'
            
        def tableview_number_of_sections(self, tableview):
            # Return the number of sections (defaults to 1). Someone else can mess with 
            # sections and section logic
            return 1
    
        def tableview_number_of_rows(self, tableview, section):
            # Return the number of rows in the section
            return self.currentNumLines #needed to be in sync with displayed version, 
    
        def tableview_cell_for_row(self, tableview, section, row):
            # Create and return a cell for the given section/row
            cell = ui.TableViewCell()
            cell.text_label.text =  self.items[row]['title']
            # or you could comment out the line above and use
            #
            #if self.items[row]['accessory_type'] == 'checkmark':
            #   cell.text_label.font = ('<system-bold>',20)
            # or 
            # cell.text_label.text_color = '#FF0000'
            #
            # for emphasis instead 
            #  
            return cell
    
    
        def tableview_can_delete(self, tableview, section, row):
            # Return True if the user should be able to delete the given row.
            return True # you can use logic to lock out specific ("pinned" entries) 
    
        def tableview_can_move(self, tableview, section, row):
            # Return True if a reordering control should be shown for the given row (in editing mode).
            return True # see above
    
        def tableview_delete(self, tableview, section, row):
            # Called when the user confirms deletion of the given row.
            self.currentNumLines -=1 # see above regarding hte "syncing"
            tableview.delete_rows((row,)) # this animates the deletion  could also 'tableview.reload_data()'
            del self.items[row]
    
        def tableview_move_row(self, tableview, from_section, from_row, to_section, to_row):
            # Called when the user moves a row with the reordering control (in editing mode).
            
            self.items = listShuffle(self.items,from_row,to_row) 
            # cynchronizes what is displayed with the underlying list
            
            
    class serviceTable(object): #also acts as the data_source.  Can be separate, but this is easier.  
        def __init__(self,items):   
            self.items = items
            self.currentNumLines = len(items)
            self.currentTitle = None
            self.currentRow = None
            
        def tableview_did_select(self, tableview, section, row):
            # Called when a row was selected.
            selectedItem = self.items[row]['title']
            serviceData.append(listForTable([selectedItem]))
            servTable.reload()
            
        def tableview_did_deselect(self, tableview, section, row):
            # Called when a row was de-selected (in multiple selection mode).
            pass
    
        def tableview_title_for_delete_button(self, tableview, section, row):
            # Return the title for the 'swipe-to-***' button.
            return 'Delete' # or 'bye bye' or 'begone!!!'
            
        def tableview_number_of_sections(self, tableview):
            # Return the number of sections (defaults to 1). Someone else can mess with 
            # sections and section logic
            return 1
    
        def tableview_number_of_rows(self, tableview, section):
            # Return the number of rows in the section
            return self.currentNumLines #needed to be in sync with displayed version, 
    
        def tableview_cell_for_row(self, tableview, section, row):
            # Create and return a cell for the given section/row
            cell = ui.TableViewCell()
            cell.text_label.text =  self.items[row]['title']
            # or you could comment out the line above and use
            #
            #if self.items[row]['accessory_type'] == 'checkmark':
            #   cell.text_label.font = ('<system-bold>',20)
            # or 
            # cell.text_label.text_color = '#FF0000'
            #
            # for emphasis instead 
            #  
            return cell
    
    
        def tableview_can_delete(self, tableview, section, row):
            # Return True if the user should be able to delete the given row.
            return True # you can use logic to lock out specific ("pinned" entries) 
    
        def tableview_can_move(self, tableview, section, row):
            # Return True if a reordering control should be shown for the given row (in editing mode).
            return True # see above
    
        def tableview_delete(self, tableview, section, row):
            # Called when the user confirms deletion of the given row.
            self.currentNumLines -=1 # see above regarding hte "syncing"
            tableview.delete_rows((row,)) # this animates the deletion  could also 'tableview.reload_data()'
            del self.items[row]
    
        def tableview_move_row(self, tableview, from_section, from_row, to_section, to_row):
            # Called when the user moves a row with the reordering control (in editing mode).
            
            self.items = listShuffle(self.items,from_row,to_row) 
            # cynchronizes what is displayed with the underlying list
    
    
    
    
    
    libDel = libraryTable(libraryData)
    servDel = serviceTable(serviceData)
    
    control = ui.load_view()
    control.name = "Church Presentation App"
    
    libTable = control['libraryTable']
    servTable = control['serviceTable']
    
    libTable.delegate = libTable.data_source = libDel
    servTable.delegate = servTable.data_source = servDel
    
    nav = ui.NavigationView(control)
    nav.present('fullscreen',hide_title_bar=True)
    
    

    posted in Pythonista read more
  • robertiii

    Beta has expired....Any way of renewing?

    posted in Pythonista read more
  • robertiii

    I am curious why no log was left behind...I even added a startup script to log problems and it always left nothing.

    posted in Pythonista read more
  • robertiii

    I feel like an idiot. The variable set and setup was supposed to be one. It was running continually in the thread and causing a crash I assume because of taking too much space. Changed the variables to the same and no problem.

    posted in Pythonista read more
  • robertiii

    Weirdest part is the fact that there is no error log. It kills Pythonista with no log.

    posted in Pythonista read more
  • robertiii

    So pardon my ignorance. I have a script with us and it works great....until it crashes the entire app. Hahaha.

    from pyftpdlib.authorizers import DummyAuthorizer
    from pyftpdlib.handlers import FTPHandler
    from pyftpdlib.servers import FTPServer
    import threading
    import os
    import time
    import ui
    
    port = 2121
    
    def getLocalIP():
        import socket
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        try:
            s.connect(('google.com', 80))
            ip = s.getsockname()[0]
            s.close()
        except:
            ip = 'N/A'
        return ip
    
    def imageSetter(valid_extensions=('jpg','jpeg','png')):
        while True:
            currentImage = ''
            set = False
            dirpath = os.path.expanduser('~/Documents/tetherShootPhotos')
            try:
                valid_files = [os.path.join(dirpath, filename) for filename in os.listdir(dirpath)]
                valid_files = [f for f in valid_files if '.' in f and f.rsplit('.',1)[-1] in valid_extensions and os.path.isfile(f)]
    
                if not valid_files:
                    raise ValueError("No valid images in %s" % dirpath)
        
                imageLink = max(valid_files, key=os.path.getmtime)
                
                if imageLink != currentImage:
                    newImage = ui.Image.named(imageLink)
                    currentImage = imageLink
                    v['image'].image = newImage
                    v['ipAddress'].hidden = True
                    v['connectAt'].hidden = True
                    set = False
            except:
                if set == False:
                    set = True
                    newImage = ui.Image.named('tetherShoot.png')
                    v['image'].image = newImage
                    v['ipAddress'].hidden = False
                    v['connectAt'].hidden = False
                    ipAddr = getLocalIP()+':'+str(port)
                    v['ipAddress'].text = ipAddr
            time.sleep(1)
    
    def main():
        authorizer = DummyAuthorizer()
        authorizer.add_anonymous(os.path.expanduser('~/Documents/tetherShootPhotos'), perm='elradfmwM')
        handler = FTPHandler
        handler.authorizer = authorizer
        server = FTPServer(('0.0.0.0', port), handler)
        t = threading.Thread(target=server.serve_forever)
        t.start()
        try:
            setup = False
            while True: pass
        except KeyboardInterrupt:
            server.close_all()
    
    if __name__ == '__main__':
        import ui 
        v = ui.load_view()
        v['ipAddress'].hidden   = True
        v['connectAt'].hidden = True
        v['image'].content_mode = ui.CONTENT_SCALE_ASPECT_FIT
        imageUpdater = threading.Thread(target=imageSetter)
        imageUpdater.start()
        v.present('fullscreen',hide_title_bar=True)
        main()
    

    posted in Pythonista read more
  • robertiii

    Any idea on how to go to workflow and return a variable using the Xcode template? I am at a total loss.

    posted in Pythonista read more
  • robertiii

    I can get the ui to change for a device getting connected, but not when I turn the device off. How can I detect that the device has been turned off and is no longer connected to the iPad

    posted in Pythonista read more
  • robertiii

    Thank you!!!!!!!

    posted in Pythonista read more
  • robertiii

    Strangely enough it does work if called from a button action....

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!