Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

How do I get Tk to display on a remote computer?

by @ncientgoose (Novice)
on Aug 10, 2002 at 16:42 UTC ( [id://189197]=perlquestion: print w/replies, xml ) Need Help??

@ncientgoose has asked for the wisdom of the Perl Monks concerning the following question:

I am a beginner with the Tk set of modules, and I am realizing that I cannot get the Tk MainWindow to display in a browser (probably because the code is not parsed for http protocol). I am getting this message in my error file when I try to call the script with my browser:
couldn't connect to display ":0" at /usr/lib/perl5/site_perl/5.6.0/i38 +6-linux/Tk/MainWindow.pm line 5 . MainWindow->new() at newTk.cgi line + 6


Is this :0 the UNIX device name? I've heard that it can append an IP address of a remote host like 123.56.257.2:0. Is that also incorrect. I'm lost and any guidance is much appreciated.
Thanks,
@ncientgoose

Replies are listed 'Best First'.
Re: How do I get Tk to display on a remote computer?
by chromatic (Archbishop) on Aug 10, 2002 at 17:09 UTC

    Tk is a GUI library used for writing applications that need a local display (though remote X connections are available through X11 forwarding, as you have heard). It sounds as if you've written a program to be executed from a web server, which will output data to be displayed in a web browser.

    In other words, I could rephrase your question as "I have a Perl CGI program on my web server that launches a web browser on the server. I cannot see that web browser running in my web browser on my client." The answer to that is, "That's true. It doesn't work that way."

    Does that make sense?

      Yes I do see what you mean. When I started with Tk, I thought that it didn't require a local display, but could be sent to a client browser. Do you know of a module that allows the manipulation of buttons and such for a web browser. I really don't want to use java instead.
      Thanks,
      @ncientgoose

        That's also a hard question to answer, for much the same reason. The way a program running on the server communicates with the client is by sending a chunk of data back to the client. The client decides what to do with that data.

        There are ways to return HTML, XML, CSS, JavaScript, Java, and even Flash to the client, but you're at the mercy of the client as to what it will and will not accept. In a tightly controlled environment, you can use client-side Perl Script, but it sounds like server-side Perl, by itself, is not the right solution for you.

Re: How do I get Tk to display on a remote computer?
by Nitrox (Chaplain) on Aug 10, 2002 at 16:49 UTC
    Try: export DISPLAY=<remote machine>:0. on the server.

    The remote machine will also need to be xhost+ (bad idea) or have the server name listed in X.0

    -Nitrox

      Another option might be to use X forwarding over SSH. If X forwarding is enabled on the server, it should be no problem. Check the man page, and this link here.


      _______________
      DamnDirtyApe
      Those who know that they are profound strive for clarity. Those who
      would like to seem profound to the crowd strive for obscurity.
                  --Friedrich Nietzsche

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://189197]
Approved by Courage
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (4)
As of 2025-11-12 21:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (68 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.