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.


    Woo woo, question number 4! Seems simple.... change a node's (shapenode primarily) size after the fact?

    Pythonista
    6
    20
    10791
    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.
    • Phuket2
      Phuket2 @WTFruit last edited by

      @WTFruit , thanks for the info. I do remember reading it sometime ago. But because I am still learning, it doesn't all sink in at the same time. I will try to get the AnalogClock.py from the Pythonista examples working in a ui.View. That would be great if I can manage it

      WTFruit 1 Reply Last reply Reply Quote 0
      • WTFruit
        WTFruit @Phuket2 last edited by

        @Phuket2

        Again, I'm still learning (hence all the questions I keep asking), but I've been basically focusing all my energy on doing stuff with scenes so please feel free to hit me up if you have any questions.

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

          I'm learning too! :)

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

            Thanks guys, I will also answer if i can

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

              I haven't used the scene module since it was updated from the render-loop version to nodes, so I can't help you with your main problem. But just a small thing about tuples and assignments. In Python, the lines name = a, b and name = (a, b) do exactly the same. When assigining a tuple, it makes no difference if you use parens or not, because there's no other way that the operator precedence could work out. (Assignment is not an expression in Python, so (name = a), b is invalid syntax and cannot happen by accident.)

              In many other cases you need parens around tuples though, for example when calling a function, or when concatenating tuples with +. For example 1, 2 + 3, 4 will result in the tuple (1, 5, 4), and (1, 2) + (3, 4) will result in (1, 2, 3, 4). Personally I almost always put parens around tuples just to be sure.

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

                Assigning to the size attribute of a ShapeNode should work, with or without parentheses around the (x, y) value. I don't know why it didn't at first, I'd have to see the full code to know if this was due to some bug in the scene module or something else.

                As you've seen though, the shape gets distorted when you assign a different size. The reason is basically that a ShapeNode is a pretty simple subclass of SpriteNode. The only difference is that a ShapeNode gets its texture from a vector path instead of an image file. But once the texture is generated, it behaves just like any other bitmap, i.e. you can't scale it without getting a blurry image or distortion.

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

                  @omz

                  I would assume user-error for now on my earlier attempts... Lord knows I make enough of them!

                  I know I'm cross-threading now but interestingly, I've had another error go away: when I asked about the modal_scene issue, and the last comment I made was that I got it to work but it was still throwing the same error into the console at the same time. Well, as I kept working that just randomly stopped eventually. I was adding things (more nodes and tweaking things) to the modal scene so based on your original comment that's likely related I suppose?

                  EDIT: on the subject of bugs, I'm assuming this is one: I have a codebase that works 100% fine at the moment, but when I try adding a new method to one of my classes it's throwing me an indentation error. I made it as simple as possible so there's nothing I could have screwed up... it's the most basic method I could create, it contains one print comment, I'm not calling it anywhere, I added the colon at the end of the definition... but it gives me the indentation error. Comment out those two lines of code though and it runs like a charm again.

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

                    You might be mixing tabs and spaces by accident. In the Pythonista settings, try enabling "Show Mixed Indentation", then the indent type that is not your default will be highlighted. In a single file, you should only use one type of indentation, and always the same number of spaces/tabs for one indentation level.

                    WTFruit 1 Reply Last reply Reply Quote 0
                    • WTFruit
                      WTFruit @dgelessus last edited by

                      @dgelessus

                      My indentation has been very consistent (only using tab) but I think I figured it out sort of. I neglected to mention that I actually got my project up and running in X-Code and I'm pretty sure that's what was causing trouble. I messed with the "intelligent indenting" preferences a little bit and the problem hasn't come back so far.

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

                        @WTFruit When you're editing Python code in Xcode, I would recommend never to use the regular "Paste" command – always use "Paste and Preserve Formatting". Xcode's automatic re-indentation fails spectacularly with Python code.

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

                          @omz Yeah I noticed that - never realised there was an option to paste with preserved formatting! Had to turn on 'show invisibles' and delete all the spaces that had appeared!

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

                            https://atom.io is a wonderful editor that I highly recommend. If you add the package linter-flake8, Atom will catch indentation issues and a multitude of other errors in your Python code in realtime as you type! I find that it consistently saves me several run-and-crash cycles on Mac, Windoze, and Linux. See the video at https://atom.io/packages/linter-flake8

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