• text recognition is a bugabear without access to libraries such as tesseract-ocr. if younare willing to let google do the work for you, iirc there is an api for google photos whch will give you ocr

  • what's the story with ipv6 now? I'm still getting problems indicated by has_ipv6 false

  • I ended up with this, which functions as expected.

    # Create a tableview, with data self.tv = ui.TableView() self.tv.row_height = 30 self.tv.data_source = MyTableViewDataSource(self.tv.row_height) self.tv.delegate = MyTableViewDelegate() # Update tableview data self.tv.data_source.items = sorted(self.c.read_vouchers(), key=itemgetter(0), reverse=True) # Do not allow selection on the TableView #self.tv.allows_selection = False self.tv.allows_selection = True # Add the table self.add_subview(self.tv) # Define the class for the Table Data class MyTableViewDataSource(object): def __init__(self, row_height): self.row_height = row_height self.width = None def tableview_number_of_rows(self, tableview, section): return len(tableview.data_source.items) def tableview_cell_for_row(self, tableview, section, row): self.width, height = ui.get_screen_size() cell = ui.TableViewCell() cell.bounds = (0, 0, self.width, self.row_height) for i in range(3): self.make_labels(cell, tableview.data_source.items[row][i], i) return cell def make_labels(self, cell, text, pos): label = ui.Label() label.border_color = 'lightgrey' label.border_width = 0.5 label.text = str(text) if pos == 0: label.frame = (self.width*0/5, 0, self.width/5, self.row_height) elif pos == 1: label.frame = (self.width*1/5, 0, self.width*2/5, self.row_height) elif pos == 2: label.frame = (self.width*3/5, 0, self.width*2/5, self.row_height) label.alignment = ui.ALIGN_CENTER cell.content_view.add_subview(label) class MyTableViewDelegate(object): @ui.in_background def tableview_did_select(self, tableview, section, row): select_voucher_index, select_voucher = tableview.data_source.items[row][:2] Common().write_config('select_voucher_index', select_voucher_index) Common().write_config('select_voucher', select_voucher) MyTableView().refresh_last_voucher()```
  • If your app is doing a lot of this, be careful that there may be a memory leak. you may need to use someobject ._cached_methods.clear() for every ObjCInstance that you create inside the callback, which breaks a reference cycle (well, at least untangles it a bit so gc can handle it)

  • @JonB said:

    confdefs.h

    No luck in finding confdefs.h or any setting with IPV6.

    There is:
    PythonistaAppTemplate/PythonistaKit.framework/pylib/_sysconfigdata.py

    'ENABLE_IPV6': 1,```

    But the header says:

    # [omz] NOTE: This is required by site.py, but the values are not correct. # It's a copy of the default OS X _sysconfigdata, but there shouldn't # be much need for this on iOS anyway. # system configuration generated and used by the sysconfig module
  • So I made an initial script "strip_pylib.py".

    This script should be runned in pythonista at the phone.
    It will make a "pylib_clean.sh" file, which should be copied to:

    "PATH/PythonistaAppTemplate/PythonistaKit.framework"
    at the Xcode project.

    And then issue:

    source pylib_clean.sh rm pylib_clean.sh

    (Note: pylib_clean.sh should be deleted in the PythonistaKit.framework folder afterwards,
    or there will be problems with signing and sending to App store.)

    pylib_clean.sh will delete a lot of files.

    After compilation in Xcode, the program did not work.
    I had to manually copy back the directory: "/pylib/encodings" from another copy of PythonistaAppTemplate, and then it worked.

    The compilation in Xcode is a lot faster. :)

    And the app size went from 60 MB to 30 MB.
    There are still some files left, but I am not sure why they survived.

    strip_pylib.py

    # Clear all # To get pythonista to work again, restart the app import sys sys.modules[__name__].__dict__.clear() # Now import import sys import inspect import importlib splitstr = "PythonistaKit.framework" pyt_mods = [ "os", "datetime", "json", "requests", "operator", "time", ] pythonista_mods = [ "ui", "console", "dialogs", "objc_util" ] all_mods = pyt_mods + pythonista_mods keep_list = [] for imods in all_mods: try: m = importlib.import_module(imods) dirpath, filepath = inspect.getfile(m).split(splitstr) keep_list.append(filepath) except TypeError as e: #print(e) pass # Get the imported modules dict = sys.modules for key in dict: val = dict[key] if val == None: continue else: try: filepath = inspect.getfile(val) if splitstr in filepath: filepath_append = filepath.split(splitstr)[1] keep_list.append(filepath_append) else: pass except TypeError as e: #print(e) pass # Make uniq and sort keep_list = sorted(set(keep_list)) # Now find all files import os fp = dirpath+splitstr extensions = [".py", ".pyo"] all_files = [] for path, dirs, files in os.walk(fp): for f in files: filename, file_extension = os.path.splitext(f) if "/pylib/" in path or "/pylib_ext/" in path: if file_extension in extensions: stringfp = os.path.join(path, f) dirpath, filepath = stringfp.split(splitstr) all_files.append(filepath) # Make uniq and sort all_files = sorted(set(all_files)) # Make a delete list dellist = [x for x in all_files if x not in keep_list] # Write delete file fname = 'pylib_clean.sh' f = open(fname,'w') f.write("#!/usr/bin/env bash\n") for idel in dellist: f.write("rm ."+idel+"\n") f.close() f = open(fname, "r") for line in f: print(line), f.close()
Internal error.

Oops! Looks like something went wrong!