hey paddy, i was thinking more along the lines of a text overlay also suggested by the OP..
transparency effects and closing/opening of tkinter windows is possible and something i wanted to put into this example but i just dont have time right now, so if the OP is wanting to use tkinter theyll have to put some work in.. but heres a borderless tkinter window displaying a variable which will update on each press of +/- keys..
Code: Select all
from Tkinter import *
from pynput import keyboard
import threading
volume = 0
def on_press(key):
global volume
try:
if key.char == '+':
volume += 1
label.config(text="Volume "+"%02d" % volume)
t1.update_idletasks()
if key.char == '-':
volume -= 1
label.config(text="Volume " + "%02d" % volume)
t1.update_idletasks()
except:
pass
def on_release(key):
if key.char == '+' or '-':
pass
def key_input():
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
thread = threading.Thread(target=key_input)
thread.daemon = True
thread.start()
t1 = Tk()
t1.overrideredirect(True)
label = Label(t1, text="Volume "+"%02d" % volume, width=12, font=('aharoni', 28, 'bold'), fg='red')
label.grid(padx=10, pady=5, row=0, column=0, sticky='W,E,N,S')
t1.lift()
t1.mainloop()