0

I want to to add text ontop of other windows (even fullscreen ones) which can be changed in a while loop. For example the script is While True, and it reads numbers on the screen and the superimposed text is always showing the sum of the numbers like so: enter image description here

Its important that it can be edited for new numbers, and removed when there are no numbers on screen. I have found some which can add text using win32 or tkinter but no which actually can be changed in a loop

This code from How to display text on the screen without a window using Python is the closest i'ev gotten, but its not quite it.

import tkinter, win32api, win32con, pywintypes  

label = Tkinter.Label(text='Text on the screen', font=('Times New Roman','80'), fg='black', bg='white') 
label.master.overrideredirect(True) 
label.master.geometry("+250+250") 
label.master.lift() 
label.master.wm_attributes("-topmost", True) 
label.master.wm_attributes("-disabled", True) 
label.master.wm_attributes("-transparentcolor", "white")

label.pack() 
label.mainloop()

This wont allow me to change or remove the text after its been added

  • Why, what happens when you try to change it? One potential issue is that you're writing the text with transparent background. Nothing in the system saves a copy of what's underneath the text you wrote, so if you write something new, the old text will still be visible. – Tim Roberts Jun 05 '23 at 18:54
  • Might be that I am trying to change it in the wrong way, but .destroy() doesn't remove the text whatsoever. Also, It could be a non-transparent background, that's not too important, it could also be destroyed and re-created for all i care if that works – Tobias Christensen Jun 05 '23 at 18:58
  • Also, when I run label.mainloop it stalls the code, and subsequent code isn't run. – Tobias Christensen Jun 05 '23 at 19:17
  • Nothing will run after `mainloop` until the last open window is closed, and since you don't have any way to close the window, that's a problem. You might look at the pygame solution suggested here: https://stackoverflow.com/questions/45427411/simple-way-to-display-text-on-screen-in-python – Tim Roberts Jun 05 '23 at 23:11

0 Answers0