from tkinter import * def Hello(): text.insert(END, "Hello, C.Y.\n") def Quit(): print("Quit!") main.destroy() def Clear(): text.delete(0.0, END) main = Tk() main.wm_title("Test C.Y.") text = Text(main, width=50) buttonHello = Button(main, text="Hello", command=Hello) buttonQuit = Button(main, text="Quit", command=Quit) buttonClear = Button(main, text="Clear", command=Clear) text.insert('0.0', "Hello Python\n") text.pack() buttonHello.pack() buttonClear.pack() buttonQuit.pack() main.mainloop()
好像在寫Java Swing以及AWT XD
參考資料:
http://docs.python.org/3/library/tk.html
http://docs.python.org/3/library/tkinter.html#tkinter-modules
http://www.tcl.tk/man/tcl8.6/
https://wiki.python.org/moin/TkInter
http://www.tutorialspoint.com/python/python_gui_programming.htm
http://www.tkdocs.com/index.html
http://www.tutorialspoint.com/python/tk_text.htm
http://stackoverflow.com/questions/18346206/python-tkinter-how-to-insert-text-at-the-beginning-of-the-text-box
http://www.tutorialspoint.com/python/tk_button.htm