Skip to main content

A package that creates and manipulates screen overlays based on tkinter.

Project description

py-overlay

Fork of davidmaamoaix/overlay
Reason: Original repository not updated in a long time (2019) as the time of writing this, even though not archived.

A package that creates and manipulates screen overlays based on tkinter.

Platforms

  • Mac OS (not tested)
  • Linux (not tested)
  • Windows (tested and does not work)

Installation

pip install py-overlay

Usage

A basic overlay is created as such:

from overlay import Window

win = Window()
Window.launch()

The constructor of the Window class takes the following (optional) parameters:

  • size: tuple, the dimension (width, height) of the overlay window.
  • position: tuple, the position of the overlay (on screen).
  • transparent: bool, whether to set the overlay background transparent.
  • alpha: float [0, 1], the alpha (transparency) of the overlay.
  • draggable: bool, whether the window can be dragged

Note that the parameters mentioned above can be edited any time as attributes of an instance of Window.

In order to edit the content of a overlay, one needs to obtain the root of the overlay, upon which all else shall be build.

import tkinter as tk
from overlay import Window

win = Window()
label = tk.Label(win.root, text="Window_0")
label.pack()
Window.launch()

Multiple overlays can be created just as easily:

import tkinter as tk
from overlay import Window

win_0 = Window()
label_0 = tk.Label(win_0.root, text="Window_0")
label_0.pack()
win_1 = Window()
label_1 = tk.Label(win_1.root, text="Window_1")
label_1.pack()
Window.launch()

The following program covers a brief explaination on other methods of the Window class.

import tkinter as tk
from time import sleep
from overlay import Window

def other_stuff(text):
	'''A simple demonstration. The usage of sleep is to emphasize the effects of each action.'''
	print(text)
	sleep(2)
	win_0.hide() # Hides the overlay.
	sleep(1)
	win_0.show() # Shows the overlay.
	sleep(1)
	win_0.focus() # Sets focus to overlay.
	win_1.center() # Moves the overlay to the center of the screen.
	sleep(1)
	Window.hide_all() # Hides all overlays.
	sleep(1)
	Window.show_all() # Shows all overlays.
	sleep(1)
	win_0.destroy() # Kills the overlay.
	sleep(1)
	Window.destroy_all() # Kills all overlays and ends the mainloop.


'''Creates two windows.'''
win_0 = Window()
label_0 = tk.Label(win_0.root, text="Window_0")
label_0.pack()
win_1 = Window()
label_1 = tk.Label(win_1.root, text="Window_1")
label_1.pack()

Window.after(2000, other_stuff, 'Hello World') # Identical to the after method of tkinter.Tk.

Window.launch()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_tkoverlay-1.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

py_tkoverlay-1.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file py_tkoverlay-1.1.0.tar.gz.

File metadata

  • Download URL: py_tkoverlay-1.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.4

File hashes

Hashes for py_tkoverlay-1.1.0.tar.gz
Algorithm Hash digest
SHA256 b68c792f128afc88cf14425b92ce829f5cf0aa08f9dcdf69b2a30bacfa1f623f
MD5 5480057368b73bbae11f21c89724382b
BLAKE2b-256 32c109238fd1d80b755a7a4a3d636a2e0ee82477f72aace5a03e1d241f52ce7c

See more details on using hashes here.

File details

Details for the file py_tkoverlay-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for py_tkoverlay-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e4e6bc258686ff4602e89c069da7888e11936bafb7d2ad07355755f14630806
MD5 9b6796f07a11a029c72ad16baafac299
BLAKE2b-256 ca8df86ca05581a03ec06841896e524d7be98b7fde2e767a23e42086e61eb3c5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page