Have been going through the tutorial on
http://gnipsel.com/linuxcnc/gui/gui03b.html

I am running off a Linuxcnc 2.5.0 install. Had a problem with PYTHONPATH,
but I managed to work around it by adding the path specifically to the
script.

Here is my existing script:

#!/usr/bin/env python

import sys,os
sys.path.append('/usr/lib/pymodules/python2.6/gladevcp/')
import pygtk
#pygtk.require("2.0")
import gtk
import gobject
import linuxcnc
import gladevcp.makepins
from gladevcp.gladebuilder import GladeBuilder
import hal
import hal_widgets

# set up paths to files
BASE = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), ".."))
libdir = os.path.join(BASE, "lib", "python")
sys.path.insert(0, libdir)
datadir = os.path.join(BASE, "share", "linuxcnc")
xmlname = os.path.join(datadir,"gui3.glade")


class gui3(object):

  def __init__(self):
    self.emc = linuxcnc
    self.status = self.emc.stat()
    self.builder = gtk.Builder()
    self.builder.add_from_file(xmlname)
    self.halcomp = hal.component("gui3")
    self.builder.connect_signals(self)
    self.window = self.builder.get_object("window1")
    self.window.show()
    self.panel = gladevcp.makepins.GladePanel(self.halcomp, xmlname,
self.builder, None)
    self.halcomp.ready()
    # The gobject.timeout_add() function sets a function to be called at
regular intervals
    gobject.timeout_add(100, self.periodic) # time between calls to the
function, in milliseconds
    self.machine_status = 0

  def periodic(self): # fetch status items and update screen
    self.status.poll()

    data = self.status.actual_position[0]
    text = "% 9.4f"% (data)
    self.builder.get_object("dro_x").set_text(text)

    data = self.status.actual_position[1]
    text = "% 9.4f"% (data)
    self.builder.get_object("dro_y").set_text(text)

    data = self.status.actual_position[2]
    text = "% 9.4f"% (data)
    self.builder.get_object("dro_z").set_text(text)

    return True # must return True to keep running

  def on_hal_stat1_mode_mdi(self, widget, data=None):
    self.mode_mdi = 1

  def on_test_button_clicked(self, widget, data=None):
    self.status.poll()
    print self.machine_status

  def on_window1_destroy(self, widget, data=None):
    print "quit with cancel"
    gtk.main_quit()

  def on_gtk_quit_activate(self, menuitem, data=None):
    print "quit from menu"
    gtk.main_quit()

if __name__ == "__main__":
  app = gui3()
  gtk.main()

--------------------

I get the following when I run it:

cnc@cnc-desktop:~/linuxcnc/configs/gui3$ linuxcnc ./gui3.ini
LINUXCNC - 2.5.0
Machine configuration directory is '/home/cnc/linuxcnc/configs/gui3/.'
Machine configuration file is 'gui3.ini'
Starting LinuxCNC...
/usr/lib/pymodules/python2.6/gtk-2.0/gobject/__init__.py:114: Warning:
cannot register existing type `HAL_HBox'
  type_register(cls, namespace.get('__gtype_name__'))
Traceback (most recent call last):
  File "/usr/bin/gui3", line 13, in <module>
    import hal_widgets
  File "/usr/lib/pymodules/python2.6/gladevcp/hal_widgets.py", line 65, in
<module>
    class HAL_HBox(gtk.HBox, _HalSensitiveBase):
  File "/usr/lib/pymodules/python2.6/gtk-2.0/gobject/__init__.py", line 60,
in __init__
    cls._type_register(cls.__dict__)
  File "/usr/lib/pymodules/python2.6/gtk-2.0/gobject/__init__.py", line
114, in _type_register
    type_register(cls, namespace.get('__gtype_name__'))
RuntimeError: could not create new GType: HAL_HBox (subclass of GtkHBox)
Shutting down and cleaning up LinuxCNC...
Cleanup done
LinuxCNC terminated with an error.  You can find more information in the
log:
    /home/cnc/linuxcnc_debug.txt
and
    /home/cnc/linuxcnc_print.txt
as well as in the output of the shell command 'dmesg' and in the terminal


----

cnc@cnc-desktop:~/linuxcnc/configs/gui3$ more /home/cnc/linuxcnc_debug.txt
Can not find -sec MOT -var MOT -num 1
Can not find -sec IO -var IO -num 1
Can not find -sec LINUXCNC -var NML_FILE -num 1
Can not find -sec EMC -var NML_FILE -num 1
28640
  PID TTY      STAT   TIME COMMAND
28694
  PID TTY      STAT   TIME COMMAND
Stopping realtime threads
Unloading hal components

----

cnc@cnc-desktop:~/linuxcnc/configs/gui3$ more /home/cnc/linuxcnc_print.txt
RUN_IN_PLACE=no
LINUXCNC_DIR=
LINUXCNC_BIN_DIR=/usr/bin
LINUXCNC_TCL_DIR=/usr/lib/tcltk/linuxcnc
LINUXCNC_SCRIPT_DIR=
LINUXCNC_RTLIB_DIR=/usr/realtime-2.6.32-122-rtai/modules/linuxcnc
LINUXCNC_CONFIG_DIR=
LINUXCNC_LANG_DIR=/usr/share/linuxcnc/tcl/msgs
INIVAR=inivar
HALCMD=halcmd
LINUXCNC_EMCSH=/usr/bin/wish8.5
INIFILE=/home/cnc/linuxcnc/configs/gui3/./gui3.ini
PARAMETER_FILE=linuxcnc.var
TASK=milltask
HALUI=
DISPLAY=gui3
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Starting TASK program: milltask
Starting DISPLAY program: gui3
Killing task linuxcncsvr, PID=28640
Killing task milltask, PID=28694
Removing HAL_LIB, RTAPI, and Real Time OS modules
Removing NML shared memory segments


----------------------

The problem seems to be defining the GTK resource in hal_widgets. Is this a
known issue, or am I missing something simple?

Thanks for any help.
Chuck Buckley
------------------------------------------------------------------------------
AlienVault Unified Security Management (USM) platform delivers complete
security visibility with the essential security capabilities. Easily and
efficiently configure, manage, and operate all of your security controls
from a single console and one unified framework. Download a free trial.
http://p.sf.net/sfu/alienvault_d2d
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to