def __init__(self): super().__init__() self.setMinimumWidth(200) self.box_frame = QVBoxLayout() self.box_frame.setContentsMargins(0, 0, 0, 0) self.icon_bar = QWidget() self.icon_bar_spacer = QWidget() self.icon_bar.setStyleSheet('background-color: rgba(204, 51, 0, 0.5)') policy = QSizePolicy() policy.setRetainSizeWhenHidden(True) self.icon_bar.setSizePolicy(policy) # widget which contains the icons self.iconBox = QVBoxLayout() self.iconBox_spacer = QVBoxLayout() self.iconBox_spacer.addStretch(1) self.iconBox.setContentsMargins(0, 0, 0, 0) self.iconBox_spacer.setContentsMargins(0, 0, 0, 0) self.icon_bar.setLayout(self.iconBox) self.icon_bar_spacer.setLayout(self.iconBox_spacer) self.box_frame.addWidget(self.icon_bar) self.box_frame.addWidget(self.icon_bar_spacer) self.setLayout(self.box_frame) self.addBox() self.tmp_config = None self.tmp_element = None
def initUI(self): vbox = QVBoxLayout() vbox.setSpacing(0) vbox.setContentsMargins(0, 0, 0, 0) label = QLabel('Media') label.setFont(UIFonts.label_font) vbox.addWidget(label) hbox = QHBoxLayout() hbox.setSpacing(10) self.check = QCheckBox() self.media_num = QComboBox() sp = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum) sp.setRetainSizeWhenHidden(True) self.media_num.setSizePolicy(sp) hbox.addWidget(self.check) hbox.addWidget(self.media_num) vbox.addLayout(hbox) self.setLayout(vbox) self.refreshMedia() self.check.stateChanged.connect(self.showNumBox) self.media_num.currentIndexChanged.connect(self.numStateChanged)
def __init__(self): super().__init__() self.filename = None self.icon_bar = QWidget() self.icon_bar.setStyleSheet('background-color: silver') policy = QSizePolicy() policy.setRetainSizeWhenHidden(True) self.icon_bar.setSizePolicy(policy) # widget which contains the icons self.iconBox = QHBoxLayout(self.icon_bar) self.iconBox.setContentsMargins(8, 0, 0, 0) # buttons self.save_as_button = SaveAsButton() self.save_button = SaveButton() self.open_file_button = OpenFile() self.new_file_button = NewFile() self.run_button = RunButton() self.start_debug_button = StartDebugButton() self.stop_exec_button = StopExecButton() # change the icons background self.save_as_button.mousePressEvent = self.saveFileDialog self.save_as_button.saveAsHover.connect(self.setInfoText) self.save_button.mousePressEvent = self.simpleSave self.save_button.saveHover.connect(self.setInfoText) self.open_file_button.mousePressEvent = self.openFileNameDialog self.open_file_button.openHover.connect(self.setInfoText) self.run_button.runHover.connect(self.setInfoText) self.run_button.mousePressEvent = (self.startExec) self.start_debug_button.startDebugHover.connect(self.setInfoText) self.start_debug_button.mousePressEvent = self.startDebug self.new_file_button.mousePressEvent = self.saveQuestion self.new_file_button.newHover.connect(self.setInfoText) self.stop_exec_button.mousePressEvent = self.stop_execution self.stop_exec_button.stopExecHover.connect(self.setInfoText) self.iconBox.addWidget(self.new_file_button) self.iconBox.addWidget(self.open_file_button) self.iconBox.addWidget(self.save_as_button) self.iconBox.addWidget(self.save_button) self.iconBox.addWidget(self.start_debug_button) self.iconBox.addWidget(self.run_button) self.iconBox.addWidget(self.stop_exec_button) self.iconBox.addStretch(1) self.iconBox.setContentsMargins(3, 3, 0, 0) self.setLayout(self.iconBox)
def __init__(self, parent=None): super().__init__(parent) self.parent = parent self.setMinimumWidth(200) self.box_frame = QVBoxLayout() self.box_frame.setContentsMargins(0, 0, 0, 0) self.icon_bar = QWidget() self.icon_bar_spacer = QWidget() self.icon_bar.setStyleSheet( 'background-color: rgba(77, 103, 125, 0.5);\ border-radius: 10px') #self.icon_bar.setStyleSheet('background-color: \ # qlineargradient(x1:0.5 y1:0, x2:0.5 y2:1, stop:0 #646464, stop:1 #366a97);\ # border-radius: 10px') policy = QSizePolicy() policy.setRetainSizeWhenHidden(True) self.icon_bar.setSizePolicy(policy) # widget which contains the icons self.iconBox = QVBoxLayout() self.iconBox_spacer = QVBoxLayout() self.iconBox_spacer.addStretch(1) self.iconBox.setContentsMargins(0, 0, 0, 0) self.iconBox_spacer.setContentsMargins(0, 0, 0, 0) self.icon_bar.setLayout(self.iconBox) self.icon_bar_spacer.setLayout(self.iconBox_spacer) self.box_frame.addWidget(self.icon_bar) self.box_frame.addWidget(self.icon_bar_spacer) self.setLayout(self.box_frame) self.addBox() # temporary config store when an elements config is # parked as a dropbox. tmp_config holds the config # before the element is destroyed self.tmp_config = None self.tmp_element = None
def __init__(self): super().__init__() logging.debug('__init__() called IconBar') #self.setAutoFillBackground(True) #self.setGeometry(0, 0, 20, 100) self.iconBox = QVBoxLayout() self.edit_button = EditButton() #self.debug_button = QLabel() self.debug_button = DebugButton() self.del_button = DelButton() policy = QSizePolicy() policy.setRetainSizeWhenHidden(True) self.setSizePolicy(policy) self.iconBox.addWidget(self.edit_button) self.iconBox.addWidget(self.debug_button) self.iconBox.addWidget(self.del_button) self.setLayout(self.iconBox) self.setObjectName('IconBar') self.setStyleSheet('#IconBar { background-color: #636363; border: 3px solid #ff5900; border-radius: 15px; }') #self.del_button.mousePressEvent = self.click_del_element #self.edit_button.mousePressEvent = self.click_edit_element #self.debug_button.mousePressEvent = self.click_debug_element self.del_button.delete_pressed.connect(self.click_del_element) self.edit_button.edit_pressed.connect(self.click_edit_element) self.debug_button.debug_pressed.connect(self.click_debug_element)
def build_gui(self): vbox = QVBoxLayout() self.setLayout(vbox) grid = QGridLayout() vbox.addLayout(grid) self.amount_label = QLabel('') grid.addWidget(QLabel(_("Target for confirmation")), 0, 0) self.qtarget = QDateTimeEdit(QDateTime.currentDateTime().addSecs( int(self.main_window.config.get('bitpost_target_interval')) * 60)) grid.addWidget(self.qtarget, 0, 1) self.asap_check = QCheckBox("ASAP") self.asap_check.clicked.connect(self.toggle_target) grid.addWidget(self.asap_check, 0, 2) grid.addWidget(QLabel(_("Maximum Fee")), 2, 0) self.max_fees = QLineEdit( str(self.main_window.config.get('bitpost_max_fee'))) self.max_fees.textChanged.connect(self.change_max_fees) grid.addWidget(self.max_fees, 2, 1) self.fee_combo = QComboBox() fee_combo_values = get_fee_units( self.main_window, self.main_window.config.get('bitpost_max_fee_unit')) self.fee_combo.addItems(fee_combo_values) grid.addWidget(self.fee_combo, 2, 2) self.schedule_check = QCheckBox(_("Schedule transaction")) self.schedule_check.clicked.connect(self.toggle_delay) grid.addWidget(self.schedule_check, 3, 0, 1, -1) self.qdelay = QDateTimeEdit(QDateTime.currentDateTime()) grid.addWidget(self.qdelay, 4, 0) sp_retain = QSizePolicy(self.qdelay.sizePolicy()) sp_retain.setRetainSizeWhenHidden(True) self.qdelay.setSizePolicy(sp_retain) self.qdelay.setVisible(False) self.message_label = QLabel(self.default_message()) grid.addWidget(self.message_label, 9, 0, 1, -1) self.pw_label = QLabel(_('Password')) self.pw_label.setVisible(self.password_required) self.pw = PasswordLineEdit() self.pw.setVisible(self.password_required) grid.addWidget(self.pw_label, 11, 0) grid.addWidget(self.pw, 11, 1, 1, -1) self.send_button = QPushButton(_('Send')) self.send_button.clicked.connect(self.on_send) self.send_button.setDefault(True) self.preview_button = QPushButton(_('Preview')) self.preview_button.clicked.connect(self.on_preview) self.preview_button.setDefault(True) vbox.addLayout( Buttons(CancelButton(self), self.preview_button, self.send_button)) # set default to ASAP checked self.asap_check.setChecked(True) self.toggle_target() self.update() self.is_send = False
def __init__(self): super().__init__() self.filename = None self.last_saved = QC.translate('', 'Not yet') self.icon_bar = QWidget() self.icon_bar.setStyleSheet('background-color: silver') policy = QSizePolicy() policy.setRetainSizeWhenHidden(True) self.icon_bar.setSizePolicy(policy) #home directory of the user self.home_dict = str(Path.home()) mod_path = os.path.dirname(Pythonic.__file__) # widget which contains the icons self.iconBox = QHBoxLayout(self.icon_bar) self.iconBox.setContentsMargins(8, 0, 0, 0) # buttons self.save_as_button = SaveAsButton() self.save_button = SaveButton() self.open_file_button = OpenFile() self.new_file_button = NewFile() self.run_button = RunButton() self.start_debug_button = StartDebugButton() self.stop_exec_button = StopExecButton() self.kill_proc_button = KillProcButton() # Logo self.logo_horizontal = QLabel() logo_height = self.save_as_button.pixmap().height() * 1.5 self.logo_horizontal.setPixmap( QPixmap(join( mod_path, 'images/horizontal_blur.png')).scaledToHeight(logo_height)) self.logo_horizontal.pixmap() # change the icons background self.save_as_button.mousePressEvent = self.saveFileDialog self.save_as_button.saveAsHover.connect(self.setInfoText) self.save_button.mousePressEvent = self.simpleSave self.save_button.saveHover.connect(self.setInfoText) self.open_file_button.mousePressEvent = self.openFileNameDialog self.open_file_button.openHover.connect(self.setInfoText) self.run_button.runHover.connect(self.setInfoText) self.run_button.mousePressEvent = (self.startExec) self.start_debug_button.startDebugHover.connect(self.setInfoText) self.start_debug_button.mousePressEvent = self.startDebug self.new_file_button.mousePressEvent = self.saveQuestion self.new_file_button.newHover.connect(self.setInfoText) self.stop_exec_button.mousePressEvent = self.stop_execution self.stop_exec_button.stopExecHover.connect(self.setInfoText) self.kill_proc_button.mousePressEvent = self.killProc self.kill_proc_button.killProcHover.connect(self.setInfoText) self.iconBox.addWidget(self.new_file_button) self.iconBox.addWidget(self.open_file_button) self.iconBox.addWidget(self.save_button) self.iconBox.addWidget(self.save_as_button) self.iconBox.addWidget(self.start_debug_button) self.iconBox.addWidget(self.run_button) self.iconBox.addWidget(self.stop_exec_button) self.iconBox.addWidget(self.kill_proc_button) self.iconBox.addStretch(1) self.iconBox.addWidget(self.logo_horizontal) self.iconBox.setContentsMargins(3, 3, 0, 0) self.setLayout(self.iconBox)
def __init__(self, window: 'ElectrumWindow'): QWidget.__init__(self, window) Logger.__init__(self) self.window = window self.wallet = window.wallet self.fx = window.fx self.config = window.config # A 4-column grid layout. All the stretch is in the last column. # The exchange rate plugin adds a fiat widget in column 2 self.receive_grid = grid = QGridLayout() grid.setSpacing(8) grid.setColumnStretch(3, 1) self.receive_message_e = SizedFreezableLineEdit(width=400) grid.addWidget(QLabel(_('Description')), 0, 0) grid.addWidget(self.receive_message_e, 0, 1, 1, 4) self.receive_amount_e = BTCAmountEdit(self.window.get_decimal_point) grid.addWidget(QLabel(_('Requested amount')), 1, 0) grid.addWidget(self.receive_amount_e, 1, 1) self.fiat_receive_e = AmountEdit( self.fx.get_currency if self.fx else '') if not self.fx or not self.fx.is_enabled(): self.fiat_receive_e.setVisible(False) grid.addWidget(self.fiat_receive_e, 1, 2, Qt.AlignLeft) self.window.connect_fields(self.receive_amount_e, self.fiat_receive_e) self.expires_combo = QComboBox() evl = sorted(pr_expiration_values.items()) evl_keys = [i[0] for i in evl] evl_values = [i[1] for i in evl] default_expiry = self.config.get('request_expiry', PR_DEFAULT_EXPIRATION_WHEN_CREATING) try: i = evl_keys.index(default_expiry) except ValueError: i = 0 self.expires_combo.addItems(evl_values) self.expires_combo.setCurrentIndex(i) def on_expiry(i): self.config.set_key('request_expiry', evl_keys[i]) self.expires_combo.currentIndexChanged.connect(on_expiry) msg = ''.join([ _('Expiration date of your request.'), ' ', _('This information is seen by the recipient if you send them a signed payment request.' ), '\n\n', _('For on-chain requests, the address gets reserved until expiration. After that, it might get reused.' ), ' ', _('The bitcoin address never expires and will always be part of this electrum wallet.' ), ' ', _('You can reuse a bitcoin address any number of times but it is not good for your privacy.' ), '\n\n', _('For Lightning requests, payments will not be accepted after the expiration.' ), ]) grid.addWidget(HelpLabel(_('Expires after') + ' (?)', msg), 2, 0) grid.addWidget(self.expires_combo, 2, 1) self.expires_label = QLineEdit('') self.expires_label.setReadOnly(1) self.expires_label.setFocusPolicy(Qt.NoFocus) self.expires_label.hide() grid.addWidget(self.expires_label, 2, 1) self.clear_invoice_button = QPushButton(_('Clear')) self.clear_invoice_button.clicked.connect(self.do_clear) self.create_invoice_button = QPushButton(_('Create Request')) self.create_invoice_button.clicked.connect( lambda: self.create_invoice()) self.receive_buttons = buttons = QHBoxLayout() buttons.addStretch(1) buttons.addWidget(self.clear_invoice_button) buttons.addWidget(self.create_invoice_button) grid.addLayout(buttons, 4, 0, 1, -1) self.receive_address_e = ButtonsTextEdit() self.receive_address_help_text = WWLabel('') vbox = QVBoxLayout() vbox.addWidget(self.receive_address_help_text) self.receive_address_help = QWidget() self.receive_address_help.setVisible(False) self.receive_address_help.setLayout(vbox) self.receive_URI_e = ButtonsTextEdit() self.receive_URI_help = WWLabel('') self.receive_lightning_e = ButtonsTextEdit() self.receive_lightning_help_text = WWLabel('') self.receive_rebalance_button = QPushButton('Rebalance') self.receive_rebalance_button.suggestion = None def on_receive_rebalance(): if self.receive_rebalance_button.suggestion: chan1, chan2, delta = self.receive_rebalance_button.suggestion self.window.rebalance_dialog(chan1, chan2, amount_sat=delta) self.receive_rebalance_button.clicked.connect(on_receive_rebalance) self.receive_swap_button = QPushButton('Swap') self.receive_swap_button.suggestion = None def on_receive_swap(): if self.receive_swap_button.suggestion: chan, swap_recv_amount_sat = self.receive_swap_button.suggestion self.window.run_swap_dialog( is_reverse=True, recv_amount_sat=swap_recv_amount_sat, channels=[chan]) self.receive_swap_button.clicked.connect(on_receive_swap) buttons = QHBoxLayout() buttons.addWidget(self.receive_rebalance_button) buttons.addWidget(self.receive_swap_button) vbox = QVBoxLayout() vbox.addWidget(self.receive_lightning_help_text) vbox.addLayout(buttons) self.receive_lightning_help = QWidget() self.receive_lightning_help.setVisible(False) self.receive_lightning_help.setLayout(vbox) self.receive_address_qr = QRCodeWidget() self.receive_URI_qr = QRCodeWidget() self.receive_lightning_qr = QRCodeWidget() for e in [ self.receive_address_e, self.receive_URI_e, self.receive_lightning_e ]: e.setFont(QFont(MONOSPACE_FONT)) e.addCopyButton() e.setReadOnly(True) self.receive_lightning_e.textChanged.connect( self.update_receive_widgets) self.receive_address_widget = ReceiveTabWidget( self, self.receive_address_e, self.receive_address_qr, self.receive_address_help) self.receive_URI_widget = ReceiveTabWidget(self, self.receive_URI_e, self.receive_URI_qr, self.receive_URI_help) self.receive_lightning_widget = ReceiveTabWidget( self, self.receive_lightning_e, self.receive_lightning_qr, self.receive_lightning_help) from .util import VTabWidget self.receive_tabs = VTabWidget() self.receive_tabs.setMinimumHeight(ReceiveTabWidget.min_size.height() + 4) # for margins self.receive_tabs.addTab(self.receive_URI_widget, read_QIcon("link.png"), _('URI')) self.receive_tabs.addTab(self.receive_address_widget, read_QIcon("bitcoin.png"), _('Address')) self.receive_tabs.addTab(self.receive_lightning_widget, read_QIcon("lightning.png"), _('Lightning')) self.receive_tabs.currentChanged.connect(self.update_receive_qr_window) self.receive_tabs.setCurrentIndex( self.config.get('receive_tabs_index', 0)) self.receive_tabs.currentChanged.connect( lambda i: self.config.set_key('receive_tabs_index', i)) receive_tabs_sp = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) receive_tabs_sp.setRetainSizeWhenHidden(True) self.receive_tabs.setSizePolicy(receive_tabs_sp) self.receive_tabs.setVisible(False) self.receive_requests_label = QLabel(_('Receive queue')) from .request_list import RequestList self.request_list = RequestList(self) # layout vbox_g = QVBoxLayout() vbox_g.addLayout(grid) vbox_g.addStretch() hbox = QHBoxLayout() hbox.addLayout(vbox_g) hbox.addStretch() hbox.addWidget(self.receive_tabs) self.searchable_list = self.request_list vbox = QVBoxLayout(self) vbox.addLayout(hbox) vbox.addStretch() vbox.addWidget(self.receive_requests_label) vbox.addWidget(self.request_list) vbox.setStretchFactor(hbox, 40) vbox.setStretchFactor(self.request_list, 60) self.request_list.update( ) # after parented and put into a layout, can update without flickering