R
R
Ruslan Gilfanov2018-08-14 17:13:07
linux
Ruslan Gilfanov, 2018-08-14 17:13:07

How to run a fullscreen Python GTK3 application on Debian 9.5 (i386) without a desktop environment installed?

In Debian 9.5 (i386) without a shell installed, the fullscreen method on an object of the Gtk.Window class does not work:

import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from gi.repository import Gdk, Gtk, GdkPixbuf


class LockScreen(Gtk.Window):
    def __init__(self, app, config):
        super().__init__(name='lock_screen')
        self.app = app
        cssProvider = Gtk.CssProvider()
        cssProvider.load_from_path('./static/styles.css')
        screen = Gdk.Screen.get_default()
        styleContext = Gtk.StyleContext()
        styleContext.add_provider_for_screen(screen, cssProvider, Gtk.STYLE_PROVIDER_PRIORITY_USER)
        self.box = Gtk.Box(halign=Gtk.Align.CENTER, orientation=Gtk.Orientation.VERTICAL, parent=self,
                           valign=Gtk.Align.CENTER, name='lock_screen_box')
        self.tonb_label = Gtk.Label('Тюменская Областная Научная Библиотека', justify=Gtk.Justification.CENTER,
                                    name='tonb_label', parent=self.box)
        self.icons = {
            name: GdkPixbuf.Pixbuf.new_from_file_at_scale('./static/icons/{0}.svg'.format(name), 96, 96, True)
            for name in [
                'app_started',
                'network_connected',
                'network_disconnected',
                'workstation_locked',
                'workstation_unlocked',
                'workstation_shutdown',
                'reader_binded',
                'error',
            ]
        }
        self.status_icon = Gtk.Image(name='status_icon', parent=self.box)
        self.status_label = Gtk.Label(justify=Gtk.Justification.CENTER, name='status_label', parent=self.box,
                                      width_chars=56)
        self.fullscreen()
        self.connect("destroy", Gtk.main_quit)
        self.show_all()

    ...

The Python Gtk3 application window gets the minimum size:
IN4PPE7TseY.jpg
However, freerdp runs in full screen mode (-f switch) as it should:
jDrr24ZVLK8.jpg
In addition, everything works as it should in Linux Mint 18.3 Cinnamon, the Python Gtk3 application runs in full screen mode without problems.
Packages installed on Debian to run Gtk3:
xorg python3-gi python3-click python3-gi-cairo python3-cairo gir1.2-gtk-3.0 libglib2.0-dev libcairo2-dev libgirepository1.0-dev
The application is launched via lightdm.
/etc/lightdm/lightdm.conf
greeter-session=defender_greeter
/usr/share/xgreeters/defender_greeter.desktop
[Desktop Entry]
Name=TONB Thin Defender
Comment=No comments
Exec=/bin/bash /home/defender/thin-defender/thin_defender/run.sh
Type=Application
X-Ubuntu-Gettext-Domain=lightdm

/home/defender/thin-defender/thin_defender/run.sh
cd /home/defender/thin-defender/thin_defender
/home/defender/thin-defender/.venv/bin/python3 /home/defender/thin-defender/thin_defender/manage.py run_app --config test

UPDATE
A number of Gtk.Window methods require a window manager to work correctly, including the fullscreen method.
Possible solutions to the problem: try to do without these methods or install some kind of window manager.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Gilfanov, 2018-08-15
@ri_gilfanov

I tried to install and configure openbox as a window manager, but got tired of the configs.
It turned out to be easier not to use the fullscreen() method, which depends on window managers:
But to get the current display width and height from Gdk.Screen and set it using the resize() method:
Result:
YvkZsPd_fns.jpg

C
CityCat4, 2018-08-14
@CityCat4

Without what "shell"? Without X? Nothing graphic will ever start without them :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question