Part 6d Adding Menu Items

Adding Show Hal

  1. In the glade file add to the menu_halshow GtkMenuItem activate signal the on_menu_halshow_activate handler.

  2. In the gui6 python file add the following libary.

    import subprocess
  3. In the gui6 init method add the following lines. These store the path to the installed LinuxCNC tcl directory and the ini file name that was used to launch this configuration to be used with the subprocess method.

        self.tcl_dir = os.environ["LINUXCNC_TCL_DIR"] + "/bin/"
        self.ini_file = os.environ["INI_FILE_NAME"]
  4. In the gui6 class add the following method.

      def on_menu_halshow_activate(self, widget, data=None):
        print "Menu Hal Show"
        subprocess.Popen([self.tcl_dir + "halshow.tcl", "-- -ini " + self.ini_file])

    The subprocess.Popen() method runs the program halshow.tcl with the ini file as an argument. The Popen runs the program as a seperate file and not as a child process.

  5. Copy the python file to the installed directory.

    sudo cp gui6 /usr/bin

Now when you run the GUI and select View > Show Hal you get the Hal Configuration program up so you can examine pins and parameters.


Adding Action

  1. Open up and add the following EMC Actions.

    • EMC Action Run

    • EMC Action Step

    • EMC Action Stop

    • EMC Action MDI

    • EMC Action Home

    • EMC Action Unhome

    • EMC ToggleAction ESTOP, Stock Icon: Stop

    • EMC ToggleAction Power, Stock Icon: Disconnect

    • EMC ToggleAction Pause

    • EMC Action Open, Label: Open

    • EMC Action Reload, Stock Icon: Refresh

  2. Click on the tool bar and open up the Tool Bar Editor and add the following types of buttons, actions and change Use Action Apearance: to Yes.

    • Toggle, Related Action: hal_toggleaction_estop1

    • Toggle, Related Action: hal_toggleaction_power1

    • Button, Related Action: hal_action_reload1

      Your project should look like this now

  3. Click on the menu bar and open up the Edit Menu Bar. Change the Name: of imagemenuitem2 under File to menu_open. Add hal_action_open1 to this menu item and select Use Action Appearance.

  4. Change the labels of the top set of buttons in the Manual tab to:

    1. Run, Stop

    2. Pause, Step

    3. Flood, Mist

  5. Add the following actions to the buttons:

    • Run, hal_action_run1 (EMC Action Run)

    • Stop, hal_action_stop1 (EMC Action Stop)

    • Pause, hal_toggleaction_pause1 (EMC ToggleAction Pause)

    • Step, hal_action_run2 (EMC Action Step)

  6. Save the glade file then copy the file to the installed directory.

sudo cp /usr/share/linuxcnc

E-Stop Loopback

  1. Open up gui6.hal and add the E-Stop loop back so when the E-Stop is released you can turn the power button on.

    # estop loopback or the power button won't work
    net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in

Test Run

You sould now be able to run the GUI from the desktop lanuncher. You should be able to open a file, toggle the E-Stop, toggle the Power. The Manual and MDI tabs are not avaliable yet. The HAL container needs to be connected to the power button but that must be done after the GUI loads.

Your GUI should look like this now.