omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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?

    Pythonista
    4
    9
    3441
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • codecowboy
      codecowboy last edited by

      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

      cvp 1 Reply Last reply Reply Quote 0
      • BapeHiks
        BapeHiks last edited by

        I don't have an iPad, but maybe you could use an option

        import console
        console.set_font('Menlo', 12)
        del console
        
        1 Reply Last reply Reply Quote 0
        • cvp
          cvp @codecowboy last edited by

          @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 screen

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

          ==>

          1 Reply Last reply Reply Quote 1
          • cvp
            cvp last edited by

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

            codecowboy 1 Reply Last reply Reply Quote 1
            • codecowboy
              codecowboy @cvp last edited by codecowboy

              @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

              cvp 2 Replies Last reply Reply Quote 0
              • cvp
                cvp @codecowboy last edited by cvp

                @codecowboy said:

                how would I set this ‘as a pythonista tool’

                Then

                Then

                codecowboy 1 Reply Last reply Reply Quote 1
                • cvp
                  cvp @codecowboy last edited by

                  @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

                  mikael 1 Reply Last reply Reply Quote 0
                  • mikael
                    mikael @cvp last edited by

                    @cvp, yes.

                    There was a thread recently discussing the feasibility of the Swift option, with no promising results.

                    1 Reply Last reply Reply Quote 0
                    • codecowboy
                      codecowboy @cvp last edited by

                      @cvp thank you 😊

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Powered by NodeBB Forums | Contributors