How to create self POP Message window in tkinter





below is code for above screen shot.

#program

try :
from Tkinter import * # supports Python 2
except:
from tkinter import * # supports Python 3



class Main_window():
def __init__(self):
self.mw = Tk()
self.mw.title("AETies : Automation Expert Technologies")
self.mw.geometry('1400x850+20+20')
self.pic = PhotoImage(file='./Images/favicon.ico')
self.mw.iconphoto(False, self.pic)

self.pic = PhotoImage(file="./Images/6.png")
self.lbl = Label(self.mw, image=self.pic)
self.lbl.pack(fill=BOTH, expand=YES)
self.popup("successful", 1)

def popup(self, message, state):
self.ww = Frame(self.mw, width=500, height=100)
self.ww.place(x=700, y=300)
self.header_fm = Frame(self.ww, bg='cyan', padx=1, pady=1)
self.btn = Button(self.header_fm, text="X", command=self.ww.destroy).pack(side=LEFT)
self.header = Label(self.header_fm, text="AETies : Message Box", padx=20, bg='cyan').pack(side=LEFT)
self.header_fm.pack()

if state == 1:
self.s = PhotoImage(file="./Images/s.png")
if state == 2:
self.s = PhotoImage(file="./Images/w.png")
if state == 3:
self.s = PhotoImage(file="./Images/f.png")

self.fm = Frame(self.ww, width=100, height=80, bg='red')
self.fm.pack(side=LEFT)
self.lbl = Label(self.fm, image=self.s).pack()
self.fm1 = Frame(self.ww, width=200, height=80)
self.fm1.pack(side=LEFT)
self.lbl1 = Text(self.fm1, width=20, height=2)
self.lbl1.insert(INSERT,message)
self.lbl1.pack()
mainloop()

mw = Main_window()


search for the  below line (last line of __init__)

self.popup("successful", 1)

output of this is


replace it with

self.popup("warning", 2)

output of this is


replace it with

self.popup("failed", 3)

output of this is




we can use default widgets for pop-up window.


Comments

My photo
Techno Xpresss
Bangalore, Karnataka, India