develooper Front page | perl.tcltk | Postings from July 2018

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

Thread Next
From:
Christopher Chavez
Date:
July 29, 2018 12:31
Subject:
Re: status of fileevent support? (for use with Tcl::pTk)
Message ID:
28D78852-BB96-4726-A67F-EFBDB7273B36@gmx.us
(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=125662 <https://rt.cpan.org/Ticket/Display.html?id=125662>
>> I noticed there's comments in Tcl::pTk's fileevent <https://metacpan.org/source/CERNEY/Tcl-pTk-0.92/lib/Tcl/pTk/Widget.pm#L2109> 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.
>> 
>> 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.
>> 
> 
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;
> 
> 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.
> 

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.
Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About