Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Turtle with IDLE on Mac OS X #55284

Closed
amcnerney13 mannequin opened this issue Jan 31, 2011 · 14 comments
Closed

Using Turtle with IDLE on Mac OS X #55284

amcnerney13 mannequin opened this issue Jan 31, 2011 · 14 comments
Assignees
Labels
OS-mac topic-IDLE topic-tkinter type-bug An unexpected behavior, bug, or error

Comments

@amcnerney13
Copy link
Mannequin

amcnerney13 mannequin commented Jan 31, 2011

BPO 11075
Nosy @rhettinger, @ronaldoussoren, @abalkin, @ned-deily, @bitdancer

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/ned-deily'
closed_at = <Date 2011-02-02.03:38:35.336>
created_at = <Date 2011-01-31.05:26:32.158>
labels = ['OS-mac', 'expert-IDLE', 'type-bug', 'expert-tkinter']
title = 'Using Turtle with IDLE on Mac OS X'
updated_at = <Date 2011-02-02.07:40:13.454>
user = 'https://bugs.python.org/amcnerney13'

bugs.python.org fields:

activity = <Date 2011-02-02.07:40:13.454>
actor = 'ned.deily'
assignee = 'ned.deily'
closed = True
closed_date = <Date 2011-02-02.03:38:35.336>
closer = 'amcnerney13'
components = ['IDLE', 'macOS', 'Tkinter']
creation = <Date 2011-01-31.05:26:32.158>
creator = 'amcnerney13'
dependencies = []
files = []
hgrepos = []
issue_num = 11075
keywords = []
message_count = 14.0
messages = ['127577', '127585', '127586', '127677', '127678', '127687', '127689', '127692', '127696', '127697', '127700', '127702', '127716', '127717']
nosy_count = 7.0
nosy_names = ['rhettinger', 'ronaldoussoren', 'belopolsky', 'gregorlingl', 'ned.deily', 'r.david.murray', 'amcnerney13']
pr_nums = []
priority = 'normal'
resolution = 'works for me'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue11075'
versions = ['Python 2.7', 'Python 3.2']

@amcnerney13
Copy link
Mannequin Author

amcnerney13 mannequin commented Jan 31, 2011

Info: I have Python 2.7.1:86832 (32-bit) installed using ActiveState Tcl/Tk 8.5.9 on Mac OS X 10.6

Problem:
Whenever I try to run (from the IDLE) a Python script using the turtle module, the window that shows up will draw anything passed to it, but it will not come to the front using the listen() function, nor will clicking on the window do anything more than cause the spinning beach ball to appear. Because it does not come the the foreground, functions like onkey() and onclick() are completely unusable.

However, when said Python script is run from the Terminal, the window is completely responsive. I believe this to be some sort of problem with the IDLE.app

Things that I have tried:
Tried different versions of tcl/tk: 8.4.19, 8.4.7, 8.5.9
Tried different versions of Python 2.7.1: 32-bit, 32/64-bit, 32-bit compiled from source.

Other things that may be useful:
This probably has no relevancy, but just in case:
In the .mpkg installed Python 2.7.1 (32-bit), the IDLE says the GCC version is 4.0.1
In the source compiled version, it says 4.2.1

It is quite annoying to not be able to use the IDLE to create and test programs using the turtle module. Please help.

@amcnerney13 amcnerney13 mannequin added type-crash A hard crash of the interpreter, possibly with a core dump topic-IDLE OS-mac topic-tkinter labels Jan 31, 2011
@ned-deily
Copy link
Member

Since IDLE and the turtle modules both use Tkinter and thus are both Tcl/Tk applications, it wouldn't be surprising if you had problems trying to run a program using the IDLE module from within IDLE. However, I find I can successfully run at least one of the supplied Turtle demos from IDLE 2.7.1 and IDLE 2.6:

cd /Applications/Python 2.7/Extras/Demo/turtle
idle2.7 tdemo_paint.py # or idle2.6

and with either of the two IDLE variants (32-bit -> Tk 8.4, 64-/32-bit -> Tk 8.5). Can you supply a simple script to demonstrate the problem you see?

Keep in mind that, at the moment, neither of the standard python.org 2.7.1 installers support using ActiveState Tk 8.5.9. The 32-bit-only installer will use ActiveState Tk 8.4, if installed, otherwise use the Apple-supplied Tk 8.4.19(?) in 10.6. Python 2.7.1 was released before a 64-bit capable version of ActiveState Tk 8.5 was available so, as released, it will only link to the Apple-supplied Cocoa Tk 8.5.7 in 10.6 and that version has proven to be very unreliable when used with IDLE. You should be able to build from source a Python 2.7.1 that will link to ActiveState 8.5.9 if it is present during the build but beware that there are a number of issues both major and minor that have been recently fixed in Python (and are in the current release-2.7 maintenance branch that should appear as a 2.7.2 release in the future) as well as a few issues in Cocoa Tk itself which should be fixed in an upcoming release of ActiveState Tk 8.5.

@ned-deily
Copy link
Member

er, "trying to run a program using the turtle module from within IDLE"

@amcnerney13
Copy link
Mannequin Author

amcnerney13 mannequin commented Feb 1, 2011

It may be because the program that I am trying to run automatically exits, I do not know yet how to keep a turtle program running (waiting for input). The only way I know so far is to use the function "exitonclick()," but when using that, my I cannot use any other mouseevents in my program. (Help?) Anyways, an example of a script that will cause turtle to hang/crash is even such a simple one as:
"
import turtle as t
def flfr():
t.fd(10)
t.lt(45)
t.fd(10)
t.rt(45)
t.onkey(flfr, "Up")
t.listen()
"
Is there anyway to keep a turtle program running, waiting for user interaction without using the exitonclick() function? Also, thank you for pointing out the maintenance svn, I did an svn checkout, compiled, and installed it and it fixed other problems that I was having with Python 2.7.1 ActiveState Tcl/Tk 8.5.9 (such as hanging when running a program when the shell isn't open.)

Another quick question that you don't have to answer: is there anyway to ignore interaction (keystrokes, mouseclicks) while an onkey function is activated? Like if I make a function that takes 10 seconds to complete, can I ignore all interaction while that function is being run?

Thank you for your time.

@bitdancer
Copy link
Member

Well, the bug tracker isn't really the place to get help on using Python. I would suggest posting to python-list, you are more likely to find people with the time to help you there. You should also take a look at the Turtle demo programs, I'm pretty sure you can find your answers there as I know some of them are interactive.

Turtle is designed to work from IDLE, so if it doesn't it's a bug.

You haven't mentioned an actual crash of the python interpreter, so I'm changing the type to behavior.

@bitdancer bitdancer added type-bug An unexpected behavior, bug, or error and removed type-crash A hard crash of the interpreter, possibly with a core dump labels Feb 1, 2011
@amcnerney13
Copy link
Mannequin Author

amcnerney13 mannequin commented Feb 1, 2011

Sorry to keep bothering, but running Python 2.7.1:88286 (maintenance) on ActiveState Tcl/Tk 8.5.9 causes the idle to hang when a simple script like:
"
x = raw_input("x: ")
print x
"
is run. Is this a bug in Tcl/Tk? Looking in the logs I see several instances of "setCanCycle: is deprecated. Please use setCollectionBehavior instead" Does this have any relevancy?

Relating to this, I don't know if it is proper to ask here, but is it possible to link Python to a specific Tcl/Tk when compiling from the source?

Note: When running Python 2.7.1 (32-bit from installer) with Tcl/Tk 8.4, the above problem is not there.

@ned-deily
Copy link
Member

Now that I looked at the documentation (http://docs.python.org/library/turtle.html), I see that it is clear that Turtle is designed to work from IDLE *but*, as is noted, "when using the module from within IDLE run with the -n switch", which means run IDLE without a subprocess. What may not be so obvious is how to do that on Mac OS X. Double-clicking on IDLE.app launches it with default values including a subprocess and there is no straightforward to override those. From a terminal shell, it is easy to start bin/idle:

   $ idle2.7 -n

although that has a few cosmetic disadvantages with bin/idle over IDLE.app (for example, the application name displayed is "Python" not "IDLE"). It has aways been possible to launch an OS X GUI app from a shell command line using the open(1) command; as of OS X 10.6 it is now also possible to pass regular command line arguments to the application. So the following would work in 10.6 and probably be preferable:

   $ open -a "/Applications/Python 2.7/IDLE.app" --args -n

If you want to have a double-clickable application, a simple approach is to create a launcher application with AppleScript:

   $ osacompile -o 'IDLE-n.app' <<EOF
   > do shell script "open -a '/Applications/Python 2.7/IDLE.app' --args -n"
   > EOF

As someone not used to using Turtle and given the intended user base for Turtle, I wonder whether the current Turtle module documentation is sufficient on this point. Two possible actions I could see are: (1) expanding the documentation to include a suggestion like the above to allow for an OS X clickable app; and/or (2) actually supplying such a simple no-subprocess app with the standard python.org installer distribution (or some other solution). How is this issue handled on Windows? Is there a need to expand the documentation in general?
(adding Raymond to the nosy list)

@ned-deily ned-deily changed the title Turtle crash with IDLE on Mac OS X 10.6 Using Turtle with IDLE on Mac OS X Feb 1, 2011
@ned-deily
Copy link
Member

[Please don't add new topics to the same tracker issue. As David mentioned, it would be better to ask for help on one of the user lists to be sure before opening an issue. Besides the general python-list, there is an active OS X users list (pythonmac-sig) where you will find users of IDLE; see http://www.python.org/community/sigs/

That said, to address your most recent message, that appears to indeed be a problem. I've opened bpo-11088 for it. The "setCanCycle: is deprecated" messages are a harmless artifact; they should disappear in an upcoming maintenance release of ActiveState Tcl 8.5.]

@bitdancer
Copy link
Member

Ned: I read the bits in the turtle docs about -n as meaning *if* you use -n *then* you should set this profile option (but if you don't, things should work). I didn't go over the docs in detail, though, so maybe I'm misreading. Since you and I clearly don't know what we are talking about in detail, I'm adding Gregor and Alexander (the latter since he's clearly been using it) to nosy.

@ned-deily
Copy link
Member

It's clear from testing it and from some searches that -n is, in fact, required.

@bitdancer
Copy link
Member

Ah, in that case I think the docs could be improved on that point.

@ned-deily
Copy link
Member

I saw this post by Gregor: http://thread.gmane.org/gmane.comp.python.general/334881/focus=334996

I don't know applicable it still is on Windows. But it does seem to be still true on OS X.

@amcnerney13
Copy link
Mannequin Author

amcnerney13 mannequin commented Feb 2, 2011

Thank you so much for pointing out the -n option!
Hopefully the Tk 8.5.9 input issue will be solved soon enough.
Thank you both again.
I'm not sure if I'm supposed to or not, but I am marking this as closed – seeing as the main issue has been solved.

@amcnerney13 amcnerney13 mannequin closed this as completed Feb 2, 2011
@amcnerney13
Copy link
Mannequin Author

amcnerney13 mannequin commented Feb 2, 2011

solved* or rather, a workaround has been found.

@ned-deily ned-deily self-assigned this Feb 2, 2011
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS-mac topic-IDLE topic-tkinter type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants