如何创建一个填充整个桌面的主窗口,而不覆盖(或被任务栏覆盖)任务栏并且没有最大化?我可以找到整个屏幕尺寸并相应地设置主窗口:
window = gtk.Window() screen = window.get_screen() window.resize(screen.get_width(), screen.get_height())
但窗口的底部由任务栏覆盖.
你完全受到窗口管理员的支配,这里的关键问题是:
没有最大化
因此,我们留下了许多黑客,因为基本上最大化和调整大小是两个独立的事情,以便您可以记住它在未最大化时的位置.
所以在我向你展示这个可怕的黑客之前,我敦促你考虑使用适当的最大化并且对它感到满意.
所以这里:
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()