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 this
from 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()
