Re: status of fileevent support? (for use with Tcl::pTk)

[email protected] (Christopher Chavez) Sun, 29 Jul 2018 07:31:07 -0500
Newsgroups perl.tcltk
Message-ID <[email protected]>
--Apple-Mail=_23B3027B-D1FF-4563-B9D8-42DC3231238B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

(Continuing discussion from https://github.com/gisle/tcl.pm/issues/14 =
<https://github.com/gisle/tcl.pm/issues/14> here per Vadim's suggestion)

> chrstphrchvz <https://github.com/chrstphrchvz> commented Jul 11, 2018, =
3:06 PM CDT:
>> I came across an issue using fileevent from Tcl::pTk on macOS, which =
I've documented here: https://rt.cpan.org/Ticket/Display.html?id=3D125662 =
<https://rt.cpan.org/Ticket/Display.html?id=3D125662>
>> I noticed there's comments in Tcl::pTk's fileevent =
<https://metacpan.org/source/CERNEY/Tcl-pTk-0.92/lib/Tcl/pTk/Widget.pm#L21=
09> suggesting it be rewritten, since it has known shortcomings (e.g. =
only supporting 'readable', relies on polling interval). Another =
suggestion it makes is for Tcl.pm to support CreateFileHandler.
>>=20
>> But do Tcl::Tk and/or Tkx already allow using fileevent 'as-is' =
through Tcl.pm? (I haven't yet successfully tried; is there a readily =
available example somewhere?) If that's the case, then I'm wondering if =
it's a matter of making Tcl::pTk recognize fileevent as something it =
should just pass through to Tcl.pm if it's syntax is sufficiently =
compatible with Perl/Tk's.
>>=20
>=20
vadrer <https://github.com/vadrer> commented Jul 12, 2018, 2:46 AM CDT:
> I haven't tried tcl/tk's fileevent, and actually I have no much plans =
on doing so.
> The reason is that I mostly use tcl/tk for GUI, and perl for IO;
>=20
> however it is possible to use tcl/tk's fileevent, but in this case we =
should expect for it to perform said IO.
> problem with Tcl::pTk could be that it should "join" perl IO and =
tcl/tk IO; which is not very easy, plus I do not foresee much benefits =
from doing so.
>=20

For the program I'm working on (cf. =
https://github.com/hotwolf/HSW12/issues/16 =
<https://github.com/hotwolf/HSW12/issues/16>) the existing fileevent is =
for reading a serial port. It already uses separate read and write =
filehandles; it might be sufficient to use Tcl syntax to open a read =
handle for the device and make a fileevent for it (from Tcl rather than =
Perl), while continuing to use a Perl write filehandle in UI event =
callbacks.

For other uses, I'm not quite sure what the best approach will be. It =
doesn't seem possible to use some modern module like IO::Async in the =
same thread with e.g. Tcl::pTk due to separate event loops. If combining =
the file handles is best, that seems like something needing to be done =
from C/XS (not pure Perl or Tcl), which is what using =
Tcl_CreateFileHandler would entail.=

--Apple-Mail=_23B3027B-D1FF-4563-B9D8-42DC3231238B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><div =
dir=3D"auto" style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
line-break: after-white-space;" class=3D"">
 =20
    <meta http-equiv=3D"content-type" content=3D"text/html; =
charset=3DUTF-8" class=3D"">
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF" class=3D""><p =
class=3D"">(Continuing discussion from <a class=3D"moz-txt-link-freetext" =
href=3D"https://github.com/gisle/tcl.pm/issues/14">https://github.com/gisl=
e/tcl.pm/issues/14</a>
      here per Vadim's suggestion)</p>
    <h3 class=3D"timeline-comment-header-text text-normal f5" =
style=3D"box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; =
max-width: 78%; padding-top: 10px; padding-bottom: 10px; color: rgb(88, =
96, 105); font-variant-ligatures: normal; font-variant-caps: normal; =
letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; =
text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; font-weight: 400 !important;"><span =
style=3D"font-size: 12px;" class=3D""></span></h3><blockquote =
type=3D"cite" class=3D""><h3 class=3D"timeline-comment-header-text =
text-normal f5" style=3D"box-sizing: border-box; margin-top: 0px; =
margin-bottom: 0px; max-width: 78%; padding-top: 10px; padding-bottom: =
10px; color: rgb(88, 96, 105); font-variant-ligatures: normal; =
font-variant-caps: normal; letter-spacing: normal; orphans: 2; =
text-align: start; text-indent: 0px; text-transform: none; white-space: =
normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; =
font-weight: 400 !important;"><span style=3D"font-size: 12px;" =
class=3D""><strong class=3D"css-truncate" style=3D"box-sizing: =
border-box; font-weight:
        600;"><a class=3D"css-truncate-target author text-inherit" =
data-hovercard-user-id=3D"7941193" =
data-octo-click=3D"hovercard-link-click" =
data-octo-dimensions=3D"link_type:self" =
href=3D"https://github.com/chrstphrchvz" style=3D"box-sizing:

          border-box; background-color: transparent; color: rgb(88,
          96,
 105); text-decoration: none; display: inline-block;
          max-width:
 125px; overflow: hidden; text-overflow:
          ellipsis; white-space:
 nowrap; vertical-align: top;">chrstphrchvz</a><span =
class=3D"">&nbsp;</span></strong>commented<span class=3D"">
        Jul 11, 2018, 3:06 PM CDT:<br class=3D"">
      </span></span></h3>
    <blockquote type=3D"cite" class=3D""><p style=3D"box-sizing: =
border-box; margin-top: 0px !important;

        margin-bottom: 16px; color: rgb(36, 41, 46); font-family:

        -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;,

        Helvetica, Arial, sans-serif, &quot;Apple Color
        Emoji&quot;,
 &quot;Segoe UI Emoji&quot;, &quot;Segoe UI
        Symbol&quot;;
 font-size: 14px; font-style: normal;
        font-variant-ligatures:
 normal; font-variant-caps: normal;
        font-weight: 400;
 letter-spacing: normal; orphans: 2;
        text-align: start;
 text-indent: 0px; text-transform: none;
        white-space: normal;
 widows: 2; word-spacing: 0px;
        -webkit-text-stroke-width: 0px;
 background-color: rgb(255,
        255, 255); text-decoration-style:
 initial;
        text-decoration-color: initial;" class=3D"">I came across an =
issue using<span class=3D"">&nbsp;</span><code style=3D"box-sizing: =
border-box; padding: 0.2em 0.4em; margin: 0px; background-color: =
rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; =
border-top-right-radius: 3px; border-bottom-right-radius: 3px; =
border-bottom-left-radius: 3px;" class=3D"">fileevent</code><span =
class=3D"">&nbsp;</span>from
        Tcl::pTk on macOS, which I've documented here:<span =
class=3D"">&nbsp;</span><a =
href=3D"https://rt.cpan.org/Ticket/Display.html?id=3D125662" =
rel=3D"nofollow" style=3D"box-sizing: border-box;

          background-color: transparent; color: rgb(3, 102, 214);

          text-decoration: none;" =
class=3D"">https://rt.cpan.org/Ticket/Display.html?id=3D125662</a></p><p =
style=3D"box-sizing: border-box; margin-top: 0px;
        margin-bottom:
 16px; color: rgb(36, 41, 46); font-family:
        -apple-system,
 BlinkMacSystemFont, &quot;Segoe UI&quot;,
        Helvetica, Arial,
 sans-serif, &quot;Apple Color
        Emoji&quot;, &quot;Segoe UI
 Emoji&quot;, &quot;Segoe UI
        Symbol&quot;; font-size: 14px;
 font-style: normal;
        font-variant-ligatures: normal;
 font-variant-caps: normal;
        font-weight: 400; letter-spacing:
 normal; orphans: 2;
        text-align: start; text-indent: 0px;
 text-transform: none;
        white-space: normal; widows: 2;
 word-spacing: 0px;
        -webkit-text-stroke-width: 0px;
 background-color: rgb(255,
        255, 255); text-decoration-style:
 initial;
        text-decoration-color: initial;" class=3D"">I noticed there's =
comments in<span class=3D"">&nbsp;</span><a =
href=3D"https://metacpan.org/source/CERNEY/Tcl-pTk-0.92/lib/Tcl/pTk/Widget=
.pm#L2109" rel=3D"nofollow" style=3D"box-sizing: border-box;

          background-color: transparent; color: rgb(3, 102, 214);

          text-decoration: none;" class=3D"">Tcl::pTk's =
fileevent</a><span class=3D"">&nbsp;</span>suggesting
        it be rewritten, since it has known shortcomings (e.g. only
        supporting<span class=3D"">&nbsp;</span><code style=3D"box-sizing:=

          border-box;
 font-family: SFMono-Regular, Consolas,
          &quot;Liberation
 Mono&quot;, Menlo, Courier, monospace;
          font-size: 11.9px;
 padding: 0.2em 0.4em; margin: 0px;
          background-color: rgba(27,
 31, 35, 0.05); border-radius:
          3px;" class=3D"">'readable'</code>, relies on polling =
interval). Another
        suggestion it makes is for Tcl.pm to support<span =
class=3D"">&nbsp;</span><code style=3D"box-sizing: border-box; padding: =
0.2em 0.4em; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); =
border-top-left-radius: 3px; border-top-right-radius: 3px; =
border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;" =
class=3D"">CreateFileHandler</code>.</p><div style=3D"box-sizing: =
border-box; margin-top: 0px; color: rgb(36, 41, 46); font-style: normal; =
font-variant-ligatures: normal; font-variant-caps: normal; font-weight: =
400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: 2; word-spacing: =
0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, =
255); margin-bottom: 0px !important;" class=3D"">But do Tcl::Tk and/or =
Tkx
        already allow using fileevent 'as-is' through Tcl.pm? (I haven't
        yet successfully tried; is there a readily available example
        somewhere?) If that's the case, then I'm wondering if it's a
        matter of making Tcl::pTk recognize<span =
class=3D"">&nbsp;</span><code style=3D"box-sizing: border-box; =
font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, =
Menlo, Courier, monospace; padding: 0.2em 0.4em; margin: 0px; =
background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: =
3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; =
border-bottom-left-radius: 3px;" class=3D"">fileevent</code><span =
class=3D"">&nbsp;</span>as
        something it should just pass through to Tcl.pm if it's syntax
        is sufficiently compatible with Perl/Tk's.</div><div =
style=3D"box-sizing: border-box; margin-top: 0px; color: rgb(36, 41, =
46); font-style: normal; font-variant-ligatures: normal; =
font-variant-caps: normal; font-weight: 400; letter-spacing: normal; =
orphans: 2; text-align: start; text-indent: 0px; text-transform: none; =
white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); =
margin-bottom: 0px !important;" class=3D""><br class=3D"">
      </div>
    </blockquote>
    <br class=3D"">
    </blockquote><h3 class=3D"timeline-comment-header-text text-normal =
f5" style=3D"box-sizing: border-box; margin-top: 0px; margin-bottom: =
0px; max-width: 78%; padding-top: 10px; padding-bottom: 10px; color: =
rgb(88, 96, 105); font-variant-ligatures: normal; font-variant-caps: =
normal; letter-spacing: normal; orphans: 2; text-align: start; =
text-indent: 0px; text-transform: none; white-space: normal; widows: 2; =
word-spacing: 0px; -webkit-text-stroke-width: 0px; font-weight: 400 =
!important;"><span style=3D"font-size: 12px;" class=3D""><strong =
class=3D"css-truncate" style=3D"box-sizing: border-box; font-weight:
        600;"><a class=3D"css-truncate-target author text-inherit" =
data-hovercard-user-id=3D"122038" data-octo-click=3D"hovercard-link-click"=
 data-octo-dimensions=3D"link_type:self" =
href=3D"https://github.com/vadrer" style=3D"box-sizing:

          border-box; background-color: transparent; color: rgb(88,
          96,
 105); text-decoration: none; display: inline-block;
          max-width:
 125px; overflow: hidden; text-overflow:
          ellipsis; white-space:
 nowrap; vertical-align: top;">vadrer</a><span =
class=3D"">&nbsp;</span></strong>commented<span class=3D"">
        Jul 12, 2018, 2:46 AM CDT:</span></span></h3>
    <blockquote type=3D"cite" class=3D""><p style=3D"box-sizing: =
border-box; margin-top: 0px !important;

        margin-bottom: 16px; color: rgb(36, 41, 46); font-family:

        -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;,

        Helvetica, Arial, sans-serif, &quot;Apple Color
        Emoji&quot;,
 &quot;Segoe UI Emoji&quot;, &quot;Segoe UI
        Symbol&quot;;
 font-size: 14px; font-style: normal;
        font-variant-ligatures:
 normal; font-variant-caps: normal;
        font-weight: 400;
 letter-spacing: normal; orphans: 2;
        text-align: start;
 text-indent: 0px; text-transform: none;
        white-space: normal;
 widows: 2; word-spacing: 0px;
        -webkit-text-stroke-width: 0px;
 background-color: rgb(255,
        255, 255); text-decoration-style:
 initial;
        text-decoration-color: initial;" class=3D"">I haven't tried =
tcl/tk's
        fileevent, and actually I have no much plans on doing so.<br =
style=3D"box-sizing: border-box;" class=3D"">
        The reason is that I mostly use tcl/tk for GUI, and perl for =
IO;</p><p style=3D"box-sizing: border-box; margin-top: 0px;
        margin-bottom:
 16px; color: rgb(36, 41, 46); font-family:
        -apple-system,
 BlinkMacSystemFont, &quot;Segoe UI&quot;,
        Helvetica, Arial,
 sans-serif, &quot;Apple Color
        Emoji&quot;, &quot;Segoe UI
 Emoji&quot;, &quot;Segoe UI
        Symbol&quot;; font-size: 14px;
 font-style: normal;
        font-variant-ligatures: normal;
 font-variant-caps: normal;
        font-weight: 400; letter-spacing:
 normal; orphans: 2;
        text-align: start; text-indent: 0px;
 text-transform: none;
        white-space: normal; widows: 2;
 word-spacing: 0px;
        -webkit-text-stroke-width: 0px;
 background-color: rgb(255,
        255, 255); text-decoration-style:
 initial;
        text-decoration-color: initial;" class=3D"">however it is =
possible to use
        tcl/tk's fileevent, but in this case we should expect for it to
        perform said IO.<br style=3D"box-sizing: border-box;" class=3D"">
        problem with Tcl::pTk could be that it should "join" perl IO and
        tcl/tk IO; which is not very easy, plus I do not foresee much
        benefits from doing so.</p>
    </blockquote><p class=3D""><br class=3D"">
    </p><p class=3D"">For the program I'm working on (cf. <a =
class=3D"moz-txt-link-freetext" =
href=3D"https://github.com/hotwolf/HSW12/issues/16">https://github.com/hot=
wolf/HSW12/issues/16</a>)
      the existing fileevent is for reading a serial port. It already =
uses separate read and write filehandles; it might be sufficient to use =
Tcl syntax to open a read handle for the device
      and make a fileevent for it (from Tcl rather than Perl), while =
continuing to use a Perl write filehandle in UI event callbacks.</p><p =
class=3D"">For other uses, I'm not quite sure what the best approach =
will be. It doesn't seem possible to use some modern module like =
IO::Async in the same thread with e.g. Tcl::pTk due to separate event =
loops. If combining the file handles is best, that seems like something =
needing to be done from C/XS (not pure Perl or Tcl), which is what using =
Tcl_CreateFileHandler would entail.</p>
  </div>

</div>
</body></html>=

--Apple-Mail=_23B3027B-D1FF-4563-B9D8-42DC3231238B--