from Tkinter import* import ttk, Frame label1=Label(root, text='Enter a color:') label1.grid(column=0, row=0) def __init__(self, parent): Tk.__init__(self, parent) self.parent=parent self.initialize( ) def initialize(self): initframe=Frame(self, padding="3 3 12 12") initframe.grid(column=0, row=0, sticky=(N, W, E, S)) initframe.columnconfigure(0, weight=1) initframe.rowconfigure(0, weight=1) self.resizable(False, False) for child in initframe.winfo_children( ): child.grid_configure(padx=20, pady=20) self.update( ) self.geometry(self.geometry()) self.bind('<Return>', self.check_info_enter) def goback(self): self.info_frame.destroy( ) def check_info(self): self.info_frame=Frame(self, padding="3 3 12 12") self.info_frame.grid(column=0, row=0, sticky=(N, W ,E, S)) self.info_frame.columnconfigure(0, weight=1) self.info_frame.rowconfigure(0, weight=1) self.resizable(False, False) b3=Button(self.info_frame, text="Home", command=self.goback) b3.grid(column=3, row=2, sticky=(W, E)) def check_info_enter(self, event): self.update( ) def printtext(): global color col=color.get() print col if col!=colors: tkMessageBox.showwarning('Sorry', 'Color cannot be display') return True else: return False root=Tk() root.title("Colors") color=Entry(root) color.pack() color.focus_set() def create_window(): window=tk.Toplevel(root) b1=Button(root, text='Continue', command=create_window, command=printtext) b1.pack() window=Tk() def close_window(root): root.destroy frame=Frame(window) frame.pack() b4=Button(frame, text='Quit', command=close_window) b4.pack() root.mainloop()
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question