from pydm import Display
class example(Display):
def __init__(self,parent = None,args = []):
super(example,self).__init__(parent = parent,args = args)
self.ui.PyDMSpinbox.valueChanged.connect(self.test_color)
def ui_filename(self):
return 'image.ui'
def ui_filepath(self):
return path.join(path.dirname(path.realpath(__file__)),self.ui_filename())
def test_color(self):
mapMax = float(self.ui.PyDMSpinbox.text())
self.PyDMImageView.setProperty("colorMapMax", mapMax)
test_color()
一个函数,而不是每多复制一个控件就多一个test_color()
函数from pydm import Display
class example(Display):
def __init__(self,parent = None,args = []):
super(example,self).__init__(parent = parent,args = args)
self.ui.PyDMSpinbox.valueChanged.connect(self.test_color(mapMax = float(self.ui.PyDMSpinbox.text())))
def ui_filename(self):
return 'image.ui'
def test_color(self,mapMax=255):
self.PyDMImageView.setProperty("colorMapMax", mapMax)
spinbox控件的定义一个信号槽,当改变spinbox值就触发,将spinbox值写入一个类属性,其他控制直接调用这个类属性即可