Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Tk OSX couldn't connect to display :0

by Washizu (Scribe)
on Nov 26, 2006 at 18:06 UTC ( [id://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

Replies are listed 'Best First'.
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 (Bishop) 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

Re: Tk OSX couldn't connect to display :0
by Anonymous Monk on Aug 22, 2015 at 23:21 UTC
    Afte some struggle with my PTKDB perl debugger. Here is how I fix it. Get the latest download from the PERL/PTKDB team: http://ptkdb.sourceforge.net/download.html Best luck to you!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
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?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (8)
As of 2024-04-19 15:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found