# 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
どくしょ 本を読む どくしょ 読書
Please tell me if that is what you hoped...
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
import ui from objc_util import * import urllib.parse #===================== delegate of UIDocumentPickerViewController: begin def documentPickerWasCancelled_(_self, _cmd, _controller): #print('documentPickerWasCancelled_') UIDocumentPickerViewController = ObjCInstance(_controller) UIDocumentPickerViewController.uiview.close() if UIDocumentPickerViewController.callback: UIDocumentPickerViewController.callback('canceled') UIDocumentPickerViewController.picked = 'canceled' UIDocumentPickerViewController.done = True def documentPicker_didPickDocumentsAtURLs_(_self, _cmd, _controller, _urls): #print('documentPicker_didPickDocumentsAtURLs_') UIDocumentPickerViewController = ObjCInstance(_controller) UIDocumentPickerViewController.uiview.close() urls = ObjCInstance(_urls) if len(urls) == 1: url = urllib.parse.unquote(str(urls)) else: url =  for i in range(0,len(urls)): url.append(urllib.parse.unquote(str(urls[i]))) if UIDocumentPickerViewController.callback: UIDocumentPickerViewController.callback(url) UIDocumentPickerViewController.picked = url UIDocumentPickerViewController.done = True methods = [documentPicker_didPickDocumentsAtURLs_,documentPickerWasCancelled_] protocols = ['UIDocumentPickerDelegate'] try: MyUIDocumentPickerViewControllerDelegate = ObjCClass('MyUIDocumentPickerViewControllerDelegate') except: 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]) @on_main_thread 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': uiview.present('sheet',hide_title_bar=True) elif mode == 'popover': if popover_location: uiview.present('popover', hide_title_bar=True, popover_location=popover_location) else: return else: return 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) #print(dir(UIDocumentPickerViewController)) 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: break fs = fs - 1 l.frame = (wb,0,wl,fs) l.text_color = 'green' UIDocumentPickerViewController.view().addSubview_(ObjCInstance(l)) 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 UIDocumentPickerViewController.view().setTintColor_(ObjCClass('UIColor').colorWithRed_green_blue_alpha_(r,g,b,1.0)) return UIDocumentPickerViewController def main(): # demo code def callback(param): # you could check if file save at hoped place... print(param) MyPickDocument(600,500, callback=callback, title='test', allowsMultipleSelection=True) #MyPickDocument(600,500, mode ='popover', popover_location=(mv.width-40,60)) if __name__ == '__main__': main()
It allows even to select a folder (I didn't know 😀)
@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() vanimation.present('sheet')
@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
- Q1: since some versions, I've commented some lines to avoid confusion
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
@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.
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.
#!python2 # 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 script = arg path = '/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/' + script arg = arg[2:] # other arguments I3=ObjCClass('PYK3Interpreter').sharedInterpreter() # run a script like in wrench menu (path, args, reset env yes/no) #print(path,script) I3.runScriptAtPath_argv_resetEnvironment_(path, arg, True)