X

News, tips, partners, and perspectives for the Oracle Solaris operating system

Running GUIs From A Zone

Guest Author

Zones in OpenSolaris are pretty svelte. If you've been given an OpenSolaris zone to work with you'll most likely need to add additional software to do much of anything. In this blog I'm going to look at running GUIs. For my test case I'll use this simple Python application:

bleonard@myzone:~$ cat gui.py
from Tkinter import Label
widget = Label(None, text='Hello GUI world!')
widget.pack()
widget.mainloop()

If you try to run it from a zone:

bleonard@myzone:~$ python gui.py
Traceback (most recent call last):
File "gui.py", line 1, in ?
from Tkinter import Label
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 38, in ?
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: ld.so.1: isapython2.4: fatal: libX11.so.4: open failed: No such file or directory

The problem here is that we need the X Window System software, which is not installed:

 bleonard@myzone:~$ pkg info -r SUNWxwplt
Name: SUNWxwplt
Summary: X Window System platform software
Category: System/X11
State: Not installed
Publisher: opensolaris.org
Version: 0.5.11
Build Release: 5.11
Branch: 0.111
Packaging Date: Fri May 8 16:45:51 2009
Size: 14.34 MB
FMRI: pkg:/SUNWxwplt@0.5.11,5.11-0.111:20090508T164551Z
bleonard@myzone:~$ pfexec pkg install SUNWxwplt
DOWNLOAD PKGS FILES XFER (MB)
Completed 29/29 6447/6447 93.98/93.98
PHASE ACTIONS
Install Phase 7846/7846

Let's see if the GUI application works now:

bleonard@myzone:~$ python gui.py
Traceback (most recent call last):
File "gui.py", line 2, in ?
widget = Label(None, text='Hello GUI world!')
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 2397, in __init__
Widget.__init__(self, master, 'label', cnf, kw)
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1856, in __init__
BaseWidget._setup(self, master, cnf)
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1831, in _setup
_default_root = Tk()
File "/usr/lib/python2.4/lib-tk/Tkinter.py", line 1569, in __init__
self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
_tkinter.TclError: no display name and no $DISPLAY environment variable

Ah, now we're having a problem with the display settings. This is easily resolved by using the -X option when we ssh into the zone to enable X11 forwarding:

bleonard@opensolaris:~$ ssh -X bleonard@10.0.1.196
Password:
Last login: Sat Sep 19 09:14:22 2009 from 10.0.1.9
Sun Microsystems Inc. SunOS 5.11 snv_111b November 2008
bleonard@myzone:~$  

And alas we can now see our elaborate GUI:

bleonard@myzone:~$ python gui.py &
[1] 5952



Join the discussion

Comments ( 1 )
  • andrewk7 Thursday, May 27, 2010

    I got individual X apps working too, but I couldn't find a way to get a zone to serve up an X desktop - is this possible?


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.