I am making a text editor for a programming class at school. I wish to have a font selection menu for it. The following code is what i have found that shows the list of fonts, but i want to be able to use it rather than just look at the way the fonts look.:
set typeThis "The quick brown fox jumps over the lazy dog."
entry .l -textvariable typeThis -width 30
pack .l
button .go -command "go" -text "Go!" -width 6 -underline 0
bind . <Return> {go}
bind . <Alt-g> {go}
pack .go
proc go {} {
global typeThis fontOver
bind . <Alt-g> {}
bind . <Return> {}
destroy .l
destroy .go
frame .t
pack .t -expand 1 -fill both
text .t.t -yscrollcommand {.t.sb set} -undo 1
pack .t.t -side left -expand 1 -fill both
scrollbar .t.sb -command {.t.t yview}
pack .t.sb -side right -fill y
label .l -textvariable ::fontOver
set fontOver "Loading Fonts. Please Wait..."
pack .l
frame .demo
pack .demo
label .demo.d1 -text "Click a font for a demo"
pack .demo.d1 -side left
label .demo.d2
pack .demo.d2 -side left
label .demo.d3
pack .demo.d3 -side left
label .demo.d4
pack .demo.d4 -side left
update
set i 0
foreach x [lsort [font families]] {
.t.t tag configure tag$i -font [list $x 12 {}]
.t.t insert end "$typeThis\n" tag$i
.t.t tag bind tag$i <Enter> "set ::fontOver [list $x]"
.t.t tag bind tag$i <ButtonPress-1> "demoOf [list $x]"
.t.t tag bind tag$i <Leave> {set ::fontOver ""}
incr i
}
set fontOver ""
};# go
proc demoOf {x} {
.demo.d1 configure -text "Font: $x"
.demo.d2 configure -text "In Bold..." -font [list $x 12 bold]
.demo.d3 configure -text "In Italics..." -font [list $x 12 italic]
.demo.d4 configure -text "In Underline..." -font [list $x 12 underline]
};# demoOf
any clues as to how this is going to be accomplished?
set typeThis "The quick brown fox jumps over the lazy dog."
entry .l -textvariable typeThis -width 30
pack .l
button .go -command "go" -text "Go!" -width 6 -underline 0
bind . <Return> {go}
bind . <Alt-g> {go}
pack .go
proc go {} {
global typeThis fontOver
bind . <Alt-g> {}
bind . <Return> {}
destroy .l
destroy .go
frame .t
pack .t -expand 1 -fill both
text .t.t -yscrollcommand {.t.sb set} -undo 1
pack .t.t -side left -expand 1 -fill both
scrollbar .t.sb -command {.t.t yview}
pack .t.sb -side right -fill y
label .l -textvariable ::fontOver
set fontOver "Loading Fonts. Please Wait..."
pack .l
frame .demo
pack .demo
label .demo.d1 -text "Click a font for a demo"
pack .demo.d1 -side left
label .demo.d2
pack .demo.d2 -side left
label .demo.d3
pack .demo.d3 -side left
label .demo.d4
pack .demo.d4 -side left
update
set i 0
foreach x [lsort [font families]] {
.t.t tag configure tag$i -font [list $x 12 {}]
.t.t insert end "$typeThis\n" tag$i
.t.t tag bind tag$i <Enter> "set ::fontOver [list $x]"
.t.t tag bind tag$i <ButtonPress-1> "demoOf [list $x]"
.t.t tag bind tag$i <Leave> {set ::fontOver ""}
incr i
}
set fontOver ""
};# go
proc demoOf {x} {
.demo.d1 configure -text "Font: $x"
.demo.d2 configure -text "In Bold..." -font [list $x 12 bold]
.demo.d3 configure -text "In Italics..." -font [list $x 12 italic]
.demo.d4 configure -text "In Underline..." -font [list $x 12 underline]
};# demoOf
any clues as to how this is going to be accomplished?