Running GUIs From A Zone

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



Comments:

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?

Posted by andrewk7 on May 27, 2010 at 08:34 AM GMT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

The Observatory is a blog for users of Oracle Solaris. Tune in here for tips, tricks and more as we explore the Solaris operating system from Oracle.

Connect with Oracle Solaris:


Search

Archives
« July 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today