• Re: ANNOUNCE:: oowidgets 0.2

    From Gerald Lester@21:1/5 to D Groth on Mon Mar 20 09:09:53 2023
    On 3/20/23 08:51, D Groth wrote:
    Dear all,

    I played a little bit around of using TclOO for the creation of megawidgets. Usually I use snit, but TclOO offers the benefit of redefining methods at runtime. Using TclOO from my side for the first time everything was straight forward. In my second
    version I implemented :

    - inheritance
    - composition
    - mixins

    Please have a look at the manual

    https://htmlpreview.github.io/?https://raw.githubusercontent.com/mittelmark/oowidgets/master/tutorial.html

    and the project page:

    https://github.com/mittelmark/oowidgets

    For discussion you could use the Wikipage:

    https://wiki.tcl-lang.org/page/oowidgets

    Currently the package only contains the required code to build your own megawidgets, and a few examples on how to do so.
    Feedback welcome.

    If I have missed an existing package which does a similar thing, please tell me.

    Have you wrapped the existing widgets?

    For some related prototyping, see:
    https://chiselapp.com/user/gwlester/repository/PTK/index

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From D Groth@21:1/5 to All on Mon Mar 20 06:51:52 2023
    Dear all,

    I played a little bit around of using TclOO for the creation of megawidgets. Usually I use snit, but TclOO offers the benefit of redefining methods at runtime. Using TclOO from my side for the first time everything was straight forward. In my second
    version I implemented :

    - inheritance
    - composition
    - mixins

    Please have a look at the manual

    https://htmlpreview.github.io/?https://raw.githubusercontent.com/mittelmark/oowidgets/master/tutorial.html

    and the project page:

    https://github.com/mittelmark/oowidgets

    For discussion you could use the Wikipage:

    https://wiki.tcl-lang.org/page/oowidgets

    Currently the package only contains the required code to build your own megawidgets, and a few examples on how to do so.
    Feedback welcome.

    If I have missed an existing package which does a similar thing, please tell me.

    Best,
    Detlef

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From D Groth@21:1/5 to Gerald Lester on Mon Mar 20 07:25:01 2023
    Gerald Lester schrieb am Montag, 20. März 2023 um 15:09:59 UTC+1:
    On 3/20/23 08:51, D Groth wrote:
    Dear all,

    I played a little bit around of using TclOO for the creation of megawidgets. Usually I use snit, but TclOO offers the benefit of redefining methods at runtime. Using TclOO from my side for the first time everything was straight forward. In my second
    version I implemented :

    - inheritance
    - composition
    - mixins

    Please have a look at the manual

    https://htmlpreview.github.io/?https://raw.githubusercontent.com/mittelmark/oowidgets/master/tutorial.html

    and the project page:

    https://github.com/mittelmark/oowidgets

    For discussion you could use the Wikipage:

    https://wiki.tcl-lang.org/page/oowidgets

    Currently the package only contains the required code to build your own megawidgets, and a few examples on how to do so.
    Feedback welcome.

    If I have missed an existing package which does a similar thing, please tell me.
    Have you wrapped the existing widgets?

    For some related prototyping, see: https://chiselapp.com/user/gwlester/repository/PTK/index

    Yes, all existing widgets are wrapped in a tkoo namespace. If you do a `package require tkoo` you get all widgets from ttk and tk (if there is no ttk widget, so cancas, text and listbox) as tkoo::Text or tkoo::Button classes and tkoo::text and tkoo::
    button widget commands for easier extending. See the mixin part of the tutorial.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Schelte@21:1/5 to D Groth on Mon Mar 20 16:06:50 2023
    On 20/03/2023 14:51, D Groth wrote:
    If I have missed an existing package which does a similar thing, please tell me.

    Tk comes with the ::tk::Megawidget class, which at first glance seems to
    do something similar.


    Schelte.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From D Groth@21:1/5 to Schelte on Mon Mar 20 08:38:33 2023
    Schelte schrieb am Montag, 20. März 2023 um 16:06:55 UTC+1:
    On 20/03/2023 14:51, D Groth wrote:
    If I have missed an existing package which does a similar thing, please tell me.
    Tk comes with the ::tk::Megawidget class, which at first glance seems to
    do something similar.


    Schelte.

    Thanks, yes. I saw this before, but from the Wikipage https://wiki.tcl-lang.org/page/tk%3A%3AMegawidget it did not looked that promising for me and I could not really find any examples or documentation. Will look a little bit around about this.
    Detlef

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Christian Gollwitzer@21:1/5 to All on Mon Mar 20 19:20:23 2023
    Am 20.03.23 um 14:51 schrieb D Groth:
    Dear all,

    I played a little bit around of using TclOO for the creation of megawidgets. Usually I use snit, but TclOO offers the benefit of redefining methods at runtime. Using TclOO from my side for the first time everything was straight forward. In my second
    version I implemented :

    - inheritance
    - composition
    - mixins

    If I have missed an existing package which does a similar thing, please tell me.


    Maybe also have a look at "snot", which is a reimplementation (not 1:1)
    of Snit in TclOO. Looks very promising to me:

    http://chiselapp.com/user/aspect/repository/snot/dir?ci=tip

    Christian

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From D Groth@21:1/5 to Christian Gollwitzer on Tue Mar 21 07:23:20 2023
    Christian Gollwitzer schrieb am Montag, 20. März 2023 um 19:20:28 UTC+1:
    Am 20.03.23 um 14:51 schrieb D Groth:
    Dear all,

    I played a little bit around of using TclOO for the creation of megawidgets. Usually I use snit, but TclOO offers the benefit of redefining methods at runtime. Using TclOO from my side for the first time everything was straight forward. In my second
    version I implemented :

    - inheritance
    - composition
    - mixins
    If I have missed an existing package which does a similar thing, please tell me.

    Maybe also have a look at "snot", which is a reimplementation (not 1:1)
    of Snit in TclOO. Looks very promising to me:

    http://chiselapp.com/user/aspect/repository/snot/dir?ci=tip

    Christian

    Thanks Christian,

    I knew this project before, but having another syntax to learn was something I did not like at that time. My goal was to have a widget creation framework which does not introduce a new syntax. That's one of the reasons I was looking into oo::class,
    arguing that knowing oo::class better opens more possibilities outside of megawidget creation ;)

    At the bottom of the Readme: https://github.com/mittelmark/oowidgets I have a comparison of a snit vs a oowidget, the latter is much easier to read for someone coding in TclOO. The only non TclOO syntax is the class declaration using oowidgets::widgets
    instead of oo::class create ... (callback instead of mymethod will be introduced with 8.7).

    I will add a few more examples of real megawidgets later, currently just two a dlabel based on ttk::label and a composite widget based on label, frame and progressbar..

    Detlef

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From D Groth@21:1/5 to D Groth on Tue Mar 21 10:12:58 2023
    D Groth schrieb am Dienstag, 21. März 2023 um 15:23:23 UTC+1:
    Christian Gollwitzer schrieb am Montag, 20. März 2023 um 19:20:28 UTC+1:
    Am 20.03.23 um 14:51 schrieb D Groth:
    Dear all,

    I played a little bit around of using TclOO for the creation of megawidgets. Usually I use snit, but TclOO offers the benefit of redefining methods at runtime. Using TclOO from my side for the first time everything was straight forward. In my
    second version I implemented :

    - inheritance
    - composition
    - mixins
    If I have missed an existing package which does a similar thing, please tell me.

    Maybe also have a look at "snot", which is a reimplementation (not 1:1)
    of Snit in TclOO. Looks very promising to me:

    http://chiselapp.com/user/aspect/repository/snot/dir?ci=tip

    Christian
    Thanks Christian,

    I knew this project before, but having another syntax to learn was something I did not like at that time. My goal was to have a widget creation framework which does not introduce a new syntax. That's one of the reasons I was looking into oo::class,
    arguing that knowing oo::class better opens more possibilities outside of megawidget creation ;)

    At the bottom of the Readme: https://github.com/mittelmark/oowidgets I have a comparison of a snit vs a oowidget, the latter is much easier to read for someone coding in TclOO. The only non TclOO syntax is the class declaration using oowidgets::widgets
    instead of oo::class create ... (callback instead of mymethod will be introduced with 8.7).

    I will add a few more examples of real megawidgets later, currently just two a dlabel based on ttk::label and a composite widget based on label, frame and progressbar..

    Detlef

    May be a code example explains it at best, here the at that time amazing implementation, no OOP in the core, of the read only text widget in snit: https://wiki.tcl-lang.org/page/Snit's+Not+Incr+Tcl (rotext).

    Here is now the implementation using oowidgets based on TclOO:

    ```
    package require oowidgets
    namespace eval ::test { }

    ::oowidgets::widget ::test::Rotext {
    variable textw
    constructor {path args} {
    # we need the real widget (underline at the end)
    set textw ${path}_
    # Create the text widget; turn off its insert cursor
    my install tk::text $path -insertwidth 0 -border 5 -relief flat
    my configure {*}$args
    }
    # Disable the text widget's insert and delete methods
    # to make this readonly even if the user writes text.
    method insert {args} { }
    method delete {args} { }
    # programmatically we can still insert and delete ...
    method ins {args} { $textw insert {*}$args }
    method del {args} { $textw delete {*}$args }
    }
    ```

    That are just 10 lines of code with no special keywords anywhere (install is a method defined in the base class). BTW: the widget is then test::rotext (lowercase R).
    I was my self wondering how short and clear this can be ...

    Detlef

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