================================= ``grail.ip.gview`` Module ================================= .. include:: ../../version.h .. contents:: Table of Contents :backlinks: top -------- Overview -------- GView windows are used in MineSightŪ Interactive Planner (IP) scripts to display reserves information. The GView windows are controlled by display calls in the user script, the functions defined below. ----------------------- Creating a Simple GView ----------------------- Whenever we start creating a GView we are basically using the functions defined in this module to write a file that is read by the :file:`gview.exe`. The first stages are, .. Python:: numrows = 3 numcols = 3 windownum = 1 phndl = gview.OpenStdGrid(numrows, numcols, windownum) gview.SetWinLev(phndl, 1) gview.SetWindowTitle(phndl, 'Cumulative Reserves') The important items to notice here are the :a:`windownum` and :a:`phndl`. You may want to display more than one table during your script execution, the :a:`windownum` defines which table (window) you are working with. The :a:`phndl` is used as a reference for all subsequent operations involving the insertion of data and the naming of the window title (see `How GView.exe Works`_). Now lets insert some data into the window. .. Python:: gview.SetCellValue(phndl, 1, 1, "Data") This will set the cell at row equal to 1 and column equal to 1 to contain "Data". If you wanted to insert a floating point value, you will need to format it into a string prior to calling :f:`SetCellValue`. For example, .. Python:: gview.SetCellValue(phndl, 1, 2, "%6.2f" % (10.2)) Will set the string value ' 10.20' [#python-lib-string-formatting]_. When you are done filling in your GView data, you must end your script with a close and display instructions, .. Python:: gview.CloseStdGrid(phndl) gview.DisplayStdGrid(phndl) ------------------------------ Setting GView Window Positions ------------------------------ You may position your window in a specific location using the following functions, * :f:`Stewing` * :f:`SetWinLev` * :f:`SetWinSize` ------------------- How GView.exe Works ------------------- Underneath this module there is really a call to the :file:`gview.exe`. A basic understanding of how :file:`gview.exe` works should help to make this module more informative. :file:`gview.exe` works by accepting a description file which is passed in as an argument to :file:`gview.exe` (along with an instance index). This module creates the description file and starts the :file:`gview.exe` program. :file:`gview.exe` opens the description file and looks at the index passed in. If this index exists for another :file:`gview.exe` instance it passes the description file information on to the other window for display and stops itself. If the description file does not exist then it set itself with that index and displays the information. To close all windows spawn :file:`gview.exe` with a negative index and a close signal is sent to all other windows then :file:`gview.exe` closes itself. --------- Functions --------- :df:`OpenStdGrid(rows, columns, index[,filename])` Returns MetaGrid used in all other calls. Can use different :a:`index` values to spawn different windows, and use the same :a:`index` value to update one. If your :a:`index` is equal to -1, then all active windows will close. The default filename is :file:`ptemp.gvw`. :df:`CloseStdGrid(MetaGrid)` Close the grid before trying to display it. :df:`DisplayStdGrid(MetaGrid)` Displays the new grid, or updates an existing grid if one with the same indexes exists. :df:`SetCellValue(MetaGrid, row, col, value)` Sets cell value. :df:`SetCellColor(MetaGrid, row, col, red, green, blue)` Sets cell color. :df:`SetColumnColor(MetaGrid, col, red, green, blue)` Sets column color. :df:`SetRowColor(MetaGrid, row, red, green, blue)` Sets row color. :df:`SetWinSize(MetaGrid, width, height)` Sets window size. :df:`SetWinLev(MetaGrid, lev)` Sets precedence behavior of window i.e. who is on top (lev = 1-4). :df:`SetWindowTitle(MetaGrid, title)` Sets window title. ---- .. [#python-lib-string-formatting] "String Formatting Operations" *Python Library Reference*. 21 December 2001. 31 May 2004