hello again
i still have the font problem i posted yesterday .... this is a new topic.
i have a vertical scrollbar attached to a text widget and it works just fine. but if i scroll down (move text up) and then write the contents of the text widget to a file, the output does not start at the *actual* first line of the text widget....it starts at the *visible* first line .... that is, the scrollbar seems to have moved the start index to the first visible position in the window. i have tried a number of things to write out the entire contents of the text widget .....here is one where i tried using a mark at the start of the *actual* text.... (this scheme also opens a file dialog box to select the output file ....which works fine )
# define the write button
button .textframe.writebutton \
-background $buttoncolor \
-foreground $buttforecolor \
-font davesfont \
-padx $padding -pady $padding\
-width $buttonwidth \
-height $buttonheight \
-text "write" \
-command {
# set a mark at the very beginning of the textbox.....
.textframe.maintextbox mark set beginmark 1.0;
set initialdir [pwd];
set file_types { \
{ "Tcl Files" { .tcl .TCL .tk .TK } } \
{ "Text Files" { .txt .TXT .dat .DAT } } \
{ "HTML Files" { .html .HTML .htm .HTM } } \
};
# open file dialog box
set outputfile [tk_getSaveFile \
-initialdir $initialdir \
-filetypes $file_types \
-parent .textframe.maintextbox]
# write out text to file
set junkfilename [open $outputfile w+];
puts $junkfilename [.textframe.maintextbox get beginmark end];
close $junkfilename
}
# .........................................
my question is: when using a vertical scrollbar, how can i set the starting point for output back to the first character of the actual text in the box (without having to remember to scroll all the way back to the top).
thanks for your time.
daveleo
i still have the font problem i posted yesterday .... this is a new topic.
i have a vertical scrollbar attached to a text widget and it works just fine. but if i scroll down (move text up) and then write the contents of the text widget to a file, the output does not start at the *actual* first line of the text widget....it starts at the *visible* first line .... that is, the scrollbar seems to have moved the start index to the first visible position in the window. i have tried a number of things to write out the entire contents of the text widget .....here is one where i tried using a mark at the start of the *actual* text.... (this scheme also opens a file dialog box to select the output file ....which works fine )
# define the write button
button .textframe.writebutton \
-background $buttoncolor \
-foreground $buttforecolor \
-font davesfont \
-padx $padding -pady $padding\
-width $buttonwidth \
-height $buttonheight \
-text "write" \
-command {
# set a mark at the very beginning of the textbox.....
.textframe.maintextbox mark set beginmark 1.0;
set initialdir [pwd];
set file_types { \
{ "Tcl Files" { .tcl .TCL .tk .TK } } \
{ "Text Files" { .txt .TXT .dat .DAT } } \
{ "HTML Files" { .html .HTML .htm .HTM } } \
};
# open file dialog box
set outputfile [tk_getSaveFile \
-initialdir $initialdir \
-filetypes $file_types \
-parent .textframe.maintextbox]
# write out text to file
set junkfilename [open $outputfile w+];
puts $junkfilename [.textframe.maintextbox get beginmark end];
close $junkfilename
}
# .........................................
my question is: when using a vertical scrollbar, how can i set the starting point for output back to the first character of the actual text in the box (without having to remember to scroll all the way back to the top).
thanks for your time.
daveleo