I have created an application to track our internal IP address usage. It features a button in a view (render: veiw, viewPath: viewPingButton) which opens a popup which runs the ping test.
The problem is that after the popup has been closed the button can’t be pressed a second time unless the user clicks elsewhere on the table to de-select the cell’s rendered view. The column is set to editable: false. It’s as though the button is being held down and needs to have the focus removed from it.
Any ideas?
For anyone interested, the popup looks like this:
The red label is lblPingStatus and has a custom prop pingResult which is used to control the caption and color.
and the code like this:
def runAction(self):
self.getChild("lblPingStatus").custom.pingResult = -1 # Suppress any previous results.
self.getChild("lblHelper").meta.visible = False
import datetime
import os # Required for ping operation
import re # Required to strip leading zeros from IP address octets.
timeout = 1500 # ping timeout (ms).
shortIp = re.sub('(^|\.)0+(?=[^.])', r'\1', self.view.params.value.IpAddress) # Strip the leading zeros from each octet or Windows ping won't find it!
# For Windows: -n 1 = ping once. -w 200 = timeout value.
# r = os.system('ping -n 1 -w ' + str(timeout) + ' ' + shortIp) == 0 # Python method superceded.
# os.system('ping -c 1 {}'.format(myip)) See https://stackoverflow.com/questions/23661900/python-os-systemping-argument-not-working
r = os.system('ping -n 1 -w ' + str(timeout) + ' {}'.format(shortIp)) == 0
# 1 = Good.
# 0 = Nothing.
self.getChild("lblPingStatus").custom.pingResult = r
if r == 0:
self.getChild("lblHelper").props.text = 'No response in ' + str(timeout) + ' ms'
self.getChild("lblHelper").meta.visible = True,