Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

show notification on tkinter window – python

How can I show the print statements (which are under the def run () function) inside the tkinter window one by one. I did with msgbox but then user has to click "OK" in order to let the other VL2.py script to execute, I dont want this I just want to show the print statement on window and automatically continue executing. No interaction with user.

enter image description here

from tkinter import *
import tkinter as tk
import os

def run():
        print('Processing')
        os.system('VL.py')
        print("First Vlookup is done!")
        os.system('VL2.py')
        print("Second Vlookup is doen!")
        print('Done!')


screen = tk.Tk()
screen.title("Generate weekly report")
screen.geometry("300x320")
instruction = Label(text='Click "Generate"', fg = 'black',)
instruction.pack()
click_me = Button(text = 'Generate', fg ='black', bg = 'light gray', command = run)
click_me.place(x=130, y= 280)


screen.mainloop()

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can change text in label.

Like this

def run(observer_label: tk.Label):
    observer_label.config(text="Processing")
    os.system('VL.py')
    observer_label.config(text="First Vlookup is done!")
    ....
....
click_me = Button(text = 'Generate', fg ='black', bg = 'light gray', command = lambda *args: run(instruction))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading