from gi.repository import Gdk # get the display display = Gdk.Display.get_default() # get the default screen screen = display.get_default_screen() # get the root window root_window = screen.get_root_window() # get the geometry of the window x, y, width, height = root_window.get_geometry() # print the position and size of the window print(f"position: ({x}, {y}), size: ({width}, {height})")
from gi.repository import Gtk, Gdk # create a window window = Gtk.Window() # show the window window.show_all() # get the Gdk.Window associated with the Gtk.Window gdk_window = window.get_window() # resize the window to 400x300 gdk_window.resize(400, 300)In this example, we create a new Gtk.Window object, show it on the screen, get the Gdk.Window associated with it, and then use the resize() method to set its size to 400x300. In conclusion, the gi.repository Gdk Geometry package is a useful library for performing geometric calculations and transformations on graphical objects in Python programs. It is a part of the GTK+ GUI toolkit and is used in many GTK+ applications.