Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

How to interpret this Perl Tk.pm error?

by newbie00 (Beadle)
on Dec 13, 2001 at 23:53 UTC ( [id://131730]=perlquestion: print w/replies, xml ) Need Help??

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

Hello.

I wrote a test scipt that uses the Tk.pm module on a server. I am just beginning to find uses for what Tk.pm has to offer.

The script is:

#!/usr/bin/perl use Tk; $win_main = MainWindow->new(); $win_main->title ("Main Window"); $button = $win_main->Button(text => 'OK', width => 10, height => 4); $button->pack(); MainLoop();

When I invoked the script, I received the following message:

~~~~~~~~~~~~~~~~
_X11TransSocketUNIXConnect: Can't connect: errno = 2
_X11TransSocketUNIXConnect: Can't connect: errno = 2
_X11TransSocketUNIXConnect: Can't connect: errno = 2
_X11TransSocketUNIXConnect: Can't connect: errno = 2
_X11TransSocketUNIXConnect: Can't connect: errno = 2
_X11TransSocketUNIXConnect: Can't connect: errno = 2
couldn't connect to display ":0" at
../foo_path/5.005/i386-bsdos/Tk/MainWindow.pm line 55.
MainWindow->new() at testtk.cgi line 4

(notice - the path was changed here to a generic path)
~~~~~~~~~~~~~~~~
The reply I received from the sys admin was the following:

"That error signifies that the script can not connect to the Unix Xwindows system that you are logging in from. You do not have $DISPLAY set up properly in your .Xauth or rc files."
~~~~~~~~~~~~~~~~

How do I do whatever this response is telling me to do in order to use Tk.pm?

Thank you.

Replies are listed 'Best First'.
Re: How to interpret this Perl Tk.pm error?
by Rich36 (Chaplain) on Dec 14, 2001 at 00:07 UTC
    Try setting your shell variable $DISPLAY as your ip address. Find out your IP address (for example 123.12.342.12) and use the following syntax. This tells the system what terminal or machine to display the GUI/Tk elements. If you're running on a PC using a emulator, you can open a DOS command shell and type "ipconfig" to get your IP. On a UNIX box, you can use your hostname instead of the IP address.
    # C shell syntax setenv DISPLAY 123.12.342.12:0

    Rich36
    There's more than one way to screw it up...

      Thank you for your reply.

      I guess I have a misconception about the Tk.pm module.

      After reading about its features, I was under the impression that this module could be used to add graphics to my scipts so that anyone who invokes a script that uses Tk.pm will all see the graphics.

      Based on the responses, it appears that 'individual' computer terminals must set a parameter on their computer in order to see the graphics, which is why I have to set the '$Display' parameter on my computer to my IP address. Is this correct?

      If so, is there another way to integrate graphics into Perl scripts via a 3rd party software program or other method?

      Thank you. --newbie00

Re: How to interpret this Perl Tk.pm error?
by Zaxo (Archbishop) on Dec 14, 2001 at 00:18 UTC

    Your test script runs fine locally. Are you sure that you want to open an X connection through a cgi interface? I hope not.

    Typically, one would open a remote X session through 'ssh -X host' with proper authentication all round.

    After Compline,
    Zaxo

      Thank you for your reply. I do not know what 'X session' or a 'ssh -X host' or '.Xauth' or 'rc files' are, therefore I cannot answer your question.

      Shown below, is my reply to someone who just replied to my question. Maybe this can shed some more light on my 'newbie-knowledge' or lack thereof.

      I am open for alternative methods for using this module if those methods are available. I am also open to other alternatives if this module is not for what I am seeking for my scripts. Here is my reply to the other reply I received:
      ~~~~~~~~~~~~~~~~

      "I guess I have a misconception about the Tk.pm module.

      After reading about its features, I was under the impression that this module could be used to add graphics to my scipts so that anyone who invokes a script that uses Tk.pm will all see the graphics.

      Based on the responses, it appears that 'individual' computer terminals must set a parameter on their computer in order to see the graphics, which is why I have to set the '$Display' parameter on my computer to my IP address. Is this correct?

      If so, is there another way to integrate graphics into Perl scripts via a 3rd party software program or other method?"
      ~~~~~~~~~~~~~~~

      Thank you. --newbie00

        Tk allows you to write perl programs with a graphical user interface - you know, buttons to click, entry fields to type in text - a nice 'point and click' interface. Is this what you want to do?

        If you really do just want to 'add graphics' to your scripts I think additional information is necessary. What sort of graphics do you want to add? For charts and graphs you might want to check out the GD.pm module.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-20 02:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found