0

i´m trying to execute a script as i open a tkinter window. i want the outputs of the script to be printed in continuous on the tkinter window, without i´ve to press any command button. i´ve already read some questions in the site, took some ideas but with no success for what i want. Thanks for any help.

# code for tkinter window
from tkinter import *

root = Tk()

loop_active = True
while loop_active:
    root.update()
    root["bg"] = "black"
    root.title('windowtitle')
    root.update_idletasks()
    width = root.winfo_screenwidth()
    heigth = root.winfo_screenheight()

root(root)
root.mainloop()
Cod
  • 1
  • 1
    don't you get any error message ? `root(root)` is not correct. It is not good idea to run loop in any `GUI`. Better use `root.after` to run some code periodically. – furas Nov 24 '19 at 16:46
  • you print nothing - so want do you expect ? – furas Nov 24 '19 at 16:47
  • if you want to run other script in this code then better run it in thread - to not block `mainloop()` – furas Nov 24 '19 at 16:51
  • Read [How do you run your own code alongside Tkinter's event loop?](https://stackoverflow.com/questions/459083/how-do-you-run-your-own-code-alongside-tkinters-event-loop) – stovfl Nov 24 '19 at 22:41
  • The root(root) seems to work fine. – Cod Nov 24 '19 at 22:54
  • I didnt put anything to print because i dont know how. – Cod Nov 24 '19 at 22:57

0 Answers0