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.


    Show the console over top of a fullscreen presentation?

    Pythonista
    console presentation
    3
    8
    3863
    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.
    • shinyformica
      shinyformica last edited by

      Looking in the console module, I see the console.hide_output() function, but no console.show_output()...is it possible to slide the console in on top of a view being presented fullscreen? I want to be able to show/hide the console for debugging purposes without closing my fullscreen presentation window.

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

        @shinyformica see here

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

          @shinyformica Try this quick and dirty script

          from objc_util import *
          import ui
          
          def GetConsoleText(cv):
          	win = ObjCClass('UIApplication').sharedApplication().keyWindow()
          	main_view = win.rootViewController().view() 
          	ret = '' 
          	next_is_console = False
          	def analyze(v,indent):
          		global next_is_console
          		ret = None
          		for sv in v.subviews():
          			#print(indent,sv._get_objc_classname())
          			if 'OMTextView' in str(sv._get_objc_classname()):
          				if 'line in console 0' in str(sv.text()):
          					cv.text = str(sv.text())
          				#print(sv.text())
          			ret = analyze(sv,indent+'  ')
          			if ret:
          				return ret
          	ret = analyze(main_view,'')
          	return ret
          
          if __name__ == '__main__':	
          	for i in range(0,10):
          		print('line in console '+str(i))
          	v =ui.View()
          	v.background_color = 'white'
          	b = ui.ButtonItem()
          	b.title = 'show console'
          	def b_action(sender):
          		if 'show' in sender.title:
          			cv = ui.TextView(name='console')
          			cv.frame = v.frame
          			v.add_subview(cv)
          			GetConsoleText(cv)
          			sender.title = 'hide console'
          		else:
          			v.remove_subview(v['console'])
          			sender.title = 'show console'
          	b.action = b_action
          	v.right_button_items = (b,)
          	v.present()
          
          1 Reply Last reply Reply Quote 0
          • shinyformica
            shinyformica last edited by

            @cvp interesting...I'm not super psyched about hunting for and grabbing the contents of the console text view, seems a bit fragile.

            I like the idea in that thread you pointed to, of showing the console, but presenting a button to hide it...but I don't see a way of just "presenting" the console? hide_output() will hide the console...but how do I just make it pop up? Do I have to "show_image()" with an empty path or empty image or something?

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

              @shinyformica Ask @jonb how he saw that...

              1 Reply Last reply Reply Quote 0
              • shinyformica
                shinyformica last edited by

                @JonB you can blame @cvp for the ping...in the thread referenced here: https://forum.omz-software.com/topic/1551/open-close-console you mentioned showing the console, but I don't see a way to just make the console pop/slide up? Is there some trick which will bring the console up, even if a view is being presented full screen?

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

                  @shinyformica You could not do shorter and more robust, I think 😇 (perhaps @ccc excepted )

                  import ui
                  
                  #========================= module: begin
                  from objc_util import *
                  main_view = ObjCClass('UIApplication').sharedApplication().keyWindow().rootViewController().view() 
                  def GetConsoleText(v=main_view):
                  	for sv in v.subviews():
                  		if 'OMTextView' in str(sv._get_objc_classname()):
                  			if 'OMTextEditorView' not in str(sv.superview()._get_objc_classname()):
                  				# not the script it-self
                  				return str(sv.text())
                  		ret = GetConsoleText(sv)
                  		if ret: return ret
                  #========================= module: end
                  
                  if __name__ == '__main__':  
                      v =ui.View()
                      v.background_color = 'white'
                      console_view = ui.TextView(name='console_view')
                      console_view.border_width = 1
                      console_view.border_color = 'blue'
                      console_view.hidden = True
                      console_view.frame = v.frame
                      console_view.flex = 'wh'
                      v.add_subview(console_view)
                      b = ui.ButtonItem()
                      b.title = 'show console'
                      def b_action(sender):
                          if 'show' in sender.title:
                              console_view.text = GetConsoleText() # <============= usage
                              console_view.hidden = False
                              sender.title = 'hide console'
                          else:
                              sender.title = 'show console'
                              console_view.hidden = True
                      b.action = b_action
                      v.right_button_items = (b,)
                      v.present()
                      print('example of something in console')
                  
                  1 Reply Last reply Reply Quote 0
                  • JonB
                    JonB last edited by

                    UIApplication.sharedApplication().keyWindow().rootViewController().showAccessoryWithAnimationDuration_(1)

                    Is the equivalent of show_console. It certainly works with editor or panel, but very well might not work with fullscreen or sheet.

                    What could work would be to find the view that contains the fullscreen view (by walking up the heirarchy in objc), and just shift the frame so it is partially off the screen, enough to get to underlying console. You may need to go up a few levels, as there may be some "shield" views. Basically, find the common ancestor to the console view and the presented fullscreen view, then resize the child leg that contains the presented view.

                    I could be totally wrong.. it might be some kind of modal view controller that will prevent any other interaction.

                    I usually use panel for this sort of thing -- you get the extra titlebar stuff, but you can easily go back and forth to console.

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