The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 126,079β€…    Votes:  3β€…
Tags: python   tkinter   transparency  
Link: πŸ” See Original Answer on Stack Overflow ⧉ πŸ”—

URL: https://stackoverflow.com/q/67994877
Title: Transparent background in a Tkinter window
ID: /2021/06/16/Transparent-background-in-a-Tkinter-window
Created: June 16, 2021    Edited:  June 16, 2021
Upload: April 8, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


The Linux Way - Install pqiv

The β€œLinux Way” seems to be installing another package:

$ sudo apt install pqiv

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  pqiv
0 upgraded, 1 newly installed, 0 to remove and 11 not upgraded.
Need to get 34.6 kB of archives.
After this operation, 136 kB of additional disk space will be used.
Get:1 http://ca.archive.ubuntu.com/ubuntu xenial/universe amd64 pqiv amd64 2.2-1 [34.6 kB]
Fetched 34.6 kB in 0s (96.0 kB/s)
Selecting previously unselected package pqiv.
(Reading database ... 442035 files and directories currently installed.)
Preparing to unpack .../archives/pqiv_2.2-1_amd64.deb ...
Unpacking pqiv (2.2-1) ...
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for mime-support (3.59ubuntu1) ...
Setting up pqiv (2.2-1) ...

But as I’ve had to install xdotool and other packages for my application what’s another one right? Plus it will make the docker folks happy :)

The good news is it is only 136KB and automatically places the splash screen in the center of the active monitor instead of the center of the primary monitor or the center of the X11 screen (which can look funny on three monitor systems of different resolutions).


Calling pqiv

From the command line (which you can easily duplicate inside Python with os.popen() or subprocess.Popen()) you simply type:

pqiv -c -c -i m.png

Here’s what it looks like with my png image:

mserve transparent splash screen.gif


Closing pqiv

In the terminal I have to send Control + C when loading is finished. In Python you would have to grep the output from ps and kill the job. Pretty straight forward in Linux I guess but probably foreign to our Windows friends.

Credit to Super User answer.

⇧ How to tell Compiz not to manage/manipulate a specifc Window ID How to improve/fix choppy audio when streaming with pulseaudio?  β‡©