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.


    Where to store custom data for a UI view?

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

      I am building a little share extension with a view UI. For this UI I need a few extra variables along side the view of the extension.

      What's the best place to store these variables?

      • Global variables (either individually or as a class object with attributes)?

      or

      • Using a sub-classed View just to hold these variables in the UI?
      cvp 1 Reply Last reply Reply Quote 0
      • cvp
        cvp @halloleooo last edited by

        @halloleooo you can add your own attributes to the standard ui.View without sub-classing it.

        import ui
        v = ui.View()
        v.user_attribute = 'my data'
        v.present()
        print(dir(v))
        print(v.user_attribute)
        
        halloleooo 1 Reply Last reply Reply Quote 2
        • halloleooo
          halloleooo @cvp last edited by

          @cvp That's so super-cool! That's the perfect solution for me: Then I don't need global variables!

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

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Powered by NodeBB Forums | Contributors