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.


    Relationship between the .py and the .pyui files?

    Pythonista
    3
    4
    2936
    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.
    • SteveIves
      SteveIves last edited by

      Hi,

      Just getting started with using the Pythonista UI builder.

      If I select 'Script with UI' and I call my file 'Test UI', then I get an empty Test UI.pyui file and a Test UI.py file with just an 'import ui' in it. Touching the button on the screen flip-flops between the 2 files.

      Am I correct in thinking that my actual code goes in a separate source file (e.g. Test Code.py) in which I reference 'Test UI', or should my code go in the 'Test UI.py' file?

      Thanks in advance for advice.

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

        Your code should typically be in the Test UI.py file. Assuming you created Test UI.py and Test UI.pyui, a minimal example for Test UI.py would be:

        import ui
        
        v = ui.load_view()
        v.present('sheet')
        
        1 Reply Last reply Reply Quote 0
        • Phuket2
          Phuket2 last edited by

          Wow, I can help out with something, I think.
          If you have a file 'x.py' and a file 'x.pyui' pythonista basically gives you a nice way to switch between the code view and the user interface. The files are only connected via the interface. No implicit connection is made.

          
          # this file called x.py
          import ui
          
          if __name__ == '__main__':
          	# this will work given you have a
          	# file named x.pyui in the same dir
          	v = ui.load_view()
          	v.present()
          # but you can easily load another view by specifying the file. The .pyui not required.
          v = ui.load_view(another_view.pyui)
          v.present()
          
          1 Reply Last reply Reply Quote 0
          • Phuket2
            Phuket2 last edited by

            Sorry, indentation off... I am still new.

            
            # this file called x.py
            import ui
            
            if __name__ == '__main__':
            	# this will work given you have a
            	# file named x.pyui in the same dir
            	v = ui.load_view()
            	v.present()
            # but you can easily load another view by specifying the file. The .pyui not required.
            	v = ui.load_view(another_view.pyui)
            	v.present()
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors