本文整理汇总了Python中matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg.setParent方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QTAgg.setParent方法的具体用法?Python NavigationToolbar2QTAgg.setParent怎么用?Python NavigationToolbar2QTAgg.setParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg
的用法示例。
在下文中一共展示了NavigationToolbar2QTAgg.setParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyForm
# 需要导入模块: from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.NavigationToolbar2QTAgg import setParent [as 别名]
class MyForm(QMainWindow):
def __init__(self, parent = None):
# standard GUI code
QWidget.__init__(self, parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.canvas = FigureCanvas(self.ui.mplwidgetPulseSeq.figure)
self.canvas.setParent(self.ui.widgetMPLPlot)
# MPL toolbar
self.mpl_toolbar = NavigationToolbar(self.canvas, self.ui.widgetMPLPlot)
self.mpl_toolbar.setParent(self.ui.widgetMPLToolbar)
vboxPlot = QVBoxLayout()
vboxPlot.addWidget(self.canvas) # the matplotlib canvas
vboxToolbar = QVBoxLayout()
vboxToolbar.addWidget(self.mpl_toolbar) # the matplotlib toolbar
self.ui.widgetMPLPlot.setLayout(vboxPlot)
self.ui.widgetMPLToolbar.setLayout(vboxToolbar)
self.ui.mplwidgetPulseSeq = self.canvas
self.error_message = QErrorMessage(parent=self)
self.pulse_sequence = PulseSequence()
# Connect the buttons
self.connect(self.ui.comboBoxChannel, SIGNAL("currentIndexChanged(int)"), self.changeChannel)
self.connect(self.ui.comboBoxPulseTrainIndex, SIGNAL("currentIndexChanged(int)"), self.changePulseTrainIndex)
self.connect(self.ui.lineEditTimeOn, SIGNAL("returnPressed()"), self.EditPulseTrain)
self.connect(self.ui.lineEditPulseWidth, SIGNAL("returnPressed()"), self.EditPulseTrain)
self.connect(self.ui.lineEditPulseSeparation, SIGNAL("returnPressed()"), self.EditPulseTrain)
self.connect(self.ui.lineEditPulsesInTrain, SIGNAL("returnPressed()"), self.EditPulseTrain)
self.connect(self.ui.pushButtonAddPulse, SIGNAL("clicked()"), self.addPulseTrain)
self.connect(self.ui.pushButtonDeletePulse, SIGNAL("clicked()"), self.deletePulseTrain)
self.connect(self.ui.pushButtonChooseSaveFile, SIGNAL("clicked()"), self.choose_save_file)
self.connect(self.ui.pushButtonSavePS, SIGNAL("clicked()"), self.save_ps)
self.connect(self.ui.pushButtonLoadPS, SIGNAL("clicked()"), self.load_ps)
self.connect(self.ui.pushButtonChooseLoadFile, SIGNAL("clicked()"), self.choose_load_file)
self.connect(self.ui.comboBoxWaitEvents, SIGNAL("currentIndexChanged(int)"), self.changeWaitEventIndex)
self.connect(self.ui.pushButtonAddWait, SIGNAL("clicked()"), self.addWaitEvent)
self.connect(self.ui.pushButtonDeleteWait, SIGNAL("clicked()"), self.deleteWaitEvent)
self.connect(self.ui.lineEditWaitTime, SIGNAL("returnPressed()"), self.editWaitEvent)
self.connect(self.ui.pushButtonInitializePB, SIGNAL("clicked()"), lambda: self.communicate_with_pb('Initialize'))
self.connect(self.ui.pushButtonClosePB, SIGNAL("clicked()"), lambda: self.communicate_with_pb('Close'))
self.connect(self.ui.pushButtonSendSequence, SIGNAL("clicked()"), lambda: self.communicate_with_pb('Send sequence'))
self.connect(self.ui.pushButtonStartSequence, SIGNAL("clicked()"), lambda: self.communicate_with_pb('Start sequence'))
self.connect(self.ui.pushButtonStopSequence, SIGNAL("clicked()"), lambda: self.communicate_with_pb('Stop sequence'))
self.connect(self.ui.pushButtonGetStatus, SIGNAL("clicked()"), lambda: self.communicate_with_pb('Get status'))
self.connect(self.ui.pushButtonClearMessages, SIGNAL("clicked()"), self.ui.textEditMessages.clear)
# Set validators for pulse train attributes
vTimeOn = QDoubleValidator(self.ui.lineEditTimeOn)
vTimeOn.setRange(12.5e-09, 10000.0, 9)
vDouble = QDoubleValidator(self.ui.lineEditPulseWidth)
vDouble.setRange(2.5e-09, 10000.0, 9)
vDouble.setNotation(1)
self.ui.lineEditTimeOn.setValidator(vTimeOn)
self.ui.lineEditPulseWidth.setValidator(vDouble)
self.ui.lineEditPulseSeparation.setValidator(vDouble)
self.ui.lineEditPBClockFrequency.setValidator(vDouble)
self.ui.lineEditWaitTime.setValidator(vDouble)
vInt = QIntValidator(1, 1000, self.ui.lineEditPulsesInTrain)
self.ui.lineEditPulsesInTrain.setValidator(vInt)
# Create threads
self.save_ps_thread = Save_pulse_sequence()
self.load_ps_thread = Load_pulse_sequence()
self.plot_ps_thread = Plot_pulse_sequence()
self.communicate_with_pb_thread = Communicate_with_PB()
# Connect the threads
self.connect(self.save_ps_thread, SIGNAL("Save attempted."), self.update_save_status)
self.connect(self.load_ps_thread, SIGNAL("Load attempted."), self.update_load_status)
self.connect(self.load_ps_thread, SIGNAL("Initiate loaded pulse sequence."), self.initiate_loaded_ps)
self.connect(self.communicate_with_pb_thread, SIGNAL("New message."), self.update_messages)
self.connect(self.communicate_with_pb_thread, SIGNAL("New command."), self.update_command)
self.connect(self.communicate_with_pb_thread, SIGNAL("New status."), self.update_status)
# Populate pulse sequence with channels:
for i in xrange(21):
self.pulse_sequence.addChannel()
self.currentChannel = self.pulse_sequence.channels[i]
self.ui.comboBoxChannel.addItem(str(self.currentChannel.pulse_channel_index))
self.ui.comboBoxChannel.setCurrentIndex(0)
self.changeChannel()
def changeChannel(self):
self.currentChannel = self.pulse_sequence.channels[self.ui.comboBoxChannel.currentIndex()]
self.ui.comboBoxPulseTrainIndex.clear()
if self.currentChannel.num_of_pulse_trains > 0:
self.ui.comboBoxPulseTrainIndex.addItems(map(str, range(self.currentChannel.num_of_pulse_trains)))
self.ui.comboBoxPulseTrainIndex.setCurrentIndex(0)
self.changePulseTrainIndex()
#.........这里部分代码省略.........