Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Pythonista special key row problems in IOS 14
-
@Enez-Houad Good job. I let real Python specialists like @ccc, @mikael and other ones advice you about Python it-self, they are far ahead of me
For those who want to see the keyboard
And even horizontally scroll this first row, whaaaa
-
@cvp I learn a lot adapting your scripts to my needs !
You will find after this message my/your script to add a keyboard icon in the titlebar to call my script to add my special key row to the keyboard.
The system is rather practical, but to make the handling as transparent as possible : when I add my key row, I hide the keyboard withtv.endEditing(True)
, and I would like to make it reappear with my special key row : but I’ve not found a command as simple as tv.startEditing 🙁 ; it’s perharps possible to simulate a touch in the TextView, but I neither can’t find a solution to do it 🥶
After several hours of searching, I throw in the towel and ask for help…🥵from objc_util import * import ui from ui3.sfsymbol import * w = ObjCClass('UIApplication').sharedApplication().keyWindow() main_view = w.rootViewController().view() def get_toolbar(view): # get main editor toolbar, by recursively walking the view sv = view.subviews() for v in sv: if v._get_objc_classname().startswith(b'OMTabViewToolbar'): return v tb = get_toolbar(v) if tb: return tb # ——————————————————————————————————————————————————————————————————— def keyboard_btn_action(sender): def run_script(scriptPath): import os from objc_util import ObjCInstance,ObjCClass dir = os.path.expanduser(scriptPath) I3=ObjCClass('PYK3Interpreter').sharedInterpreter() I3.runScriptAtPath_argv_resetEnvironment_(dir, [''], True) iCloudPath = "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/" iPadPath = '~/Documents/' scriptPath = 'PROJETS/KEYBOARD/my_special_key_row.py' run_script(iCloudPath + scriptPath) # ——————————————————————————————————————————————————————————————————— def create_keyboard_button(action,index=0): global __persistent_views assert(callable(action)) tb = get_toolbar(main_view) try: __persistent_views except NameError: __persistent_views={} #check for existing button in this index and delete if needed remove_toolbar_button(index) btn = ui.Button() btn.frame = (110, 24, 40, 40) if ui.get_ui_style() == 'dark': btn.tint_color = 'white' else: btn.tint_color = '#0D89B5' btn.image = SymbolImage('keyboard', point_size=14, weight=THIN, scale=SMALL) btn.image = btn.image.with_rendering_mode(ui.RENDERING_MODE_AUTOMATIC) btn.action=action btn_obj=ObjCInstance(btn) __persistent_views[index]=(btn,action) tb.superview().superview().addSubview_(btn_obj) # in front of all buttons return btn # ——————————————————————————————————————————————————————————————————— def remove_toolbar_button(index): global __persistent_views try: btn,action = __persistent_views.pop(index) btn.action= None ObjCInstance(btn).removeFromSuperview() except KeyError: pass # =================================================================== #if __name__=='__main__': # if imported by pythonista startup create_keyboard_button(keyboard_btn_action) create_keyboard_button(keyboard_btn_action)
-
@Enez-Houad try
def keyboard_btn_action(sender): def run_script(scriptPath): import os from objc_util import ObjCInstance,ObjCClass dir = os.path.expanduser(scriptPath) I3=ObjCClass('PYK3Interpreter').sharedInterpreter() I3.runScriptAtPath_argv_resetEnvironment_(dir, [''], True) iCloudPath = "/private/var/mobile/Library/Mobile Documents/iCloud~com~omz-software~Pythonista3/Documents/" iPadPath = '~/Documents/' scriptPath = 'PROJETS/KEYBOARD/my_special_key_row.py' run_script(iCloudPath + scriptPath) @on_main_thread def disp_kbd(): from editor import _get_editor_tab tab = _get_editor_tab() if tab: tab.editorView().textView().becomeFirstResponder() disp_kbd()
-
@Enez-Houad said:
my/your script to add a keyboard icon in the titlebar
I must admit with humulity that the most complex part of this code comes from @JonB 🤫
-
@cvp Thanks a lot ! I’m happy to see that I progress slowly…
I had foundtextView().becomeFirstResponder()
but couldn’t find to witch element it had to be applied. The_get_editor_tab
is not documented ! To find it, do you openeditor.py
in thesite-packages
ofStandard Library
?
It's very instructive 🤓, I'm going to end up managing on my own. 😉 -
-
the problem gets worse, and don't ask me how it happens...
-
I begin to panic
-
With me on iOS 14.3 / iPad it seems to have something to do with the “darkmode” setting. When running in “light” mode the problem did not occur yet. When I switch back to dark mode, the extra keyboard row splits again after switching between file tabs in the editor.
so, maybe use light mode for Pythonista? -
@janplxt said:
iPad it seems to have something to do with the “darkmode” setting.
I don't think so, see my first examples in the topic.