예제 #1
0
파일: settings.py 프로젝트: whs/runekit
    def _layout(self):
        layout = QFormLayout(self)
        self.setLayout(layout)

        layout.addRow(
            None,
            QLabel("RuneKit needs to be restarted for changes to take effect",
                   self),
        )

        tooltip_label = QLabel("Display tooltips as", self)
        tooltip_field = QComboBox(self)

        selected = int(
            self.settings.value("settings/tooltip",
                                AutoNotifier.METHOD_NOTIFICATION))
        selected_idx = 0
        for idx, method in enumerate(AutoNotifier.availableMethods().items()):
            tooltip_field.insertItem(idx, method[1])
            if method[0] == selected:
                selected_idx = idx

        tooltip_field.setCurrentIndex(selected_idx)

        tooltip_field.currentIndexChanged.connect(self.preview_tooltip)
        tooltip_field.currentIndexChanged.connect(self.on_tooltip_change)
        layout.addRow(tooltip_label, tooltip_field)

        border_field = QCheckBox("Styled window border", self)
        border_field.setDisabled(sys.platform == "darwin")
        border_field.setChecked(
            (self.settings.value("settings/styledBorder", "true") == "true")
            and sys.platform != "darwin")
        border_field.stateChanged.connect(self.on_change_styled_border)
        layout.addRow(None, border_field)
    def table_setup(self, series, item):
        """Generates table elements based on series.

        Clears any existing elements in the table, then uses series to
        generate a two-column table, with headings in the first column
        and data in the second. The first column is not editable,
        and the second column is editable.

        """
        headings = ["Name", "Alt. Names", "Author", "Volumes Owned",
                    "Next Volume", "Publisher", "Completed"]
        data = [series.name, series.alt_names, series.author,
                series.volumes_owned_readable, series.next_volume,
                series.publisher, "Yes" if series.is_completed else "No"]

        # Prepare table
        self.edit_series_table.clear()
        self.edit_series_table.setRowCount(len(headings))
        self.edit_series_table.setColumnCount(2)
        self.edit_series_table.setEditTriggers(
            QAbstractItemView.AllEditTriggers)
        header = self.edit_series_table.horizontalHeader()
        header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(1, QHeaderView.Stretch)

        # Populate table
        for i in range(len(headings)):
            headerItem = QTableWidgetItem(headings[i])
            headerItem.setFlags(headerItem.flags() & ~int(Qt.ItemIsEditable))
            dataItem = None
            self.edit_series_table.setItem(i, 0, headerItem)

            if headings[i] == "Completed":
                dataItem = QComboBox()
                dataItem.insertItem(0, "No")
                dataItem.insertItem(1, "Yes")
                if str(data[i]) == "No":
                    dataItem.setCurrentIndex(0)
                else:
                    dataItem.setCurrentIndex(1)
                self.edit_series_table.setCellWidget(i, 1, dataItem)
            else:
                dataItem = QTableWidgetItem(str(data[i]))
                if headings[i] == "Next Volume":
                    dataItem.setFlags(dataItem.flags()
                                      & ~int(Qt.ItemIsEditable))
                self.edit_series_table.setItem(i, 1, dataItem)

            # set property editable if series_info_display double-clicked
            if headings[i] == item and item not in ["Next Volume",
                                                    "Completed"]:
                self.edit_series_table.editItem(dataItem)
예제 #3
0
class ManageData(QWidget):
    def __init__(self, referenced_table, parent=None):
        super().__init__(parent)
        self.table = referenced_table

        self.search_layout = QHBoxLayout()

        self.search_text = QLabel()
        self.search_text.setText("Search Table: ")

        self.input_field = QLineEdit()

        self.input_field.setPlaceholderText("Type field value...")
        self.input_field.textChanged.connect(self.search_table)
        self.input_field.returnPressed.connect(self.search_table)

        self.combo_text = QLabel("Search by column: ")
        self.combo_options = QComboBox()
        self.combo_options.insertItem(0, "None chosen")
        self.add_combo_options()

        self.search_layout.addWidget(self.search_text)
        self.search_layout.addWidget(self.input_field)
        self.search_layout.addWidget(self.combo_text)
        self.search_layout.addWidget(self.combo_options)

        self.setLayout(self.search_layout)

    def add_combo_options(self):
        list_of_columns = self.table.model().metadata["columns"]
        i = 0
        for column in list_of_columns:
            i += 1
            self.combo_options.insertItem(i, column)

    def search_table(self, line=None):
        if line == None:
            if self.input_field.text() == "":
                return
            input_line = self.input_field.text()
            combo_line = self.combo_options.currentText()
            self.table.model().table_search(input_line, combo_line)
        else:
            combo_line = self.combo_options.currentText()
            self.table.model().table_search(line, combo_line)
    def table_setup(self):
        """Generates table elements for creation of a new series.

        Clears any existing elements in the table, then generates a
        two-column table, with headings in the first column and space
        for series info in the second. The first column is not
        editable, and the second column is editable. By default, only
        two fields are filled in when the table is completed: 'Name'
        and 'Completed'.

        """
        headings = ["Name", "Alt. Names", "Author", "Volumes Owned",
                    "Publisher", "Completed"]
        data = ["Unknown", "", "", "", "", "No"]

        # Prepare table
        self.add_series_table.clear()
        self.add_series_table.setRowCount(len(headings))
        self.add_series_table.setColumnCount(2)
        header = self.add_series_table.horizontalHeader()
        header.setSectionResizeMode(0, QHeaderView.ResizeToContents)
        header.setSectionResizeMode(1, QHeaderView.Stretch)

        # Populate table
        for i in range(len(headings)):
            headerItem = QTableWidgetItem(headings[i])
            headerItem.setFlags(headerItem.flags() & ~int(Qt.ItemIsEditable))
            self.add_series_table.setItem(i, 0, headerItem)

            if headings[i] == "Completed":
                dataItem = QComboBox()
                dataItem.insertItem(0, "No")
                dataItem.insertItem(1, "Yes")
                if str(data[i]) == "No":
                    dataItem.setCurrentIndex(0)
                else:
                    dataItem.setCurrentIndex(1)
                self.add_series_table.setCellWidget(i, 1, dataItem)
            else:
                dataItem = QTableWidgetItem(str(data[i]))
                self.add_series_table.setItem(i, 1, dataItem)

        self.add_series_table.itemChanged.connect(self.validate_cells)
예제 #5
0
    def _layout(self):
        layout = QFormLayout(self)
        self.setLayout(layout)

        tooltip_label = QLabel("Display tooltips as", self)
        tooltip_field = QComboBox(self)
        tooltip_field.insertItem(0, "Disabled")
        tooltip_field.insertItem(1, "Notification")  # XXX: Check support
        tooltip_field.insertItem(2, "Cursor tooltip")
        tooltip_field.currentIndexChanged.connect(self.preview_tooltip)
        layout.addRow(tooltip_label, tooltip_field)

        border_field = QCheckBox("Styled window border", self)
        border_field.setDisabled(sys.platform == "darwin")
        border_field.setChecked(sys.platform != "darwin")
        layout.addRow(None, border_field)

        # I think this doesn't belong to "Interface"
        # either rename it to settings or make separate game tab
        capturei_label = QLabel("Capture interval", self)
        capturei_layout = QHBoxLayout()
        capturei_field = QSpinBox(self)
        capturei_field.setRange(100, 2000)
        capturei_field.setSingleStep(100)
        capturei_field.setValue(100)
        capturei_layout.addWidget(capturei_field, 1)
        capturei_unit = QLabel("ms", self)
        capturei_layout.addWidget(capturei_unit, 0)
        layout.addRow(capturei_label, capturei_layout)
예제 #6
0
class CharUI(QWidget):
    """
    Main widget for the Character creator view.

    :param MainFrame mainframe: the application mainframe
    :param QWidget op: parent widget
    """
    def __init__(self, mainframe, op):
        print("Starting...")
        QWidget.__init__(self)
        self.mainframe = mainframe
        self.op = op
        self.nameT = None
        self.infoT = None
        self.importantB = None
        self.initUI()

    def initUI(self):
        """
        Initializes the GUI.
        Does a lot of stuff.
        """
        self.mainframe.setWindowTitle("Character Creator")

        grid = QGridLayout()
        self.setLayout(grid)

        nameL = QLabel(self, text="Name:")
        grid.addWidget(nameL, 1, 1)

        self.nameT = QLineEdit(self)
        self.nameT.setFixedSize(200, 20)
        grid.addWidget(self.nameT, 1, 2, 1, 2)

        self.importantB = QCheckBox(self, text="Important?")
        grid.addWidget(self.importantB, 1, 4)

        infoL = QLabel(self, text="Info:")
        grid.addWidget(infoL, 2, 1)

        self.infoT = QTextEdit(self)
        self.infoT.setFixedSize(300, 150)
        grid.addWidget(self.infoT, 2, 2, 1, 3)

        save = QPushButton(self, text="Save")
        save.clicked.connect(self.save)
        grid.addWidget(save, 4, 1)

        remove = QPushButton(self, text="Remove")
        remove.clicked.connect(self.remove)
        grid.addWidget(remove, 4, 2)

        back = QPushButton(self, text="Back")
        back.clicked.connect(self.back)
        grid.addWidget(back, 4, 3)

        names = json_reader.readCharNames()
        names.append("New")
        self.allChars = QComboBox(self)
        self.allChars.activated.connect((lambda: self.loadChar(self.allChars.currentText())))
        self.allChars.addItems(names)
        self.allChars.setCurrentIndex(self.allChars.count()-1)
        grid.addWidget(self.allChars, 4, 4)

    def loadChar(self, name):
        """
        Load one character from file based on the name.

        :param str name: name of character to load
        """
        print("Loading...")
        if self.importantB.isChecked():
            self.importantB.toggle()
        self.nameT.clear()
        self.infoT.clear()
        if name == "New":
            return
        characterL = json_reader.readOne(name, 'chars')
        charTL = Character(characterL["name"], characterL["desc"], characterL["important"])
        if charTL.getImportant():
            self.importantB.toggle()
        self.nameT.setText(charTL.getName())
        self.infoT.setText(charTL.getDesc())
        print("Loaded character " + self.allChars.currentText())

    def remove(self):
        """
        Remove a character from the list, and remove them from disk.
        """
        if not popup("Are you certain you want to completely remove this character?\n(Cannot be undone)",
                     "Warning"):
            return
        print("Removing character " + self.allChars.currentText())
        json_reader.deleteChar(self.allChars.currentText())
        self.allChars.removeItem(self.allChars.currentIndex())
        self.allChars.setCurrentIndex(self.allChars.count()-1)
        self.loadChar("New")

    def save(self):
        """
        Save a character to disk from the information entered in the GUI.
        """
        if self.nameT.text() in ["New", ""]:
            popup("Sorry, your character cannot be called \""+self.nameT.text()+"\". That is a reserved "
                  "keyword (and it's also a dumb name)", "Critical")
            return
        print("Saving")
        try:
            toWrite = Character(self.nameT.text(), self.infoT.toPlainText(), self.importantB.isChecked())
        except UnicodeEncodeError as e:
            print(e)
            print(type(e))
            popup("Sorry, unicode characters are not supported.", "Critical")
            return
        json_reader.writeOne(toWrite, 'chars')
        if toWrite.getName() not in [self.allChars.itemText(i) for i in range(self.allChars.count())]:
            self.allChars.insertItem(self.allChars.count()-1, self.nameT.text())
            self.allChars.setCurrentIndex(self.allChars.count()-2)
        print("Saved")

    def back(self):
        """
        Return the view to the calling widget.
        """
        self.mainframe.changeState(self.op)
예제 #7
0
class AddData(QWidget):
    def __init__(self, referenced_table, parent=None):
        super().__init__(parent)
        self.table = referenced_table
        self.layout = QVBoxLayout()

        self.search_layout = QHBoxLayout()

        self.search_text = QLabel()
        self.search_text.setText("Search Table: ")

        self.input_field = QLineEdit()
        self.input_field.setPlaceholderText("Type field value...")
        self.input_field.textChanged.connect(self.search_table)
        self.input_field.returnPressed.connect(self.search_table)

        self.combo_text = QLabel("Search by column: ")
        self.combo_options = QComboBox()
        self.combo_options.insertItem(0, "None chosen")
        self.add_combo_options()

        self.search_layout.addWidget(self.search_text)
        self.search_layout.addWidget(self.input_field)
        self.search_layout.addWidget(self.combo_text)
        self.search_layout.addWidget(self.combo_options)

        self.form = QFormLayout()
        self.form.setFieldGrowthPolicy(QFormLayout.FieldsStayAtSizeHint)
        self.form.setFormAlignment(Qt.AlignLeft | Qt.AlignTop)
        for column in self.table.model().metadata['columns']:
            self.form.addRow(column, QLineEdit())
        self.button = QPushButton("Add")
        self.button.setStyleSheet("width: 125px")
        self.button.clicked.connect(self.add_row)
        self.fresh_button = QPushButton("Start Fresh")
        self.fresh_button.clicked.connect(self.clean)
        self.form.addWidget(self.button)
        self.form.addWidget(self.fresh_button)
        self.fresh_button.setVisible(False)

        self.layout.addLayout(self.search_layout)
        self.layout.addLayout(self.form)
        self.setLayout(self.layout)

    def add_row(self):
        obj = {}
        i = 0
        j = 0
        while i < 2 * len(self.table.model().metadata["columns"]):
            obj[self.table.model().metadata["columns"][j]] = self.form.itemAt(
                i + 1).widget().text()
            j += 1
            i += 2

        self.table.model().insert_row(obj)
        self.fresh_button.setVisible(True)

    def clean(self):
        i = 0
        while i < 2 * len(self.table.model().metadata["columns"]):
            self.form.itemAt(i + 1).widget().setText("")
            i += 2

    def add_combo_options(self):
        list_of_columns = self.table.model().metadata["columns"]
        i = 0
        for column in list_of_columns:
            i += 1
            self.combo_options.insertItem(i, column)

    def search_table(self, line=None):
        if line == None:
            if self.input_field.text() == "":
                return
            input_line = self.input_field.text()
            combo_line = self.combo_options.currentText()
            self.table.model().table_search(input_line, combo_line)
        else:
            combo_line = self.combo_options.currentText()
            self.table.model().table_search(line, combo_line)
예제 #8
0
class MyWidget(QWidget):
    def __init__(self):
        QWidget.__init__(self)

        self.ip = default_ip
        self.nPoint = 1000
        self.nChannel = 4
        self.nRow = 4
        layout_final = QVBoxLayout()

        #layout: ip and connect checkbox
        text = QLabel("IPv4 Address:", self)
        text.setAlignment(Qt.AlignCenter)
        self.ip_input = QLineEdit(self.ip, self)
        self.connect_input = QCheckBox("connect", self)

        layout = QHBoxLayout()
        layout.addWidget(text)
        layout.addWidget(self.ip_input)
        layout.addWidget(self.connect_input)
        layout_final.addLayout(layout)

        #layout: Name
        text = QLabel("Name:", self)
        text.setAlignment(Qt.AlignRight)
        self.name = QLabel("", self)

        layout = QHBoxLayout()
        layout.addWidget(text)
        layout.addWidget(self.name)
        layout_final.addLayout(layout)

        #layout: Time
        text = QLabel("Time:", self)
        text.setAlignment(Qt.AlignRight)
        self.time = QLabel("", self)

        layout = QHBoxLayout()
        layout.addWidget(text)
        layout.addWidget(self.time)
        layout_final.addLayout(layout)

        #layout: Horizontal
        text = QLabel("Horizontal: Scale (second per division):", self)
        self.x_scale_output = QLineEdit("", self)
        self.x_scale_input_zoom_in = QPushButton("+", self)
        self.x_scale_input_zoom_out = QPushButton("-", self)

        layout = QHBoxLayout()
        layout.addWidget(text)
        layout.addWidget(self.x_scale_output)
        layout.addWidget(self.x_scale_input_zoom_in)
        layout.addWidget(self.x_scale_input_zoom_out)
        layout_final.addLayout(layout)

        #layout: Vertical
        text1 = QLabel("Vertical: Channel:", self)
        self.y_channel_input = QComboBox(self)
        for i in range(self.nChannel):
            self.y_channel_input.insertItem(i, "Ch{0}".format(i + 1))
        self.y_enabled = QCheckBox("Enabled", self)

        text2 = QLabel("Coupling:", self)
        self.y_coupling = QComboBox(self)
        self.y_coupling.insertItem(0, "DC")
        self.y_coupling.insertItem(1, "AC")

        text3 = QLabel("Scale (V per division):", self)
        self.y_scale_output = QLineEdit("", self)
        self.y_scale_input_zoom_in = QPushButton("+", self)
        self.y_scale_input_zoom_out = QPushButton("-", self)

        layout = QHBoxLayout()
        layout.addWidget(text1)
        layout.addWidget(self.y_channel_input)
        layout.addWidget(self.y_enabled)
        layout.addWidget(text2)
        layout.addWidget(self.y_coupling)
        layout.addWidget(text3)
        layout.addWidget(self.y_scale_output)
        layout.addWidget(self.y_scale_input_zoom_in)
        layout.addWidget(self.y_scale_input_zoom_out)
        layout_final.addLayout(layout)

        #layout: Measurement config
        text1 = QLabel("Measurement:", self)
        text2 = QLabel("Row:", self)
        text2.setAlignment(Qt.AlignRight)
        self.measurement_row_input = QComboBox(self)
        for i in range(self.nRow):
            self.measurement_row_input.insertItem(i, str(i + 1))
        self.measurement_row_input.setCurrentText("1")

        self.measurement_enabled = QCheckBox("Enabled", self)

        text3 = QLabel("Channel:", self)
        text3.setAlignment(Qt.AlignRight)
        self.measurement_channel_input = QComboBox(self)
        for i in range(self.nChannel):
            self.measurement_channel_input.insertItem(i, "CH{0}".format(i + 1))

        text4 = QLabel("Type:", self)
        text4.setAlignment(Qt.AlignRight)
        self.measurement_type_input = QComboBox(self)
        self.measurement_type_input.insertItem(0, "MEAN")
        self.measurement_type_input.insertItem(1, "RMS")

        layout = QHBoxLayout()
        layout.addWidget(text1)
        layout.addWidget(text2)
        layout.addWidget(self.measurement_row_input)
        layout.addWidget(self.measurement_enabled)
        layout.addWidget(text3)
        layout.addWidget(self.measurement_channel_input)
        layout.addWidget(text4)
        layout.addWidget(self.measurement_type_input)
        layout_final.addLayout(layout)

        #layout: ChartView
        chartView = QtCharts.QChartView()
        layout_final.addWidget(chartView)

        #layout: Measurement table
        self.measurement_table = QTableWidget(self)
        self.measurement_table.setRowCount(self.nRow)

        self.measurement_statistics_list = [
            "Value", "Mean", "Minimum", "Maximum", "StdDev"
        ]
        self.measurement_table.setColumnCount(
            2 + len(self.measurement_statistics_list))
        self.measurement_table.setHorizontalHeaderItem(
            0, QTableWidgetItem("Channel"))
        self.measurement_table.setHorizontalHeaderItem(
            1, QTableWidgetItem("Type"))

        for i in range(len(self.measurement_statistics_list)):
            self.measurement_table.setHorizontalHeaderItem(
                2 + i, QTableWidgetItem(self.measurement_statistics_list[i]))
        layout_final.addWidget(self.measurement_table)

        self.setLayout(layout_final)

        #signal and slot
        self.ip_input.returnPressed.connect(self.update_ip)
        self.connect_input.stateChanged.connect(self.connect)

        self.x_scale_input_zoom_in.clicked.connect(self.x_scale_zoom_in)
        self.x_scale_input_zoom_out.clicked.connect(self.x_scale_zoom_out)
        self.x_scale_output.returnPressed.connect(self.set_x_scale)

        self.y_channel_input.activated.connect(self.update_channel)
        self.y_enabled.clicked.connect(self.channel_enabled)
        self.y_coupling.activated.connect(self.set_coupling)
        self.y_scale_input_zoom_in.clicked.connect(self.y_scale_zoom_in)
        self.y_scale_input_zoom_out.clicked.connect(self.y_scale_zoom_out)
        self.y_scale_output.returnPressed.connect(self.set_y_scale)

        self.measurement_row_input.activated.connect(
            self.update_measurement_config)
        self.measurement_enabled.clicked.connect(self.enable_measurement)
        self.measurement_channel_input.activated.connect(
            self.update_measurement_channel)
        self.measurement_type_input.activated.connect(
            self.update_measurement_type)

        #Timer
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.update_data)

        #Line Chart
        chart = QtCharts.QChart()
        self.series = []
        for i in range(self.nChannel):
            self.series.append(QtCharts.QLineSeries())
            chart.addSeries(self.series[i])
            for j in range(self.nPoint):
                self.series[i].append(0, 0)

        chart.legend().setVisible(True)
        chart.legend().setAlignment(Qt.AlignTop)
        markers = chart.legend().markers()
        for i in range(self.nChannel):
            markers[i].setLabel("Ch{0}".format(i + 1))

        self.axisX = QtCharts.QValueAxis()
        self.axisX.setTickCount(11)
        self.axisX.setLabelFormat("%.1e")
        self.axisX.setTitleText("Time (s)")
        self.axisX.setRange(-2e-3, 2e-3)
        chart.addAxis(self.axisX, Qt.AlignBottom)
        for i in range(self.nChannel):
            self.series[i].attachAxis(self.axisX)

        self.axisY = QtCharts.QValueAxis()
        self.axisY.setTickCount(11)
        self.axisY.setLabelFormat("%.1e")
        self.axisY.setTitleText("Voltage Division")
        self.axisY.setRange(-5, 5)
        self.axisY.setLabelsVisible(False)
        chart.addAxis(self.axisY, Qt.AlignLeft)
        for i in range(self.nChannel):
            self.series[i].attachAxis(self.axisY)

        chartView.setChart(chart)
        chartView.setRenderHint(QPainter.Antialiasing)

    @Slot()
    def update_ip(self):
        self.ip = self.ip_input.text()

    @Slot()
    def connect(self):
        if self.connect_input.isChecked():
            print("connecting " + self.ip)
            self.timer.start(sample_interval_secs * 1000)
            self.MDO = MDO3000(self.ip)
            self.name.setText(self.MDO.getIdent())

            dtime = datetime.datetime.now()
            self.time.setText(dtime.strftime('%c'))

            self.isShowChannel = []
            for i in range(self.nChannel):
                self.isShowChannel.append(
                    bool(
                        int(
                            self.MDO.MySocket.send_receive_string(
                                "Select:Ch{0}?".format(i + 1)))))

            self.x_scale_output.setText(
                self.MDO.MySocket.send_receive_string("horizontal:scale?"))
            self.update_channel()

            self.MDO.MySocket.send_only("data:source CH1")
            self.MDO.MySocket.send_only("data:start 1")
            self.MDO.MySocket.send_only("data:stop {0}".format(self.nPoint))
            self.MDO.MySocket.send_only("data:encdg ascii")
            self.MDO.MySocket.send_only("data:width 1")
            #self.MDO.MySocket.send_only("data:width 2")

            self.MDO.MySocket.send_only("ACQuire:STOPAfter RunStop")
            #self.MDO.MySocket.send_only("ACQuire:STOPAfter sequence")

            #measurement
            self.measurement_channel_list = []
            self.measurement_type_list = []
            for i in range(self.nRow):
                channel = self.MDO.MySocket.send_receive_string(
                    "Measurement:Meas{0}:source?".format(i + 1))
                self.measurement_channel_list.append(channel)
                Type = self.MDO.MySocket.send_receive_string(
                    "Measurement:Meas{0}:type?".format(i + 1))
                self.measurement_type_list.append(Type)

            #measurement config
            self.update_measurement_config()

        else:
            print("disconnecting...")
            self.timer.stop()
            del self.MDO

            self.name.setText("")
            print("disconnect successfully.")

    @Slot()
    def update_data(self):
        dtime = datetime.datetime.now()
        self.time.setText(dtime.strftime('%c'))

        #waveform chart
        data = []
        YMULT = []
        YOFF = []
        YZERO = []
        YDiv = []
        for i in range(len(self.isShowChannel)):
            if self.isShowChannel[i]:
                self.MDO.MySocket.send_only("data:source CH{0}".format(i + 1))

                #self.MDO.MySocket.send_only(":header 1")
                #self.MDO.MySocket.send_only("verbose on")
                #print(self.MDO.MySocket.send_receive_string("WfmOutPre?"))
                #self.MDO.MySocket.send_only("header 0")

                #x-axis
                self.XINCR = float(
                    self.MDO.MySocket.send_receive_string("WfmOutPre:XINCR?"))
                self.XZERO = float(
                    self.MDO.MySocket.send_receive_string("WfmOutPre:XZERO?"))
                self.axisX.setRange(self.XZERO,
                                    self.XZERO + self.XINCR * self.nPoint)

                #y-axis
                data.append(self.MDO.MySocket.send_receive_string("curve?"))
                YMULT.append(
                    float(
                        self.MDO.MySocket.send_receive_string(
                            "WfmOutPre:YMULT?")))
                YOFF.append(
                    int(
                        float(
                            self.MDO.MySocket.send_receive_string(
                                "WfmOutPre:YOFF?"))))
                YZERO.append(
                    float(
                        self.MDO.MySocket.send_receive_string(
                            "WfmOutPre:YZERO?")))
                YDiv.append(
                    float(
                        self.MDO.MySocket.send_receive_string(
                            "CH{0}:scale?".format(i + 1))))
            else:
                data.append("")
                YMULT.append(0)
                YOFF.append(0)
                YZERO.append(0)
                YDiv.append(0)

        for i in range(len(self.isShowChannel)):
            if self.isShowChannel[i]:
                data[i] = data[i].split(",")

                x = self.XZERO
                index = 0
                for element in data[i]:
                    y = ((int(element) - YOFF[i]) * YMULT[i]) + YZERO[i]
                    y = y / YDiv[i]
                    #print(x,y)
                    self.series[i].replace(index, x, y)

                    index += 1
                    x += self.XINCR

        #layout: Measurement table
        for i in range(self.nRow):
            self.measurement_table.setItem(
                i, 0, QTableWidgetItem(self.measurement_channel_list[i]))
            self.measurement_table.setItem(
                i, 1, QTableWidgetItem(self.measurement_type_list[i]))

            state = self.MDO.MySocket.send_receive_string(
                "Measurement:Meas{0}:state?".format(i + 1))
            if state == "1":
                unit = self.MDO.MySocket.send_receive_string(
                    "Measurement:Meas{0}:units?".format(i + 1))
                unit = unit[1:]
                unit = unit[:-1]
                for j in range(len(self.measurement_statistics_list)):
                    value = self.MDO.MySocket.send_receive_string(
                        "Measurement:Meas{0}:".format(i + 1) +
                        self.measurement_statistics_list[j] + "?")
                    self.measurement_table.setItem(
                        i, 2 + j, QTableWidgetItem(value + " " + unit))

    @Slot()
    def x_scale_zoom_in(self):
        if self.connect_input.isChecked():
            self.MDO.MySocket.send_only("FPanel:turn HorzScale, 1")
            self.x_scale_output.setText(
                self.MDO.MySocket.send_receive_string("horizontal:scale?"))

    @Slot()
    def x_scale_zoom_out(self):
        if self.connect_input.isChecked():
            self.MDO.MySocket.send_only("FPanel:turn HorzScale, -1")
            self.x_scale_output.setText(
                self.MDO.MySocket.send_receive_string("horizontal:scale?"))

    @Slot()
    def set_x_scale(self):
        if self.connect_input.isChecked():
            self.MDO.MySocket.send_only("horizontal:scale " +
                                        self.x_scale_output.text())
            self.x_scale_output.setText(
                self.MDO.MySocket.send_receive_string("horizontal:scale?"))

    @Slot()
    def update_channel(self):
        if self.connect_input.isChecked():
            channel_string = self.y_channel_input.currentText()
            isEnabled = self.MDO.MySocket.send_receive_string("Select:" +
                                                              channel_string +
                                                              "?")

            #enabled
            if isEnabled == "0":
                self.y_enabled.setCheckState(Qt.Unchecked)
            elif isEnabled == "1":
                self.y_enabled.setCheckState(Qt.Checked)

            #coupling
            self.y_coupling.setCurrentText(
                self.MDO.MySocket.send_receive_string(channel_string +
                                                      ":coupling?"))

            #vertical scale
            self.y_scale_output.setText(
                self.MDO.MySocket.send_receive_string(channel_string +
                                                      ":scale?"))

    @Slot()
    def channel_enabled(self):
        if self.connect_input.isChecked():
            channel_string = self.y_channel_input.currentText()
            channel_index = int(channel_string[-1:]) - 1
            if self.y_enabled.isChecked():
                self.MDO.MySocket.send_only("Select:" + channel_string + " on")
                self.isShowChannel[channel_index] = True
            else:
                self.isShowChannel[channel_index] = False
                self.MDO.MySocket.send_only("Select:" + channel_string +
                                            " off")
                for i in range(self.nPoint):
                    self.series[channel_index].replace(i, 0, 0)

    @Slot()
    def set_coupling(self):
        if self.connect_input.isChecked():
            channel_string = self.y_channel_input.currentText()
            channel_index = int(channel_string[-1:]) - 1
            if self.isShowChannel[channel_index]:
                self.MDO.MySocket.send_only(channel_string + ":coupling " +
                                            self.y_coupling.currentText())

    @Slot()
    def y_scale_zoom_in(self):
        if self.connect_input.isChecked():
            channel_string = self.y_channel_input.currentText()
            channel_index = int(channel_string[-1:]) - 1
            if self.isShowChannel[channel_index]:
                self.MDO.MySocket.send_only("FPanel:turn VertScale" +
                                            channel_string[-1:] + ", 1")
                self.y_scale_output.setText(
                    self.MDO.MySocket.send_receive_string(channel_string +
                                                          ":scale?"))

    @Slot()
    def y_scale_zoom_out(self):
        if self.connect_input.isChecked():
            channel_string = self.y_channel_input.currentText()
            channel_index = int(channel_string[-1:]) - 1
            if self.isShowChannel[channel_index]:
                self.MDO.MySocket.send_only("FPanel:turn VertScale" +
                                            channel_string[-1:] + ", -1")
                self.y_scale_output.setText(
                    self.MDO.MySocket.send_receive_string(channel_string +
                                                          ":scale?"))

    @Slot()
    def set_y_scale(self):
        if self.connect_input.isChecked():
            channel_string = self.y_channel_input.currentText()
            channel_index = int(channel_string[-1:]) - 1
            if self.isShowChannel[channel_index]:
                self.MDO.MySocket.send_only(channel_string + ":scale " +
                                            self.y_scale_output.text())
                self.y_scale_output.setText(
                    self.MDO.MySocket.send_receive_string(channel_string +
                                                          ":scale?"))

    @Slot()
    def update_measurement_config(self):
        if self.connect_input.isChecked():
            state = self.MDO.MySocket.send_receive_string(
                "Measurement:Meas" + self.measurement_row_input.currentText() +
                ":state?")
            if state == "0":
                self.measurement_enabled.setCheckState(Qt.Unchecked)
            elif state == "1":
                self.measurement_enabled.setCheckState(Qt.Checked)

            channel = self.MDO.MySocket.send_receive_string(
                "Measurement:Meas" + self.measurement_row_input.currentText() +
                ":source?")
            self.measurement_channel_input.setCurrentText(channel)
            Type = self.MDO.MySocket.send_receive_string(
                "Measurement:Meas" + self.measurement_row_input.currentText() +
                ":type?")
            self.measurement_type_input.setCurrentText(Type)

    @Slot()
    def enable_measurement(self):
        if self.connect_input.isChecked():
            row_string = self.measurement_row_input.currentText()
            index = int(row_string) - 1
            if self.measurement_enabled.isChecked():
                self.MDO.MySocket.send_only("Measurement:Meas" + row_string +
                                            ":state on")
            else:
                self.MDO.MySocket.send_only("Measurement:Meas" + row_string +
                                            ":state off")
                for j in range(len(self.measurement_statistics_list)):
                    self.measurement_table.setItem(index, 2 + j,
                                                   QTableWidgetItem(""))

    @Slot()
    def update_measurement_channel(self):
        if self.connect_input.isChecked():
            row_string = self.measurement_row_input.currentText()
            index = int(row_string) - 1
            self.MDO.MySocket.send_only(
                "Measurement:Meas" + row_string + ":source " +
                self.measurement_channel_input.currentText())
            self.measurement_channel_list[
                index] = self.measurement_channel_input.currentText()

    @Slot()
    def update_measurement_type(self):
        if self.connect_input.isChecked():
            row_string = self.measurement_row_input.currentText()
            index = int(row_string) - 1
            self.MDO.MySocket.send_only(
                "Measurement:Meas" + row_string + ":type " +
                self.measurement_type_input.currentText())
            self.measurement_type_list[
                index] = self.measurement_type_input.currentText()