Perl/Tk Tutorialанаcreate GUI with Perl's Tk Module
Total Page:16
File Type:pdf, Size:1020Kb
Perl/Tk Tutorial - Create GUI with Perl©s Tk Module Introduction ......................................................................................................................................................................... 2 Applications ................................................................................................................................................................... 2 Philosophy ...................................................................................................................................................................... 2 Perl/Tk Requirements ..................................................................................................................................................... 3 Installing/Using Perl ....................................................................................................................................................... 3 Hello World ......................................................................................................................................................................... 3 Widgets 1 : Button, Entry, Label ........................................................................................................................................ 5 Button ............................................................................................................................................................................. 6 Entry ............................................................................................................................................................................... 6 Label ............................................................................................................................................................................... 7 Widgets 2 : Frame, Text, Scrollbar, Scale ........................................................................................................................... 8 Frame ............................................................................................................................................................................. 8 Text ................................................................................................................................................................................. 8 Scrollbar ......................................................................................................................................................................... 9 Scale ............................................................................................................................................................................. 11 Dialogs .............................................................................................................................................................................. 12 messageBox .................................................................................................................................................................. 12 chooseColor .................................................................................................................................................................. 13 getOpenFile .................................................................................................................................................................. 13 Toplevel ........................................................................................................................................................................ 14 Widgets 3 : Radiobutton, Checkbutton ............................................................................................................................. 15 Radiobutton .................................................................................................................................................................. 15 Checkbutton .................................................................................................................................................................. 16 Widgets 4 : Listbox ........................................................................................................................................................... 18 Listbox .......................................................................................................................................................................... 18 Widgets 5 : Menubutton, Menu, Optionmenu .................................................................................................................. 20 Menubutton .................................................................................................................................................................. 20 Menu ............................................................................................................................................................................. 21 Optionmenu ................................................................................................................................................................. 23 Some more Widgets - Canvas, Message, Adjuster, Scrolled ............................................................................................ 24 Canvas .......................................................................................................................................................................... 24 Message ........................................................................................................................................................................ 24 Adjuster ........................................................................................................................................................................ 24 Scrolled ........................................................................................................................................................................ 25 Geometry Management : Grid, Pack ................................................................................................................................ 26 grid ............................................................................................................................................................................... 26 pack ............................................................................................................................................................................. 27 Some Common Widget Options ....................................................................................................................................... 28 Some Tk Commands ......................................................................................................................................................... 29 Bind .............................................................................................................................................................................. 29 Now What? ........................................................................................................................................................................ 31 Reference ........................................................................................................................................................................... 31 Books ........................................................................................................................................................................... 31 Manual .......................................................................................................................................................................... 31 External Sites ................................................................................................................................................................ 31 Appendix ........................................................................................................................................................................... 31 Appendix A : About the Author ................................................................................................................................... 31 Appendix B : Commonly Made mistakes in Perl/Tk ................................................................................................... 32 Appendix C : Tcl/Tk And Perl/Tk ................................................................................................................................ 32 Appendix D : Codes ..................................................................................................................................................... 32 Appendix E : FeedBacks .............................................................................................................................................. 33 Appendix F : Comments .............................................................................................................................................. 33 Index ........................................................................................................................................................................ 33 Introduction ............................................................................................................................................................. 33 Hello World