Home > Enterprise >  show notification on tkinter window - python
show notification on tkinter window - python

Time:02-17

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()

CodePudding user response:

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))
  • Related