• Can I have a ruled paper effect?

    From Luc@luc@sep.invalid to comp.lang.tcl on Fri Feb 27 22:50:32 2026
    From Newsgroup: comp.lang.tcl

    Has anybody ever devised a clever way to simulate ruled paper in a
    text widget?

    I've been searching high and low and can't find anything.

    So I figured that if I make the text widget background all black,
    then use tags to make all lines have white background and - here is
    the trick - create some very thin spacing between the lines, the
    black background will show through the spacing and everything will
    look like thin black lines across a white background.

    But I am here asking, so of course it's not working.

    Canvas won't work either, I need the real deal text widget in all
    its legendary glory, and the ruled lines have to scale with varying
    font size.

    Is there a way?

    TIA,
    --
    Luc


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From greg@gregor.ebbing@gmx.de to comp.lang.tcl on Mon Mar 2 00:23:05 2026
    From Newsgroup: comp.lang.tcl

    Am 28.02.26 um 02:50 schrieb Luc:
    Has anybody ever devised a clever way to simulate ruled paper in a
    text widget?

    I've been searching high and low and can't find anything.

    So I figured that if I make the text widget background all black,
    then use tags to make all lines have white background and - here is
    the trick - create some very thin spacing between the lines, the
    black background will show through the spacing and everything will
    look like thin black lines across a white background.

    But I am here asking, so of course it's not working.

    Canvas won't work either, I need the real deal text widget in all
    its legendary glory, and the ruled lines have to scale with varying
    font size.

    Is there a way?

    TIA,


    There's a solution somewhere in the wiki using `place`. I can't find it
    again, though.

    Here's another way, also using `place`, but with only one font at a time.


    https://github.com/gregnix/ruledtext

    Gregor
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Luc@luc@sep.invalid to comp.lang.tcl on Mon Mar 2 00:07:51 2026
    From Newsgroup: comp.lang.tcl

    On Mon, 2 Mar 2026 00:23:05 +0100, greg wrote:

    There's a solution somewhere in the wiki using `place`. I can't find it >again, though.

    Here's another way, also using `place`, but with only one font at a time.


    https://github.com/gregnix/ruledtext

    Gregor
    **************************

    Thank you! That should do it.
    --
    Luc


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Arjen@user153@newsgrouper.org.invalid to comp.lang.tcl on Mon Mar 2 12:34:29 2026
    From Newsgroup: comp.lang.tcl


    Luc <luc@sep.invalid> posted:

    On Mon, 2 Mar 2026 00:23:05 +0100, greg wrote:

    There's a solution somewhere in the wiki using `place`. I can't find it >again, though.

    Here's another way, also using `place`, but with only one font at a time.


    https://github.com/gregnix/ruledtext

    Gregor
    **************************

    Thank you! That should do it.


    Have you tried with -bgstipple? This puts a bitmap into the background
    of the text widget and with a suitably filled bitmap, you should be able to get the ruling that you need. At least, that is what I think will happen,
    I have not tried it myself :).
    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Arjen@user153@newsgrouper.org.invalid to comp.lang.tcl on Mon Mar 2 12:48:19 2026
    From Newsgroup: comp.lang.tcl


    Arjen <user153@newsgrouper.org.invalid> posted:


    Luc <luc@sep.invalid> posted:

    On Mon, 2 Mar 2026 00:23:05 +0100, greg wrote:

    There's a solution somewhere in the wiki using `place`. I can't find it >again, though.

    Here's another way, also using `place`, but with only one font at a time.


    https://github.com/gregnix/ruledtext

    Gregor
    **************************

    Thank you! That should do it.


    Have you tried with -bgstipple? This puts a bitmap into the background
    of the text widget and with a suitably filled bitmap, you should be able to get the ruling that you need. At least, that is what I think will happen,
    I have not tried it myself :).

    It turns out to be an option for the tags, so not an option for the
    text widget as a whole.

    This script does give an idea of what it might look like:

    pack [text .t]
    .t tag configure X -bgstipple error -background green
    .t insert end "AAAA" X

    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From Luc@luc@sep.invalid to comp.lang.tcl on Tue Mar 3 16:22:35 2026
    From Newsgroup: comp.lang.tcl

    On Mon, 02 Mar 2026 12:48:19 GMT, Arjen wrote:

    Have you tried with -bgstipple? This puts a bitmap into the background
    of the text widget and with a suitably filled bitmap, you should be able
    to get the ruling that you need. At least, that is what I think will
    happen, I have not tried it myself :).

    It turns out to be an option for the tags, so not an option for the
    text widget as a whole.

    This script does give an idea of what it might look like:

    pack [text .t]
    .t tag configure X -bgstipple error -background green
    .t insert end "AAAA" X

    **************************

    Thank you very much for your interest!

    Sadly, that won't work.

    I tested your example and see, with Arial 12, the background contains
    one row of the pattern.

    With Arial 24, it contains two rows.

    With Arial 36, yup, three rows.

    In other words, it won't scale according to font size.
    It will "fill," or rather tile, but not scale.

    Such is life.

    Thank you for the idea.
    --
    Luc


    --- Synchronet 3.21d-Linux NewsLink 1.2
  • From greg@gregor.ebbing@gmx.de to comp.lang.tcl on Tue Mar 3 23:03:07 2026
    From Newsgroup: comp.lang.tcl

    Am 02.03.26 um 00:23 schrieb greg:
    Am 28.02.26 um 02:50 schrieb Luc:
    Has anybody ever devised a clever way to simulate ruled paper in a
    text widget?

    I've been searching high and low and can't find anything.

    So I figured that if I make the text widget background all black,
    then use tags to make all lines have white background and - here is
    the trick - create some very thin spacing between the lines, the
    black background will show through the spacing and everything will
    look like thin black lines across a white background.

    But I am here asking, so of course it's not working.

    Canvas won't work either, I need the real deal text widget in all
    its legendary glory, and the ruled lines have to scale with varying
    font size.

    Is there a way?

    TIA,


    There's a solution somewhere in the wiki using `place`. I can't find it again, though.

    Here's another way, also using `place`, but with only one font at a time.


    https://github.com/gregnix/ruledtext

    Gregor


    Here's the relevant section in the wiki:

    https://wiki.tcl-lang.org/page/A+vertical+line+in+a+text+widget

    I thought it was a great idea.

    Gregor
    --- Synchronet 3.21d-Linux NewsLink 1.2