Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Tk OSX couldn't connect to display :0

by Washizu (Scribe)
on Nov 26, 2006 at 18:06 UTC ( #586134=perlquestion: print w/ replies, xml ) Need Help??
Washizu has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to run a Perl/Tk app on Mac OSX 10.4.8 (Tiger) and ran into an error message when I tried to create a new MainWindow object.
couldn't connect to display ":0" at usr/local/ActivePerl-5.8/lib/Tk/Ma +inWindow.pm line 55
So I tried a the basic MainWindow example script and came up with the same error.
use Tk; # Main Window my $mw = new MainWindow; my $label = $mw -> Label(-text=>"Hello World") -> pack(); my $button = $mw -> Button(-text => "Quit", -command => sub { exit }) -> pack(); MainLoop;
The Tk module is up to date, so I'm not sure what is going on here Any ideas?

-----------------------------------
Washizu
Odd Man In: Guns and Game Theory

Comment on Tk OSX couldn't connect to display :0
Select or Download Code
Re: Tk OSX couldn't connect to display :0
by neniro (Priest) on Nov 26, 2006 at 18:47 UTC
    Start your X11.app first.

    EDIT:If you work in a terminal-window you can type open /Applications/Utilities/X11.app/ to start the X11.app.

      Thanks for your help. I thought X11 was installed, because when I tried to install it from apple's site it said I already had it. It turned out I had to install it from the installation DVD and now it works. Of course, my app doesn't run exactly right but it at least runs now!

      -----------------------------------
      Washizu
      Odd Man In: Guns and Game Theory

Re: Tk OSX couldn't connect to display :0
by Fletch (Chancellor) on Nov 26, 2006 at 18:56 UTC

    Aside from making sure that X11.app is running, check that you can run another X program from a Terminal window (say xterm and/or xhost). Some things can confuzzle the xauth authentication, such as disappearing network connections (disconnecting from a WiFi network, or disconnecting a modem connection).

      Indeed.

      I don't recall if it's actually necessary on OSX, but some time ago I ended up putting the following in my .profile or .bashrc so I never have to think about it ever again:

      export DISPLAY=localhost:0.0


      --chargrill
      s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; = qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)

        Which could be OK in your case, but if you use ssh and X forwarding, your exported DISPLAY will overwrite the special one that ssh gave you.
        The result will be that your X app will try to run on the machine that you ssh'd to instead of the machine that you ssh'd from.
        Usually not what you want.

        non-Perl: Andy Ford

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (11)
As of 2014-08-21 14:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (136 votes), past polls