• scrollutil an text-Widgets

    From Matthias Meier@21:1/5 to All on Wed Jul 26 09:03:49 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From nemethi@21:1/5 to All on Wed Jul 26 18:59:05 2023
    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:csaba.nemethi@t-online.de

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Rich@21:1/5 to Matthias Meier on Wed Jul 26 16:38:53 2023
    Matthias Meier <diemeiers21@googlemail.com> wrote:
    Hi all!

    I would like to build (since i haven't found a ready to use package)
    a text-widget with dynamic scrollbars.

    Does the 'autoscroll' package in TkLib not fit your needs?

    https://core.tcl-lang.org/tklib/doc/trunk/embedded/md/tklib/files/modules/autoscroll/autoscroll.md

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)