Wednesday, September 2, 2015

Python: Tkinter (7)

Abstract: message window

The GUI:


The script:
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 31 13:41:26 2015

@author: yuan
"""
from Tkinter import *

def message_win(title='ERROR', text='Great'):
    #toplevel window
    root=Tk()
    root.option_add('*Font', 'Arial',12)
    root.title(title)
    #frame outer
    f=Frame(root, width=300, height=100)
   
    f.pack(expand=YES,fill=BOTH)   
    #frame inner
    xf=Frame(f,relief=GROOVE, borderwidth=2)
    xf.place(relx=0.01, rely=0.125,anchor=NW)   
    xf.pack(expand=YES,fill=BOTH)   
    #content
    Label(xf, text=text).pack(pady=10)
    Button(xf, text='Close', command=root.quit).pack(side=TOP)
    #autoclose the window after 10s
    root.after(10000, lambda w=root:w.destroy())
    #
    root.mainloop()

##





if __name__=="__main__":
   
message_win('Error', 'Passwords should be identical!')
   
   
   
print 'ok'

No comments:

Post a Comment