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.


    How to use custom attribures in pyui?

    Pythonista
    pyui view ui.view
    2
    2
    2017
    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.
    • oraant
      oraant last edited by

      I have a view like this

      class PathView (ui.View):
      	def __init__(self, *arg, **kw):
      		print(arg, kw)    # notice here!
      		self.flex = 'WH'
      		self.path = None
      		self.paths = []
      		self.action = None
      

      And I made a pyui, use the custom view PathView, and put some custom attributes like this:

      {"bc": "oooo" }
      

      When I run the first script, it printed this:

      () {}
      

      Why?How should I use it?

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

        Those are custom attributes not custom arguments. what happens is the view is created, with no input args:

         v=PathView()
        

        then, arguments are set:

         v.width =....
         v.bc="oooo"
        

        and so on.
        if you need to take action based on the custom attributes, you need to have those as @property's, to implement a setter.

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