For Programmers: Free Programming Magazines  


Home > Archive > PerlTk > March 2007 > Can Tk do this









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Can Tk do this
Ed Jay

2007-03-13, 10:04 pm

I'm fairly new to Perl, and just discovered Perl.Tk. Before I take the leap
into Tk, I want to know if I'm wasting my time trying to resolve an issue.

My users are using a web-based application to evaluate images uploaded by
others. I don't want the images to display in the user's browser. I want to
download selected images and have them appear in a window removed from the
browser. Can I craft a widget and program my web app such that the images
appear in the widget?

I use Opera and have it set up so that downloaded images launch IrfanView. I
don't expect all my users to use Opera, so I'm sing an alternative.

All I'm looking for is a Yes/No answer to my question.

TIA,
--
Ed Jay (remove 'M' to respond by email)
brian

2007-03-13, 10:04 pm

Ed Jay wrote:

> I'm fairly new to Perl, and just discovered Perl.Tk. Before I take the
> leap into Tk, I want to know if I'm wasting my time trying to resolve an
> issue.
>
> My users are using a web-based application to evaluate images uploaded by
> others. I don't want the images to display in the user's browser. I want
> to download selected images and have them appear in a window removed from
> the browser. Can I craft a widget and program my web app such that the
> images appear in the widget?
>
> I use Opera and have it set up so that downloaded images launch IrfanView.
> I don't expect all my users to use Opera, so I'm sing an alternative.
>
> All I'm looking for is a Yes/No answer to my question.



Yes. If you can launch IrfanView (don't really know what that is, but
assuming some sort of image viewer), then you should be able to launch your
perl/Tk app.

Good luck,
brian
Ed Jay

2007-03-13, 10:04 pm

brian scribed:

>Ed Jay wrote:
>
>
>
>Yes. If you can launch IrfanView (don't really know what that is, but
>assuming some sort of image viewer), then you should be able to launch your
>perl/Tk app.
>
>Good luck,
>

Thanks, Brian. I recognize as you say, but can other users launch the Tk app
via my s/w command and can my code populate the Tk app with the image my
user downloads? (Irfan is a free image viewer.)
--
Ed Jay (remove 'M' to respond by email)
QoS@domain.invalid.com

2007-03-13, 10:04 pm


Ed Jay <edMbj@aes-intl.com> wrote in message-id:
<g43ev2hq0aboekaqm7qjarrk2o4dab634i@4ax.com>
>
>brian scribed:
>
>Thanks, Brian. I recognize as you say, but can other users launch the Tk app
>via my s/w command and can my code populate the Tk app with the image my
>user downloads? (Irfan is a free image viewer.)
>--
>Ed Jay (remove 'M' to respond by email)


I am not clear on this; are you aiming to create an image viewer?
Or do you want remote computers to start your Tk app press go and
receive data from a server which will be displayed in the client?

If either of these cases is what your after then, yes it can do it.



Ed Jay

2007-03-13, 10:04 pm

QoS@domain.invalid.com scribed:

>
>Ed Jay <edMbj@aes-intl.com> wrote in message-id:
><g43ev2hq0aboekaqm7qjarrk2o4dab634i@4ax.com>
>
>I am not clear on this; are you aiming to create an image viewer?
>Or do you want remote computers to start your Tk app press go and
>receive data from a server which will be displayed in the client?
>
>If either of these cases is what your after then, yes it can do it.
>

Yes and yes. Thanks...off to the books. I'll be back...you may safely bet on
it. :-)
--
Ed Jay (remove 'M' to respond by email)
zentara

2007-03-14, 7:07 pm

On Tue, 13 Mar 2007 11:33:33 -0700, Ed Jay <edMbj@aes-intl.com> wrote:

>I'm fairly new to Perl, and just discovered Perl.Tk. Before I take the leap
>into Tk, I want to know if I'm wasting my time trying to resolve an issue.
>
>My users are using a web-based application to evaluate images uploaded by
>others. I don't want the images to display in the user's browser. I want to
>download selected images and have them appear in a window removed from the
>browser. Can I craft a widget and program my web app such that the images
>appear in the widget?
>
>I use Opera and have it set up so that downloaded images launch IrfanView. I
>don't expect all my users to use Opera, so I'm sing an alternative.
>
>All I'm looking for is a Yes/No answer to my question.
>
>TIA,


If I follow your idea correctly, you want to make an image viewer with
Tk, that you can launch as a helper application. That would be easy,
just pass the file as %1 (or whatever Opera uses) to the Tk script.

There is a trick which you may or may-not have to use.
Tk likes it's images base64-encoded. If you read from a disk
file, it encodes it automatically. But if it's an inline file
(say passed in on the command line as %1), you will
need to base64encode it.

Here is a simple example. If you need help passing the
%1 filename into Tk, let us know.

#!/usr/bin/perl -w
use strict;
use Tk;
use Tk::JPEG; #take jpegs, gif, or png
use Tk::PNG; #gif is a built in
use LWP::Simple;
use MIME::Base64;

my $URL = 'http://zentara.net/2uni2.jpg';
# here the browser may pass the binary in as %1
my $content = encode_base64(get($URL)) or die $!;

my $mw = MainWindow->new();
my $image = $mw->Photo(-data => $content);
$mw->Label(-image => $image)->pack(-expand => 1, -fill => 'both');
$mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
MainLoop;
########################################
##################################33
#1 liner
# perl -MLWP::Simple -MMIME::Base64 -MTk -MTk::JPEG -e '$mw=tkinit;
# $mw->Label(-image => $mw->Photo(-data =>
# encode_base64(get(shift))))->pack;MainLoop'
# http://...whatever

__END__

zentara


--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
Ed Jay

2007-03-14, 7:07 pm

zentara scribed:

>On Tue, 13 Mar 2007 11:33:33 -0700, Ed Jay <edMbj@aes-intl.com> wrote:
>
>
>If I follow your idea correctly, you want to make an image viewer with
>Tk, that you can launch as a helper application.


Exactly.

> That would be easy,
>just pass the file as %1 (or whatever Opera uses) to the Tk script.


I'm trying to not limit it to Opera, but make it universal with a script.

What I'm dealing with is a multi-page form in which the user answers
questions pertaining to an image (like a CT-Scan image). The image needs to
be large (likely full screen on a second monitor), so I can't include it on
the same page as the form questions. My users are medical professionals
using the full spectrum of browsers. They can't be expected to install a
helper app, nor configure their browsers to accommodate the need. Hence, the
entire task has to be performed for them with scripting.
>
>There is a trick which you may or may-not have to use.
>Tk likes it's images base64-encoded. If you read from a disk
>file, it encodes it automatically. But if it's an inline file
>(say passed in on the command line as %1), you will
>need to base64encode it.


Thanks. Good to know!
>
>Here is a simple example. If you need help passing the
>%1 filename into Tk, let us know.
>
>#!/usr/bin/perl -w
>use strict;
>use Tk;
>use Tk::JPEG; #take jpegs, gif, or png
>use Tk::PNG; #gif is a built in
>use LWP::Simple;
>use MIME::Base64;
>
>my $URL = 'http://zentara.net/2uni2.jpg';
># here the browser may pass the binary in as %1
>my $content = encode_base64(get($URL)) or die $!;
>
>my $mw = MainWindow->new();
>my $image = $mw->Photo(-data => $content);
>$mw->Label(-image => $image)->pack(-expand => 1, -fill => 'both');
>$mw->Button(-text => 'Quit', -command => [destroy => $mw])->pack;
>MainLoop;
> ########################################
##################################33
>#1 liner
># perl -MLWP::Simple -MMIME::Base64 -MTk -MTk::JPEG -e '$mw=tkinit;
># $mw->Label(-image => $mw->Photo(-data =>
># encode_base64(get(shift))))->pack;MainLoop'
># http://...whatever
>
>__END__
>

Thanks very much for the pointers and the helpful attitude.
--
Ed Jay (remove 'M' to respond by email)
smallpond

2007-03-14, 7:07 pm

On Mar 14, 10:11 am, Ed Jay <e...@aes-intl.com> wrote:
> zentara scribed:
>
>
>
>
>
>
>
>
>
>
> Exactly.
>
>
> I'm trying to not limit it to Opera, but make it universal with a script.
>
> What I'm dealing with is a multi-page form in which the user answers
> questions pertaining to an image (like a CT-Scan image). The image needs to
> be large (likely full screen on a second monitor), so I can't include it on
> the same page as the form questions. My users are medical professionals
> using the full spectrum of browsers. They can't be expected to install a
> helper app, nor configure their browsers to accommodate the need. Hence, the
> entire task has to be performed for them with scripting.
>
>
>
>
> Thanks. Good to know!
>
>
>
>
>
>
>
>
> Thanks very much for the pointers and the helpful attitude.
> --
> Ed Jay (remove 'M' to respond by email)


Ed-
There should be no way to run a program on your local machine
from a web page without adding some kind of extension to the
browser. If there were, it would be a security hole.
In firefox, it's fairly easy to define a new MIME type and
add a helper - which could get you your IrfanView solution
or a perl/Tk viewer. Not sure about IE.

One way would be to have the viewer running and provide a
URL on the webpage which can be copy-n-pasted to a text box
on the viewer. The viewer would then download the file and
display it.
-- S

QoS@domain.invalid.com

2007-03-14, 7:07 pm


"smallpond" <smallpond@juno.com> wrote in message-id:
<1173894880.201609.43260@d57g2000hsg.googlegroups.com>
>
>On Mar 14, 10:11 am, Ed Jay <e...@aes-intl.com> wrote:
>
>Ed-
>There should be no way to run a program on your local machine
>from a web page without adding some kind of extension to the
>browser. If there were, it would be a security hole.
>In firefox, it's fairly easy to define a new MIME type and
>add a helper - which could get you your IrfanView solution
>or a perl/Tk viewer. Not sure about IE.
>
>One way would be to have the viewer running and provide a
>URL on the webpage which can be copy-n-pasted to a text box
>on the viewer. The viewer would then download the file and
>display it.
>-- S


yeah imho..
forget the browser and forget the webserver.
just make a client / server application.

the client app should present the form and send the form data
to the server; it should also be able to connect to the server
and display any data sent from the server (e.g. images)

the server app should be able to receive and record data sent
from the client application, and send the client data.

then you just have to get the users to download & install
your client application.

not so much really, good luck!


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com