Last active
February 11, 2021 14:43
-
-
Save diazvictor/885b9556688965bea1095a4a91c3080b to your computer and use it in GitHub Desktop.
WindowScreen - How To Set Window To Current Screen Resolution Using LGI (Lua + Gtk)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local lgi = require('lgi') | |
local Gtk = lgi.require('Gtk', '3.0') | |
local Gdk = lgi.require('Gdk', '3.0') | |
--- I collect the value of the screen resolution | |
-- and I pick up its width and height | |
local screen = Gdk.Screen:get_default() | |
local width, height = screen:get_width(), screen:get_height() | |
-- Creates the window | |
local window = Gtk.Window { | |
title = 'Window Screen', | |
application = self, | |
default_width = width, | |
default_height = height, | |
{ | |
Gtk.Label { | |
use_markup = true, | |
label = ('My resolution is: <b>%sx%s</b>'):format(width, height) | |
} | |
} | |
} | |
function window:on_destroy() | |
Gtk.main_quit() | |
end | |
window:show_all() | |
Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Si 😎