Skip to content

Commit

Permalink
fixes Issue #360 by redirecting mouseDoubleClick events to mouseClick…
Browse files Browse the repository at this point in the history
… events

improved attach for networked Phidgets
  • Loading branch information
MAKOMO committed Jul 5, 2019
1 parent 239c553 commit 53c1500
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/artisanlib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6860,7 +6860,8 @@ def flavorchart(self):

self.ax1.fill_between(angles,0,plotf, facecolor='#1985ba', alpha=0.1, interpolate=True)

self.fig.canvas.draw()
#self.fig.canvas.draw()
self.fig.canvas.draw_idle()
except Exception:
pass

Expand Down Expand Up @@ -6951,7 +6952,10 @@ def startPhidgetManager(self):
if self.phidgetManager is None:
try:
self.phidgetManager = PhidgetManager()
libtime.sleep(0.3)
if self.phidgetRemoteFlag:
libtime.sleep(0.9)
else:
libtime.sleep(0.3)
except Exception as e:
if aw.qmc.device in aw.qmc.phidgetDevices:
aw.qmc.adderror(QApplication.translate("Error Message","Exception: PhidgetManager couldn't be started. Verify that the Phidget driver is correctly installed!",None))
Expand Down Expand Up @@ -37304,7 +37308,7 @@ def setlabel(self,x):
def setvalue(self,_,x):
valueSpinBox = self.flavortable.cellWidget(x,1)
aw.qmc.flavors[x] = valueSpinBox.value()
aw.qmc.flavorchart()
QTimer.singleShot(0,lambda : aw.qmc.flavorchart())

def setdefault(self):
if self.lastcomboboxIndex == 10:
Expand Down Expand Up @@ -41843,7 +41847,7 @@ def phidgetVOUTclose(self):
# move(ch,pos) # sets position, enables servo, disables servo once target position is reached

def phidgetRCattach(self,channel):
if not aw.ser.PhidgetRCServo and aw.qmc.phidgetManager is not None:
if not aw.ser.PhidgetRCServo:
aw.qmc.startPhidgetManager()
# try to attach an Phidget RCC1000 module
ser,port = aw.qmc.phidgetManager.getFirstMatchingPhidget('PhidgetRCServo',DeviceID.PHIDID_RCC1000,
Expand Down Expand Up @@ -41873,7 +41877,10 @@ def phidgetRCattach(self,channel):
rcservo.setIsLocal(False)
try:
if not aw.ser.PhidgetRCServo[channel].getAttached():
aw.ser.PhidgetRCServo[channel].openWaitForAttachment(1000)
if aw.qmc.phidgetRemoteFlag:
aw.ser.PhidgetRCServo[channel].openWaitForAttachment(3000)
else:
aw.ser.PhidgetRCServo[channel].openWaitForAttachment(1500)
except:
pass

Expand Down Expand Up @@ -48951,6 +48958,14 @@ def __init__(self, *args, **kwargs):
def wheelEvent(self, *args, **kwargs):
if self.hasFocus():
return QDoubleSpinBox.wheelEvent(self, *args, **kwargs)

# we re-direct the mouse double-click event to the standard mouse press event and add
# the (at least in PyQt 5.12.2/5.12.3) missing mouse release event
# which had the effect that a double click an DoubleSpinBox arrow in the Cup Profile dialog
# leads to a non-terminating sequence of setvalue() calls until the end of the spinner is reached.
def mouseDoubleClickEvent(self, event):
super(MyQDoubleSpinBox, self).mousePressEvent(event)
super(MyQDoubleSpinBox, self).mouseReleaseEvent(event)

class MyTableWidgetItemQLineEdit(QTableWidgetItem):
def __init__(self, sortKey):
Expand Down
1 change: 1 addition & 0 deletions src/artisanlib/phidgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def releaseChannel(self,channel):

# returns the first matching Phidget channel and reserves it
def getFirstMatchingPhidget(self,phidget_class_name,device_id,channel=None,remote=False,remoteOnly=False):
# print("getFirstMatchingPhidget",phidget_class_name,device_id,channel,remote,remoteOnly)
try:
self.managersemaphore.acquire(1)
if device_id in [
Expand Down

0 comments on commit 53c1500

Please sign in to comment.