Python graphics window not interactive with mouse - python-2.7

I am using the graphics.py library from the book "Python Programming" by John Zelle. For some reason on my mac, the mouse does not interact with the graphics window using this command: "win.getMouse()". When typed in the Python interpreter, the prompt ">>>" does not return and the command has to be killed with CNTRL-C. The specific problem is "triangle.py" from chapter 5.
Is there a way to fix this or use an alternative python graphics system more friendly on a mac.
thanks for any suggestions.

Answer from Prof. Zelle. Download the current graphics.py file from http://mcsp.wartburg.edu/zelle/python/ and rerun program. It works fine now.

Related

Tkinter no $DISPLAY or display name (Berkley pacman project)

I am trying to use Berkley's AI pacman projects.
Specifically this project.
A little bit about me: I'm on Windows 10 using cygwin as my terminal. I have both python and python3 installed as well as both versions of Tkinter and tkinter respectively. This project uses python 2.7. Trying to run the main project using the python pacman.py results in a long trace with the error being '_tkinter.TclError: no display name and no $DISPLAY environment variable'.
Calling echo $DISPLAY outputs an empty string.
I believe this is the most relevant file:
http://ai.berkeley.edu/projects/release/search/v1/001/docs/graphicsUtils.html
I understand this is a relatively specific and difficult issue, but any advice would be greatly appreciated. Thank you in advance!
Edit: I have installed xwin and the relevant packages. I am able to start a server in one terminal with startxwin and then I try to run the same command in another terminal but arrive at the same issue. I believe my problem is that I cannot establish the xwin server as my $DISPLAY.

Is there a way to clear Eclipse console in C++?

I'm developing a C++ application that interacts with user. I want to clear the screen in some situations. I found a command called system("CLS"). By the way, I'am working on Windows. But, the command works only if I am running the program from CMD or PowerShell. The thing I want is to clear the Eclipse IDE console.
ECLIPSE VERSION: 4.3.2 Kepler (a little bit old)

Youtube-DL.exe Closes After Launching Command Line

I've used YouTube-dl successfully on my mac for quite some time.
I downloaded YouTube-dl.exe (after downloading Microsoft Visual C++ I was told a newer version already exists on my computer - it also says Python is not required), but when I launch the executable, it briefly opens a command line window but then closes immediately and nothing else happens. I've tried Googling and even went to the IRC support chat (who turned out to be more rude than helpful) to no avail. Any ideas what to do?
youtube-dl is a command-line application. To use it directly, start a terminal windows by pressing Win+R, and entering cmd. To get to know the command-line interface, you probably want to consult a tutorial.
If you were looking for a graphical application, use one of the graphical frontends instead; for instance, youtube-dlg.

How do I get Wand for the Raspberry Pi?

I am trying to learn more about displaying graphics with Python 2.7.9 and one post on StackOverflow directed me to wand, but nowhere can I find how to install wand. 'sudo apt-get install wand' fails with 'Unable to locate package wand'.
http://docs.wand-py.org/en/0.4.4/ says to install using '$ sudo apt-get install libmagickwand-dev' but any sample programs end in error with "no module named wand."
What I am trying to do is to flash a number on the console screen that is readable from across the room. I am making an Easter Egg hunt game in Python which is mostly finished, but the numbers on the screen from print ("5") are just too small. My thought was to just use Photoshop to make an image of the number then something like wand to display it instead of printing it to the screen.
So if Wand isn't the correct answer, suggestions would be appreciated. If wand will work for my game display, how do I get it?
Thanks
You can also try pygame if you are doing game display. I tried it and it is very simple to learn. It is normally already downloaded on most python interpreters but if you for some reason do not have pygame, then go here; it teaches well and can help installing:
https://inventwithpython.com/pygame/chapter1.html

How can I get the figures from matplotlib on top of the windows with spyder?

I am using spyder with python to plot some images with matplotlib. When I generate a figure it is not showed on top of the windows, but hidden.
How can I get the figures on top?
I have this problem in Windows and Linux.
This is the code:
plt.figure(0)
plt.imshow(img)
Thanks for your help !
I had the same problem, with Spyder 3.3.2, (python 3.7) and QT5 backend.
The answer in this older query says you may use a trick with TkAgg backend. (at least, the trick does not work with my QT5 backend)
So I switched the backend in Spyder preferences (Tools==> Preferences ==> Ipython ==> Graphis ==> backend).
and now, my windows already comes on top without any other tricks...
Unfortunately there is no way to do what you're asking for because Matplotlib doesn't have the functionality to make it possible. See this issue for more details.
This has been bugging me for a while and I've discovered an answer in an older query
Basically, make window "always on top", then undo that so that other windows can then come on top again.
Code to add after your plot:
#Put figure window on top of all other windows
fig.canvas.manager.window.attributes('-topmost', 1)
#After placing figure window on top, allow other windows to be on top of it later
fig.canvas.manager.window.attributes('-topmost', 0)
I met the same problem yesterday. but I found that if you open the Ipython qtconsole at the same time, the figure window will turn out