Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tkx and xml-rpc

7 views
Skip to first unread message

Kevin Walzer

unread,
Jan 23, 2013, 9:59:35 AM1/23/13
to tc...@perl.org
I'm wondering if there's a way to configure a Perl Tkx app to also serve
as an XML-RPC server.

What I'm trying to accomplish is driving/scripting/sending messages to a
running Perl Tkx app that causes the Tkx app to run an operation, and
then return data to the client. The idea is to have the Tkx app serve in
a similar capacity to a COM server (think Excel) on Windows or an
AppleScriptable app on the Mac (think iTunes), which provide an
interface for external commands, but in a more platform- and
language-neutral way.

I'm currently using the RPC::XML::Server, which seems perfect for my
requirements in terms of simplicity but it seems that only one event
loop can run at a time--Tkx or the XML::RPC server. That's not
surprising, but I do wonder if there are any other CPAN modules that
might serve here, or if there is a way to layer the XML::RPC bits over
Tk's event loop.

Ruby has a module called "distributed Ruby" (drb) in its core that
allows a Ruby program to send messages to a running instance of another
Ruby program, even one running Tk; it's really cool. I'd love to see
something similar in Perl, and suggestions are appreciated.

--Kevin


--
Kevin Walzer
Code by Kevin
http://www.codebykevin.com

Jeff Hobbs

unread,
Jan 23, 2013, 12:29:26 PM1/23/13
to k...@codebykevin.com, Tcl/ Tk Mailing List
If there was a way to do this in Tcl, you could do it through Tkx.
For some of our Perl programs we leveraged the Tcl-based event loop
for other file operations. The interface between Tcl and Perl is very
tight, allowing you to call into each from the other.

Otherwise the idea of controlling something over a pipe (and have 2
separate processes) is a common unix paradigm, but you might still
have issues if the Perl side needs an event loop for it.

Jeff

Kevin Walzer

unread,
Jan 28, 2013, 9:35:34 PM1/28/13
to tc...@perl.org
On 1/23/13 12:29 PM, Jeff Hobbs wrote:
> If there was a way to do this in Tcl, you could do it through Tkx.
> For some of our Perl programs we leveraged the Tcl-based event loop
> for other file operations. The interface between Tcl and Perl is very
> tight, allowing you to call into each from the other.

I'm considering rolling my own XML-RPC server on top of the Tkx event
loop, setting up a listener via the fileevent API. None of the existing
implementations support such a thing.

Jan Dubois

unread,
Jan 29, 2013, 3:22:05 PM1/29/13
to k...@codebykevin.com, tc...@perl.org
On Mon, Jan 28, 2013 at 6:35 PM, Kevin Walzer <k...@codebykevin.com> wrote:
> On 1/23/13 12:29 PM, Jeff Hobbs wrote:
>>
>> If there was a way to do this in Tcl, you could do it through Tkx.
>> For some of our Perl programs we leveraged the Tcl-based event loop
>> for other file operations. The interface between Tcl and Perl is very
>> tight, allowing you to call into each from the other.
>
>
> I'm considering rolling my own XML-RPC server on top of the Tkx event loop,
> setting up a listener via the fileevent API. None of the existing
> implementations support such a thing.

I have not looked at all at how much work it would be, but I think it
might be worthwhile to see how hard it would be to write an
AnyEvent::Impl::Tkx module. That would allow it to be used with any
module that uses the AnyEvent interface to event loops. I see that
XML::RPC::Fast does have an XML::RPC::UA::AnyEvent adapter, but don't
know if XML::RPC::Fast has the right features for you.

Cheers,
-Jan

Kevin Walzer

unread,
Jan 29, 2013, 10:46:31 PM1/29/13
to Jan Dubois, tc...@perl.org
On 1/29/13 3:22 PM, Jan Dubois wrote:

> I have not looked at all at how much work it would be, but I think it
> might be worthwhile to see how hard it would be to write an
> AnyEvent::Impl::Tkx module. That would allow it to be used with any
> module that uses the AnyEvent interface to event loops. I see that
> XML::RPC::Fast does have an XML::RPC::UA::AnyEvent adapter, but don't
> know if XML::RPC::Fast has the right features for you.

Interesting idea. I'll take a look at this and see if I can get
something to work.

--Kevin

Kevin Walzer

unread,
Jan 30, 2013, 10:51:25 AM1/30/13
to Jan Dubois, tc...@perl.org
On 1/29/13 3:22 PM, Jan Dubois wrote:
> I have not looked at all at how much work it would be, but I think it
> might be worthwhile to see how hard it would be to write an
> AnyEvent::Impl::Tkx module. That would allow it to be used with any
> module that uses the AnyEvent interface to event loops. I see that
> XML::RPC::Fast does have an XML::RPC::UA::AnyEvent adapter, but don't
> know if XML::RPC::Fast has the right features for you.

As yet another alternative, this package:

https://sourceforge.net/projects/xmlrpctcl/

works flawlessly when run from Tk directly. It enabled my Tk app to
serve as the XMLRPC server and returned data to a Perl-based client with
no trouble.

Its license is GPL, which prevents it from being used in a proprietary
app, but it's food for thought. I wonder how easy it would be to wrap
the package from Perl and call it via Tkx.

--Kevin

Jan Dubois

unread,
Jan 30, 2013, 1:19:48 PM1/30/13
to k...@codebykevin.com, tc...@perl.org
On Wed, Jan 30, 2013 at 7:51 AM, Kevin Walzer <k...@codebykevin.com> wrote:
> As yet another alternative, this package:
>
> https://sourceforge.net/projects/xmlrpctcl/
>
> works flawlessly when run from Tk directly. It enabled my Tk app to serve as
> the XMLRPC server and returned data to a Perl-based client with no trouble.
>
> Its license is GPL, which prevents it from being used in a proprietary app,
> but it's food for thought. I wonder how easy it would be to wrap the package
> from Perl and call it via Tkx.

There is no need to wrap it from Perl; Tkx.pm is using Tcl.pm, which
is a generic bridge between Perl and Tcl. So you should already be
able to use xmlrpctcl directly from Tkx apps. That's what Jeff meant
when he wrote "If there was a way to do this in Tcl, you could do it
through Tkx" earlier in this thread.

Cheers,
-Jan
0 new messages