Am 26.07.23 um 18:03 schrieb Matthias Meier:
Hi all!
I would like to build (since i haven't found a ready to use package) a text-widget with dynamic scrollbars.
I want to get the scrollbars only, when the text within the text-widget is larger then the visible part of the widget.
I thought it would be a good idea to use "scrollutil" for, instead building it from scratch.
But either the scrollbars are shown when the toplevel gets smaller then the text-widget (not the text) or the scrollbars are shown never. (depending on -fitcontentwidth/-fitcontentheight)
Is it possible to archive this goal with the scrollutil-package or do i have to build a megawidget myself? (canvas+text+scrollbars)
Here is my sample code:
----------------------------------------------------
package require scrollutil
toplevel .t
scrollutil::scrollarea .t.sa
scrollutil::scrollableframe .t.sa.sf
.t.sa setwidget .t.sa.sf
set cf [.t.sa.sf contentframe]
text $cf.t -wrap none
$cf.t insert 1.0 "this is a text line in a text widget\nanother line"
grid .t.sa -row 0 -column 0 -sticky nesw
grid columnconfigure .t 0 -weight 1
grid rowconfigure .t 0 -weight 1
grid $cf.t -row 0 -column 0 -sticky nesw
grid columnconfigure $cf 0 -weight 1
grid rowconfigure $cf 0 -weight 1
# .t.sa.sf configure -fitcontentwidth 1
# .t.sa.sf configure -fitcontentheight 1
Thank you very much,
Matthias
The code needed for a a text-widget with dynamic scrollbars is much
simpler (it doesn't use any scrollableframe):
package require scrollutil
toplevel .t
scrollutil::scrollarea .t.sa
text .t.sa.t -wrap none
.t.sa setwidget .t.sa.t
.t.sa.t insert 1.0 "this is a text line in a text widget\nanother line"
grid .t.sa -row 0 -column 0 -sticky nesw
grid columnconfigure .t 0 -weight 1
grid rowconfigure .t 0 -weight 1
--
Csaba Nemethi
https://www.nemethi.de mailto:
[email protected]
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)