Re: Tkinter problem: TclError> couldn't connect to display ":0

2016-02-05 Thread Dave Farrance
gemjack...@gmail.com wrote:

>This fixed my problem with thkinter.   sudo cp ~/.Xauthority ~root/

Which means that you were creating a GUI window with Python as root,
which is to be avoided if you can. If you can't avoid it and you're
running it with sudo in a bash console, rather than a root console, then
I'd suggest adding the line...

XAUTHORITY=$HOME/.Xauthority

...to the root's .bashrc which avoids putting a specific user's
xauthority file in the root directory.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError> couldn't connect to display ":0

2016-02-04 Thread gemjack . pb
On Sunday, 29 December 2013 20:20:00 UTC, Michael Matveev  wrote:
> Hi,
> I use live Debian on VM and trying to compile this code.
> 
> 
> import Tkinter
>  
> root = Tkinter.Tk()
>  
> root.title("Fenster 1")
> root.geometry("100x100")
>  
> root.mainloop()
> 
> 
> The shell gives out that kind of message:
> 
> File "test.py", line 5, in 
> root = Tkinter.Tk()
> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1712, in __init__
> self.tk = _tkinter.create(screenName, baseName, className, interactive, 
> wantobjects, useTk, sync, use)
> _tkinter.TclError: couldn't connect to display ":0"
> 
> 
> 
> thanks for helping out.
> 
> greets.
> Mike

This fixed my problem with thkinter.   sudo cp ~/.Xauthority ~root/
-- 
https://mail.python.org/mailman/listinfo/python-list


Tkinter problem: TclError couldn't connect to display :0

2013-12-29 Thread Michael Matveev
Hi,
I use live Debian on VM and trying to compile this code.


import Tkinter
 
root = Tkinter.Tk()
 
root.title(Fenster 1)
root.geometry(100x100)
 
root.mainloop()


The shell gives out that kind of message:

File test.py, line 5, in module
root = Tkinter.Tk()
File /usr/lib/python2.7/lib-tk/Tkinter.py, line 1712, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, 
wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display :0



thanks for helping out.

greets.
Mike
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError couldn't connect to display :0

2013-12-29 Thread Chris Angelico
On Mon, Dec 30, 2013 at 7:20 AM, Michael Matveev
misch...@googlemail.com wrote:
 The shell gives out that kind of message:

 File test.py, line 5, in module
 root = Tkinter.Tk()
 File /usr/lib/python2.7/lib-tk/Tkinter.py, line 1712, in __init__
 self.tk = _tkinter.create(screenName, baseName, className, interactive, 
 wantobjects, useTk, sync, use)
 _tkinter.TclError: couldn't connect to display :0

Worked for me on an installed Debian, inside Xfce with xfce4-terminal.

1) What version of Python are you running?
2) Are you running inside some kind of graphical environment?
3) Do you have any sort of permissions/environment change happening? I
get an error like that if I try sudo python without any sort of
guard.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError couldn't connect to display :0

2013-12-29 Thread Steven D'Aprano
Michael Matveev wrote:

 Hi,
 I use live Debian on VM and trying to compile this code.
 
 
 import Tkinter
  
 root = Tkinter.Tk()
  
 root.title(Fenster 1)
 root.geometry(100x100)
  
 root.mainloop()
 
 
 The shell gives out that kind of message:
 
 File test.py, line 5, in module
 root = Tkinter.Tk()
 File /usr/lib/python2.7/lib-tk/Tkinter.py, line 1712, in __init__
 self.tk = _tkinter.create(screenName, baseName, className, interactive,
 wantobjects, useTk, sync, use) _tkinter.TclError: couldn't connect to
 display :0


Are you using ssh to connect to the system? If I create a file and run it
directly from the machine I am physically sitting at, it works fine and the
window is displayed as expected:

[steve@ando ~]$ cat test.py
import Tkinter
root = Tkinter.Tk()
root.title(Fenster 1)
root.geometry(100x100)
root.mainloop()
[steve@ando ~]$ python2.7 test.py
[steve@ando ~]$


But if I ssh to the machine, I get an error (although a different error from
you):

steve@orac:~$ ssh ando
steve@ando's password:
Last login: Thu Dec 12 19:27:04 2013 from 203.7.155.68
[steve@ando ~]$ python2.7 test.py
Traceback (most recent call last):
  File test.py, line 2, in module
root = Tkinter.Tk()
  File /usr/local/lib/python2.7/lib-tk/Tkinter.py, line 1685, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable


If I set the $DISPLAY environment variable, it works for me:

[steve@ando ~]$ export DISPLAY=:0
[steve@ando ~]$ python2.7 test.py
[steve@ando ~]$ logout
Connection to ando closed.

But ando is the machine I am physically seated at, so it's not surprising
that I can see the window on the X display. If I go the other way, and try
to run the code on orac (the remote machine), I get the same error as you:

steve@orac:~$ export DISPLAY=:0
steve@orac:~$ python2.6 test.py
No protocol specified
Traceback (most recent call last):
  File test.py, line 2, in module
root = Tkinter.Tk()
  File /usr/lib/python2.6/lib-tk/Tkinter.py, line 1646, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive,
wantobjects, useTk, sync, use)
_tkinter.TclError: couldn't connect to display :0


So you need to X-forward from the remote machine to the machine you are
physically on, or perhaps it's the other way (X is really weird). I have no
idea how to do that, but would love to know.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError couldn't connect to display :0

2013-12-29 Thread Chris Angelico
On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 So you need to X-forward from the remote machine to the machine you are
 physically on, or perhaps it's the other way (X is really weird). I have no
 idea how to do that, but would love to know.

With SSH, that's usually just ssh -X target, and it'll mostly work.
But there are potential issues with .Xauthority, which is why the sudo
example fails.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError couldn't connect to display :0

2013-12-29 Thread Steven D'Aprano
On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote:

 On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 So you need to X-forward from the remote machine to the machine you are
 physically on, or perhaps it's the other way (X is really weird). I
 have no idea how to do that, but would love to know.
 
 With SSH, that's usually just ssh -X target, and it'll mostly work.

Holy cow, it works! Slwly, but works.


steve@runes:~$ ssh -X ando.pearwood.info
st...@ando.pearwood.info's password: 
Last login: Mon Dec 30 10:10:13 2013 from orac
[steve@ando ~]$ python2.7 test.py 
[steve@ando ~]$ 


-- 
Steven
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError couldn't connect to display :0

2013-12-29 Thread Chris Angelico
On Mon, Dec 30, 2013 at 2:29 PM, Steven D'Aprano st...@pearwood.info wrote:
 On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote:

 On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info wrote:
 So you need to X-forward from the remote machine to the machine you are
 physically on, or perhaps it's the other way (X is really weird). I
 have no idea how to do that, but would love to know.

 With SSH, that's usually just ssh -X target, and it'll mostly work.

 Holy cow, it works! Slwly, but works.


 steve@runes:~$ ssh -X ando.pearwood.info
 st...@ando.pearwood.info's password:
 Last login: Mon Dec 30 10:10:13 2013 from orac
 [steve@ando ~]$ python2.7 test.py
 [steve@ando ~]$

On a LAN, it's not even slow! I've actually run VLC through ssh -X and
watched a DVD that was in a different computer's drive. That was fun.

You can even get a Windows X server and run Linux GUI programs on a
Windows client. *Very* useful if you're working with both types of
computer.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Tkinter problem: TclError couldn't connect to display :0

2013-12-29 Thread Jason Swails
On Sun, Dec 29, 2013 at 10:29 PM, Steven D'Aprano st...@pearwood.infowrote:

 On Mon, 30 Dec 2013 10:30:11 +1100, Chris Angelico wrote:

  On Mon, Dec 30, 2013 at 10:22 AM, Steven D'Aprano
  steve+comp.lang.pyt...@pearwood.info wrote:
  So you need to X-forward from the remote machine to the machine you are
  physically on, or perhaps it's the other way (X is really weird). I
  have no idea how to do that, but would love to know.
 
  With SSH, that's usually just ssh -X target, and it'll mostly work.

 Holy cow, it works! Slwly, but works.


I usually use ssh -Y.  The -Y argument toggles trusted forwarding.  From
the ssh man-page:

 -Y  Enables trusted X11 forwarding.  Trusted X11 forwardings are
not subjected to the X11
 SECURITY extension controls.

I've found -Y is a bit faster than -X in my experience (I've never really
had many problems with X-forwarding on LANs in my experience -- even with
OpenGL windows)
-- 
https://mail.python.org/mailman/listinfo/python-list