• cvp

    @sendog3c said:

    Where can I find literature about it

    In your script, select the word sqlite3, then help

    posted in Pythonista read more
  • cvp

    @sendog3c sqlite3.connect('myfile.db') stores your dB in the files system of Pythonista on your iPad.
    ':memory:' stores the dB in the RAM, temporary memory during the run of your script.

    posted in Pythonista read more
  • cvp

    @shinya.ta said:

    f you convert kanji characters, you can speak English and kanji characters

    I don't understand: you want that the program speaks English?

    posted in Pythonista read more
  • cvp

    @sendog3c 10 seconds here

    vanimation = mainscreen()
    def chge_name():
        vanimation.name = 'HABITFUN'

    posted in Pythonista read more
  • cvp

    @shinya.ta New Version 1.5

    # Version 1.5
    # - new: set color of title of buttons which have a background image
    #                as transparent, so title is invisible while it will
    #                still be read by VoiceOver
    #                nb: conversion button does not have a background image,
    #                --- so its title will stay visible
    # - mod: user confirmed that he/she does not need support of space/blank
    # - new: suppport user additional "Hirgana -> Kanji" via a
    #                HiraganaToKanji.txt file containing one line by additional item
    #                a tab is needed between hirgana and kanji

    If you want to try to add new Hirgana->Kanji, édit a HiraganaToKanji.txt file
    and write line by line: hirgana tab kanji, like

    どくしょ    本を読む
    どくしょ    読書

    Tab =

    Please tell me if that is what you hoped...

    posted in Pythonista read more
  • cvp

    Q2: http://www.yoihari.com/tenji/tkigo.htm shows that
    Braille dot 5 alone is a interwords point.
    But, dot 5 is also used as prefix for another character => dakuten
    ex: dot 5 = .
    ex: dot 5 followed by dots 1-6 = が
    when the user taps dot-5, the script has no way to know what will follow...
    I propose that if the character after dot-5 is not a possible dakuten,
    I transform the dot-5 into a point
    so dot 5 followed by dots 1456 = ず
    dot 5 followed by dots 145 = .る
    Please confirm that you agree...

    Q4: see next version

    Q5: No process for a space/blank

    posted in Pythonista read more
  • cvp

    @shinya.ta Let me some time to answer....

    But first, Please, give me an example of Chinese character you want to add, to be sure I correctly understand your request

    posted in Pythonista read more
  • cvp

    @nizz71 Try this code

    import ui
    from objc_util import *
    import urllib.parse
    #===================== delegate of UIDocumentPickerViewController: begin
    def documentPickerWasCancelled_(_self, _cmd, _controller):
        UIDocumentPickerViewController = ObjCInstance(_controller)
        if UIDocumentPickerViewController.callback:
        UIDocumentPickerViewController.picked = 'canceled'
        UIDocumentPickerViewController.done = True
    def documentPicker_didPickDocumentsAtURLs_(_self, _cmd, _controller, _urls):
        UIDocumentPickerViewController = ObjCInstance(_controller)
        urls = ObjCInstance(_urls)
        if len(urls) == 1:
            url = urllib.parse.unquote(str(urls[0]))
            url = []
            for i in range(0,len(urls)):
        if UIDocumentPickerViewController.callback:
        UIDocumentPickerViewController.picked = url
        UIDocumentPickerViewController.done = True
    methods = [documentPicker_didPickDocumentsAtURLs_,documentPickerWasCancelled_]
    protocols = ['UIDocumentPickerDelegate']
            MyUIDocumentPickerViewControllerDelegate = ObjCClass('MyUIDocumentPickerViewControllerDelegate')
        MyUIDocumentPickerViewControllerDelegate = create_objc_class('MyUIDocumentPickerViewControllerDelegate', methods=methods, protocols=protocols)
    #===================== delegate of UIDocumentPickerViewController: end
    #def handler(_cmd):
    #   print('here')
    #handler_block = ObjCBlock(handler, restype=None, argtypes=[c_void_p])
    def MyPickDocument(w, h, mode='sheet', popover_location=None, callback=None, title=None, UTIarray=['public.item'], allowsMultipleSelection=False, PickerMode=1,tint_color=None):
        # view needed for picker
        uiview = ui.View()
        uiview.frame = (0,0,w,h)
        if mode == 'sheet':
        elif mode == 'popover':
            if popover_location:
                uiview.present('popover', hide_title_bar=True, popover_location=popover_location)
        UIDocumentPickerMode = PickerMode
                                                            # 1 = UIDocumentPickerMode.open
                                                            #   this mode allows a search field
                                                            #   and url in delegate is the original one
                                                            # 0 = UIDocumentPickerMode.import
                                                            #   url is url of a copy
        UIDocumentPickerViewController = ObjCClass('UIDocumentPickerViewController').alloc().initWithDocumentTypes_inMode_(UTIarray,UIDocumentPickerMode)
        objc_uiview = ObjCInstance(uiview)
        SUIViewController = ObjCClass('SUIViewController')
        vc = SUIViewController.viewControllerForView_(objc_uiview)  
        if title:
            l = ui.Label()
            wb = 80                                     
            wl = uiview.width - 2*wb        # title width
            #l.border_width = 1                 # for tests only
            l.text = title
            l.alignment = ui.ALIGN_CENTER
            # find greatest font size allowing to display title between buttons
            fs = 16
            while True:
                wt,ht = ui.measure_string(title,font=('Menlo',fs))
                if wt <= wl:
                fs = fs - 1
            l.frame = (wb,0,wl,fs)
            l.text_color = 'green'
        UIDocumentPickerViewController.setModalPresentationStyle_(3) #currentContext
        # Use new delegate class:
        delegate = MyUIDocumentPickerViewControllerDelegate.alloc().init()
        UIDocumentPickerViewController.delegate = delegate  
        UIDocumentPickerViewController.callback = callback  # used by delegate
        UIDocumentPickerViewController.uiview   = uiview        # used by delegate
        UIDocumentPickerViewController.done = False
        UIDocumentPickerViewController.allowsMultipleSelection = allowsMultipleSelection
        vc.presentViewController_animated_completion_(UIDocumentPickerViewController, True, None)#handler_block)
        if tint_color != None:
            r,g,b = tint_color
        return UIDocumentPickerViewController
    def main():
            # demo code
            def callback(param):
                # you could check if file save at hoped place...
            MyPickDocument(600,500, callback=callback, title='test', allowsMultipleSelection=True)
            #MyPickDocument(600,500, mode ='popover', popover_location=(mv.width-40,60))
    if __name__ == '__main__':

    It allows even to select a folder (I didn't know 😀)

    posted in Pythonista read more
  • cvp

    @sendog3c hoping that helps, else, sorry, it's time to go to sleep... 2:00 night

    import ui
    equis = 0
    yee = 0
    ancho = 800
    alto = 800
    bgcolor = 'white'
    bordercolor = 'green'
    nameapp = 'HABITFUN'
    class mainscreen(ui.View):
        def __init__(self, *args, **kwargs):
            self.frame = (equis,yee,ancho,alto)
            self.background_color = bgcolor
            self.border_color = bordercolor
            self.name = nameapp
    vanimation = mainscreen()

    posted in Pythonista read more
  • cvp

    @nizz71 Tomorrow, I'll try...

    posted in Pythonista read more
  • cvp

    @nizz71 It should be possible with ObjectiveC UIDocumentPickerViewController to allow multiple selection, select all files of the folder you want and get urls of all files of a folder....

    My iPad is French speaking, "tout select" = "select all"

    posted in Pythonista read more
  • cvp

    @nizz71 How could you select a folder which has sub-folders?
    Actually, tapping on a folder goes down...to display sub-folders or files.

    posted in Pythonista read more
  • cvp

    @shinya.ta I would prefer to maintain my-self the script because it would be easier for both if you find bugs or ask modifications and we would have different programs

    But, anyway, you are free if YOU prefer.
    I could modify the script so the Kanji's are in a file, outside the program.
    Please, give me an example of Chinese character you want to add

    But, I think that the program is not fully finished, here-after are some questions I would like you answer, please.

    • Q1: since some versions, I've commented some lines to avoid confusion
      between sentences spoken by the script or by VoiceOver.
      Could you describe in which cases the script has to speech text?
    • Q2: the Braille dots set with only dot 5 can be used as
      - a prefix for Dakuon
      - an interwords dot
      do you agree if the program, when it meets a dot-5 character,
      will consider it as a prefix unless if next character is not
      a dakuon dots set?
    • Q3: when you tap on up/down/ok button of the conversion list, VoiceOver
      says a sentence as an example of the Kanji. Perhaps is the sentence not
      sufficient to explain the Kanji.
      Do you want a supplementar button that generates another sentence?
      So, next tap on ok will say another example.
    • Q4: buttons have an icon and a title used by VoiceOver.
      Do you want that I use a transparent color for the title, so you would
      only see the icon but VoiceOver will still say the title?
    • Q5: do you want a way to insert a space, and if yes, how?
      By example, a "large" button between the left and right

    posted in Pythonista read more
  • cvp

    @aidensala Is it ok now? For info, name is an attribute giving the name of the object

    posted in Pythonista read more
  • cvp


    Try New Version 1.4 and tell me which one you prefer

    # Version 1.4
    # - mod: remove variable title of up and down scroll buttons in list
    #       to avoid confusion with ok button when using VoiceOver
    #        ***** needs to be confirmed by user tests *****
    # - new: support some punctuations by pair: () 「」
    #       with only one dots-character as delimiter

    posted in Pythonista read more
  • cvp

    @aidensala named instead of name

    posted in Pythonista read more
  • cvp

    @kevinspacely script is ok for Python 2

    Put as 1st line


    And test so

    posted in Pythonista read more
  • cvp

    @aidensala try

    import ui
    iv = ui.ImageView()
    iv.image = ui.Image.named('My image.jpg')

    posted in Pythonista read more
  • cvp

    @shinya.ta Good news😅 We go on step by step, slowly but we'll survive.

    Now, when the conversion list is displayed, you have 3 buttons.
    When you tap a scroll up or down button, VoiceOver says the Kanji that you will get if you tap ok after.
    And if you tap ok once, it says the same Kanji, just to be sure before you tap twice to accept this Kanji and send it to the TextField.

    I don't understand what you want.
    I could say nothing when you tap on a scroll but in this case, you should need to tap the ok button once to hear what is the selected Kanji. That way needs a step more.
    Think about that and try to explain clearly what you want for each of the 3 buttons.

    posted in Pythonista read more
  • cvp

    @madivad said:

    I have grown accustomed to running my apps in the cloud version

    If you need to run an iCloud script with the App Store version, you could try to run
    this script, passing it as 1st argument, the folder/script_name.py. Other arguments may follow.
    I've tested it with the beta because I don't have anymore the normal version.

    # force this script to use Python 2 Interpreter so you can start
    # Python 3 Interpreter to run your iCloud script
    from objc_util import * 
    import sys
    arg = sys.argv
    # this script = arg[0]
    script = arg[1]
    path = '/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/' + script
    arg = arg[2:]   # other arguments
    # run a script like in wrench menu (path, args, reset env yes/no)
    I3.runScriptAtPath_argv_resetEnvironment_(path, arg, True)

    posted in Pythonista read more
Internal error.

Oops! Looks like something went wrong!