def customizeUi(self, default_channels): #this will be a dictionnary with the same keys as self.channel_controls corresponding to list #of 'N_channel' control Qwidgets. self.channel_objects={} for name,item in self.channel_controls.items(): self.channel_objects[name]=[] # create a layout within the blank "plot_holder" widget and put the # custom matplotlib zoom widget inside it. This way it expands to fill # the space, and we don't need to customize the ui_recordsweep.py file self.gridLayout_2 = QtGui.QGridLayout(self.plot_holder) self.gridLayout_2.setMargin(0) self.gridLayout_2.setObjectName("gridLayout_2") self.mplwidget = MatplotlibZoomWidget(self.plot_holder) self.mplwidget.setObjectName("mplwidget") self.gridLayout_2.addWidget(self.mplwidget, 0, 0, 1, 1)
class PlotDisplayWindow(QtGui.QMainWindow,ui_plotdisplaywindow.Ui_PlotDisplayWindow): """ The argument 'channel_controls' should be an OrderedDict object (from collections import OrderedDict)\n Each key will be a unique identifier of the channel control, the item should consist of a list for which the first element is the label of the channel control and the second element, the type of QtQui.\n It need to be either 'lineEdit','radioButton','checkBox' or 'comboBox', any other keyword will create an error.\n What callback function is associated with each control can be defined in the method 'add_channel_control' """ def __init__(self, parent=None, data_array=np.array([]),name="Main Window",default_channels=10,channel_controls=chan_contr): # run the initializer of the class inherited from super(PlotDisplayWindow, self).__init__() #store the choice of channel controls parameters self.channel_controls=channel_controls self.color_set=color_blind_friendly_colors(default_channels) # this is where most of the GUI is made self.setupUi(self,self.channel_controls) self.customizeUi(default_channels) #Create an instance of auto-hiding widget which will contain the channel controls autoHide = QtTools.QAutoHideDockWidgets(Qt.RightDockWidgetArea, self) # axes and figure initialization - short names for convenience self.fig = self.mplwidget.figure self.setWindowTitle(name) self.ax = self.mplwidget.axes self.axR = self.mplwidget.axesR self.ax.xaxis.set_major_formatter(ticker.ScalarFormatter(useOffset = False)) self.major_locator=self.ax.xaxis.get_major_locator() self.ax.yaxis.set_major_formatter(ticker.ScalarFormatter(useOffset = False)) self.axR.yaxis.set_major_formatter(ticker.ScalarFormatter(useOffset = False)) self.fig.canvas.draw() # this is for a feature that doesn't exist yet self.history_length = 0 self.num_channels = 0 self.left_lines = [] self.right_lines = [] #Fills self.lineEdit_Name = [], self.comboBox_Type = [], self.comboBox_Instr = []. self.comboBox_Param = [] #Whenever connect(obbject,SIGNAL(),function) is used it will call the function whenever the object is manipulated or something emits the same SIGNAL() for i in range (default_channels): self.add_channel_controls() # objects to hold line data. Plot empty lists just to make handles # for line objects of the correct color # create data_array attribute and use channel 0 as X by default self.data_array = data_array self.chan_X = 0 self.time_Xaxis=False self.date_txt=self.fig.text(0.03,0.95,"",fontsize=15) def closeEvent(self, event): """ when the window get close the destruction of the layout is handled properly by the second parent class method """ logging.debug("Closing the Plotdisplaywindow") self.__delete_layouts__() def customizeUi(self, default_channels): #this will be a dictionnary with the same keys as self.channel_controls corresponding to list #of 'N_channel' control Qwidgets. self.channel_objects={} for name,item in self.channel_controls.items(): self.channel_objects[name]=[] # create a layout within the blank "plot_holder" widget and put the # custom matplotlib zoom widget inside it. This way it expands to fill # the space, and we don't need to customize the ui_recordsweep.py file self.gridLayout_2 = QtGui.QGridLayout(self.plot_holder) self.gridLayout_2.setMargin(0) self.gridLayout_2.setObjectName("gridLayout_2") self.mplwidget = MatplotlibZoomWidget(self.plot_holder) self.mplwidget.setObjectName("mplwidget") self.gridLayout_2.addWidget(self.mplwidget, 0, 0, 1, 1) def add_channel_controls (self): """ create an instance of each of the channel control objects for a new channel, assign the settings and link to the callback function.\n It also create an empty line for each axis. """ #index of boxes to create i = self.num_channels self.num_channels = self.num_channels + 1 pos_LE = lambda x: 20 * (x + 1) line1, = self.ax.plot([], []) line2, = self.axR.plot([], []) for name,item in self.channel_controls.items(): #this value is set to true if there is one new QtGui object per line multiple_item = True if item[1]=="radioButton": self.channel_objects[name].append(QtGui.QRadioButton(self.groupBoxes[name])) self.channel_objects[name][i].setText("") if name == "groupBox_X": self.connect(self.channel_objects[name][i], SIGNAL("toggled(bool)"),self.XRadioButtonHandler) elif item[1]=="checkBox": self.channel_objects[name].append(QtGui.QCheckBox(self.groupBoxes[name])) self.channel_objects[name][i].setText("") self.connect(self.channel_objects[name][i], SIGNAL("stateChanged(int)"), self.YCheckBoxHandler) elif item[1]=="comboBox": self.channel_objects[name].append(QtGui.QComboBox(self.groupBoxes[name])) if get_groupBox_purpouse(name)=="marker": cbb_list=marker_set elif get_groupBox_purpouse(name)=="line": cbb_list=line_set self.channel_objects[name][i].addItems(cbb_list) # self.channel_objects[name][i].setStyleSheet ("QComboBox::drop-down {border-width: 0px;} QComboBox::down-arrow {image: url(noimg); border-width: 0px;}") self.channel_objects[name][i].setMaxVisibleItems(len(cbb_list)) self.connect(self.channel_objects[name][i], SIGNAL("currentIndexChanged(int)"), self.ComboBoxHandler) elif item[1]=="lineEdit": self.channel_objects[name].append(QtGui.QLineEdit(self.groupBoxes[name])) self.channel_objects[name][i].setText(QtGui.QApplication.translate("RecordSweepWindow", "", None, QtGui.QApplication.UnicodeUTF8)) self.connect(self.channel_objects[name][i], SIGNAL("textEdited(QString)"), self.lineEditHandler) elif item[1]=="colorButton": self.channel_objects[name].append(QtGui.QPushButton(self.groupBoxes[name])) color=self.color_set[np.mod(i,len(self.color_set))] line1.set_color(color) line2.set_color(color) self.channel_objects[name][i].setStyleSheet('QPushButton {background-color: %s}'%color) self.channel_objects[name][i].setFixedSize(15,15) self.connect(self.channel_objects[name][i], SIGNAL("clicked()"),self.colorButtonHandler) elif item[1]=="single_comboBox": if self.channel_objects[name]==[]: self.channel_objects[name]=QtGui.QComboBox(self.groupBoxes[name]) self.connect(self.channel_objects[name], SIGNAL("currentIndexChanged(int)"), self.singleComboBoxHandler) self.channel_objects[name].setObjectName(name + item[1]) multiple_item = False if multiple_item : self.channel_objects[name][i].setObjectName(name + "#" + str(i)) self.channel_objects[name][i].setGeometry(QRect(7, 20*(i+1), 16, 16)) else: self.channel_objects[name].setGeometry(QRect(7, 10*(i+1), 70, 16)) #resize the comboBoxes and the lineEdit if item[1]=="lineEdit": self.channel_objects[name][i].setGeometry(QRect(10, pos_LE(i), 81, 16)) elif item[1]=="comboBox" : self.channel_objects[name][i].setGeometry(QRect(7, 20*(i+1), 32, 16)) if multiple_item : self.channel_objects[name][i].show() else : self.channel_objects[name].show() # self.radio #create line objects and append them to self.ax[R].lines autoatically """#####################################################################""" """These handler function take action when someone interact with the button, checkbox, lineEdit etc... the names are explicit""" def XRadioButtonHandler(self): # print "X clicked" obj=self.sender() name=obj.objectName() name=str(name.split("#")[0]) for num, box in enumerate(self.channel_objects[name]): if box.isChecked(): self.chan_X = num label=self.channel_objects["groupBox_Name"][num].text() self.ax.set_xlabel(label) if label=="time(s)": self.time_Xaxis=True hfmt=self.set_axis_time(want_format=True) self.ax.xaxis.set_major_formatter(hfmt) major_ticks=self.ax.xaxis.get_major_ticks() # for i,tick in enumerate(major_ticks): if i==1: n=tick.label.get_text() label_i=n.split(" ")[0] tick.label.set_rotation('vertical') self.date_txt.set_text("Date :"+label_i) else: self.time_Xaxis=False self.date_txt.set_text("") self.ax.xaxis.set_major_locator(self.major_locator) self.ax.xaxis.set_major_formatter(ticker.ScalarFormatter(useOffset = False)) for tick in self.ax.xaxis.get_major_ticks(): tick.label.set_rotation('horizontal') self.update_plot() def YCheckBoxHandler(self): """Update which data is used for the Y axis (both left and right)""" tot_label = [] # print "Y clicked" obj=self.sender() name=obj.objectName() name=str(name.split("#")[0]) for num, box in enumerate(self.channel_objects[name]): if box.isChecked(): label = str(self.channel_objects["groupBox_Name"][num].text()) #unit = self.UNITS[str(self.comboBox_Param[num].currentText())] tot_label.append(label) #+ " (" + unit + ")" + ", " print get_groupBox_purpouse(name) if get_groupBox_purpouse(name)=="Y": self.set_Y_axis_label(tot_label) elif get_groupBox_purpouse(name)=="YR": self.set_YR_axis_label(tot_label) self.update_plot() def ComboBoxHandler(self,num): obj=self.sender() name=obj.objectName() name,idx=name.split("#") name=str(name) idx=int(idx) if get_groupBox_purpouse(name)=="marker": self.set_marker(idx,str(obj.currentText())) elif get_groupBox_purpouse(name)=="line": self.set_linestyle(idx,str(obj.currentText())) def singleComboBoxHandler(self,num): """ this takes care of the signal sent by a single combo box (as opposed to one combobox per row) The single combo box should be used to plot X versus Y or YR for different data sets in a children class of this one """ pass def colorButtonHandler(self): obj=self.sender() name=obj.objectName() name,idx=name.split("#") name=str(name) idx=int(idx) color = QtGui.QColorDialog.getColor(initial = obj.palette().color(1)) obj.setStyleSheet('QPushButton {background-color: %s}'%color.name()) # btn.palette().color(1).name() print color.name() self.set_color(idx,str(color.name())) def lineEditHandler(self,mystr): obj=self.sender() name=obj.objectName() name,idx=name.split("#") name=str(name) idx=int(idx) if self.channel_objects["groupBox_X"][idx].isChecked(): self.set_X_axis_label(self.channel_objects[name][idx].text()) self.update_plot() def set_axis_ticks(self,ticks): if not len(ticks)==3: print "some ticks are missing, you should have ticks for X, YL and YR axes" else: for t in ticks[1]: self.channel_objects["groupBox_Y"][t].setCheckState(True) # print "Y",str(self.lineEdit_Name[t].text()) for t in ticks[2]: self.channel_objects["groupBox_YR"][t].setCheckState(True) # print "YR",str(self.lineEdit_Name[t].text()) self.channel_objects["groupBox_X"][ticks[0]].setChecked(True) # print "X",str(self.lineEdit_Name[ticks[0]].text()) def get_X_axis_label(self): """Update which data is used for the X axis""" for num, box in enumerate(self.channel_objects["groupBox_X"]): if box.isChecked(): label=str(self.channel_objects["groupBox_Name"][num].text()) #getting rid of the eventual units if label.find('(')==-1: pass else: label=label[0:label.rfind('(')] return label def get_Y_axis_labels(self): """Update which data is used for the Y axis (both left and right)""" labels = [] for num, box in enumerate(self.channel_objects["groupBox_Y"]): if box.isChecked(): label=str(self.channel_objects["groupBox_Name"][num].text()) label=label[0:label.rfind('(')] labels.append(label) for num, box in enumerate(self.channel_objects["groupBox_YR"]): if box.isChecked(): label=str(self.channel_objects["groupBox_Name"][num].text()) label=label[0:label.rfind('(')] if not label in labels: labels.append(label) return labels def get_X_axis_index(self): """Update which data is used for the X axis""" index=0 for num, box in enumerate(self.channel_objects["groupBox_X"]): if box.isChecked(): index=num return index def get_fit_axis_index(self): """Update which data is used for the fitting procedure""" index=0 for num, box in enumerate(self.channel_objects["groupBox_fit"]): if box.isChecked(): index=num return index def get_Y_axis_index(self): """Update which data is used for the Y axis (only left)""" index = 0 for num, box in enumerate(self.channel_objects["groupBox_Y"]): if box.isChecked(): index=num return index def set_X_axis_label(self,newlabel): """Update which label is used for the X axis""" self.ax.set_xlabel(newlabel) def set_Y_axis_label(self,newlabel): """Update which label is used for the Y axis""" if np.size(newlabel) > 1: tot_label = newlabel[0] for i in range(1,np.size(newlabel)): tot_label = "%s, %s"%(tot_label,newlabel[i]) newlabel = tot_label elif not isinstance(newlabel,str) and np.iterable(newlabel): #a list with only one element newlabel = newlabel[0] print newlabel self.ax.set_ylabel(newlabel) def set_YR_axis_label(self,newlabel): """Update which label is used for the YR axis""" if np.size(newlabel) > 1: tot_label = newlabel[0] for i in range(1,np.size(newlabel)): tot_label = "%s, %s"%(tot_label,newlabel[i]) newlabel = tot_label elif np.iterable(newlabel): #a list with only one element newlabel = newlabel[0] self.axR.set_ylabel(newlabel) def convert_timestamp(self, timestamp): dts = map(datetime.datetime.fromtimestamp, timestamp) return dates.date2num(dts) # converted def set_axis_time(self,want_format=False): """ convert the time to a certain format """ if want_format: time_interval=self.data_array[-1,self.chan_X]-self.data_array[0,self.chan_X] if time_interval<500: hfmt = dates.DateFormatter('%m/%d %H:%M:%S') else: hfmt = dates.DateFormatter('%m/%d %H:%M') return hfmt else: time_data = self.convert_timestamp(self.data_array[:,self.chan_X]) return time_data def set_marker(self,idx,marker): """change the marker style of the plotted line in position idx""" if idx < len(self.ax.lines): self.ax.lines[idx].set_marker(marker) self.axR.lines[idx].set_marker(marker) self.mplwidget.rescale_and_draw() def set_linestyle(self,idx,linesty): """change the style of the plotted line in position idx""" if idx < len(self.ax.lines): self.ax.lines[idx].set_linestyle(linesty) self.axR.lines[idx].set_linestyle(linesty) self.mplwidget.rescale_and_draw() def set_color(self,idx,color): """change the color of the plotted line in position idx""" if idx < len(self.ax.lines): self.ax.lines[idx].set_color(color) self.axR.lines[idx].set_color(color) self.mplwidget.rescale_and_draw() def update_markers(self, marker_list): """change the marker style of all the lines according to a maker list""" for idx, m in enumerate(marker_list): if idx < len(self.ax.lines): self.ax.lines[idx].set_marker(m) self.axR.lines[idx].set_marker(m) self.mplwidget.rescale_and_draw() def update_colors(self, color_list): """change the color of all the lines according to a color list""" for idx, color in enumerate(color_list): if idx < len(self.ax.lines): self.ax.lines[idx].set_color(color) self.axR.lines[idx].set_color(color) self.mplwidget.rescale_and_draw() def update_labels(self, label_list): """change the label of all the lines according to a label list""" for idx, label_text in enumerate(label_list): if idx == len(self.channel_objects["groupBox_Name"]): self.add_channel_controls() self.channel_objects["groupBox_Name"][idx].setText(label_text) def update_plot(self, data_array = None): """ take a matrix (data_array) with a number of rows equal to the number of channel/lines in the window and plot them along the line direction it only plots if the checkbox of the line is checked """ if not data_array == None: if not isnparray(data_array) == True: raise isnparray(data_array) else: logging.debug("update the data_array") self.data_array = data_array if self.data_array.size>0 : # if the number of columns is more than the number of control boxes try: num_channels = self.data_array.shape[1] except: num_channels = self.data_array.size #if there is more instruments than channel numbers we expand the channels on the window while self.num_channels < num_channels: self.add_channel_controls() #there is a different treatment if x is choosen to be a time axis or quantity measured by an instrument if self.time_Xaxis: xdata=self.set_axis_time() else: xdata = self.data_array[:,self.chan_X] #go through the channels and update the lines for those who are checked for chan_Y, [line_L, line_R] in enumerate(zip (self.ax.lines, self.axR.lines)): if self.data_array.size>0: if self.channel_objects["groupBox_invert"][chan_Y].isChecked(): ydata = -self.data_array[:, chan_Y] else: ydata = self.data_array[:, chan_Y] #look which checkbox is checked and plot corresponding data if self.channel_objects["groupBox_Y"][chan_Y].isChecked() and self.data_array.size>0: line_L.set_data(xdata, ydata) else: line_L.set_data([],[]) #look which checkbox is checked and plot corresponding data if self.channel_objects["groupBox_YR"][chan_Y].isChecked() and self.data_array.size>0: line_R.set_data(xdata, ydata) else: line_R.set_data([],[]) else: #if an empty array was given we set the lines to empty arrays for line_L, line_R in zip (self.ax.lines, self.axR.lines): line_L.set_data([],[]) line_R.set_data([],[]) self.mplwidget.rescale_and_draw() def update_fit(self,fitp): """ take a matrix (data_array) with a number of lines equal to 2 and a number of rows equal the number of lines in self.data_array and plot line 1 as a function of line 2 right now there is only the possibility to create one fit at the time as we wanted to be able to access the line number and modify the fit or delete it. we can always plot more things on the plot area but we wanted to have some control on the objects """ logging.debug(fitp) # if the number of columns is more than the number of control boxes if self.num_channels == len(self.ax.lines): line, = self.ax.plot([],[],"-", color = "#e62e00",linewidth = 2) line, = self.ax.plot([],[],"--", color = "#e62e00",linewidth = 2) #if there is a resctiction on the data set idx_start = fitp["limits"][0] idx_stop = fitp["limits"][1] #there is a different treatment if x is choosen to be a time axis or quantity measured by an instrument if self.time_Xaxis: xdataw=self.set_axis_time() else: xdataw = self.data_array[:,self.chan_X] xdata = xdataw[idx_start:idx_stop] fitYw = fitp["fit_func"](xdataw, *fitp["fitp_val"]) fitY = fitp["fit_func"](xdata, *fitp["fitp_val"]) self.ax.lines[-1].set_data(xdataw, fitYw) self.ax.lines[-2].set_data(xdata, fitY) #call a method defined in the module mplZoomwidget.py self.mplwidget.rescale_and_draw() def remove_fit(self): """ remove the last line on the ax as this position is by default reserved for the fit function. There is probaly a cleverer way to do so... """ if self.num_channels < len(self.ax.lines): self.ax.lines[-1].set_data([], []) self.ax.lines[-2].set_data([], []) def print_figure(self, file_name = "unknown"): """Sends the current plot to a printer""" printer = QPrinter() # Get the printer information from a QPrinter dialog box dlg = QPrintDialog(printer) if(dlg.exec_()!= QDialog.Accepted): return p = QPainter(printer) # dpi*3 because otherwise it looks pixelated (not sure why, bug?) dpi = printer.resolution() # # copy the current figure contents to a standard size figure # fig2 = plt.figure(figsize=(8,5), dpi = dpi) # # ax = fig2.add_subplot(1,1,1) # for line in self.ax.lines: # if line.get_xdata() != []: # ax.plot (line.get_xdata(), line.get_ydata(), label= line.get_label()) # ax.set_xlim(self.ax.get_xlim()) # ax.set_ylim(self.ax.get_ylim()) # ax.set_xlabel(self.ax.get_xlabel()) # ax.set_ylabel(self.ax.get_ylabel()) # # self.fig.savefig( # # support for printing right axes should go here # # # Shink current axis by 20% # box = ax.get_position() # ax.set_position([box.x0, box.y0, box.width * 0.8, box.height]) # Put a legend to the right of the current axis #ax.legend(loc='center left', bbox_to_anchor=(1, 0.5)) # goal: print the figure with the same aspect ratio as it's shown on the # screen, but fixed width to fill the page nicely margin_inches = 0.5 paper_width = 8.5 max_width = paper_width - 2*margin_inches max_height = 7 width = self.fig.bbox_inches.width height = self.fig.bbox_inches.height ratio = height/width if ratio > max_height/max_width: # scale on width, because otherwise won't fit on page. dpi_scale = max_height/height height = max_height width = ratio/height else: dpi_scale = max_width/width width = max_width height = ratio * width self.fig.savefig("temp.png", dpi=dpi * dpi_scale * 10) # half inch margins margin_top = 0.5*dpi margin_left = 0.5*dpi # matplotlib's svg rendering has a bug if the data extends beyond the # plot limits. Below is what would be used for temp.svg #svg = QtSvg.QSvgRenderer("temp.svg") #svg.render(p, QRectF(margin_top,margin_left, 8*dpi, 5*dpi)) p.drawImage(QRectF(margin_top,margin_left, width*dpi, height*dpi), QImage("temp.png", format='png')) p.drawText(margin_left, 600, "Data recorded to: " + file_name) p.end() def is_plot_display_window(self): """used to differentiate PlotDisplayWindow from LoadPlotWindow""" return True
def setupUi(self, RecordSweepWindow): RecordSweepWindow.setObjectName(_fromUtf8("RecordSweepWindow")) RecordSweepWindow.resize(1099, 520) RecordSweepWindow.setWindowTitle( QtGui.QApplication.translate("RecordSweepWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8) ) self.centralwidget = QtGui.QWidget(RecordSweepWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.gridLayout = QtGui.QGridLayout(self.centralwidget) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.mplwidget = MatplotlibZoomWidget(self.centralwidget) self.mplwidget.setObjectName(_fromUtf8("mplwidget")) self.gridLayout.addWidget(self.mplwidget, 0, 0, 2, 1) self.startStopButton = QtGui.QPushButton(self.centralwidget) self.startStopButton.setText( QtGui.QApplication.translate("RecordSweepWindow", "Start", None, QtGui.QApplication.UnicodeUTF8) ) self.startStopButton.setObjectName(_fromUtf8("startStopButton")) self.gridLayout.addWidget(self.startStopButton, 0, 1, 1, 1) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.groupBox_Name = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Name.sizePolicy().hasHeightForWidth()) self.groupBox_Name.setSizePolicy(sizePolicy) self.groupBox_Name.setMinimumSize(QtCore.QSize(100, 0)) self.groupBox_Name.setTitle( QtGui.QApplication.translate("RecordSweepWindow", "Channel", None, QtGui.QApplication.UnicodeUTF8) ) self.groupBox_Name.setObjectName(_fromUtf8("groupBox_Name")) self.horizontalLayout_3.addWidget(self.groupBox_Name) self.tabWidget = QtGui.QTabWidget(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth()) self.tabWidget.setSizePolicy(sizePolicy) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.tab = QtGui.QWidget() self.tab.setObjectName(_fromUtf8("tab")) self.horizontalLayout = QtGui.QHBoxLayout(self.tab) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.groupBox_Type = QtGui.QGroupBox(self.tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Type.sizePolicy().hasHeightForWidth()) self.groupBox_Type.setSizePolicy(sizePolicy) self.groupBox_Type.setMinimumSize(QtCore.QSize(80, 0)) self.groupBox_Type.setTitle( QtGui.QApplication.translate("RecordSweepWindow", "Type", None, QtGui.QApplication.UnicodeUTF8) ) self.groupBox_Type.setObjectName(_fromUtf8("groupBox_Type")) self.horizontalLayout.addWidget(self.groupBox_Type) self.groupBox_Instr = QtGui.QGroupBox(self.tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Instr.sizePolicy().hasHeightForWidth()) self.groupBox_Instr.setSizePolicy(sizePolicy) self.groupBox_Instr.setMinimumSize(QtCore.QSize(80, 0)) self.groupBox_Instr.setTitle( QtGui.QApplication.translate("RecordSweepWindow", "Instrument", None, QtGui.QApplication.UnicodeUTF8) ) self.groupBox_Instr.setObjectName(_fromUtf8("groupBox_Instr")) self.horizontalLayout.addWidget(self.groupBox_Instr) self.groupBox_Param = QtGui.QGroupBox(self.tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Param.sizePolicy().hasHeightForWidth()) self.groupBox_Param.setSizePolicy(sizePolicy) self.groupBox_Param.setMinimumSize(QtCore.QSize(80, 0)) self.groupBox_Param.setTitle( QtGui.QApplication.translate("RecordSweepWindow", "Parameter", None, QtGui.QApplication.UnicodeUTF8) ) self.groupBox_Param.setObjectName(_fromUtf8("groupBox_Param")) self.horizontalLayout.addWidget(self.groupBox_Param) self.tabWidget.addTab(self.tab, _fromUtf8("")) self.tab_2 = QtGui.QWidget() self.tab_2.setObjectName(_fromUtf8("tab_2")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.tab_2) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.groupBox_X = QtGui.QGroupBox(self.tab_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_X.sizePolicy().hasHeightForWidth()) self.groupBox_X.setSizePolicy(sizePolicy) self.groupBox_X.setTitle( QtGui.QApplication.translate("RecordSweepWindow", "X", None, QtGui.QApplication.UnicodeUTF8) ) self.groupBox_X.setObjectName(_fromUtf8("groupBox_X")) self.horizontalLayout_2.addWidget(self.groupBox_X) self.groupBox_Y = QtGui.QGroupBox(self.tab_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Y.sizePolicy().hasHeightForWidth()) self.groupBox_Y.setSizePolicy(sizePolicy) self.groupBox_Y.setTitle( QtGui.QApplication.translate("RecordSweepWindow", "Y", None, QtGui.QApplication.UnicodeUTF8) ) self.groupBox_Y.setObjectName(_fromUtf8("groupBox_Y")) self.horizontalLayout_2.addWidget(self.groupBox_Y) spacerItem = QtGui.QSpacerItem(187, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.tabWidget.addTab(self.tab_2, _fromUtf8("")) self.horizontalLayout_3.addWidget(self.tabWidget) self.gridLayout.addLayout(self.horizontalLayout_3, 1, 1, 1, 1) RecordSweepWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(RecordSweepWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 1099, 21)) self.menubar.setObjectName(_fromUtf8("menubar")) RecordSweepWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(RecordSweepWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) RecordSweepWindow.setStatusBar(self.statusbar) self.actionSave_figure = QtGui.QAction(RecordSweepWindow) self.actionSave_figure.setText( QtGui.QApplication.translate("RecordSweepWindow", "Save figure", None, QtGui.QApplication.UnicodeUTF8) ) self.actionSave_figure.setObjectName(_fromUtf8("actionSave_figure")) self.actionQuit = QtGui.QAction(RecordSweepWindow) self.actionQuit.setText( QtGui.QApplication.translate("RecordSweepWindow", "Quit", None, QtGui.QApplication.UnicodeUTF8) ) self.actionQuit.setObjectName(_fromUtf8("actionQuit")) self.retranslateUi(RecordSweepWindow) self.tabWidget.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(RecordSweepWindow)
def setupUi(self, RecordSweepWindow): RecordSweepWindow.setObjectName(_fromUtf8("RecordSweepWindow")) RecordSweepWindow.resize(1099, 520) RecordSweepWindow.setWindowTitle(QtGui.QApplication.translate("RecordSweepWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) self.centralwidget = QtGui.QWidget(RecordSweepWindow) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.gridLayout = QtGui.QGridLayout(self.centralwidget) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.mplwidget = MatplotlibZoomWidget(self.centralwidget) self.mplwidget.setObjectName(_fromUtf8("mplwidget")) self.gridLayout.addWidget(self.mplwidget, 0, 0, 2, 1) self.startStopButton = QtGui.QPushButton(self.centralwidget) self.startStopButton.setText(QtGui.QApplication.translate("RecordSweepWindow", "Start", None, QtGui.QApplication.UnicodeUTF8)) self.startStopButton.setObjectName(_fromUtf8("startStopButton")) self.gridLayout.addWidget(self.startStopButton, 0, 1, 1, 1) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) self.groupBox_Name = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Name.sizePolicy().hasHeightForWidth()) self.groupBox_Name.setSizePolicy(sizePolicy) self.groupBox_Name.setMinimumSize(QtCore.QSize(100, 0)) self.groupBox_Name.setTitle(QtGui.QApplication.translate("RecordSweepWindow", "Channel", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_Name.setObjectName(_fromUtf8("groupBox_Name")) self.horizontalLayout_3.addWidget(self.groupBox_Name) self.tabWidget = QtGui.QTabWidget(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.tabWidget.sizePolicy().hasHeightForWidth()) self.tabWidget.setSizePolicy(sizePolicy) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.tab = QtGui.QWidget() self.tab.setObjectName(_fromUtf8("tab")) self.horizontalLayout = QtGui.QHBoxLayout(self.tab) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.groupBox_Type = QtGui.QGroupBox(self.tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Type.sizePolicy().hasHeightForWidth()) self.groupBox_Type.setSizePolicy(sizePolicy) self.groupBox_Type.setMinimumSize(QtCore.QSize(80, 0)) self.groupBox_Type.setTitle(QtGui.QApplication.translate("RecordSweepWindow", "Type", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_Type.setObjectName(_fromUtf8("groupBox_Type")) self.horizontalLayout.addWidget(self.groupBox_Type) self.groupBox_Instr = QtGui.QGroupBox(self.tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Instr.sizePolicy().hasHeightForWidth()) self.groupBox_Instr.setSizePolicy(sizePolicy) self.groupBox_Instr.setMinimumSize(QtCore.QSize(80, 0)) self.groupBox_Instr.setTitle(QtGui.QApplication.translate("RecordSweepWindow", "Instrument", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_Instr.setObjectName(_fromUtf8("groupBox_Instr")) self.horizontalLayout.addWidget(self.groupBox_Instr) self.groupBox_Param = QtGui.QGroupBox(self.tab) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Param.sizePolicy().hasHeightForWidth()) self.groupBox_Param.setSizePolicy(sizePolicy) self.groupBox_Param.setMinimumSize(QtCore.QSize(80, 0)) self.groupBox_Param.setTitle(QtGui.QApplication.translate("RecordSweepWindow", "Parameter", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_Param.setObjectName(_fromUtf8("groupBox_Param")) self.horizontalLayout.addWidget(self.groupBox_Param) self.tabWidget.addTab(self.tab, _fromUtf8("")) self.tab_2 = QtGui.QWidget() self.tab_2.setObjectName(_fromUtf8("tab_2")) self.horizontalLayout_2 = QtGui.QHBoxLayout(self.tab_2) self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.groupBox_X = QtGui.QGroupBox(self.tab_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_X.sizePolicy().hasHeightForWidth()) self.groupBox_X.setSizePolicy(sizePolicy) self.groupBox_X.setTitle(QtGui.QApplication.translate("RecordSweepWindow", "X", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_X.setObjectName(_fromUtf8("groupBox_X")) self.horizontalLayout_2.addWidget(self.groupBox_X) self.groupBox_Y = QtGui.QGroupBox(self.tab_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_Y.sizePolicy().hasHeightForWidth()) self.groupBox_Y.setSizePolicy(sizePolicy) self.groupBox_Y.setTitle(QtGui.QApplication.translate("RecordSweepWindow", "YL", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_Y.setObjectName(_fromUtf8("groupBox_Y")) self.horizontalLayout_2.addWidget(self.groupBox_Y) self.groupBox_YR = QtGui.QGroupBox(self.tab_2) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.groupBox_YR.sizePolicy().hasHeightForWidth()) self.groupBox_YR.setSizePolicy(sizePolicy) self.groupBox_YR.setTitle(QtGui.QApplication.translate("RecordSweepWindow", "YR", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_YR.setObjectName(_fromUtf8("groupBox_YR")) self.horizontalLayout_2.addWidget(self.groupBox_YR) spacerItem = QtGui.QSpacerItem(187, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem) self.tabWidget.addTab(self.tab_2, _fromUtf8("")) self.horizontalLayout_3.addWidget(self.tabWidget) self.gridLayout.addLayout(self.horizontalLayout_3, 1, 1, 1, 1) RecordSweepWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(RecordSweepWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 1099, 21)) self.menubar.setObjectName(_fromUtf8("menubar")) RecordSweepWindow.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(RecordSweepWindow) self.statusbar.setObjectName(_fromUtf8("statusbar")) RecordSweepWindow.setStatusBar(self.statusbar) self.actionSave_figure = QtGui.QAction(RecordSweepWindow) self.actionSave_figure.setText(QtGui.QApplication.translate("RecordSweepWindow", "Save figure", None, QtGui.QApplication.UnicodeUTF8)) self.actionSave_figure.setObjectName(_fromUtf8("actionSave_figure")) self.actionQuit = QtGui.QAction(RecordSweepWindow) self.actionQuit.setText(QtGui.QApplication.translate("RecordSweepWindow", "Quit", None, QtGui.QApplication.UnicodeUTF8)) self.actionQuit.setObjectName(_fromUtf8("actionQuit")) self.lineEdit_Name = [] self.comboBox_Type = [] self.comboBox_Instr = [] self.comboBox_Param = [] self.radioButton_X = [] self.checkBox_Y = [] self.checkBox_YR = [] for i in range (self.MAX_CHANNELS): pos_LE = lambda x: (20 * x + 1) + 50 self.lineEdit_Name.append(QtGui.QLineEdit(self.groupBox_Name)) self.lineEdit_Name[i].setGeometry(QtCore.QRect(10, pos_LE(i), 81, 16)) self.lineEdit_Name[i].setText(QtGui.QApplication.translate("RecordSweepWindow", "", None, QtGui.QApplication.UnicodeUTF8)) self.lineEdit_Name[i].setObjectName(_fromUtf8("lineEdit_Name")) self.comboBox_Type.append(QtGui.QComboBox(self.groupBox_Type)) self.comboBox_Type[i].setGeometry(QtCore.QRect(5, 20 * (i+1), 71, 16)) self.comboBox_Type[i].setObjectName(_fromUtf8("comboBox")) self.comboBox_Type[i].addItems(self.INSTRUMENT_TYPES) self.connect(self.comboBox_Type[i], QtCore.SIGNAL("currentIndexChanged(int)"), self.ComboBoxTypeHandler) self.comboBox_Instr.append(QtGui.QComboBox(self.groupBox_Instr)) self.comboBox_Instr[i].setGeometry(QtCore.QRect(5, 20 * (i+1), 71, 16)) self.comboBox_Instr[i].setObjectName(_fromUtf8("comboBox")) self.comboBox_Param.append(QtGui.QComboBox(self.groupBox_Param)) self.comboBox_Param[i].setGeometry(QtCore.QRect(5, 20 * (i+1), 71, 16)) self.comboBox_Param[i].setObjectName(_fromUtf8("comboBox")) self.radioButton_X.append(QtGui.QRadioButton(self.groupBox_X)) self.radioButton_X[i].setGeometry(QtCore.QRect(7, 20*(i+1), 16, 16)) self.radioButton_X[i].setText(_fromUtf8("")) self.radioButton_X[i].setObjectName(_fromUtf8("radioButton_" + str(i))) self.connect(self.radioButton_X[i], QtCore.SIGNAL("toggled(bool)"), self.XRadioButtonHandler) self.checkBox_Y.append(QtGui.QCheckBox(self.groupBox_Y)) self.checkBox_Y[i].setGeometry(QtCore.QRect(5, 20 * (i+1), 16, 16)) self.checkBox_Y[i].setText(_fromUtf8("")) self.checkBox_Y[i].setObjectName(_fromUtf8("checkBox_" +str(i))) self.connect(self.checkBox_Y[i], QtCore.SIGNAL("stateChanged(int)"), self.YCheckBoxHandler) self.checkBox_YR.append(QtGui.QCheckBox(self.groupBox_YR)) self.checkBox_YR[i].setGeometry(QtCore.QRect(5, 20 * (i+1), 16, 16)) self.checkBox_YR[i].setText(_fromUtf8("")) self.checkBox_YR[i].setObjectName(_fromUtf8("checkBox_" +str(i))) self.connect(self.checkBox_Y[i], QtCore.SIGNAL("stateChanged(int)"), self.YCheckBoxHandler) self.tabWidget.setCurrentIndex(0) self.retranslateUi(RecordSweepWindow) self.tabWidget.setCurrentIndex(1) QtCore.QMetaObject.connectSlotsByName(RecordSweepWindow)