Showing Plots If Checkbox Is Checked, On Python (with Pyqt4)
I'm brand new to Python and I'm trying to make my first program with PyQt4. My problem is basically the following: I have two checkboxes (Plot1 and Plot2), and a 'End' push button,
Solution 1:
Wrap the plot creation in an if statement that looks at the state of the check boxes. For example:
defPlotandEnd(self)ifself.plot1Checkbox.isChecked():
plot1=self.Plot1()
pyplot.show(plot1)
ifself.plot2Checkbox.isChecked():
plot2=self.Plot2()
pyplot.show(plot2)
You also don't need the following lines:
self.plot1Checkbox.clicked.connect(self.Plot1)
self.plot2Checkbox.clicked.conncet(self.Plot2)
This does nothing useful at the moment! Qt never uses the return value of your PlotX()
methods, and you only want things to happen when you click the End button, not when you click a checkbox. The PlotX()
methods are only currently useful for your PlotandEnd()
method.
Post a Comment for "Showing Plots If Checkbox Is Checked, On Python (with Pyqt4)"