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.


    Presenting view and console

    Pythonista
    console ui module present
    6
    19
    13619
    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.
    • JonB
      JonB last edited by

      Hmm, for some reason I thought the console is only shown the first time a particular script prints to it... but maybe I am mistaken.

      If you are doing lots of back and forth between console and ui, you might also consider an Overlay. This woeks similar to a popover, but does not disappear when you interact with the console, and can be dragged around, minimized, etc. You can also have multiple Overlays active at the same time.

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

        That Overlay class is quite nice :) I'll keep it around for later, but it does have some quirks:

        for one, the below crashes when trying to set the .text:

        if __name__=='__main__':
        	view = ui.View()
        	view.frame = (0, 0, 240, 240)
        	view.flex = 'WH'
        	view.background_color = 'white'
        	valuefield = ui.TextField()
        	valuefield.frame = (120, 34, 120, 34)
        	valuefield.text = "ana" # ⇒ crashes Pythonista
        	view.add_subview(valuefield)
        	o=Overlay(content=view,parent=AppWindows.root())
        
        JonB 1 Reply Last reply Reply Quote 0
        • JonB
          JonB @KalyJupiter last edited by

          Hmm, I couldn't reproduce the crash, though to get to run I had to add name to view (something I should fix), and also enabled touch so the textfield is active.

          Can you enable the faulthandler (see @dgelessus's pythonista_startup repo) and let me know exactly what is crashing?

          from overlay import Overlay,AppWindows
          import ui
          if __name__=='__main__':
              view = ui.View(name='hello')
              view.frame = (0, 0, 240, 240)
              view.flex = 'WH'
              view.background_color = 'white'
              valuefield = ui.TextField()
              valuefield.frame = (120, 34, 120, 34)
              valuefield.text = "ana" # ⇒ crashes Pythonista
              view.add_subview(valuefield)
              o=Overlay(content=view,parent=AppWindows.root())
              o.content_view.touch_enabled=True
          
          1 Reply Last reply Reply Quote 0
          • KalyJupiter
            KalyJupiter last edited by

            @dgelessus awesome scripts :D
            @JonB the above main body I placed in overlay.py and simply ran the file ( after correcting the name issue )

            Fatal Python error: Aborted
            
            Current thread 0x000000016e117000 (most recent call first):
            
            ------------------------------------------------------------------------
            
            Objective-C exception details:
            
            NSInternalInconsistencyException: Only run on the main thread!
            
            Stack trace:
            
            0   CoreFoundation                      0x000000018316fd50 <redacted> + 148
            1   libobjc.A.dylib                     0x0000000182684528 objc_exception_throw + 56
            2   CoreFoundation                      0x000000018316fc0c <redacted> + 0
            3   Foundation                          0x0000000183afec90 <redacted> + 88
            4   UIFoundation                        0x000000018d64a70c <redacted> + 1008
            5   UIFoundation                        0x000000018d64a194 <redacted> + 1672
            6   UIFoundation                        0x000000018d656de8 <redacted> + 168
            7   UIFoundation                        0x000000018d647494 <redacted> + 4628
            8   UIFoundation                        0x000000018d647f30 <redacted> + 196
            9   UIFoundation                        0x000000018d648640 <redacted> + 340
            10  UIFoundation                        0x000000018d6513b0 <redacted> + 2180
            11  UIFoundation                        0x000000018d67aed0 <redacted> + 332
            12  UIFoundation                        0x000000018d6a0528 <redacted> + 160
            13  UIKit                               0x000000018d1cd658 <redacted> + 524
            14  UIKit                               0x000000018c5c4eac <redacted> + 248
            15  UIKit                               0x000000018c57c000 <redacted> + 1256
            16  QuartzCore                          0x000000018714d0b4 <redacted> + 184
            17  QuartzCore                          0x0000000187151194 <redacted> + 332
            18  QuartzCore                          0x00000001870bff24 <redacted> + 336
            19  QuartzCore                          0x00000001870e6340 <redacted> + 540
            20  QuartzCore                          0x00000001870e7180 <redacted> + 92
            21  CoreFoundation                      0x00000001831178b8 <redacted> + 32
            22  CoreFoundation                      0x0000000183115270 <redacted> + 412
            23  CoreFoundation                      0x00000001830362f8 CFRunLoopRunSpecific + 468
            24  Foundation                          0x0000000183a5e6e4 <redacted> + 304
            25  Foundation                          0x0000000183a7dafc <redacted> + 96
            26  Py3Kit                              0x0000000102687508 -[PYK3Interpreter setupInterpreterThreadRunLoop] + 252
            27  Foundation                          0x0000000183b5f860 <redacted> + 996
            28  libsystem_pthread.dylib             0x0000000182d9c32c <redacted> + 308
            29  libsystem_pthread.dylib             0x0000000182d9c1f8 <redacted> + 0
            30  libsystem_pthread.dylib             0x0000000182d9ac38 thread_start + 4
            
            End of exception details.
            
            1 Reply Last reply Reply Quote 0
            • JonB
              JonB last edited by

              mmkay, looks like we need a @on_main_thread someplace. Could you try adding this in front of the init method of Overlay?

              1 Reply Last reply Reply Quote 2
              • KalyJupiter
                KalyJupiter last edited by

                yep, that worked :D I put it on attach

                @on_main_thread
                def attach(self):
                

                now that Overlay is awesome for a quick settings screen :)

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

                  Using Overlays

                  My first post to the forum.

                  Using the Overlay class successfully — added the decorator to the attach function as was mentioned.

                      @on_main_thread
                  	def attach(self):
                  		self.parent.addSubview_(self)
                  

                  In my demo file, I have a main image overlay (resizable) and two auxilary image overlays (resizable). Each of the overlays could have any kind of UI elements; just showing images for proof of concept.

                  I have found that, for each overlay, the following statements must be in the order shown or else the overlay window will not resize.

                      ooo=Overlay(name='abc', content=vvv, parent=AppWindows.root())
                      ooo.content_view.border_width=2
                      vvv.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
                  

                  Here is my demo file; provide your own PNG files (foo.png and fooe.png).

                  from overlay import Overlay, AppWindows
                  from gestures import Gestures
                  import ui
                  
                  if __name__=='__main__':
                      
                      iv0=ui.ImageView(frame=(0,0,300,300))
                      iv0.image=ui.Image.named('test:Peppers')
                      iv0.name='OMAIN▪️'
                      
                      iv1=ui.ImageView(frame=(0,0,200,200))
                      iv1.image=ui.Image.named('foo.png')
                      iv1.name='ICR▪️'
                      iv1.alpha=1
                      overlay1=Overlay(content=iv1,parent=AppWindows.root())
                      overlay1.content_view.border_width=2
                      iv1.border_width=1
                      iv1.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
                      
                      iv2=ui.ImageView(frame=(0,0,200,200))
                      iv2.image=ui.Image.named('fooe.png')
                      iv2.name='E▪️'
                      iv2.alpha=1
                      overlay2=Overlay(content=iv2,parent=AppWindows.root())
                      overlay2.content_view.border_width=2
                      iv2.border_width=1
                      iv2.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
                      
                      omain=Overlay(name='abc', content=iv0, parent=AppWindows.root())
                      omain.content_view.border_width=2
                      iv0.border_width=1
                      iv0.content_mode=ui.CONTENT_SCALE_ASPECT_FIT
                  
                  mikael struct_engr_ 2 Replies Last reply Reply Quote 0
                  • mikael
                    mikael @struct_engineer last edited by

                    @struct_engr, excellent first post.

                    1 Reply Last reply Reply Quote 1
                    • struct_engr_
                      struct_engr_ @struct_engineer last edited by

                      @struct_engr

                      Had to register as a new account.
                      Could not access my old account.
                      Several recover password attempts did not work.
                      So my new username is struct_engr_ (added underline character at the end)

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

                        @struct_engr_ , did your recover password attempts result in no email arriving, or was there some other issue?

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

                          @mikael
                          each time:
                          no email arrived ASFAIK
                          carefully checked spam folder
                          possible that email hit blacklisted IP addresses
                          FYI
                          certain IP addresses blocked because of spam

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

                            @struct_engr_ , I think the problem is that for the past 6 months or so, no emails from this forum get actually sent. Neither the password resets or other notifications. @omz, any chance you could take a look?

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