def _set_layout(self): """ Creates this Widget's Layout """ box = QVBoxLayout() box.setContentsMargins(0, 0, 0, 0) box.addSpacing(20) AboutLabel("Made by\nOlivier Lécluse & Thomas Lécluse", box) logo = QLabel() logo.setPixmap(QPixmap("assets/LDC-light")) logo.setFixedSize(QSize(512, 222)) # Original dimension is 2048x888, we divided by 4 logo.setScaledContents(True) box.addWidget(logo) box.setAlignment(logo, Qt.AlignCenter) AboutLabel( f'{self.links_style}<a href="https://bradsprojects.com/digirule2/">> Digirule2 project <</a>', box, True) AboutLabel( f'{self.links_style}<a href="https://github.com/wawachief/DigiQt">> GitHub project <</a>', box, True) AboutLabel( f'Contact: {self.contact_style}<a href="mailto:[email protected]">[email protected]</a>', box, True) AboutLabel(f"Version: {self.config.get('main', 'APP_VERSION')}", box) box.addSpacing(20) self.setLayout(box)
def _addTokenToWindow(self, token_information, resize_parent=False): wrapper_layout = QVBoxLayout() token_layout = QHBoxLayout() rows_layout = QVBoxLayout() token_label = QLabel(token_information.name) token_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) symbol_label = QLabel(token_information.symbol) symbol_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) total_supply_label = QLabel('Total Supply: %d coins' % token_information.totalSupply) total_supply_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) rows_layout.addWidget(token_label) rows_layout.addWidget(symbol_label) rows_layout.addWidget(total_supply_label) avatar = QLabel() img_filename = render_avatar(token_information.address) pixmap = QPixmap(img_filename) avatar.setPixmap(pixmap) token_layout.addWidget(avatar) token_layout.addLayout(rows_layout) wrapper_layout.addLayout(token_layout) wrapper_layout.addSpacing(20) self.tokens_layout.addLayout(wrapper_layout) if resize_parent: sizeHint = self.size() self.parentWidget().parentWidget().resize(QSize(sizeHint.width(), sizeHint.height() + 100))
def __init__(self, name, type, data=""): QGroupBox.__init__(self) if name.find(": ") != -1: name = name.split(": ")[0] self.name, self.type = name, type self.data = data self.defaultElement = QGroupBox() mainElementLayout = QVBoxLayout() elementLayout = QHBoxLayout() if self.data == "": self.lName = QLabel(str(name)) else: self.lName = QLabel(str(name) + ": " + str(self.data)) self.lName.setMinimumSize(10, 10) duplicate = QPushButton("❐") duplicate.clicked.connect(lambda: self.duplicateElement()) edit = QPushButton("✎") edit.clicked.connect(lambda: self.editText()) remove = QPushButton("×") remove.clicked.connect(lambda: self.delElement()) elementLayout.addWidget(self.lName) elementLayout.addWidget(duplicate) elementLayout.addWidget(edit) elementLayout.addWidget(remove) elementLayout.setStretch(0, 2) mainElementLayout.addLayout(elementLayout) mainElementLayout.addSpacing(10) self.defaultElement.setLayout(mainElementLayout) self.defaultElement.setFixedHeight(80)
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None): super().__init__(layer=layer, targetImage=targetImage, parent=parent) # options self.options = None self.mergeButton = QPushButton('Refresh') # button slot def f(): self.dataChanged.emit() self.mergeButton.pressed.connect(f) # layout l = QVBoxLayout() l.setAlignment(Qt.AlignTop) l.addSpacing(30) l.addWidget(self.mergeButton) l.setContentsMargins(20, 0, 20, 25) # left, top, right, bottom self.setLayout(l) self.adjustSize() self.setWhatsThis("""<b>Exposure Fusion</b> In the layer stack use the context menu to select the layers to be merged. Next, press the <i>Refresh</i> button.<br> """) # end setWhatsThis self.setDefaults()
def _addAccountToWindow(self, account, balance, resize_parent=False): wrapper_layout = QVBoxLayout() account_layout = QHBoxLayout() rows_layout = QVBoxLayout() address_layout = QHBoxLayout() account_label = QLabel(account) account_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) copy_button = QPushButton() copy_button.setAutoFillBackground(True) copy_button.setIcon(QIcon('icons/copy.svg')) self.connect(copy_button, SIGNAL('clicked()'), lambda: self.copyAddress(account)) address_layout.addWidget(account_label) address_layout.addWidget(copy_button) balance_label = QLabel('Balance: %.5f ethers' % balance) balance_label.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) self.balance_widgets[account] = balance_label rows_layout.addLayout(address_layout) rows_layout.addWidget(balance_label) avatar = QLabel() img_filename = render_avatar(account) pixmap = QPixmap(img_filename) avatar.setPixmap(pixmap) account_layout.addWidget(avatar) account_layout.addLayout(rows_layout) wrapper_layout.addLayout(account_layout) wrapper_layout.addSpacing(20) self.accounts_layout.addLayout(wrapper_layout) if resize_parent: sizeHint = self.sizeHint() self.parentWidget().parentWidget().resize( QSize(sizeHint.width(), sizeHint.height() + 40))
def __init__(self, targetImage=None, axeSize=500, layer=None, parent=None): super().__init__(layer=layer, targetImage=targetImage, parent=parent) # options self.options = None self.mergeButton = QPushButton('Refresh') self.mergeButton.setMaximumWidth(80) self.warn = QLabel( 'Use the layer stack context menu\nto add or remove layers to merge.' ) # self.warn.setStyleSheet("QLabel {color : yellow; }") # button slot def f(): self.dataChanged.emit() self.mergeButton.pressed.connect(f) # layout l = QVBoxLayout() l.setAlignment(Qt.AlignTop | Qt.AlignHCenter) l.addSpacing(30) l.addWidget(self.mergeButton) l.addSpacing(100) l.addWidget(self.warn) l.setContentsMargins(20, 0, 20, 25) # left, top, right, bottom self.setLayout(l) self.adjustSize() self.setWhatsThis("""<b>Exposure Fusion</b> In the layer stack use the context menu to select the layers to be merged. Next, press the <i>Refresh</i> button.<br> """) # end setWhatsThis self.setDefaults()
def _setup_ui(self): self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) layout = QVBoxLayout(self) self.setLayout(layout) layout.setAlignment(Qt.AlignTop) layout.setSpacing(2) layout.setMargin(2) layout.addSpacing(20) self._alarms = Alarms(self, self._usbif) layout.addWidget(self._alarms) self._meas = Measurements(self, self._usbif) layout.addWidget(self._meas) self._core_rope_sim = CoreRopeSim(self, self._usbif) layout.addWidget(self._core_rope_sim) layout.setAlignment(self._core_rope_sim, Qt.AlignTop) self._erasable_mem_sim = ErasableMemSim(self, self._usbif) layout.addWidget(self._erasable_mem_sim) layout.setAlignment(self._erasable_mem_sim, Qt.AlignTop) self._trace = Trace(self, self._usbif) layout.addWidget(self._trace)
def initUI(self): mainLayout = QVBoxLayout() self.setLayout(mainLayout) self.timeViewer = QLCDNumber() self.timeViewer.setFixedHeight(45) self.timeViewer.setDigitCount(8) # 00:00:00 mainLayout.addWidget(self.timeViewer) self.buttonStart = QPushButton(self.tr("start countup")) self.buttonStart.setMinimumHeight(35) mainLayout.addWidget(self.buttonStart) self.buttonPause = QPushButton(self.tr("pause countup")) self.buttonPause.setMinimumHeight(35) mainLayout.addWidget(self.buttonPause) self.buttonReset = QPushButton(self.tr("reset countup")) self.buttonReset.setMinimumHeight(35) mainLayout.addWidget(self.buttonReset) mainLayout.addSpacing(10) countdown_edit_hlayout = QHBoxLayout() self.countdown_edit_hour = QComboBox() self.countdown_edit_hour.setMinimumHeight(35) self.countdown_edit_hour.setFont(self.countdown_edit_font) self.countdown_edit_hour.addItems([f'{i}' for i in range(0, 24)]) self.countdown_edit_minute = QComboBox() self.countdown_edit_minute.setMinimumHeight(35) self.countdown_edit_minute.setFont(self.countdown_edit_font) self.countdown_edit_minute.addItems([f'{i}' for i in range(0, 60)]) self.countdown_edit_second = QComboBox() self.countdown_edit_second.setMinimumHeight(35) self.countdown_edit_second.setFont(self.countdown_edit_font) self.countdown_edit_second.addItems([f'{i}' for i in range(0, 60)]) countdown_edit_hlayout.addWidget(self.countdown_edit_hour) countdown_edit_hlayout.addWidget(self.countdown_edit_minute) countdown_edit_hlayout.addWidget(self.countdown_edit_second) mainLayout.addLayout(countdown_edit_hlayout) self.buttonCountDown = QPushButton(self.tr("start countdown")) self.buttonCountDown.setMinimumHeight(35) self.buttonCountDownPause = QPushButton(self.tr("pause countdown")) self.buttonCountDownPause.setMinimumHeight(35) self.buttonCountDownReset = QPushButton(self.tr("reset countdown")) self.buttonCountDownReset.setMinimumHeight(35) mainLayout.addWidget(self.buttonCountDown) mainLayout.addWidget(self.buttonCountDownPause) mainLayout.addWidget(self.buttonCountDownReset)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.labels = { key: QLabel(text=key, objectName='Header') for key in ['Controller', 'Sensor'] } self.device_menus = {key: QComboBox() for key in self.labels} self.port_menus = {key: QComboBox() for key in self.labels} self.connect_buttons = { key: QPushButton(text='Connect', objectName=key) for key in self.labels } self.buttongroup = QButtonGroup() self.buttongroup.setExclusive(False) self.buttongroup.buttonToggled.connect(self.connect_device) self.unitbuttons = { key: QRadioButton(text=key) for key in ['Temperature', 'Voltage'] } self.refresh_button = QPushButton(text='Refresh Serial', objectName='Refresh') vbox = QVBoxLayout() vbox.setSpacing(10) vbox.setContentsMargins(10, 10, 10, 10) vbox.addWidget(QLabel(text='Process Variable', objectName='Header')) for key, button in self.unitbuttons.items(): vbox.addWidget(button) button.toggled.connect( functools.partial(self.set_measurement_unit, unit=key)) vbox.addSpacing(20) for key in self.labels: self.buttongroup.addButton(self.connect_buttons[key]) self.connect_buttons[key].setCheckable(True) vbox.addWidget(self.labels[key]) vbox.addWidget(self.device_menus[key]) vbox.addWidget(self.port_menus[key]) vbox.addWidget(self.connect_buttons[key]) vbox.addSpacing(20) vbox.addWidget(self.refresh_button) self.refresh_button.clicked.connect( lambda: pubsub.pub.sendMessage('gui.request.ports')) vbox.addStretch() self.setLayout(vbox) pubsub.pub.subscribe(listener=self.update_ports, topicName='engine.answer.ports') pubsub.pub.subscribe(listener=self.update_devices, topicName='engine.answer.devices') pubsub.pub.sendMessage('gui.request.ports')
def _setup_ui(self): self.setFrameStyle(QFrame.StyledPanel | QFrame.Raised) layout = QHBoxLayout(self) self.setLayout(layout) # Create a group box for the inhibit switches nh_group = QGroupBox('INH', self) nh_group.setAlignment(Qt.AlignCenter) layout.addWidget(nh_group) layout.setAlignment(nh_group, Qt.AlignTop) layout.setMargin(1) layout.setSpacing(1) # Set up a grid layout to hold the labels, switches, and indicators nh_layout = QGridLayout(nh_group) nh_group.setLayout(nh_layout) nh_layout.setMargin(1) nh_layout.setSpacing(1) # Construct the inhibit indicators and switches col = 0 for switch, msg in INH_SWITCHES.items(): self._create_inh_control(switch, nh_group, nh_layout, col) ind = self._inh_inds[-1] self._inh_switches[-1].stateChanged.connect( lambda on, ind=ind, msg=msg: self._set_inh(ind, msg, on)) col += 1 sl_group = QWidget(self) layout.addWidget(sl_group) sl_layout = QVBoxLayout(sl_group) sl_group.setLayout(sl_layout) sl_layout.setMargin(1) sl_layout.setSpacing(1) sl_layout.addSpacing(4) stat_group = QWidget(sl_group) sl_layout.addWidget(stat_group) stat_layout = QGridLayout(stat_group) stat_layout.setMargin(3) stat_layout.setSpacing(3) col = 0 for name, label in STATUS_INDS.items(): self._status_inds[name] = self._create_status_light( label, stat_group, stat_layout, col) col += 1 label = QLabel('CONTROL', sl_group) font = label.font() font.setPointSize(12) font.setBold(True) label.setFont(font) label.setAlignment(Qt.AlignCenter) sl_layout.addWidget(label)
class ApolloGroup(QWidget): def __init__(self, parent, text, horizontal=True, nframes=1, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.widgets = [] self.layout = QVBoxLayout() self.layout.setSpacing(0) self.layout.setMargin(0) self.layout.setContentsMargins(0, 0, 0, 0) self.heading = ApolloGroupHeading(parent, text) self.layout.addWidget(self.heading) self.layout.addSpacing(12) self.framelayouts = [] for i in range(nframes): f = QFrame(parent) self.layout.addWidget(f) if horizontal: self.framelayouts.append(QHBoxLayout()) else: self.framelayouts.append(QVBoxLayout()) self.framelayouts[-1].setMargin(0) self.framelayouts[-1].setSpacing(10) f.setLayout(self.framelayouts[-1]) if i < nframes - 1: self.layout.addSpacing(8) self.layout.addStretch() self.setLayout(self.layout) def addWidget(self, w, frame=0): self.widgets.append(w) self.framelayouts[frame].addWidget(w) def addSpacing(self, spacing, frame=0): self.framelayouts[frame].addSpacing(spacing) def addStretch(self, frame=0): self.framelayouts[frame].addStretch() def group(self): bg = QButtonGroup(self) for w in self.widgets: try: bg.addButton(w.switch) except AttributeError: pass bg.exclusive()
def __init__(self): QWidget.__init__(self) # stack the different panels vertically main_layout = QVBoxLayout() main_layout.addWidget(self.create_project_section()) main_layout.addSpacing(15) main_layout.addWidget(self.create_global_stats_section()) self.setLayout(main_layout)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.labels = { key: QLabel(text=key, objectName='Header') for key in ['Setpoint', 'Rate', 'Power'] } self.entries = { key: QDoubleSpinBox(decimals=1, singleStep=1, minimum=0, maximum=10000) for key in self.labels } self.entries['Power'].setMaximum(100) self.entries['Power'].setSuffix(' %') self.buttons = { key: QRadioButton(text=key) for key in ['Automatic', 'Manual'] } vbox = QVBoxLayout() vbox.setSpacing(10) vbox.setContentsMargins(10, 10, 10, 10) for label in self.labels: self.entries[label].setKeyboardTracking(False) self.entries[label].valueChanged.connect( functools.partial(self.set_control_value, control=label)) vbox.addWidget(self.labels[label], stretch=0) vbox.addWidget(self.entries[label], stretch=0) vbox.addSpacing(10) vbox.addWidget(QLabel(text='Control mode', objectName='Header')) for button in self.buttons: vbox.addWidget(self.buttons[button]) self.buttons[button].toggled.connect( functools.partial(self.set_control_mode, mode=button)) refresh_button = QPushButton(text='Refresh', objectName='Refresh') refresh_button.clicked.connect( lambda: pubsub.pub.sendMessage('gui.request.control_parameters')) vbox.addSpacing(10) vbox.addWidget(refresh_button) vbox.addStretch() self.setLayout(vbox) pubsub.pub.subscribe(self.update_control_values, 'engine.answer.control_parameters')
def __init__(self, width, box: QVBoxLayout): """ Separator for the about box """ QLabel.__init__(self) self.setFixedHeight(3) self.setFixedWidth(int(width)) self.setStyleSheet(get_stylesheet("separator")) # Layout self.setAlignment(Qt.AlignCenter) box.addSpacing(SPACING_SIZE) box.addWidget(self, alignment=Qt.AlignCenter) box.addSpacing(SPACING_SIZE)
class Split(QtWidgets.QDialog): def __init__(self, parent, headers, callback, file_name): super().__init__(parent) self.file_name = file_name self.callback = callback self.headers = headers self.setFixedWidth(500) self.setStyleSheet(styles.split) self.v_layout = QVBoxLayout() self.button_h_layout = QHBoxLayout() self.split_by_btn = MenuButton(self, "Split By : ", self.headers) # CUSTOMIZE OPTIONS # SELECT FOLDER # DEFAULT OPTIONS # BUTTONS self.split_btn = QPushButton(QIcon(icon.SPLIT_I()), "Split", self) self.split_btn.clicked.connect(self.split) self.cancel_btn = QPushButton(QIcon(icon.DELETE_I()), "Cancel", self) self.cancel_btn.clicked.connect(self.close) self.button_h_layout.addWidget(self.split_btn) self.button_h_layout.addWidget(self.cancel_btn) # SET UP self.v_layout.addWidget(self.split_by_btn) self.v_layout.addSpacing(20) self.v_layout.addLayout(self.button_h_layout) self.setLayout(self.v_layout) self.show() def cancel(self): self.close() def split(self): parm = { "Split by": self.split_by_btn.value } self.callback(parm)
def init_image_settings(self, image_item): image_layout = QVBoxLayout() image_layout.setAlignment(Qt.AlignTop) image_group_box = QGroupBox("Image") image_layout.addLayout(init_item_opacity_layout(image_item)) image_layout.addSpacing(30) image_layout.addLayout(init_item_rotation_layout(image_item)) image_layout.addSpacing(30) image_layout.addLayout(init_image_scale_layout(image_item)) image_group_box.setLayout(image_layout) layout = QVBoxLayout() layout.addWidget(image_group_box) layout.addWidget(self.init_item_duplicate_widget(image_item)) layout.addWidget(init_item_delete_widget(image_item)) settings = QWidget() settings.setLayout(layout) self.settings_scroll_area.setWidget(settings) self.layout.setCurrentWidget(self.settings_scroll_area)
def __init__(self, parent): """ Confirm dialog for dangerous actions :param parent: gui's main window """ QDialog.__init__(self, parent) # QR Code s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.has_internet = True try: s.connect(('8.8.8.8', 1)) # connect() for UDP does not send packets, this will require an internet connection # IP and Port local_ip_address = s.getsockname()[0] s.close() port = AssetManager.getInstance().config('webapp', 'port') # get tmp folder qr_path = tempfile.mktemp() s = f"http://{local_ip_address}:{port}/mobile" # String which represents the QR code self.url = pyqrcode.create(s) # Generate QR code self.url.png(qr_path, scale=6) # Create and save the QR png file # Widget self.qr = QLabel() # Label that contains the QR pix = QPixmap(QImage(qr_path)) self.qr.setPixmap(pix) # Layout layout = QVBoxLayout() layout.setMargin(0) layout.addWidget(self.qr, alignment=Qt.AlignCenter) layout.addWidget(InfoToolTip("qr_tip"), alignment=Qt.AlignCenter) layout.addSpacing(5) self.setLayout(layout) self.setStyleSheet("background: white;") except OSError: self.has_internet = False
class Tab(QWidget): def __init__(self): QWidget.__init__(self) self.name = "NewTab" self.df = self.create_data() self.h_layout = QHBoxLayout() self.v_layout = QVBoxLayout() self.df_widget = DataFrameWidget(self.df) # self.action_button = QPushButton("info") # self.action_button.clicked.connect(self.df_widget.showSizeInfo) # self.v_layout.addStretch() self.v_layout.addSpacing(50) self.v_layout.addWidget(self.df_widget) # self.v_layout.addStretch() self.v_layout.addSpacing(50) # self.v_layout.addWidget(self.action_button) # self.h_layout.addStretch() self.h_layout.addSpacing(50) self.h_layout.addLayout(self.v_layout) # self.h_layout.addStretch() self.h_layout.addSpacing(50) self.setLayout(self.h_layout) def keyPressEvent(self, QKeyEvent): # print("A key has been pressed -> key_num = {}".format(QKeyEvent.key())) self.df_widget.showSizeInfo() def create_data(self): df = pd.DataFrame({ "Kills": [500, 510], "Deaths": [249, 255] }, index=["Before", "After"]) df["K/D"] = (df.Kills / df.Deaths).round(7) df["K/D rounded"] = df["K/D"].round(2) return df
def __init__(self): super().__init__() self._series = {} self._legend_items = {} self.setTitle("Statistiques") self.setProperty("qss-var", "pb-0") self._total_label = QLabel() self._legend_layout = QGridLayout() self._legend_layout.setVerticalSpacing(0) self._legend_layout.setHorizontalSpacing(50) main_layout = QVBoxLayout() main_layout.addWidget(self._total_label) main_layout.addLayout(self._legend_layout) main_layout.addSpacing(5) main_layout.addWidget(self._createLineChart(), 1) self.setLayout(main_layout)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) controls = ['Start', 'Clear', 'Export'] self.buttons = { key: QPushButton(parent=self, text=key, objectName=key) for key in controls } self.buttons['Start'].setCheckable(True) self.checks = { key: QCheckBox(parent=self, text=key, objectName=key) for key in ['Sensor PV', 'Controller PV', 'Setpoint', 'Power'] } self.check_group = QButtonGroup() self.check_group.setExclusive(False) vbox = QVBoxLayout() vbox.addWidget(QLabel(text='Plotting', objectName='Header')) for key in controls: vbox.addWidget(self.buttons[key]) self.buttons[key].clicked.connect({ 'Start': functools.partial(self.start_stop_plotting), 'Clear': self.clear_pplot, 'Export': self.export_data }[key]) vbox.addSpacing(20) vbox.addWidget(QLabel(text='Data sources', objectName='Header')) for key, button in self.checks.items(): button.setChecked(True) self.check_group.addButton(button) vbox.addWidget(button) vbox.addStretch() vbox.setSpacing(10) vbox.setContentsMargins(10, 10, 10, 10) self.setLayout(vbox)
def _ui_settings_params_lock_ffv8(self, vbox: QtWidgets.QVBoxLayout) -> None: vbox.addSpacing(6) lock_hbox = QtWidgets.QHBoxLayout() vbox.addLayout(lock_hbox) lock_hbox.addStretch() self.editable_v8 = QtWidgets.QPushButton() self.editable_v8.setIconSize(QtCore.QSize(24, 24)) self.editable_v8.setFixedHeight(28) edit_icon = QtGui.QIcon() edit_icon.addFile(os.path.join(self.parent_win.media, 'lock.png'), state=QtGui.QIcon.Off) edit_icon.addFile(os.path.join(self.parent_win.media, 'unlock.png'), state=QtGui.QIcon.On) self.editable_v8.setIcon(edit_icon) self.editable_v8.setCheckable(True) # noinspection PyUnresolvedReferences self.editable_v8.clicked.connect(self.on_editable_v8) self.editable_v8.setToolTip("Unlock editing for parameters") lock_hbox.addWidget(self.editable_v8) lock_hbox.addStretch() vbox.addStretch()
def _setup_ui(self): layout = QVBoxLayout(self) self.setLayout(layout) layout.setMargin(1) layout.setSpacing(1) layout.addSpacing(50) l = QLabel('BANK S', self) l.setMinimumHeight(20) l.setAlignment(Qt.AlignCenter | Qt.AlignBottom) font = l.font() font.setPointSize(7) font.setBold(True) l.setFont(font) layout.addWidget(l, Qt.AlignCenter) bank_s = QRadioButton(self) bank_s.setStyleSheet( 'QRadioButton::indicator{subcontrol-position:center;}') layout.addWidget(bank_s, Qt.AlignTop | Qt.AlignCenter) s_only = QRadioButton(self) s_only.setStyleSheet( 'QRadioButton::indicator{subcontrol-position:center;}') s_only.toggled.connect( lambda s: self._usbif.send(um.WriteControlBankS(s))) layout.addWidget(s_only, Qt.AlignTop | Qt.AlignCenter) l = QLabel('S ONLY', self) l.setAlignment(Qt.AlignCenter | Qt.AlignTop) l.setFont(font) layout.addWidget(l, Qt.AlignTop | Qt.AlignCenter) bank_s.setChecked(True)
def __init__(self, parent=None): super().__init__(parent) self.timeAxisAttributeCB = QComboBox(self) self.valuesTable = SearchableAttributeTableWidget( self, True, False, True, [Types.Numeric, Types.Ordinal]) self.indexTable = SearchableTableWidget(self) # self.meanCB = QCheckBox('Mean of selected', self) self.createButton = QPushButton('Create chart', self) sideLayout = QVBoxLayout(self) lab = QLabel('Select the column to use as time index') lab.setWordWrap(True) sideLayout.addWidget(lab) sideLayout.addWidget(self.timeAxisAttributeCB) lab = QLabel('Time axis format') self.timeAxisFormatCB = QComboBox(self) options = QStringListModel([ 'dd.MM.yyyy', 'yyyy-MM-dd', 'yyyy-MM', 'yyyy', 'MM', 'dd', 'hh:mm:ss', 'hh:mm', 'hh', 'yyyy-MM-dd HH:mm:ss', 'ddd MMM dd yyyy', 'ddd', 'MMM', 'MMM yyyy' ], parent=self) self.timeAxisFormatCB.setModel(options) self.timeAxisFormatCB.setCurrentIndex(0) sideLayout.addWidget(lab) sideLayout.addWidget(self.timeAxisFormatCB) lab = QLabel( 'Select any number of columns to show as a function of time') lab.setWordWrap(True) sideLayout.addSpacing(30) sideLayout.addWidget(lab) sideLayout.addWidget(self.valuesTable) lab = QLabel( 'Select the rows to show by index. An index attribute must be set') lab.setWordWrap(True) sideLayout.addSpacing(30) sideLayout.addWidget(lab) sideLayout.addWidget(self.indexTable) # sideLayout.addWidget(self.meanCB) sideLayout.addSpacing(30) sideLayout.addWidget(self.createButton) self.errorLabel = QLabel(self) self.errorLabel.setWordWrap(True) sideLayout.addWidget(self.errorLabel) self.errorLabel.hide()
def __init__(self, fgIndex, bgIndex, palette, informFunction, parent=None): super(PaletteSelectorLayout, self).__init__("", parent) if ZXAttribute.paletteCount() != 2: raise Exception( "The palette selector is current designed for 2 palettes only") self._bright = palette self._fgIndex = fgIndex self._bgIndex = bgIndex self._informFunction = informFunction vert_layout = QVBoxLayout() self.setLayout(vert_layout) vert_layout.addWidget(QLabel("Palette Selector:")) vert_layout.addSpacing(20) # Add check box to select brightness bright_select = QCheckBox("Bright Enabled") vert_layout.addWidget(bright_select) if palette == 1: bright_select.setChecked(True) bright_select.clicked.connect(self._brightSelect) vert_layout.addSpacing(10) # Foreground color checkboxes self._fg_group = QButtonGroup() self._fg_group.setExclusive(True) self._createLayout(vert_layout, "Foreground color:", self._fg_group, self._fgIndexSelect, fgIndex) vert_layout.addSpacing(10) # Background color checkboxes self._bg_group = QButtonGroup() self._bg_group.setExclusive(True) self._createLayout(vert_layout, "Background color:", self._bg_group, self._bgIndexSelect, bgIndex)
def __set_layout(self) -> None: """ Sets the dialog layout """ # Main layout layout = QVBoxLayout() layout.setMargin(0) layout.addSpacing(5) # Main section main_layout = QFormLayout() main_layout.addRow(tr("app_version"), self.lab_version) main_layout.addRow(tr("language"), self.combo_language) main_layout.addRow(tr("csv_sep"), self.csv_sep_edit) main_layout.addRow(tr("bdd_path"), self.btn_bdd_path) # Web app widget_port = QWidget() layout_port = QHBoxLayout() layout_port.setMargin(0) layout_port.addWidget(self.wepapp_port) layout_port.addWidget(ShutDownToolTip()) widget_port.setLayout(layout_port) main_layout.addRow(tr("web_port"), widget_port) layout.addLayout(main_layout) Separator(self.width(), layout) # Colors colors_layout1 = QFormLayout() colors_layout1.addRow(tr("tile"), self.tile_color) colors_layout1.addRow(tr("hovered_tile"), self.hovered_tile_color) colors_layout1.addRow(tr("hovered_empty_tile"), self.hovered_empty_tile_color) colors_layout1.addRow(tr("dragged_tile"), self.dragged_tile_color) colors_layout1.addRow(tr("drag_selected_tile"), self.drag_selected_tile_color) colors_layout1.addRow(tr("selected_tile"), self.selected_tile_color) colors_layout2 = QFormLayout() colors_layout2.addRow(tr("tile_text"), self.tile_text_color) colors_layout2.addRow(tr("room_bg"), self.room_bg_color) colors_layout2.addRow(tr("room_grid"), self.room_grid_color) colors_layout2.addRow(tr("main_bg"), self.main_bg_color) colors_layout2.addRow(tr("board_bg"), self.board_bg_color) colors_layout = QHBoxLayout() colors_layout.setMargin(0) colors_layout.addLayout(colors_layout1) colors_layout.addLayout(colors_layout2) layout.addLayout(colors_layout) layout.addSpacing(15) colors_layout3 = QFormLayout() colors_layout3.setMargin(0) colors_layout3.addRow(tr("attr_colors"), self.attributes_colors_chooser) layout.addLayout(colors_layout3) Separator(self.width(), layout) # Unmodifiable data sizes_layout = QFormLayout() sizes_layout.setMargin(0) sizes_layout.addRow(tr("desk_size"), self.desk_size) sizes_layout.addRow(tr("grid_rows"), self.grid_rows) sizes_layout.addRow(tr("grid_cols"), self.grid_cols) layout.addWidget(self.unmodifiable, alignment=Qt.AlignCenter) layout.addSpacing(5) layout.addLayout(sizes_layout) Separator(self.width(), layout) # Buttons layout_buttons = QHBoxLayout() layout_buttons.addWidget(self.ok_btn) layout_buttons.addWidget(self.restore_btn) layout_buttons.addWidget(self.cancel_btn) layout.addLayout(layout_buttons) self.setLayout(layout) self.setStyleSheet(get_stylesheet("dialog2"))
def __init__(self, choice_list, title="", subtitle="", cancel_button=False, choice=None, parent=None): """ :type cancel_button: if True then a Cancel button will appear :type choice: contains either None or the number of the chosen button :param title: window title :param subtitle: subtitle, appears inside window :param choice_list: list of couples (caption, text) where caption will be the text in the button, and text will be displayed as the corresponding choice """ super(ButtonsDialog, self).__init__(parent) self.setWindowTitle(title) self.subtitle = subtitle self.buttons = [] self.choices = [] self.choice = choice # Display # layout = QVBoxLayout() # title line subtitle_line = QLabel(subtitle, self, StyleSheet='font-weight: bold;') subtitle_layout = QHBoxLayout() subtitle_layout.addWidget(subtitle_line) subtitle_layout.addStretch(1) # Filling the lines layout.addLayout(subtitle_layout) # 1st line layout.addSpacing(10) # Buttons and corresponding texts, one new_layout per line for caption, choice in choice_list: new_button = QPushButton(caption) self.buttons.append(new_button) self.choices.append(QLabel(choice, self)) new_layout = QHBoxLayout() new_layout.addWidget(self.buttons[-1]) new_layout.addWidget(self.choices[-1]) new_layout.addStretch(1) layout.addLayout(new_layout) layout.addSpacing(-10) # Cancel button if cancel_button: self.cancel = QPushButton("Cancel") new_layout = QHBoxLayout() new_layout.addStretch(1) new_layout.addWidget(self.cancel) new_layout.addStretch(1) layout.addLayout(new_layout) self.setLayout(layout) # Signals if cancel_button: self.cancel.clicked.connect(self.reject) for button in self.buttons: # call the button_clicked function with the right number button.clicked.connect( partial(self.button_clicked, number=self.buttons.index(button)))
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) parameters = { 'Gain Scheduling': { 'GS': 'Gain scheduling', 'AS': 'Active Set', 'B12': 'Boundary 1/2', 'B23': 'Boundary 2/3' }, 'Set 1': { 'P1': 'Proportional 1', 'I1': 'Integral 1', 'D1': 'Derivative 1' }, 'Set 2': { 'P2': 'Proportional 2', 'I2': 'Integral 2', 'D2': 'Derivative 2' }, 'Set 3': { 'P3': 'Proportional 3', 'I3': 'Integral 3', 'D3': 'Derivative 3' } } self.units = { 'I1': ' s', 'I2': ' s', 'I3': ' s', 'D1': ' s', 'D2': ' s', 'D3': ' s' } self.entries = { key: QComboBox() if key == 'GS' else QSpinBox(minimum=1, maximum=3) if key == 'AS' else QDoubleSpinBox( decimals=0, singleStep=10, minimum=0, maximum=100000) for subset in parameters for key in parameters[subset] } self.entries['GS'].addItems( ['None', 'Set', 'Process Variable', 'Setpoint', 'Output']) for entry, suffix in self.units.items(): self.entries[entry].setSuffix(suffix) vbox = QVBoxLayout() vbox.setSpacing(0) vbox.setContentsMargins(10, 10, 10, 10) for subset in parameters: label = QLabel(text=subset, objectName='Header') vbox.addWidget(label) vbox.addSpacing(10) form = QFormLayout() form.setSpacing(5) form.setHorizontalSpacing(20) form.setContentsMargins(0, 0, 0, 0) for key in parameters[subset]: form.addRow(parameters[subset][key], self.entries[key]) vbox.addLayout(form) vbox.addSpacing(20) refresh_button = QPushButton(text='Refresh', objectName='Refresh') refresh_button.clicked.connect( lambda: pubsub.pub.sendMessage('gui.request.pid_parameters')) vbox.addWidget(refresh_button) vbox.addStretch() self.setLayout(vbox) for key, entry in self.entries.items(): if key == 'GS': entry.currentTextChanged.connect( functools.partial(self.set_pid_parameter, control=key)) else: entry.setKeyboardTracking(False) entry.valueChanged.connect( functools.partial(self.set_pid_parameter, control=key)) pubsub.pub.subscribe(self.update_pid_parameters, 'engine.answer.pid_parameters')
def __init__(self, parent, data): assert type(data) == binaryninja.binaryview.BinaryView self.bv = data QDialog.__init__(self, parent) self.setWindowTitle("Debug Adapter Settings") self.setMinimumSize(UIContext.getScaledWindowSize(400, 130)) self.setAttribute(Qt.WA_DeleteOnClose) layout = QVBoxLayout() layout.setSpacing(0) titleLabel = QLabel("Adapter Settings") titleLayout = QHBoxLayout() titleLayout.setContentsMargins(0, 0, 0, 0) titleLayout.addWidget(titleLabel) self.argumentsEntry = QLineEdit(self) # self.addressEntry = QLineEdit(self) # self.portEntry = QLineEdit(self) formLayout = QFormLayout() formLayout.addRow("Command Line Arguments", self.argumentsEntry) # formLayout.addRow("Address", self.addressEntry) # formLayout.addRow("Port", self.portEntry) buttonLayout = QHBoxLayout() buttonLayout.setContentsMargins(0, 0, 0, 0) self.cancelButton = QPushButton("Cancel") self.cancelButton.clicked.connect(lambda: self.reject()) self.acceptButton = QPushButton("Accept") self.acceptButton.clicked.connect(lambda: self.accept()) self.acceptButton.setDefault(True) buttonLayout.addStretch(1) buttonLayout.addWidget(self.cancelButton) buttonLayout.addWidget(self.acceptButton) layout.addLayout(titleLayout) layout.addSpacing(10) layout.addLayout(formLayout) layout.addStretch(1) layout.addSpacing(10) layout.addLayout(buttonLayout) self.setLayout(layout) debug_state = binjaplug.get_state(self.bv) # settings = Settings() # address = settings.get_string_with_scope("debugger.adapter.address", data, SettingsScope.SettingsContextScope) # port = settings.get_integer_with_scope("debugger.adapter.port", data, SettingsScope.SettingsContextScope) # self.addressEntry.setText(address[0]) # self.portEntry.setText(str(port[0])) # self.addressEntry.textEdited.connect(lambda: self.updateSettings()) # self.portEntry.textEdited.connect(lambda: self.updateSettings()) self.argumentsEntry.setText(' ' .join(shlex.quote(arg) for arg in debug_state.command_line_args)) self.argumentsEntry.textEdited.connect(lambda: self.updateArguments()) self.accepted.connect(lambda: self.apply())
def __init__(self, choices, title = "", output = "", cancel_button = False, choice = None, parent = None): """ :param choices: list of couples (caption, text) where caption will be the text in the button, and text will be displayed as the corresponding choice :param title: window title :param output: output, appears inside window :type cancel_button: if True then a Cancel button will appear :type choice: contains either None or the number of the chosen button """ super(ButtonsDialog, self).__init__(parent) self.setWindowTitle(title) self.output = output self.buttons = [] self.choices = [] self.choice = choice # Display # layout = QVBoxLayout() # Output line output_line = QLabel(output, self, StyleSheet='font-weight: bold;') math_font_name = cvars.get('display.mathematics_font', 'Default') output_line.setFont(QFont(math_font_name)) output_layout = QHBoxLayout() output_layout.addWidget(output_line) output_layout.addStretch(1) # Filling the lines layout.addLayout(output_layout) # 1st line layout.addSpacing(5) # Buttons and corresponding texts, one new_layout per line for caption, choice in choices: new_button = QPushButton(caption) self.buttons.append(new_button) self.choices.append(QLabel(choice, self)) new_layout = QHBoxLayout() new_layout.addWidget(self.buttons[-1]) new_layout.addWidget(self.choices[-1]) new_layout.addStretch(1) layout.addLayout(new_layout) layout.addSpacing(-5) # Cancel button if cancel_button: self.cancel = QPushButton("Cancel") new_layout = QHBoxLayout() new_layout.addStretch(1) new_layout.addWidget(self.cancel) new_layout.addStretch(1) layout.addLayout(new_layout) layout.setContentsMargins(10, 10, 10, 20) self.setLayout(layout) # Signals if cancel_button: self.cancel.clicked.connect(self.reject) for button in self.buttons: # call the button_clicked function with the right number button.clicked.connect(partial(self.button_clicked, number=self.buttons.index(button)))
def _setup_ui(self): column_layout = QHBoxLayout() self.setLayout(column_layout) column_layout.setMargin(0) column_layout.setSpacing(1) col1_layout = QVBoxLayout() col1_layout.setMargin(0) column_layout.addLayout(col1_layout) self._write_w = WriteW(self, self._usbif) col1_layout.addWidget(self._write_w) col1_layout.setAlignment(self._write_w, Qt.AlignTop | Qt.AlignLeft) col2_layout = QVBoxLayout() col2_layout.setMargin(0) col2_layout.setSpacing(2) col2_layout.addSpacing(10) column_layout.addLayout(col2_layout) regs_layout = QVBoxLayout() regs_layout.setSpacing(2) regs_layout.setMargin(0) col2_layout.addLayout(regs_layout) col2_layout.setAlignment(regs_layout, Qt.AlignTop) # Add all of the registers for display self._reg_a = Register(self, self._usbif, 'A', False, QColor(0, 255, 0)) regs_layout.addWidget(self._reg_a) regs_layout.setAlignment(self._reg_a, Qt.AlignRight) self._reg_l = Register(self, self._usbif, 'L', False, QColor(0, 255, 0)) regs_layout.addWidget(self._reg_l) regs_layout.setAlignment(self._reg_l, Qt.AlignRight) # self._reg_y = Register(regs, self._usbif, 'Y', False, QColor(0, 255, 0)) # regs_layout.addWidget(self._reg_y) # regs_layout.setAlignment(self._reg_y, Qt.AlignRight) # self._reg_u = Register(regs, self._usbif, 'U', False, QColor(0, 255, 0)) # regs_layout.addWidget(self._reg_u) # regs_layout.setAlignment(self._reg_u, Qt.AlignRight) self._reg_z = Register(self, self._usbif, 'Z', False, QColor(0, 255, 0)) regs_layout.addWidget(self._reg_z) regs_layout.setAlignment(self._reg_z, Qt.AlignRight) # self._reg_q = Register(regs, self._usbif, 'Q', False, QColor(0, 255, 0)) # regs_layout.addWidget(self._reg_q) # regs_layout.setAlignment(self._reg_q, Qt.AlignRight) self._reg_g = Register(self, self._usbif, 'G', True, QColor(0, 255, 0)) regs_layout.addWidget(self._reg_g) regs_layout.setAlignment(self._reg_g, Qt.AlignRight) # self._reg_b = Register(regs, self._usbif, 'B', False, QColor(0, 255, 0)) # regs_layout.addWidget(self._reg_b) # regs_layout.setAlignment(self._reg_b, Qt.AlignRight) self._reg_w = Register(self, self._usbif, 'W', True, QColor(0, 255, 0)) regs_layout.addWidget(self._reg_w) regs_layout.setAlignment(self._reg_w, Qt.AlignRight) self._w_cmp = WComparator(self, self._usbif) regs_layout.addWidget(self._w_cmp) regs_layout.setAlignment(self._w_cmp, Qt.AlignRight) col2_layout.addSpacing(10) self._reg_s = AddressRegister(self, self._usbif, QColor(0, 255, 0)) col2_layout.addWidget(self._reg_s) col2_layout.setAlignment(self._reg_s, Qt.AlignRight) self._s1_comp = SComparator(self, self._usbif, 1) col2_layout.addWidget(self._s1_comp) col2_layout.setAlignment(self._s1_comp, Qt.AlignRight) self._s2_comp = SComparator(self, self._usbif, 2) col2_layout.addWidget(self._s2_comp) col2_layout.setAlignment(self._s2_comp, Qt.AlignRight) col2_layout.addSpacing(10) self._reg_i = InstructionRegister(self, self._usbif, QColor(0, 255, 0)) col2_layout.addWidget(self._reg_i) col2_layout.setAlignment(self._reg_i, Qt.AlignRight) self._i_comp = IComparator(self, self._usbif) col2_layout.addWidget(self._i_comp) col2_layout.setAlignment(self._i_comp, Qt.AlignRight) col2_layout.addSpacing(10) col2_layout.addStretch(1000) col3 = QWidget(self) col3_layout = QVBoxLayout(col3) col3_layout.setMargin(0) col3_layout.setSpacing(2) #col3_layout.addSpacing(10) column_layout.addWidget(col3) # Add the alarms panel self._alarms_panel = Alarms(col3, self._usbif) col3_layout.addWidget(self._alarms_panel) col3_layout.setAlignment(self._alarms_panel, Qt.AlignTop | Qt.AlignRight) # Add the control panel self._ctrl_panel = Control(col3, self._usbif) col3_layout.addWidget(self._ctrl_panel) col3_layout.setAlignment(self._ctrl_panel, Qt.AlignTop | Qt.AlignRight) # Add the computer stop panel self._comp_stop = CompStop(col3, self._usbif) col3_layout.addWidget(self._comp_stop) col3_layout.setAlignment(self._comp_stop, Qt.AlignTop | Qt.AlignRight) # Add the read/load panel self._read_load = ReadLoad(col3, self._usbif) col3_layout.addWidget(self._read_load) col3_layout.setAlignment(self._read_load, Qt.AlignTop | Qt.AlignRight) # Add the fixed memory panel self._fixed = FixedMemory(col3, self._usbif) col3_layout.addWidget(self._fixed) col3_layout.setAlignment(self._fixed, Qt.AlignTop | Qt.AlignRight) # Add the erasable memory panel self._erasable = ErasableMemory(col3, self._usbif) col3_layout.addWidget(self._erasable) col3_layout.setAlignment(self._erasable, Qt.AlignTop | Qt.AlignRight) col3_layout.addStretch() self.show()