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: 135,970β€…    Votes:  5β€…
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:  November 2, 2024
Upload: January 1, 2025    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

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?  β‡©