Esempio n. 1
0
    def adjust_field_widgets(self):
        """Add widgets and adjust visibility for tx field widgets."""
        tx_fields = chainparams.get_tx_fields()
        for i, field in enumerate(tx_fields):
            name = field[0]
            # Create a new widget for the tx field.
            if name not in self.field_widgets.keys():
                widget = QLineEdit()
                widget.setReadOnly(True)
                if name == 'Timestamp':
                    widget = TimestampWidget()
                label = QLabel(''.join([name, ':']))
                # Add the widget to our dict and to the layout.
                self.field_widgets[name] = widget
                self.tx_fields_layout.insertRow(i, label, widget)

            # Make sure the existing widget for the tx field is visible.
            else:
                w = self.field_widgets[name]
                l = self.tx_fields_layout.labelForField(w)
                w.show()
                l.show()

        # Hide unnecessary widgets
        tx_field_names = [i[0] for i in tx_fields]
        for name, w in self.field_widgets.items():
            if name not in tx_field_names:
                l = self.tx_fields_layout.labelForField(w)
                w.hide()
                l.hide()
Esempio n. 2
0
    def create_chainparams_tab(self):
        form = QFormLayout()
        form.setRowWrapPolicy(QFormLayout.WrapLongRows)

        desc = ''.join([
            'ChainParams define some basic rules of the blockchain.',
            ' Notably, these rules include the format of transactions.'
        ])
        desc_label = QLabel(desc)
        desc_label.setWordWrap(True)

        self.params_combo = ChainparamsComboBox(self.config)

        self.params_combo.paramsChanged.connect(self.change_chainparams)

        self.format_list = QListWidget()
        for name, _, _, _ in chainparams.get_tx_fields():
            self.format_list.addItem(name)

        form.addRow(desc_label)
        form.addRow('Params:', self.params_combo)
        form.addRow(Separator())
        form.addRow('Tx Format:', self.format_list)

        w = QWidget()
        w.setLayout(form)
        return w
Esempio n. 3
0
    def adjust_field_widgets(self):
        """Add widgets and adjust visibility for tx field widgets."""
        tx_fields = chainparams.get_tx_fields()
        for i, field in enumerate(tx_fields):
            name = field[0]
            # Create a new widget for the tx field.
            if name not in [j[0] for j in self.field_widgets]:
                widget = QLineEdit()
                widget.setReadOnly(True)
                if name == 'Timestamp':
                    widget = TimestampWidget()
                label = QLabel(''.join([name, ':']))
                # Add the widget to our list and to the layout.
                self.field_widgets.insert(i, (name, widget))
                self.tx_fields_layout.insertRow(i, label, widget)

            # Make sure the existing widget for the tx field is visible.
            else:
                w = self.field_widgets[i][1]
                l = self.tx_fields_layout.labelForField(w)
                w.show()
                l.show()

        # Hide unnecessary widgets
        tx_field_names = [i[0] for i in tx_fields]
        for i, (name, w) in enumerate(self.field_widgets):
            if name not in tx_field_names:
                l = self.tx_fields_layout.labelForField(w)
                w.hide()
                l.hide()

        self.clear()
Esempio n. 4
0
    def create_chainparams_tab(self):
        form = QFormLayout()
        form.setRowWrapPolicy(QFormLayout.WrapLongRows)

        desc = ''.join(['ChainParams define some basic rules of the blockchain.',
                        ' Notably, these rules include the format of transactions.'])
        desc_label = QLabel(desc)
        desc_label.setWordWrap(True)

        self.params_combo = ChainparamsComboBox(self.config)

        self.params_combo.paramsChanged.connect(self.change_chainparams)

        self.format_list = QListWidget()
        for name, _, _, _ in chainparams.get_tx_fields():
            self.format_list.addItem(name)

        form.addRow(desc_label)
        form.addRow('Params:', self.params_combo)
        form.addRow(Separator())
        form.addRow('Tx Format:', self.format_list)

        w = QWidget()
        w.setLayout(form)
        return w
Esempio n. 5
0
    def adjust_tx_fields(self):
        """Show or hide tx field widgets."""
        tx_fields = chainparams.get_tx_fields()
        for field in tx_fields:
            name = field[0]
            if name in ['nVersion', 'vin', 'vout', 'nLockTime']:
                continue

            default_value = field[3]
            if name not in [j[0] for j in self.tx_field_widgets]:
                widget = QLineEdit()
                if isinstance(default_value, int):
                    # Special case for timestamp fields.
                    if name == 'Timestamp':
                        widget = TimestampWidget()
                        widget.timestamp_raw.setReadOnly(False)
                    else:
                        widget = AmountEdit()
                widget.setText(str(default_value))
                label = QLabel(''.join([name, ':']))
                self.tx_field_widgets.append((name, widget))
                self.tx_fields_layout.addRow(label, widget)

        tx_field_names = [i[0] for i in tx_fields]
        for name, w in self.tx_field_widgets:
            l = self.tx_fields_layout.labelForField(w)
            if name in tx_field_names:
                w.show()
                l.show()
            else:
                w.hide()
                l.hide()

        if tx_field_names == ['nVersion', 'vin', 'vout', 'nLockTime']:
            self.tabs.setTabEnabled(3, False)
        else:
            self.tabs.setTabEnabled(3, True)
Esempio n. 6
0
    def adjust_tx_fields(self):
        """Show or hide tx field widgets."""
        tx_fields = chainparams.get_tx_fields()
        for field in tx_fields:
            name = field[0]
            if name in ['nVersion', 'vin', 'vout', 'nLockTime']:
                continue

            default_value = field[3]
            if name not in [j[0] for j in self.tx_field_widgets]:
                widget = QLineEdit()
                if isinstance(default_value, int):
                    # Special case for timestamp fields.
                    if name == 'Timestamp':
                        widget = TimestampWidget()
                        widget.timestamp_raw.setReadOnly(False)
                    else:
                        widget = AmountEdit()
                widget.setText(str(default_value))
                label = QLabel(''.join([name, ':']))
                self.tx_field_widgets.append((name, widget))
                self.tx_fields_layout.addRow(label, widget)

        tx_field_names = [i[0] for i in tx_fields]
        for name, w in self.tx_field_widgets:
            l = self.tx_fields_layout.labelForField(w)
            if name in tx_field_names:
                w.show()
                l.show()
            else:
                w.hide()
                l.hide()

        if tx_field_names == ['nVersion', 'vin', 'vout', 'nLockTime']:
            self.tabs.setTabEnabled(3, False)
        else:
            self.tabs.setTabEnabled(3, True)
Esempio n. 7
0
 def change_chainparams(self):
     self.format_list.clear()
     for name, _, _, _ in chainparams.get_tx_fields():
         self.format_list.addItem(name)
Esempio n. 8
0
 def change_chainparams(self):
     self.format_list.clear()
     for name, _, _, _ in chainparams.get_tx_fields():
         self.format_list.addItem(name)