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.
Can I adjust the console pane width?
-
Is there a way to change the console width on Pythonista? I’d like to make it slightly wider if possible. I can switch the console to full screen using the ‘side panel’ icon(?) but would prefer to have the ability to drag the border between the console and the editor to enlarge it slightly.
Pythonista 3 on iPad Pro 12.9 iOS 13.4.1
-
I don't have an iPad, but maybe you could use an option
import console console.set_font('Menlo', 12) del console
-
@codecowboy Sure it is not exactly what you want (no drag of the border but shoud be possible), try this little, quick and dirty script that you could also set as a Pythonista tool.
it has to be run when console is not in full screenfrom objc_util import * from ui import get_screen_size @on_main_thread def SetConsoleWidth(ConsoleWidthInFractionOfScreenWidth): win = ObjCClass('UIApplication').sharedApplication().keyWindow() main_view = win.rootViewController().view() def analyze(v,indent): for sv in v.subviews(): #print('.'*indent+str(sv._get_objc_classname())) if indent == 1 and sv.frame().origin.x > 0: return sv # force end of search ret = analyze(sv,indent+1) if ret: return ret v = analyze(main_view,0) if not v: return None # console hidden because in full screen frame = v.frame() ws = get_screen_size()[0] # set x of console in fraction of screen width x = int(ws*(1-ConsoleWidthInFractionOfScreenWidth)) frame.origin.x = x frame.size.width = ws - x v.setFrame_(frame) return v # if console view needed def main(): # set x of console in fraction of screen width v = SetConsoleWidth(0.75) if __name__ == '__main__': main()
==>
-
When I say "it is dirty", it is really dirty 😀
You can see that script view is partially hidden by console view, because I changed console width but not left views width.
Try thisfrom objc_util import * from ui import get_screen_size @on_main_thread def SetConsoleWidth(ConsoleWidthInFractionOfScreenWidth): win = ObjCClass('UIApplication').sharedApplication().keyWindow() main_view = win.rootViewController().view() def analyze(v,indent): for sv in v.subviews(): #print('.'*indent+str(sv._get_objc_classname())) if indent == 1 and sv.frame().origin.x > 0: return sv # force end of search ret = analyze(sv,indent+1) if ret: return ret v = analyze(main_view,0) if not v: return None # console hidden because in full screen frame = v.frame() old_w = frame.origin.x ws = get_screen_size()[0] # set x of console in fraction of screen width x = int(ws*(1-ConsoleWidthInFractionOfScreenWidth)) new_w = x frame.origin.x = x frame.size.width = ws - x v.setFrame_(frame) def analyze2(v,old_w,new_w): for sv in v.subviews(): if sv.frame().origin.x == 0 and sv.frame().size.width == old_w: frame = v.frame() frame.size.width = new_w sv.setFrame_(frame) analyze2(sv,old_w,new_w) analyze2(main_view,old_w,new_w) return v # if console view needed def main(): # set x of console in fraction of screen width v = SetConsoleWidth(0.75) if __name__ == '__main__': main()
-
@cvp thanks! Only just seen this. Will give it a try and report back. Out of interest, is there also a swift_util library or Objective-C bindings only?
Also, how would I set this ‘as a pythonista tool’? I’m still new to Pythonista
-
-
@codecowboy said:
is there also a swift_util library or Objective-C bindings only?
I'll let others answer but I think it is Objc only
-
@cvp, yes.
There was a thread recently discussing the feasibility of the Swift option, with no promising results.
-
@cvp thank you 😊