How do you create a main window that fills the entire desktop without covering (or being covered by) the task bar and without being maximized? I can find the entire screen size with and set the main window accordingly with this:
window = gtk.Window()
screen = window.get_screen()
window.resize(screen.get_width(), screen.get_height())
but the bottom of the window is covered by the task bar.
You are totally at the mercy of your window manager for this, and the key issue here is:
without being maximized
So we are left with a number of hacks, because basically maximization and resizing are two separate things, in order that you might be able to remember where it was when it is unmaximized.
So before I show you this hideous hack, I urge you to consider using proper maximization and just be happy with it.
So here goes:
import gtk
# Even I am ashamed by this
# Set up a one-time signal handler to detect size changes
def _on_size_req(win, req):
x, y, w, h = win.get_allocation()
print x, y, w, h # just to prove to you its working
win.disconnect(win.connection_id)
win.unmaximize()
win.window.move_resize(x, y, w, h)
# Create the window, connect the signal, then maximise it
w = gtk.Window()
w.show_all()
w.connection_id = w.connect('size-request', _on_size_req)
# Maximizing will fire the signal handler just once,
# unmaximize, and then resize to the previously set size for maximization.
w.maximize()
# run this monstrosity
gtk.main()
Do you mean making the window fullscreen?
Gtk has functions for making windows fullscreen and back, see gtk_window_fullscreen()
and gtk_window_unfullscreen()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With