• smath

    Are you wanting to add a watermark to an existing PDF, or make a new PDF with a watermark? If you're making a new document you might want to check out reportlab.

    posted in Pythonista read more
  • smath

    @JonB Just have to know where to look. II guess I haven't poked around the new version yet.

    @ccc Good point. Fixed.

    posted in Pythonista read more
  • smath

    @JonB, Thanks for the help. I admit I still don't totally understand how this is works. I haven't been able to find the source code for the ui module. Below is my working code. As with most of my code, I'm sure there's many ways to improve it. I had to change to using an OrderedDict so the order of elements would be preserved.

    import ui
    from collections import OrderedDict
    
    class MyTableViewDataSource (object):
        def tableview_number_of_sections(self,tableview):
            return len(self.data.keys())
            
        def tableview_title_for_header(self,tableview,section):
            return self.data.keys()[section]
            
        def tableview_number_of_rows(self,tableview,section):
            key = self.data.keys()[section]
            return len(self.data[key])
           
        def tableview_cell_for_row(self, tableview, section, row):
            # Create and return a cell for the given section/row
            key = self.data.keys()[section]
            cell = ui.TableViewCell()
            cell.text_label.text = self.data[key][row]
            return cell
            
        def fill_data(self, tableview, data):
            self.data = data
            
    multi_section = ui.TableView()
    multi_section.width = 400
    multi_section.height = 400
    
    table = OrderedDict([('Header1', ['element1', 'element2', 'element3']),
                         ('Header2', ['element3', 'element4', 'element5']),
                         ('Header3', ['element6', 'element7', 'element8']),
                         ('Header4', ['element9', 'element10'])])
    
    data = MyTableViewDataSource()
    
    multi_section.data_source = data
    data.fill_data(multi_section, table)
    
    multi_section.present('sheet')
    

    posted in Pythonista read more
  • smath

    With the unfortunate demise of computable, an iPython notebook with pandas would be awesome.

    posted in Pythonista read more
  • smath

    I'm working on this right now. My understanding is that the trick is making the right data source class as ListDataSource isn't made for multi section data. There is an example in the docs for this that I'm trying to work with, but for some reason my code is not working. I've been able to make a hard coded list that has multiple sections, but I'm trying to make a class to which I can feed a dictionary of the type shown in the code below and have it populate a tableview. Any ideas?

    # coding: utf-8
    
    import ui
    
    class MyTableViewDataSource (object):
        def tableview_number_of_sections(self, tableview):
            # Return the number of sections (defaults to 1)
            return 0
    
        def tableview_number_of_rows(self, tableview, section):
            # Return the number of rows in the section
            #print section
            return 0
    
        def tableview_cell_for_row(self, tableview, section, row):
            # Create and return a cell for the given section/row
            cell = ui.TableViewCell()
            print 'cell name: ', row
            cell.text_label.text = row
            return cell
    
        def tableview_title_for_header(self, tableview, section):
            # Return a title for the given section.
            # If this is not implemented, no section headers will be shown.
            print 'section: ', section
            return section
    
        def tableview_can_delete(self, tableview, section, row):
            # Return True if the user should be able to delete the given row.
            return False
    
        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 False
            
        def fill_data(self, tableview, data):
            for section in data:
                self.tableview_title_for_header(tableview, section)
                for row in data[section]:
                    self.tableview_cell_for_row(tableview, section, row)
    
    
    multi_section = ui.TableView()
    multi_section.width = 400
    multi_section.height = 400
    
    list = {'Header1': ['element1', 'element2', 'element3'], 'Header2': ['element3', 'element4', 'element5'], 'Header3': ['element6', 'element7', 'element8'], 'Header4': ['element9', 'element10']}
    
    data = MyTableViewDataSource()
    
    multi_section.data_source = data
    data.fill_data(multi_section, list)
    
    multi_section.present('sheet')
    

    posted in Pythonista read more
  • smath

    Seems like submitting smaller reviews would be a faster way to find out what makes it past review. Then again, if a feature that Apple might not like got buried among a huge amount of other changes... I guess I can see an argument for larger releases. ;-)

    posted in Pythonista read more
  • smath

    I'd be all about smaller realeses more often. I've been waiting for a long time for some of the features I've seen talked about on the forum. I've put myself on the list for the beta multiple times, but to no avail.

    posted in Pythonista read more
  • smath

    I assume this would also affect 1.5 users?

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!