Speed and Feed Calculator

More
31 Jul 2012 12:56 - 31 Jul 2012 12:59 #22630 by BigJohnT
I started with a simple RPM calculator and ran into a small glitch with the entry box not showing the | to indicate that the box has focus... not a deal breaker but a bit strange to get used to. It might just be a bug I don't know.

Does anyone know what the debug line is for and if there are any options?

calc.py
import hal
import glib
import time
import math

debug = 1

class HandlerClass:

  def on_calc_sfm_clicked(self, widget, data=None):
    self.sfm = float(self.builder.get_object('entry_sfm').get_text())
    self.diameter = float(self.builder.get_object('entry_diameter').get_text())
    self.rpm = str(int(self.sfm * (12/math.pi) / self.diameter))
    self.builder.get_object('label_rpm').set_text(self.rpm)

  def __init__(self, halcomp,builder,useropts):
    self.halcomp = halcomp
    self.builder = builder
    self.nhits = 0

def get_handlers(halcomp,builder,useropts):
  return [HandlerClass(halcomp,builder,useropts)]

The [DISPLAY] ini entry
# add GladeVCP panel as a tab next to Preview/DRO:
EMBED_TAB_NAME=GladeVCP demo
EMBED_TAB_COMMAND=halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -u calc.py -x {XID} calc.glade



File Attachment:

File Name: calc.glade
File Size:6 KB


John
Attachments:
Last edit: 31 Jul 2012 12:59 by BigJohnT.

Please Log in or Create an account to join the conversation.

More
31 Jul 2012 14:06 #22633 by mhaberler
BigJohnT wrote:

I started with a simple RPM calculator and ran into a small glitch with the entry box not showing the | to indicate that the box has focus... not a deal breaker but a bit strange to get used to. It might just be a bug I don't know.

Does anyone know what the debug line is for and if there are any options?


There were some hoops to jump to get GladeVCP to interoperate properly with Axis wrt key handling and focus, because the Axis GUI toolkit (tkinter) is a bit historic and not particularly friendly towards embedded windows; see the note here: www.linuxcnc.org/docs/devel/html/gui/gla...key_handling_in_axis

I'm fairly sure this causes what you see - this wont be the case in a purely GladeVCP UI, like gscreen

re the debug variable - looks like c&p leftover; since it's not referenced in your code it can be deleted

- Michael

Please Log in or Create an account to join the conversation.

More
31 Jul 2012 15:08 #22636 by BigJohnT
Michael,

Thanks for the explanation. The debug was from the samples in 2.5 so you might want to delete it from the sample configs. One other thing I noticed was that the def get_handlers(halcomp,builder,useropts): had to be on the left margin or it would not work. The manual example shows it intended the same as the def above it.

Thanks
John

Please Log in or Create an account to join the conversation.

More
31 Jul 2012 21:24 #22645 by mhaberler
ah! right you are - now I understand why Xavier had the same issue

fixed

-m

Please Log in or Create an account to join the conversation.

Moderators: HansU
Time to create page: 0.070 seconds
Powered by Kunena Forum