-
Dear friends, forgive me if my brain fog of late is blocking me to see anything obvious. I have installed Thonny 4.0-beta3-py38portable on Windows and installed thonny-py5mode (that means py5, jdk-17) YAY! Everything works fine in module mode. In imported mode, not so much, in a curious way. A minimal example, starting by something that works! Should I open an issue? Where? # this works fine
def settings():
size(400, 400)
def setup():
rect(10, 10, 20, 20) # this doesn't work
def setup():
size(400, 400)
rect(10, 10, 20, 20)
PS: This might be going for a while, in Thonny 3.3.7 too. I remember that during my pymunk course I had to separate settings/setup too! PPS: I went to check the P2D/P3D issue on an Intel Mac (confirmed it didn't work) and found the same behaviour as reported here. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
I can't reproduce this, but I see a different bug. When I put this in Thonny and run it: def setup():
size(400, 400)
rect(10, 10, 20, 20) The window appears for a split second and then exits. If I add this: def draw():
pass Then the window appears. This should be easy to fix and I'll take care of it for the next release. I don't know why you are getting that error. It should be totally fine putting the call to Python 3.9.5 (bundled)
>>> import py5
>>> py5.__version__
'0.8.0a2' |
Beta Was this translation helpful? Give feedback.
-
Missed this because I only tested a static sketch working on Thonny 4 (and it's not an issue in Thonny 3.3.7). But there's a lot of conditional stuff in the plug-in to handle Thonny 4. It seems things are one line off here -- File "C:\Users\sesc\mypy5.py", line 5, in setup
3 def setup():
4 size(400, 400)
--> 5 rect(10, 10, 20, 20)
java.lang.IllegalStateException: java.lang.IllegalStateException: size() cannot ... The error in this example, however, is correctly identified (points to the line 2) -- py5 encountered an error in your code:
1
--> 2 rect(10)
3 square(10, 10, 10)
TypeError: The parameter types (int) ... I'll investigate. UPDATE: Okay, the line offset is normal. I tried this in Thonny 3 -- def setup():
pass
def draw():
size(400, 400)
rect(10, 10, 20, 20) ... and got
Of course, this works fine in Thonny 4 (and 3) -- def settings():
size(400, 400)
def draw():
rect(10, 10, 20, 20) Not sure what's causing the original issue yet ... |
Beta Was this translation helpful? Give feedback.
-
Okay -- Thonny 4 seems to do things quite differently. It's problematic in many ways. For example: size(400, 400)
square(10, 10, 10)
print(width) results in --
|
Beta Was this translation helpful? Give feedback.
-
This is something I can't understand, why can't, in an ideal world, the size() function call all the settings() preparations itself, and then on returning control to the rest of the body of setup(), "settings is done already". |
Beta Was this translation helpful? Give feedback.
-
Okay. After banging my head against a wall for hours, I finally found a 'solution'. Change the line in the py5_tools/imported.py that reads -- _imported_mode = False to: _imported_mode = True Obviously, this approach is no good. Any ideas how I might accomplish the same result without editing the file directly? The thonny-py5mode plug-in works by calling the run_sketch.py file, and for whatever reason, the Thonny |
Beta Was this translation helpful? Give feedback.
-
Thanks @hx2A, @villares! Yes -- in the plug-in, I'm importing py5 in a way that's causing problems. It shouldn't be difficult to fix this 🥳 |
Beta Was this translation helpful? Give feedback.
Thanks @hx2A, @villares! Yes -- in the plug-in, I'm importing py5 in a way that's causing problems. It shouldn't be difficult to fix this 🥳