i'm brand new python , i'm trying make first program pyqt4. problem following: have 2 checkboxes (plot1 , plot2), , "end" push button, inside class. when press end, see plots user checks, using matplotlib. i'm not being able that. first idea was:
self.endbutton.clicked.connect(self.plotandend) self.plot1checkbox.clicked.connect(self.plot1) self.plot2checkbox.clicked.conncet(self.plot2) def plotandend(self) plot1=self.plot1() pyplot.show(plot1) plot2=self.plot2() pyplot.show(plot2) def plot1(self) plot1=pyplot.pie([1,2,5,3,2]) return plot1 def plot2(self) plot2=pyplot.plot([5,3,5,8,2]) return plot2 this doesn't work, of course, because "plotandend" plot both figures, regardless of respective checkbox. how can i'm trying to?
wrap plot creation in if statement looks @ state of check boxes. example:
def plotandend(self) if self.plot1checkbox.ischecked(): plot1=self.plot1() pyplot.show(plot1) if self.plot2checkbox.ischecked(): plot2=self.plot2() pyplot.show(plot2) you don't need following lines:
self.plot1checkbox.clicked.connect(self.plot1) self.plot2checkbox.clicked.conncet(self.plot2) this nothing useful @ moment! qt never uses return value of plotx() methods, , want things happen when click end button, not when click checkbox. plotx() methods useful plotandend() method.
Comments
Post a Comment