Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package require tile
- package require Tclx
- ttk::setTheme default
- set filetypes {{"*.txt files" ".txt"}}
- proc load_file {} {
- set fn [tk_getOpenFile -filetypes $::filetypes]
- if {$fn == ""} return
- .text.textbox delete 1.0 end
- .text.textbox insert 1.0 [read_file $fn]
- }
- proc save_file {} {
- set fn [tk_getSaveFile -filetypes $::filetypes]
- if {$fn == ""} return
- if {![string match -nocase "*.txt" $fn]} {
- set fn "$fn.txt"
- }
- write_file $fn [.text.textbox get 1.0 end]
- }
- ttk::frame .panel -height 60
- ttk::frame .text -height 340 -width 600
- pack .panel -side top -fill x
- pack .text -side bottom -fill both -expand 1
- text .text.textbox -font "Arial 14" -wrap word -yscrollcommand { .text.scrollbar set } -bg white -fg black
- ttk::scrollbar .text.scrollbar -command { .text.textbox yview }
- pack .text.textbox -side left -fill both -expand 1
- pack .text.scrollbar -side right -fill y
- ttk::button .panel.load -text Load -command load_file
- ttk::button .panel.save -text Save -command save_file
- ttk::button .panel.quit -text Quit -command exit
- pack .panel.load -side left
- pack .panel.save -side left
- pack .panel.quit -side left
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement