Wxploop And Loopset Part 1: Starting To Use Wxploop

  1. Introduction
  2. Create And Remove A Wxploop Process And Window
  3. Communication With Wxploop Using Loopset
  4. Ways To Create Wxploop Windows
  5. Overall Tutorials Table Of Contents

1. Introduction

This tutorial deals with opening a wxploop window and discusses how to communicate with a wxploop process using the program loopset. We will display a surface contour plot in a window as part of the tutorial.

The next tutorial builds on the basic wxploop commands introduced in this tutorial, but concentrates on getting multiple plots as overlays, and in creating loops for animation.

Before starting this tutorial, there are a few things to know. You will need to know where the data is stored at your site, and how to set your UDRESPATH environment variable. It would help to be familiar with the resources that are held in the site Wxp.res file, and in how to use the WXP Interactive Shell. Knowledge of using WXP programs from the command line will be required. These points are covered in previous tutorials:

If the WXP software resides on a remote machine, you should set your DISPLAY environment variable to your current terminal.

To get the most out of this tutorial, please have your user's manual on hand so that you can refer to the manual pages. As new options are introduced, we will refer to the manual pages for explanations. This process will show how information can be retrieved from the manual.

Notation: In the text below, the percent sign % refers to the system prompt. You will see a similar prompt in your working window. You should type any text following the % sign at your system prompt; you then hit return on the keyboard to enter the command. Text on the lines immediately following will show the expected response to your action. Where the next line starts with the % sign in the text below, type that line at your system prompt.

2. Create And Remove A Wxploop Process And Window

The wxploop program allows us to display simple images from other WXP programs, do overlays, and create loops for animation. Turn to the pages for the wxploop program in the WXP Program Reference section of the manual before proceeding. You will want to refer to the list of wxploop commands there.

If we start wxploop, we will create a wxploop process on our workstation. No window will be displayed at this time. The following command will start a wxploop process and background it using the & sign:

   % wxploop &
   [1] 22401

       WXP LOOP PROGRAM (VERSION:2.4-4.6-X11)
and hit return

The return gets the unix prompt back. An error message may occur on invoking wxploop:

   % wxploop &
   Unable to create message queue
   Either another wxploop program is using this queue
   or it has not been deleted (use "ipcrm -q 601")
This means that another wxploop process is using the same window number We'll discuss window numbers later. To remove the queue and thus be able to invoke wxploop, follow the instruction from the error message:

   % ipcrm -q 601
The number 601 is specific to the previous wxploop process. This number changes with each invocation of wxploop. If you had to perform this command, go ahead now and invoke a wxploop process by typing:

   % wxploop &
   [1] 22416

       WXP LOOP PROGRAM (VERSION:2.4-4.6-X11)
Now, how do we get a window to appear associated with wxploop? The above command created a wxploop process with process ID 22416. You can also use the following command to find the process ID:

   % ps -guax | grep wxploop
which returns:

   user  22416  0.0  0.9  296  872 q3 S    14:24   0:00 wxploop
   user  22441  0.0  0.3   40  240 q3 S    14:25   0:00 grep wxploop
The process ID for the wxploop program above is 22416. Note that the grep command also has a process ID. It is useful to know about the ID because occasionally, wxploop processes get hung up and need to be deleted. To remove the process, type:

   % kill 22416
which returns:

   [1]    Done                 wxploop
and then type:

   % ps -guax | grep wxploop
   user  22557  0.0  0.3   40  256 q3 S    14:29   0:00 grep wxploop
So, to start a wxploop again, type:

   % wxploop &
   [1] 22588

       WXP LOOP PROGRAM (VERSION:2.4-4.6-X11)

   (hit return)
The wxploop process has a window number associated with it, 0 in this case by default. Window numbers will become clearer in a moment so bear with us. If we now type the command:

   % loopset open
a window pops up on the screen with the title wxploop. This happens because when wxploop started up, it created a message queue to window 0 (the default window). The program loopset uses this message queue to pass commands to the wxploop process running window 0. The command open is a wxploop command that loopset sends to wxploop. A list of commands can be found in the wxploop program pages of the Program Reference.

To get a short listing of available commands, type the following:

   % loopset

   Message queue opened (id:1103)
   Connected to WXPloop program
      Type help for help
We enter help at the Message:1: prompt

   Message:1: help
and the following listing of commands is displayed:

   Help for wxploop program parameter setting
   Keywords         Remarks
   --------         -------
   status           check wxploop status
   list {type}      list out current pixmap info
   loop             start/stop looping
   step             step through images
   next             step through images
   for              step forward to next image
   back             step backward to next image
   goto {image}     go to a specific image
   set re {region}  specify region parameter
   set dir for      specify forward increment loop
   set dir back     specify backward increment loop
   set delay {time} specify loop delay time
   set pause {time} specify end of loop delay time
   ti ba {ti}       specify base image title
   ti ov {num} {ti} specify overlay num image title
   ti {num} {ti}    title an image num as title
   que {spec}       inquires current loop specifications
   add {file}       add a pixmap file to the loop
   add {file} {ti}  add a pixmap file with title specified
   cr {pix}         add a new pixmap to end of loop
   in {num} {pix}   insert a new pixmap into loop
   ld {num} {file} {ti} load a pixmap file on existing pixmap
   over {num} {file} overlay a pixmap file on existing pixmap
   del {image}      delete a specific image number
   help             display this help screen
   quit             exit loopset
   exit             exit loopset
   kill             terminate wxploop program
This list is a small section of the total wxploop commands shown in the wxploop section of the WXP program reference.

To get rid of the window and kill the wxploop process, we type:

   % loopset kill
which returns:

   WXPloop stopped!!

   [1]    Done                 wxploop
The process is stopped, and the window disappears. We can use the abrieviation k for kill. Backgrounding the process is slow, so we can set up wxploop to automatically background by using the batch option. Type the following commands:

   % wxploop -batch
   % loopset open This_Window
In this case, the unix prompt comes back after wxploop and the window opened by loopset now has the name This_Window. The underscore is required to make one character string from two words when using loopset. Now remove the window:

   % loopset k
The opening of the window This_Window can be achieved on a single line with wxploop by using the command option of wxploop. Type the following command:

   % wxploop -batch -command "open This_Window"
Note that the command set "open This_Window" must be within double quotes to associate the set with the command option.

To remove the window type:

   % loopset k
We mentioned that the window number of 0 is the default assignment. wxploop sets up a window number associated with the process. We can specify what that number should be using the window_num option. Type the following:

   % wxploop -batch -window_num 4 -command "open This_Window"
then type:

   % loopset k
    WXPloop program not running or no message queue exists
An error message has been returned. To see why, we examine the wxploop command line. The option -command "open This_Window" specifies the opening of a window with title This_Window. The option -window_num 4 specifies wxploop to open a window with id#4 to which the title This_Window is assigned. The batch means do all of the above before backgrounding the process and returning the system prompt. The error comes from the fact that no window number is specified with the loopset k command, and so loopset defaults to look for window 0.

To get rid of the window, we must now type:

   % loopset -window_num 4 k
Thus, we see that loopset is a means of communicating with wxploop. It allows us to pass commands that we want performed by wxploop. The window_num option gives us a specific wxploop process to address if more than one invocation of wxploop is running.


3. Communication With Wxploop Using Loopset

Once a wxploop process is running, you can open a window and then change items in wxploop using the loopset command in the format:

   % loopset -window_num < num > < wxploop command >

   % loopset -window_num < num > "< wxploop command;wxploop command;... > "
The window_num is required if the wxploop process was set at a number other than the default 0, or if you are running more than one wxploop window from your account.

Commands can be strung together using semicolons, but the whole string must be within quotes because of stringing more than one command. An example:

   % wxploop -batch
   % loopset "open;query window"
   Window opened with name: wxploop
The number returned is the window ID. This ID is returned by the server therefore you will see a different number. More on this type of notation later when we are better aquainted with wxploop. But for now, we can show a plot by typing the command:

   % sfccalc -current la -device w,,13631499
which brings up the WXP shell requesting that you choose variable, etc. Note that we use device with the ending w,,13631499 where the number is the ID returned on opening the wxploop window above. After you select the various options you want to view, a sfccalc plot will appear in the wxploop window.

The next tutorail discusses the ID process that allows you to create overlays and animation.


   % loopset k

4. Ways To Create Wxploop Windows

We need to set up some resources to allow us to go on with the tutorial. First, add the following line to your personal Wxp.res file in your home directory:

demo.geometry: 800x600+10+10
Second, wxploop has a geometry default of 640x512 with cursor placement. If you always want default to be a certain size and position, you can set it in the Wxp.res file with a line such as:

wxploop.geometry: 800x600+200+200
which is of the form:

< resource name > .geometry: WxH+X+Y 
where the window is width W by height H, placed at position X,Y away from the top left corner of the screen which is considered 0,0.

We now look at four general ways to open windows and then discuss which of the four to use, concluding with a brief caution note. The next six subsections are:

Simple Use Of Wxploop Command open

Open a window as we did earlier in this tutorial. Typing either:

   % wxploop -batch 
   % loopset open This_Window

   % wxploop -batch -command "open This_Window"
will open a window This_Window at the position 800x600+200+200 on the screen. In this case, the wxploop program is getting the geometry information from the wxploop.geometry line we put in the Wxp.res file. To remove the window, type:

   % loopset k

Use Of The title Option

We can use the title option on the command line of wxploop to set the title of the window by typing:

   % wxploop -batch -title "This Window"
   % loopset open

   % wxploop -batch -title "This Window" -command open
Typing loopset k will remove the window. Note that here we can write the window title without the underscore by using the title option.

Use Of Resources: The name Option

If we use the name option, we will get a window titled demo at the geometry specified in Wxp.res by typing:

   % wxploop -batch -name demo
   % loopset open

   % wxploop -batch -name demo -command open
   % wxploop -batch -command "open demo"
Either opens a window named demo.


If both name and title are on the command line, name is used to load resources and then title overrides to put the title on the window.


   % wxploop -batch -name demo -title "This Window" -command open
will produce a window with the demo geometry titled This Window.

BUT typing:

   % wxploop -batch -title "This Window"
   % loopset open demo

   % wxploop -batch -title "This Window" -command "open demo"
both give a window using the demo geometry with the title demo overriding the title option.

NOTE: COMMANDS (-command) GET PRIORITY! If you use -command "open < string > ", < string > will override any title option on the wxploop command line.

Use Of The geometry Option

Geometry can be put on the wxploop command line using the geometry option. If no geomertry option exists on the wxploop command line, wxploop will look in Wxp.res for any named resources if you use the name option. For example:

   % wxploop -batch -name demo -command open
   % loopset k
Or wxploop will use the default if no resource name is used, as below:

   % wxploop -batch -command open
   % loopset k
Default may be set using the wxploop.geometry line in the Wxp.res file. We have, infact, set this earlier in our tutorial.

If geometry is explicitly set on the command line, then it overrides all other occurrences of geometry. Thus, the following all produce the same size window and location:

   % wxploop -batch -geometry 500x500+10+10 -command open
   % loopset k

   % wxploop -batch -geometry 500x500+10+10 -title "This Window" -command open
   % loopset k

   % wxploop -batch -geometry 500x500+10+10 -name demo -command open
   % loopset k

   % wxploop -batch -geometry 500x500+10+10 -command "open demo"
   % loopset k

   % wxploop -batch -geometry 500x500+10+10 -title "Window" -command "open demo"
   % loopset k

Which Method Do I Use To Open A Window?

For a simple default window, cursor placed (if no wxploop.geometry is specified in your Wxp.res file), or in the location specified by wxploop.geometry, type:

    % wxploop -batch -command open
For a titled window at a given location, type:

    % wxploop -batch -title < title > -geometry < geom > -command open
For a window using resources and having the resources name, type:

    % wxploop -batch -name < name > -geometry < geom > -command open
For a window using resources, but with a different title, type:

    % wxploop -batch -title < title > -geometry < geom > -name < name > -command open

    % wxploop -batch -name < name > -geometry < geom > -command open
    % loopset set name < title_string >
NOTE: geometry on the command line overrides resources in Wxp.res.

A Word Of Caution

I would advise that geometry be placed only on the command line rather than using a resource via the name option. Problems can arise if the same name option is used with WXP programs that write displays to wxploop. After the second tutorial on wxploop, this point will become clear.

At this point, delete the following line from your Wxp.res file:

demo.geometry: 800x600+10+10
You may keep or delete the wxploop.geometry line in your Wxp.res file:

wxploop.geometry: 800x600+200+200

For further information about WXP from Unidata, email support@unidata.ucar.edu
Last updated by Mike Wright on July 21, 1994