PyGTK+

<

PyJH

PyJH: Python in the HEIDENHAIN NC

Copyright © 2007 DR. JOHANNES HEIDENHAIN GmbH. All rights reserved.


PyJH 1.0 Reference Manual

<>

PyJH Reference Manual

PyJH Reference:

Description of the classes and functions of the PyJH module.

Valid for:
340 49x-04


Introduction

This document describes the PyJH classes and functions. The description of the data corresponds to the Heidenhain DNC.

The jh module
  • Functions for requesting and modifying data from the control
  • Functions for controlling the event loop
  • Functions for interrogating error codes
  • Function for starting the online help
The jh.gtk module
  • Class jh.gtk.Window as expansion of the class gtk.Window for inclusion in the control layout
  • Functions for registering and unregistering gtk.Window
  • Functions for focus control and keyboard registration
  • Functions for selecting the logical screen
  • Constants declaration for focus types (jh.focus)
  • Constants declaration for key groups (jh.keys)
The jh.gtk.glade module
  • Class of jh.gtk.glade.XML as expansion of the class gtk.glade.XML for inclusion in the control layout
  • Function for registering the gtk.Window of the Glade form
  • Function for creating a jh.gtk.glade.XML from a buffer instead of a file


Introduction

Format of the Reference Manual

The format of the Reference Manual is oriented on the format of the PyGTK Reference Manual.

Functions that are italicized in the overview of functions and methods and are grayed out in the description are not implemented yet.


PyJH Classes Hierarchy

gobject.GObject
    gtk.Object
        gtk.Widget
            gtk.Container
                gtk.Bin
                    gtk.Window
                        jh.gtk.Window
    gtk.glade.XML
        jh.gtk.glade.XML


PyJH Classes Reference

jh.gtk.Window - a window that as a default has the type gtk.WINDOW_POPUP, and is shown via the parameter "usage" in the graphical context of the control.
jh.gtk.glade.XML -

permits dynamic loading of a user interface from an XML description file. All gtk.Windows are set to jh.gtk.Windows.


PyJH Class Reference

jh.gtk.Window

jh.gtk.Window

jh.gtk.Window — window that is displayed in the graphical context of the control.

Overview

class jh.gtk.Window(gtk.Window):
    jh.gtk.Window(usage="")
    def destroy()
Functions

def jh.gtk.Focus(window, type)
 def jh.gtk.Screen(window, screen, onTop=False)
def jh.gtk.Keys(window, keys)

Derivation

+-- gobject.GObject
  +-- gtk.Object
    +-- gtk.Widget
      +-- gtk.Container
        +-- gtk.Bin
          +-- gtk.Window
            +-- jh.gtk.Window

Description

The jh.gtk.Window is a window that is displayed in the graphical context of the control in accordance with the usage parameter. The position and size correspond to the description in the layout file. The window becomes visible when the corresponding layout is selected. Registration of the window in the control context occurs automatically. If the usage parameter is not set or if this name is not found in the control layout, an unregistered window (:= gtk.Window) is created. If registering fails, a RuntimeError is thrown.

Constructor

    jh.Window(usage="")
usage : Name of the window within the control layout
Returns : a new jh.gtk.Window

Creates a new jh.gtk.Window with the size and position corresponding to the specified name usage in the control layout.

If the name of the window cannot be found in any layout, or the name of the window remains empty, or the window cannot be registered, an unregistered window (:= gtk.Window) is created. Otherwise a window is created, and positioned and displayed according to the layout. If registering fails, a RuntimeError is thrown.

Here is a small example:

  window = jh.gtk.Window("PLCsmall")

Methods

jh.gtk.Window.destroy

    def destroy()
Returns :

The method destroy() destroys the instance of the jh.gtk.Window. The window is automatically unregistered when it is destroyed.

Signals

Functions

jh.gtk.Focus

    def jh.gtk.Focus(window, type)
window : Window for which the focus is to be set.
type : Type of the focus request (see constants definition)
Returns : True, if the focus could be set successfully

The function jh.gtk.Focus() requests the focus for the indicated window.

jh.gtk.Screen

    def jh.gtk.Screen(window, screen, onTop=False)
window : Window for which the target screen is to be set.
screen : Name of the screen on which the window is to appear (see constants definition)
onTop : Marker whether the window is always to be in the foreground of the selected screen.
Returns : True, if the screen could be set successfully

The function jh.gtk.Screen() selects the logical screen on which the indicated window is to be displayed. Only works on windows that are not embedded. If the OemScreen is selected as logical target screen, then the display switches to this screen. Otherwise the logical screen is maintained.

jh.gtk.Keys

    def jh.gtk.Keys(window, keys)
window : Window for which the focus is to be set.
keys : Selected key group (see constants definition)
Returns : True, if the request for the key group was successful

The function jh.gtk.Keys() requests a key group for the indicated window.

Constants

jh.gtk.focus

    Focus control
jh.gtk.focus.GET : The window requests the focus, and receives it if the current operating status permits it.
jh.gtk.focus.CAN : Window is to receive the focus via the switch focus key
jh.gtk.focus.LEAVE : Window releases the focus

screen

    Possible logical screens as string
"MachineScreen" : Logical screen on which the Manual, Program Run Full Sequence, Program Run Single Block, and MDI operating modes are displayed
"EditScreen" : Logical screen on which the editors and simulations are displayed
"OemScreen" : Logical screen, not used by the NC
"AllScreens" : Window is displayed on all logical screens

usage

    Possible embedded windows
"PLCsmall" : PLC status window
"PLCmedium" : PLC mask window
"PLClarge" : Entire screen except for soft keys and header
"OEMmachine" : OEM-pane of the machining screen (available only with 19" TFT)
"OEMedit" : OEM-pane of the editing screen (available only with 19" TFT)

jh.gtk.Keys

    Key groups
jh.gtk.keys.ALL : All keys except for the hotkeys are assigned to the window
jh.gtk.keys.ASCII: The ASCII keys are assigned to the window
jh.gtk.keys.SOFTKEYS: The soft keys are assigned to the window
jh.gtk.keys.CURSOR: The cursor control keys (including Goto) are assigned to the window
jh.gtk.keys.NUMERIC: The keys of the numeric keypad are assigned to the window
jh.gtk.keys.OPMODE: The operating mode keys are assigned to the window
jh.gtk.keys.OPENBLK: The block opening keys are assigned to the window


PyJH 0.1 Reference Manual

PyJH Class Reference

jh.gtk.glade.XML

jh.gtk.glade.XML

jh.gtk.glade.XML — permits dynamic loading of a user interface from an XML description file.

Overview

class jh.gtk.glade.XML(gtk.glade.XML):
    jh.gtk.glade.XML(fname, root="", domain="", typedict={})
    def jh.gtk.glade.get_widget( name, usage=None )

Functions

    def jh.gtk.glade.xml_new_from_buffer(buffer, size, root="", domain="", typedict={})

Derivation

+-- gobject.GObject
      +-- gtk.glade.XML
            +-- jh.gtk.glade.XML

Description

This object behaves like a gtk.glade.XML object, but all widgets of type GtkWindoware set to type jh+gtk+Window. This ensures that they are unregistered when the window is destroyed.

Constructor

    jh.gtk.glade.XML(fname, root="", domain="", typedict={})
The parameters correspond to those of a gtk.glade.XML object.
Returns : a new jh.gtk.glade.XML object

Creates a new jh.gtk.glade.XML object (and the associated "widgets") from an XML description file (Glade form) which is specified via the fname parameter. The GtkWindow widgets are converted into jh+gtk+Window widgets. This way they are automatically unregistered when the widget is destroyed.

Methods

jh.gtk.glade.XML.get_widget

    def get_widget(name, usage=None)
name: Name of the widget in the Glade form
usage: Name of the window within the control layout. If no usage or an invalid usage is indicated, the function behaves like gtk.glade.XML.get_widget()
Returns : the widget selected via name

The method jh.gtk.glade.XML.get_widget returns a gtk.widget. If a usage is indicated, then it is attempted to register the Widget and so to show it in the control layout. If registering fails, a RuntimeError is thrown.

Functions

jh.gtk.glade.xml_new_from_buffer

    def jh.gtk.glade.xml_new_from_buffer(buffer, size, root="", domain="", typedict={})
The parameters correspond to those of a gtk.glade.XML object.
Returns : a new jh.gtk.glade.XML object

The function jh.gtk.glade.xml_new_from_buffer() creates a new jh.gtk.glade.XML object (and the associated "widgets") from a buffer buffer.


PyJH Functions

jh functions — the functions of the modules jh, jh.gtk and jh.gtk.glade

Overview

jh.gtk.Window functions

def jh.gtk.Window.destroy()
def jh.gtk.Focus(window, type)
def jh.gtk.Screen(window, screen, onTop=False)
def jh.gtk.Keys(window,keys=jh.keys.ALL)

jh.gtk.glade.XML functions

def jh.gtk.glade.XML.get_widget(name, usage=None)
def jh.gtk.glade.new_from_from_buffer(buffer, size, root="", domain="", typedict={})

Server functions

def jh.Subscribe(ident, notify, cancel=None, minRepeat=0.0, onChange=False, asString=False, shortForm=True)
def jh.UnSubscribe(handle)
def jh.UnSubscribe()
def jh.Get(handle)
def jh.Get(ident, asString=False, shortForm=True)
def jh.Put(dict, ident)
def jh.Help(helpFile, contextId)
def jh.ResPath(path)

Error functions

def jh.Errno()
def jh.Errstr()

Control functions

def jh.Main()
def jh.QuitMain()
def jh.Connect(signal, callback)

Description

These functions belong to the PyJH jh module. This list contains all functions of the module, along with a corresponding link. The descriptions of functions that belong to a class are located in the class definitions. The remaining functions are described below.

Functions

jh.Subscribe

    def jh.Subscribe(ident, notify, cancel=None, minRepeat=0.0, onChange=False, asString=False, shortForm=True)
ident : Complete data designator.
notify : "callback" function, is called when new data is available.
cancel : "callback" function, is called when the server no longer considers the request to be valid.
minRepeat : Minimum time [s] that must pass before the server sends new data again.
onChange : Marker of whether the server is supposed to send an answer only if the data changes.
asString : Marker whether the data is also to be supplied as a character string.
shortForm : Marker of whether the keys of the supplied data are to be delivered in short form (only necessary identifier) or long form (complete identifier).
Returns : "handle" for later processing of the request (see Get and UnSubscribe).

The function jh.Subscribe() requests data of the NC control according to the data designator. The data designator uses the same syntax as Heidenhain DNC. If new data is available, the notify function is called automatically.

If the data is no longer available, the cancel function is called.

The response behavior of the server can be influenced with the minRepeat, onChange and asString parameters. minRepeat indicates the minimum time in seconds that must pass before the server sends new data, even if the data has changed in the meantime. onChange is used to have the server send data only if there have been changes, even if the minimum waiting period (minRepeat) has already passed. If the switch asString is set, then the data is always sent as a character string by the server. Otherwise it will be in the data format of the requested data. The shortForm switch is used to specify whether the keys in the dictionary transmitted to the callback function are in short form (only necessary identifier) or long form (complete identifier).

Structure of the "notify" function:

  def Notify( **dict ):
dict : Dictionary of the supplied values. Each entry contains the designator and the new value. (also see "Function definition")
Returns

Structure of the "cancel" function:

  def Cancel( handle ):
handle : "handle" of the request that is no longer valid. (also see "Function definition")
Returns

jh.UnSubscribe

    def jh.UnSubscribe(handle)
handle : "handle" that was supplied from a previous call of jh.Subscribe.
Returns :

The jh.UnSubscribe() function clears a previous request with jh.Subscribe().

jh.UnSubscribe

    def jh.UnSubscribe()
Returns :

The jh.UnSubscribe() function clears the corresponding request. This variant is required to release a request within the notification of jh.Subscribe().

jh.Get

    def jh.Get(handle)
handle : "handle" that was supplied from a previous call of jh.Subscribe.
Returns : Dictionary of the current values. Each entry contains the designator and the current value.

The jh.Get() function with a handle as parameter can be used to read data already requested with jh.Subscribe() out of cycle. The current data is read from the buffer.

jh.Get

    def jh.Get(ident, asString=False, shortForm=True)
ident : Complete data designator.
asString : Marker whether the data is also to be supplied as a character string.
shortForm : Marker of whether the keys of the supplied data are to be delivered in short form (only necessary identifier) or long form (complete identifier).
Returns : Dictionary of the current values. Each entry contains the designator and the current value.

The jh.Get() function with the parameters ident, asString and shortForm gets the current data from the server applications. The semantics of the parameters correspond to those of the function jh.Subscribe().

jh.Put

    def jh.Put(dict, ident="")
dict : Dictionary of the new values. Each entry contains the designator and the new value.
ident : Basic designator: If it is empty, then the "keys" in the dictionary must describe the path completely. Otherwise the "ident" will be used as a common part.
Returns : True, if the data could be written, otherwise False

The function jh.Put() sets values in the NC control via the corresponding server applications.

jh.Help

    def jh.Help(helpFile, contextId)
helpFile : Path of the help file.
contextId : Context designator within the help file.
Returns : True, if the help could be started, otherwise False

The jh.Help() function starts the help system with the indicated help file and the given context designator.

jh.ResPath

    def jh.ResPath(path)
path : TNC-specific path
Returns : Resolved path

The jh.ResPath() function resolves TNC-specific paths, so that the same paths can be used on a control as well as on a programming station.

jh.Errno

    def jh.Errno()
Returns : Current Heidenhain error code

The jh.Errno() function returns the current Heidenhain error code.

jh.Errstr

    def jh.Errstr()
Returns : Current Heidenhain error text.

The jh.Errstr() function returns the current Heidenhain error text.

jh.Main

    def jh.Main()
Returns :

The jh.Main() function constitutes the "event loop" of the Python application. GTK+ and control events are processed here, and the corresponding functions are called.

jh.QuitMain

    def jh.QuitMain()
Returns :

The jh.QuitMain() function ends the "event loop."

jh.Connect

    def jh.Connect(signal, callback)
signal : Name of the Heidenhain signal/event to be connected (see constants definition)
callback : "callback" function to be called when the signal/event occurs.
Returns :

Die jh.Connect() function connects a Heidenhain signal with a "callback" function.


PyJH 0.1 Reference Manual

<

PyJH Reference Changes

PyJH Reference Changes:

Version:
2007-11-15-en