1

For a scientific experiment I wrote a turtle.py, which opens a 800x480 window and draws a slowly growing black dot. The turtle.py is started with C:\Users\kaza>python C:\Users\kaza\Desktop\Python_scripts\turtle.py "black" 900 40 1 20 20 10 0 0 30 10 in the cmd. black and the numbers after the command are parameters of the dot, which regulate parameters of the dot like growing speed, maxsize etc.

If I execute the cmd the window opens and the turtle.py starts to draw. the size of the screen is 800x480, so the window covers the full screen. The only thing that bothers me is the menu bar. By clicking on it and choosing "undecorate" I can make it disappear but I was not able to find a way starting the window undecorated. The turtle.py should start simultaneously on 12 raspberrys and it is impossible to run to each raspberry and undecorate the window.

I already tried to modify the rc.xml of openbox but nothing changed. Is there maybe a command for the cmd, which starts the turtle.py automatically in an undecorated window?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Kazulka
  • 97
  • 10
  • 1
    A guess: `turtle` uses `Tkinter`, on whose windows you can call [`.overrideredirect(True)`](http://stackoverflow.com/questions/37197213/launch-tkinter-with-undecorated-window) to remove decoration. [Here's](http://stackoverflow.com/questions/22421888/tkinter-windows-without-title-bar-but-resizable) another example. –  Aug 13 '16 at 17:05
  • I already tried to use `overrideredirect` but there is an error `'TurtleScreen' object has no attribute 'overrideredirect'` Is there any other solution? – Kazulka Aug 15 '16 at 08:54
  • `turtle.Screen().getcanvas()._root().overrideredirect(True)` works for me. It's not the best way (you're not supposed to touch any members whose name start with a `_`), but if you want it to *just work for now*... –  Aug 15 '16 at 13:29
  • thanks @Rhymoid that worked! – Kazulka Aug 15 '16 at 14:47
  • maybe you can answer the question "officially"? – Kazulka Aug 15 '16 at 14:49

1 Answers1

2

The standard module turtle uses Tk (through the Tkinter module in Python) for its windows. When you want to undecorate Tk windows, you could use the overrideredirect method of the Toplevel class. This was suggested in an answer to a similar question. From the documentation of Tkinter:

If called with a True argument, this method sets the override redirect flag, which removes all window manager decorations from the window, so that it cannot be moved, resized, iconified, or closed. If called with a False argument, window manager decorations are restored and the override redirect flag is cleared. If called with no argument, it returns the current state of the override redirect flag.

Be sure to call the .update_idletasks() method (see Section 26, “Universal widget methods”) before setting this flag. If you call it before entering the main loop, your window will be disabled before it ever appears.

This method may not work on some Unix and MacOS platforms.

Note that the window is still resizable, but just not through the platform's window manager.

The quick and dirty way to access this method would be to say

turtle.Screen().get‌​canvas()._root().over‌​rideredirect(True)

after the window has been created (to avoid the need for the aforementioned .update_idletasks() workaround).

Normally, the _ at the beginning of a name indicates that the member should not be touched. However, according to the documentation of Tkinter, this is the way to get to the root window:

To get at the toplevel window that contains a given widget, you can often just refer to the widget’s master. Of course if the widget has been packed inside of a frame, the master won’t represent a toplevel window. To get at the toplevel window that contains an arbitrary widget, you can call the _root() method. This method begins with an underscore to denote the fact that this function is part of the implementation, and not an interface to Tk functionality.