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.


    drawing in custom views

    Pythonista
    3
    7
    3404
    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.
    • afmac
      afmac last edited by

      Sorry for what is likely a dumb question, but I'd appreciate any help I can get:

      To start: my wife asked me to build a simple "behavior tracker" for the kids, which seemed like a good first project for me. System is simple: kids start out green, and based on user input they can move through yellow to red (and back) based on their behavior throughout the day. Ultimately, I'd like to have an archive/calendar view that we can look back at to show the kids how they ended each day, but right now am just trying to get the basic functionality working.

      I've got a view built in the UI builder that has a couple different subviews built in to it. I've been able to successfully capture the appropriate touch events that enables me to touch each subview's area, and with swipes either way it adjusts the color, somewhat similar to a slider, but based on the x coordinate of the touch event.

      I'd like to have an oval (or maybe even an image at some point, so the kids can choose an icon or little avatar) drawn in the subview when the user lifts their finger, so the last position has a visual mark to identify the last set position (in addition to the color, which already works), but I can't for the life of me get one to draw. Can anyone help me out with this?

      Much appreciate it!

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

        What gave you tried?
        Have you tried the example in ImageContext or Drawing Contexts in the ui docs?

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

          I can duplicate the image context example, but I need the image drawn into my view, not the console, and I can't get that to work. My overridden draw method inside the custom view class works fine, but I can't get that to behave how I'd like it (it just draws my oval once, and it's a one shot deal, every time the code is run. I thought an easy solution might be to pass some arguments into that draw method, but no joy.

          I'd looked at the sketch example, but some of the interaction between the various types of views is a little over my head, so I haven't been able to use that to any advantage yet.

          Any ideas?

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

            Can you please put some sample code into a GitHub repo so that we can debug it together?

            iietdpctep - It Is Easier To Debug Python Code Than English Prose.
            
            1 Reply Last reply Reply Quote 0
            • afmac
              afmac last edited by

              Doh! Code is here: https://gist.github.com/ffafacbf6bbe02f94cf2

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

                I added comments on the gist.

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

                  Instantiating the self.path did the trick. After going back thru the docs, that totally makes sense...never would have gotten there on my own tho. Thanks a ton!

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