def create_editor_tab(self): form = QFormLayout() font_db = QFontDatabase() editor_font = self.gui.script_editor.font() editor_font_combo = QComboBox() editor_font_combo.addItems(font_db.families()) editor_font_combo.setCurrentIndex(font_db.families().indexOf( editor_font.family())) editor_font_size = QSpinBox() editor_font_size.setRange(5, 24) editor_font_size.setValue(editor_font.pointSize()) def change_font_family(idx): family = editor_font_combo.currentText() editor_font.setFamily(family) self.change_editor_font(editor_font) def change_font_size(value): editor_font.setPointSize(value) self.change_editor_font(editor_font) def reset_font(): editor_font_combo.setCurrentIndex(font_db.families().indexOf( monospace_font.family())) editor_font_size.setValue(monospace_font.pointSize()) editor_font_combo.currentIndexChanged.connect(change_font_family) editor_font_size.valueChanged.connect(change_font_size) reset_font_button = QPushButton('Reset to Default') reset_font_button.clicked.connect(reset_font) font_group = QGroupBox('Font') font_form = QFormLayout() font_form.addRow('Family:', editor_font_combo) font_form.addRow('Size:', editor_font_size) font_form.addRow(floated_buttons([reset_font_button])) font_group.setLayout(font_form) vars_color = ColorButton('variables', QColor('darkMagenta')) strs_color = ColorButton('strings', QColor('gray')) colors_group = QGroupBox('Colors') colors_form = QFormLayout() colors_form.addRow('Variables:', floated_buttons([vars_color], True)) colors_form.addRow('String literals:', floated_buttons([strs_color], True)) colors_group.setLayout(colors_form) form.addRow(font_group) form.addRow(colors_group) w = QWidget() w.setLayout(form) return w
def create_editor_tab(self): form = QFormLayout() font_db = QFontDatabase() editor_font = self.gui.script_editor.font() editor_font_combo = QComboBox() editor_font_combo.addItems(font_db.families()) editor_font_combo.setCurrentIndex(font_db.families().indexOf(editor_font.family())) editor_font_size = QSpinBox() editor_font_size.setRange(5, 24) editor_font_size.setValue(editor_font.pointSize()) def change_font_family(idx): family = editor_font_combo.currentText() editor_font.setFamily(family) self.change_editor_font(editor_font) def change_font_size(value): editor_font.setPointSize(value) self.change_editor_font(editor_font) def reset_font(): editor_font_combo.setCurrentIndex(font_db.families().indexOf(monospace_font.family())) editor_font_size.setValue(monospace_font.pointSize()) editor_font_combo.currentIndexChanged.connect(change_font_family) editor_font_size.valueChanged.connect(change_font_size) reset_font_button = QPushButton('Reset to Default') reset_font_button.clicked.connect(reset_font) font_group = QGroupBox('Font') font_form = QFormLayout() font_form.addRow('Family:', editor_font_combo) font_form.addRow('Size:', editor_font_size) font_form.addRow(floated_buttons([reset_font_button])) font_group.setLayout(font_form) vars_color = ColorButton('variables', QColor('darkMagenta')) strs_color = ColorButton('strings', QColor('gray')) colors_group = QGroupBox('Colors') colors_form = QFormLayout() colors_form.addRow('Variables:', floated_buttons([vars_color], True)) colors_form.addRow('String literals:', floated_buttons([strs_color], True)) colors_group.setLayout(colors_form) form.addRow(font_group) form.addRow(colors_group) w = QWidget() w.setLayout(form) return w
def do_about(self): d = QDialog(self) vbox = QVBoxLayout() about_label = QLabel() about_label.setWordWrap(True) txt = [] txt.append(' '.join([ 'Hashmal is an IDE for Bitcoin transaction scripts and a general cryptocurrency development toolbox.', 'Its primary purpose is to make it easier to write, evaluate, and learn about transaction scripts.', ])) txt.append('Hashmal is intended for cryptocurrency developers and power users.') txt = '\n\n'.join(txt) about_label.setText(txt) close_button = QPushButton('Close') close_button.clicked.connect(d.close) btn_box = floated_buttons([close_button]) vbox.addWidget(about_label) vbox.addLayout(btn_box) d.setLayout(vbox) d.setWindowTitle('About Hashmal') d.exec_()
def do_about(self): d = QDialog(self) vbox = QVBoxLayout() about_label = QLabel() about_label.setWordWrap(True) txt = [] txt.append(' '.join([ 'Hashmal is an IDE for Bitcoin transaction scripts and a general cryptocurrency development toolbox.', 'Its primary purpose is to make it easier to write, evaluate, and learn about transaction scripts.', ])) txt.append( 'Hashmal is intended for cryptocurrency developers and power users.' ) txt = '\n\n'.join(txt) about_label.setText(txt) close_button = QPushButton('Close') close_button.clicked.connect(d.close) btn_box = floated_buttons([close_button]) vbox.addWidget(about_label) vbox.addLayout(btn_box) d.setLayout(vbox) d.setWindowTitle('About Hashmal') d.exec_()
def __init__(self, main_window): super(QuickTips, self).__init__(main_window) self.gui = main_window vbox = QVBoxLayout() tips_text = ''' <ul> <li>See <i>Help > Tool Info</i> in the menubar for details on what each tool does.</li> <li>You can manage tool layouts via <i>Tools > Settings</i> in the menubar.</li> <li>When typing opcodes, you can omit the "OP_" prefix for opcodes other than OP_1, OP_2, ...OP_16. For example, "DUP" and "OP_DUP" do the same thing.</li> <li>You can quickly evaluate the script you\'re working on via <i>Script > Evaluate</i> in the menubar.</li> <li>Put text in double quotation marks to ensure that it\'s treated as text that needs to be hex-encoded.</li> </ul> <p>See <a href="https://github.com/mazaclub/hashmal/wiki">https://github.com/mazaclub/hashmal/wiki</a> for detailed help.</p> ''' tips = QLabel(tips_text) tips.setWordWrap(True) vbox.addWidget(QLabel('<b>Quick Tips:</b>')) vbox.addWidget(tips) does_show_on_startup = self.gui.qt_settings.value('quickTipsOnStart', defaultValue=QtCore.QVariant(True)).toBool() show_on_startup = QCheckBox('Show this dialog on startup.') show_on_startup.setChecked(does_show_on_startup) show_on_startup.stateChanged.connect(lambda checked: self.gui.qt_settings.setValue('quickTipsOnStart', True if checked else False)) vbox.addWidget(show_on_startup) close_button = QPushButton('Close') close_button.clicked.connect(self.close) btn_hbox = floated_buttons([close_button]) vbox.addLayout(btn_hbox) self.setLayout(vbox) self.setWindowTitle('Quick Tips')
def setup_layout(self): vbox = QVBoxLayout() tabs = QTabWidget() qt_tab = self.create_qt_tab() tabs.addTab(qt_tab, 'Window Settings') close_button = QPushButton('Close') close_button.clicked.connect(self.close) close_box = floated_buttons([close_button]) vbox.addWidget(tabs) vbox.addLayout(close_box) self.setLayout(vbox)
def __init__(self, main_window): super(QuickTips, self).__init__(main_window) self.gui = main_window vbox = QVBoxLayout() general_tips_text = ''' <ul> <li>See <i>Tools > Plugin Manager</i> in the menubar for details on what each tool does.</li> <li>The Plugin Manager also allows you to set "favorite tools" - which have keyboard shortcuts.</li> <li>You can manage tool layouts via <i>Tools > Settings</i> in the menubar.</li> </ul> ''' editor_tips_text = ''' <ul> <li>When typing opcodes, you can omit the "OP_" prefix for opcodes other than OP_1, OP_2, ...OP_16. For example, "DUP" and "OP_DUP" do the same thing.</li> <li>Put text in double quotation marks to ensure that it\'s treated as text that needs to be hex-encoded.</li> </ul> <p>See <a href="https://github.com/mazaclub/hashmal/wiki">https://github.com/mazaclub/hashmal/wiki</a> for detailed help.</p> ''' general_tips = QLabel(general_tips_text) general_tips.setWordWrap(True) vbox.addWidget(QLabel('<b>General Tips:</b>')) vbox.addWidget(general_tips) editor_tips = QLabel(editor_tips_text) editor_tips.setWordWrap(True) vbox.addWidget(QLabel('<b>Editor Tips:</b>')) vbox.addWidget(editor_tips) does_show_on_startup = self.gui.qt_settings.value( 'quickTipsOnStart', defaultValue=QtCore.QVariant(True)).toBool() show_on_startup = QCheckBox('Show this dialog on startup.') show_on_startup.setChecked(does_show_on_startup) show_on_startup.stateChanged.connect( lambda checked: self.gui.qt_settings.setValue( 'quickTipsOnStart', True if checked else False)) vbox.addWidget(show_on_startup) close_button = QPushButton('Close') close_button.clicked.connect(self.close) btn_hbox = floated_buttons([close_button]) vbox.addLayout(btn_hbox) self.setLayout(vbox) self.setWindowTitle('Quick Tips')
def setup_layout(self): vbox = QVBoxLayout() tabs = QTabWidget() qt_tab = self.create_qt_tab() editor_tab = self.create_editor_tab() general_tab = self.create_general_tab() chainparams_tab = self.create_chainparams_tab() tabs.addTab(general_tab, '&General') tabs.addTab(qt_tab, '&Window Settings') tabs.addTab(editor_tab, '&Editor') tabs.addTab(chainparams_tab, '&Chainparams') close_button = QPushButton('Close') close_button.clicked.connect(self.close) close_box = floated_buttons([close_button]) vbox.addWidget(tabs) vbox.addLayout(close_box) self.setLayout(vbox)
def __init__(self, parent=None): super(TxProperties, self).__init__(parent) self.tx_size_edit = QLineEdit() self.tx_size_edit.setReadOnly(True) tx_size = HBox(QLabel('Size:'), self.tx_size_edit) tx_size.setContentsMargins(0, 0, 0, 0) self.tx_size = QWidget() self.tx_size.setLayout(tx_size) self.tx_size.setToolTip('Size (in bytes) of the serialized tx') self.is_final = QCheckBox('Is Final') self.is_final.setToolTip('True if all inputs have a Sequence of 0xffffffff') self.is_coinbase = QCheckBox('Is Coinbase') self.is_coinbase.setToolTip('True if the tx generates new coins via mining') for i in [self.is_final, self.is_coinbase]: i.setEnabled(False) hbox = floated_buttons([self.tx_size, self.is_final, self.is_coinbase], left=True) hbox.setContentsMargins(16, 0, 0, 0) self.setLayout(hbox)
def __init__(self, main_window): super(ToolInfo, self).__init__(main_window) self.gui = main_window tool_combo = QComboBox() tool_combo.addItems( [i.tool_name for i in self.gui.dock_handler.dock_widgets] ) tool_info = QTextEdit() tool_info.setReadOnly(True) def show_tool_info(): # Create HTML paragraphs from description. tool = self.gui.dock_handler.dock_widgets[tool_combo.currentIndex()] s = [] for i in tool.description.split('\n'): s.append('<p>{}</p>'.format(i)) tool_info.setHtml(''.join(s)) tool_combo.currentIndexChanged.connect(show_tool_info) # For some reason this has to be done twice. tool_combo.setCurrentIndex(1) tool_combo.setCurrentIndex(0) close_button = QPushButton('Close') close_button.clicked.connect(self.close) vbox = QVBoxLayout() hbox = QHBoxLayout() hbox.addWidget(QLabel('Tool:')) hbox.addWidget(tool_combo, stretch=1) btn_hbox = floated_buttons([close_button]) vbox.addLayout(hbox) vbox.addWidget(QLabel('Info:')) vbox.addWidget(tool_info) vbox.addLayout(btn_hbox) self.setLayout(vbox) self.setWindowTitle('Tool Info')
def __init__(self, parent=None): super(TxProperties, self).__init__(parent) self.tx_size_edit = QLineEdit() self.tx_size_edit.setReadOnly(True) tx_size = HBox(QLabel('Size:'), self.tx_size_edit) tx_size.setContentsMargins(0, 0, 0, 0) self.tx_size = QWidget() self.tx_size.setLayout(tx_size) self.tx_size.setToolTip('Size (in bytes) of the serialized tx') self.is_final = QCheckBox('Is Final') self.is_final.setToolTip( 'True if all inputs have a Sequence of 0xffffffff') self.is_coinbase = QCheckBox('Is Coinbase') self.is_coinbase.setToolTip( 'True if the tx generates new coins via mining') for i in [self.is_final, self.is_coinbase]: i.setEnabled(False) hbox = floated_buttons([self.tx_size, self.is_final, self.is_coinbase], left=True) hbox.setContentsMargins(16, 0, 0, 0) self.setLayout(hbox)