def addWidgets(self): layout = QVBoxLayout() self.setLayout(layout) layout.addSpacing(10) label = QLabel(self) label.setTextFormat(Qt.RichText) label.setText('<p>There are currently no vaults.</p>' '<p>To store passwords in Bluepass, ' 'you need to create a vault first.</p>') label.setWordWrap(True) layout.addWidget(label) layout.addSpacing(10) hbox = QHBoxLayout() layout.addLayout(hbox) newbtn = QPushButton('Create New Vault', self) newbtn.clicked.connect(self.newVault) hbox.addStretch(100) hbox.addWidget(newbtn) hbox.addStretch(100) hbox = QHBoxLayout() layout.addLayout(hbox) connectbtn = QPushButton('Connect to Existing Vault', self) connectbtn.clicked.connect(self.connectVault) hbox.addStretch(100) hbox.addWidget(connectbtn) hbox.addStretch(100) width = max(newbtn.sizeHint().width(), connectbtn.sizeHint().width()) + 40 newbtn.setFixedWidth(width) connectbtn.setFixedWidth(width) layout.addStretch(100)
def __init__(self, buttonText, imagePath, buttonCallback, imageSize, parent=None): QWidget.__init__(self, parent) icon = QLabel(self) icon.setPixmap(QPixmap(imagePath).scaled(imageSize, imageSize)) button = QPushButton(buttonText) button.clicked.connect(buttonCallback) vbox = QVBoxLayout() vbox.addStretch(1) vbox.addWidget(icon, alignment=Qt.AlignHCenter) vbox.addSpacing(20) vbox.addWidget(button) vbox.addStretch(1) # Add some horizontal padding hbox = QHBoxLayout() hbox.addSpacing(10) hbox.addLayout(vbox) hbox.addSpacing(10) groupBox = QGroupBox() groupBox.setLayout(hbox) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(groupBox) hbox.addStretch(1) self.setLayout(hbox)
def addInitializeFromScratchTab(self): panel = QWidget() layout = QVBoxLayout() row1 = createRow(QLabel("Target case:"), CaseSelector()) layout.addLayout(row1) check_list_layout, parameter_model, members_model = createCheckLists() layout.addLayout(check_list_layout) layout.addSpacing(10) initialize_button = QPushButton("Initialize") addHelpToWidget(initialize_button, "init/initialize_from_scratch") initialize_button.setMinimumWidth(75) initialize_button.setMaximumWidth(150) def initializeFromScratch(): parameters = parameter_model.getSelectedItems() members = members_model.getSelectedItems() initializeCurrentCaseFromScratch(parameters, members) initialize_button.clicked.connect(initializeFromScratch) layout.addWidget(initialize_button, 0, Qt.AlignCenter) layout.addSpacing(10) panel.setLayout(layout) self.addTab(panel, "Initialize from scratch")
def _createLayout(self): l = QVBoxLayout() h = QHBoxLayout() v = QVBoxLayout() v.addWidget(self.ride_time) v.addWidget(self.avg_speed) v.addWidget(self.avg_hr) v.addWidget(self.avg_cad) v.addWidget(self.avg_pwr) h.addLayout(v) v = QVBoxLayout() v.addWidget(self.calories) v.addWidget(self.max_speed) v.addWidget(self.max_hr) v.addWidget(self.max_cad) v.addWidget(self.max_pwr) h.addLayout(v) l.addLayout(h) l.addSpacing(10) l.addWidget(self.laps) l.addStretch() self.setLayout(l)
def __init__(self, parent, app): super(QWidget, self).__init__() layout1 = QHBoxLayout() layout2 = QVBoxLayout() layout1.addStretch() layout1.addLayout(layout2) layout1.addStretch() label = QLabel(self) label.setText("Simple Project: <b>Display Environment Measurements on LCD</b>. Simply displays all measured values on LCD. Sources in all programming languages can be found <a href=\"http://www.tinkerforge.com/en/doc/Kits/WeatherStation/WeatherStation.html#display-environment-measurements-on-lcd\">here</a>.<br>") label.setTextFormat(Qt.RichText) label.setTextInteractionFlags(Qt.TextBrowserInteraction) label.setOpenExternalLinks(True) label.setWordWrap(True) label.setAlignment(Qt.AlignJustify) layout2.addSpacing(10) layout2.addWidget(label) layout2.addSpacing(10) self.lcdwidget = LCDWidget(self, app) layout2.addWidget(self.lcdwidget) layout2.addStretch() self.setLayout(layout1) self.qtcb_update_illuminance.connect(self.update_illuminance_data_slot) self.qtcb_update_air_pressure.connect(self.update_air_pressure_data_slot) self.qtcb_update_temperature.connect(self.update_temperature_data_slot) self.qtcb_update_humidity.connect(self.update_humidity_data_slot) self.qtcb_button_pressed.connect(self.button_pressed_slot)
def initUI(self): # title title = QLabel(self) title.setText("User Instruction") title.setAlignment(Qt.AlignCenter) # user instruction groupBox = QGroupBox() text = QLabel(self) text.setText("Create image montages and histograms from the interface:\nChoose option No. 1 to 5 on main interface.\nClick Enter to select the paths for input and output locations.\nEnjoy using the interface!") self.setStyleSheet("QLabel { color: #8B4513; font-size: 16px;font-family: cursive, sans-serif;}") title.setStyleSheet("QLabel { color: #8B4513; font-weight: 600;}") # set layout sbox = QVBoxLayout(self) sbox.addWidget(text) groupBox.setLayout(sbox) vBoxLayout = QVBoxLayout() vBoxLayout.addSpacing(15) vBoxLayout.addWidget(title) vBoxLayout.addWidget(groupBox) vBoxLayout.addSpacing(15) self.setLayout(vBoxLayout) # set background as transparent palette = QPalette() palette.setBrush(QPalette.Background,QBrush(QPixmap())) self.setPalette(palette)
def __init__(self): QWidget.__init__(self) self.__filter_popup = FilterPopup(self) self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged) layout = QVBoxLayout() self.model = DataTypeKeysListModel() self.filter_model = DataTypeProxyModel(self.model) filter_layout = QHBoxLayout() self.search_box = SearchBox() self.search_box.filterChanged.connect(self.setSearchString) filter_layout.addWidget(self.search_box) filter_popup_button = QToolButton() filter_popup_button.setIcon(util.resourceIcon("ide/cog_edit.png")) filter_popup_button.clicked.connect(self.showFilterPopup) filter_layout.addWidget(filter_popup_button) layout.addLayout(filter_layout) self.data_type_keys_widget = QListView() self.data_type_keys_widget.setModel(self.filter_model) self.data_type_keys_widget.selectionModel().selectionChanged.connect(self.itemSelected) layout.addSpacing(15) layout.addWidget(self.data_type_keys_widget, 2) layout.addStretch() # layout.addWidget(Legend("Default types", DataTypeKeysListModel.DEFAULT_DATA_TYPE)) layout.addWidget(Legend("Observations available", DataTypeKeysListModel.HAS_OBSERVATIONS)) self.setLayout(layout)
def __init__(self, base): QWidget.__init__(self) self.base = base self.showed = False self.setFixedSize(500, 120) self.text_edit = CompletionTextEdit() self.upload_button = ImageButton(base, 'action-upload.png', i18n.get('upload_image')) self.short_button = ImageButton(base, 'action-shorten.png', i18n.get('short_urls')) font = QFont() font.setPointSize(18) font.setBold(True) self.char_count = QLabel('140') self.char_count.setFont(font) self.update_button = QPushButton(i18n.get('update')) self.update_button.setToolTip(self.base.get_shortcut_string('Enter')) self.queue_button = QPushButton(i18n.get('add_to_queue')) self.queue_button.setToolTip(self.base.get_shortcut_string('P')) self.accounts_combo = QComboBox() buttons = QHBoxLayout() buttons.setSpacing(4) buttons.addWidget(self.accounts_combo) buttons.addWidget(self.upload_button) buttons.addWidget(self.short_button) buttons.addStretch(0) buttons.addWidget(self.char_count) buttons.addWidget(self.queue_button) buttons.addWidget(self.update_button) self.loader = BarLoadIndicator() self.error_message = ErrorLabel() self.update_button.clicked.connect(self.__update_status) self.queue_button.clicked.connect(self.__queue_status) self.short_button.clicked.connect(self.__short_urls) self.upload_button.clicked.connect(self.__upload_image) self.text_edit.textChanged.connect(self.__update_count) self.text_edit.quit.connect(self.closeEvent) self.text_edit.activated.connect(self.__update_status) self.text_edit.enqueued.connect(self.__queue_status) layout = QVBoxLayout() layout.setSpacing(0) layout.addWidget(self.text_edit) layout.addWidget(self.loader) layout.addSpacing(5) layout.addWidget(self.error_message) layout.addLayout(buttons) layout.setContentsMargins(5, 5, 5, 5) self.setLayout(layout) self.__clear()
def initUI(self): #Labels emailLabel = QLabel(u'Correo:') passLabel = QLabel(u'Contraseña') #Text Field self.emailField = QLineEdit() self.passField = QLineEdit() self.passField.setEchoMode(QLineEdit.Password) #Buttons sendButton = QPushButton(u'Ingresar') sendButton.clicked.connect(self.handler) #Settig up the layouts vbox = QVBoxLayout() vbox.addWidget(emailLabel) vbox.addWidget(self.emailField) vbox.addWidget(passLabel) vbox.addWidget(self.passField) hbox = QHBoxLayout() hbox.addStretch(1) hbox.addWidget(sendButton) vbox.addSpacing(10) vbox.addLayout(hbox) vbox.setContentsMargins(20, 20, 20, 30) self.setLayout(vbox) self.setFixedSize(300, 200) self.center() self.setWindowTitle(u'Iniciar Sesión') self.show()
def _initUI(self): layout = QVBoxLayout(self) layout.setContentsMargins(0, 10, 0, 0) layout.setSpacing(0) labelLayout = QHBoxLayout() labelLayout.addWidget(QLabel(u"Sorry, something went wrong:", self)) labelLayout.setContentsMargins(10, 0, 0, 0) layout.addLayout(labelLayout) layout.addSpacing(5) self._errorLog = QTextEdit(self) self._errorLog.setReadOnly(True) self._errorLog.setWordWrapMode(QTextOption.NoWrap) self._errorLog.setTextColor(QColor(180, 0, 0)) self._errorLog.setObjectName(u"__ERROR_LOG_") self._errorLog.setFrameShape(QFrame.StyledPanel) if getPlatform() == PLATFORM_MAC: self._errorLog.setStyleSheet("QFrame#__ERROR_LOG_{border-width: 1px; border-top-style: solid; border-right-style: none; border-bottom-style: solid; border-left-style: none; border-color:palette(mid)}"); layout.addWidget(self._errorLog) bottomWidget = QWidget(self) bottomLayout = QHBoxLayout(bottomWidget) self._notAgain = QCheckBox(u"Please, no more error messages!", self) bottomLayout.addWidget(self._notAgain, 1, Qt.AlignTop) buttonBox = QDialogButtonBox(QDialogButtonBox.Close, Qt.Horizontal, self) buttonBox.rejected.connect(self.reject) bottomLayout.addWidget(buttonBox) layout.addWidget(bottomWidget)
def addWidgets(self): layout = QVBoxLayout() self.setLayout(layout) layout.addSpacing(10) label = QLabel(self) label.setTextFormat(Qt.RichText) label.setText('<p>There are currently no vaults.</p>' '<p>To store passwords in Bluepass, ' 'you need to create a vault first.</p>') label.setWordWrap(True) layout.addWidget(label) layout.addSpacing(10) hbox = QHBoxLayout() layout.addLayout(hbox) newbtn = QPushButton('Create New Vault', self) newbtn.clicked.connect(self.newVault) hbox.addStretch(100); hbox.addWidget(newbtn) hbox.addStretch(100) hbox = QHBoxLayout() layout.addLayout(hbox) connectbtn = QPushButton('Connect to Existing Vault', self) connectbtn.clicked.connect(self.connectVault) hbox.addStretch(100) hbox.addWidget(connectbtn) hbox.addStretch(100) width = max(newbtn.sizeHint().width(), connectbtn.sizeHint().width()) + 40 newbtn.setFixedWidth(width) connectbtn.setFixedWidth(width) layout.addStretch(100)
class CustomizePlotWidget(QWidget): customPlotSettingsChanged = pyqtSignal(dict) def __init__(self): QWidget.__init__(self) self.__custom = { } self.__layout = QVBoxLayout() self.addCheckBox("error_bar_only", "Show only error bars", False) self.__layout.addSpacing(20) self.addColorChooser("observation", "Observation", QColor(0, 0, 0, 255)) self.addColorChooser("observation_area", "Observation Error", QColor(0, 0, 0, 38)) self.addColorChooser("observation_error_bar", "Observation Error Bar", QColor(0, 0, 0, 255)) self.addColorChooser("refcase", "Refcase", QColor(0, 0, 0, 178)) self.addColorChooser("ensemble_1", "Case #1", QColor(56, 108, 176, 204)) self.addColorChooser("ensemble_2", "Case #2", QColor(127, 201, 127, 204)) self.addColorChooser("ensemble_3", "Case #3", QColor(253, 192, 134, 204)) self.addColorChooser("ensemble_4", "Case #4", QColor(240, 2, 127, 204)) self.addColorChooser("ensemble_5", "Case #5", QColor(191, 91, 23, 204)) self.__layout.addStretch() self.setLayout(self.__layout) def emitChange(self): self.customPlotSettingsChanged.emit(self.__custom) def addCheckBox(self, name, description, default_value): checkbox = QCheckBox(description) checkbox.setChecked(default_value) self.__custom[name] = default_value def toggle(checked): self.__custom[name] = checked self.emitChange() checkbox.toggled.connect(toggle) self.__layout.addWidget(checkbox) def createJSColor(self, color): return "rgba(%d, %d, %d, %f)" % (color.red(), color.green(), color.blue(), color.alphaF()) def getCustomSettings(self): return self.__custom def addColorChooser(self, name, label, default_color): color_chooser = ColorChooser(label, default_color) self.__custom[name] = self.createJSColor(default_color) def colorChanged(color): self.__custom[name] = self.createJSColor(color) self.emitChange() color_chooser.colorChanged.connect(colorChanged) self.__layout.addWidget(color_chooser)
def __init__(self, widget): fake_page = QWidget() self._replacePage(widget.page_container, widget.keypad_page, fake_page) layout = QVBoxLayout(fake_page) layout.addSpacing(10) label = QLabel(widget._text['NoKeypad']) label.setWordWrap(True) layout.addWidget(label) layout.addStretch(1)
def addWidgets(self): layout = QVBoxLayout() self.setLayout(layout) layout.addSpacing(10) label = QLabel('<p>There are no passwords in this vault.</p>' \ '<p>Use the "+" button at the bottom of this window ' \ 'to add a password.</p>', self) label.setWordWrap(True) layout.addWidget(label) layout.addStretch(100)
def _createLayout(self): l = QVBoxLayout() l.addStretch(1) l.addWidget(self.message) l.addSpacing(10) l.addWidget(self.icon) l.addStretch(1) self.setLayout(l)
def __init__(self, base): QWidget.__init__(self) current_browser = base.core.get_default_browser() description = QLabel(i18n.get('web_browser_tab_description')) description.setWordWrap(True) self.command = QLineEdit() self.default_browser = RadioButton(i18n.get('use_default_browser'), self) self.default_browser.selected.connect(self.__on_defaul_selected) self.custom_browser = RadioButton(i18n.get('set_custom_browser'), self) self.custom_browser.selected.connect(self.__on_custom_selected) custom_label = QLabel(i18n.get('command')) self.open_button = QPushButton(i18n.get('open')) self.test_button = QPushButton(i18n.get('test')) self.test_button.clicked.connect(self.__on_test) command_box = QHBoxLayout() command_box.setSpacing(5) command_box.addWidget(custom_label) command_box.addWidget(self.command, 1) #command_box.addWidget(self.open_button) command_box.addWidget(self.test_button) self.button_group = QButtonGroup() self.button_group.addButton(self.default_browser.radiobutton) self.button_group.addButton(self.custom_browser.radiobutton) self.button_group.setExclusive(True) vbox = QVBoxLayout() vbox.setSpacing(0) vbox.setContentsMargins(5, 5, 5, 0) vbox.addWidget(description) vbox.addSpacing(15) vbox.addWidget(self.default_browser) vbox.addSpacing(10) vbox.addWidget(self.custom_browser) vbox.addLayout(command_box) vbox.addStretch(1) self.setLayout(vbox) if current_browser == '': self.default_browser.set_value(True) self.command.setText('') self.__on_defaul_selected() else: self.custom_browser.set_value(True) self.command.setText(current_browser) self.__on_custom_selected()
def __init__(self, base): QWidget.__init__(self) current_browser = base.core.get_default_browser() description = QLabel(i18n.get("web_browser_tab_description")) description.setWordWrap(True) self.command = QLineEdit() self.default_browser = RadioButton(i18n.get("use_default_browser"), self) self.default_browser.selected.connect(self.__on_defaul_selected) self.custom_browser = RadioButton(i18n.get("set_custom_browser"), self) self.custom_browser.selected.connect(self.__on_custom_selected) custom_label = QLabel(i18n.get("command")) self.open_button = QPushButton(i18n.get("open")) self.test_button = QPushButton(i18n.get("test")) self.test_button.clicked.connect(self.__on_test) command_box = QHBoxLayout() command_box.setSpacing(5) command_box.addWidget(custom_label) command_box.addWidget(self.command, 1) # command_box.addWidget(self.open_button) command_box.addWidget(self.test_button) self.button_group = QButtonGroup() self.button_group.addButton(self.default_browser.radiobutton) self.button_group.addButton(self.custom_browser.radiobutton) self.button_group.setExclusive(True) vbox = QVBoxLayout() vbox.setSpacing(0) vbox.setContentsMargins(5, 5, 5, 0) vbox.addWidget(description) vbox.addSpacing(15) vbox.addWidget(self.default_browser) vbox.addSpacing(10) vbox.addWidget(self.custom_browser) vbox.addLayout(command_box) vbox.addStretch(1) self.setLayout(vbox) if current_browser == "": self.default_browser.set_value(True) self.command.setText("") self.__on_defaul_selected() else: self.custom_browser.set_value(True) self.command.setText(current_browser) self.__on_custom_selected()
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() self._simulation_mode_combo = QComboBox() addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode") self._simulation_mode_combo.currentIndexChanged.connect( self.toggleSimulationMode) simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(self._simulation_mode_combo, 0, Qt.AlignVCenter) simulation_mode_layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Simulation") self.run_button.setIcon(resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) addHelpToWidget(self.run_button, "run/start_simulation") simulation_mode_layout.addWidget(self.run_button) simulation_mode_layout.addStretch(1) layout.addSpacing(5) layout.addLayout(simulation_mode_layout) layout.addSpacing(10) self._simulation_stack = QStackedWidget() self._simulation_stack.setLineWidth(1) self._simulation_stack.setFrameStyle(QFrame.StyledPanel) layout.addWidget(self._simulation_stack) self._simulation_widgets = OrderedDict() """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]""" self.addSimulationConfigPanel(SingleTestRunPanel()) self.addSimulationConfigPanel(EnsembleExperimentPanel()) self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel( IteratedEnsembleSmootherPanel(advanced_option=True)) self.addSimulationConfigPanel(MultipleDataAssimilationPanel()) self.setLayout(layout)
def _place_components(self): control_layout = QHBoxLayout() control_layout.addWidget(self.ok_button) main_layout = QVBoxLayout() main_layout.addWidget(self.title) main_layout.addWidget(self.description) main_layout.addSpacing(10) main_layout.addWidget(self.creator) main_layout.addSpacing(10) main_layout.addWidget(self.ok_button, 0, Qt.AlignCenter) self.setLayout(main_layout)
def __init__(self, parent, options): QDialog.__init__(self, parent) ##self.setPalette(white_palette) self.setWindowTitle(options.titre) self.parent = parent self.onglets = QTabWidget(self) main_sizer = QVBoxLayout() main_sizer.addWidget(self.onglets) self.setLayout(main_sizer) ##dimensions_onglets = [] self.widgets = {} for theme in options: panel = QWidget(self.onglets) sizer = QVBoxLayout() self.onglets.addTab(panel, theme.titre) for elt in theme: if isinstance(elt, Section): box = QGroupBox(elt.titre, panel) bsizer = QVBoxLayout() box.setLayout(bsizer) bsizer.addSpacing(3) for parametre in elt: if isinstance(parametre, Parametre): psizer = self.ajouter_parametre(parametre, panel, sizer) bsizer.addLayout(psizer) elif isinstance(parametre, basestring): bsizer.addWidget(QLabel(parametre)) else: raise NotImplementedError, repr(type(elt)) bsizer.addSpacing(3) sizer.addWidget(box) elif isinstance(elt, Parametre): psizer = self.ajouter_parametre(elt, panel, sizer) sizer.addLayout(psizer) elif isinstance(elt, basestring): sizer.addWidget(QLabel(elt)) else: raise NotImplementedError, repr(type(elt)) boutons = QHBoxLayout() ok = QPushButton(u'OK', clicked=self.ok) boutons.addWidget(ok) defaut = QPushButton(u"Défaut", clicked=self.defaut) boutons.addWidget(defaut) annuler = QPushButton(u"Annuler", clicked=self.close) boutons.addWidget(annuler) sizer.addStretch() sizer.addLayout(boutons) panel.setLayout(sizer)
def _createLayout(self): l = QVBoxLayout() l.addStretch(1) l.addWidget(self.message) l.addSpacing(10) spinner = BusySpinnerWidget(self) l.addWidget(spinner) l.addStretch(1) self.setLayout(l)
class BasePage(QWidget): def __init__(self, caption): QWidget.__init__(self) description = QLabel(caption) description.setWordWrap(True) self.layout = QVBoxLayout() self.layout.setContentsMargins(10, 10, 10, 10) self.layout.addWidget(description) self.layout.addSpacing(15) self.layout.setSpacing(5) self.setLayout(self.layout)
def __init__(self, app, parent = None): super(ResolutionSettingWidget,self).__init__(parent) self.setStyleSheet("font-size : 16px;") self.app = app CDLL("libjson-c.so", mode=RTLD_GLOBAL) self.jytcapi = cdll.LoadLibrary('../lib/libjytcapi.so') self.jytcapi.jyinittcapi() self.resolutionLabel = QLabel(self.tr("Resolution setting")) self.resolutionCombox = QComboBox() self.resolutionCombox.setFixedSize(300, 30) self.saveBtn = QPushButton(self.tr("Save")) self.saveBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 90px; height: 30px;font-size : 16px;") gridLayout = QGridLayout() gridLayout.setSpacing(15) gridLayout.setMargin(10) gridLayout.addWidget(self.resolutionLabel, 0, 0, 1, 1) gridLayout.addWidget(self.resolutionCombox, 0, 1, 1, 1) topLayout = QHBoxLayout() topLayout.addStretch() topLayout.addSpacing(50) topLayout.addLayout(gridLayout) topLayout.addStretch(1) bottomHLayout = QHBoxLayout() bottomHLayout.addStretch() bottomHLayout.addWidget(self.saveBtn) bottomHLayout.addStretch() vLayout = QVBoxLayout() vLayout.addStretch() vLayout.addSpacing(50) vLayout.addLayout(topLayout) vLayout.addStretch(2) vLayout.addSpacing(10) vLayout.addLayout(bottomHLayout) self.setLayout(vLayout) self.updateResolutionCombox() self.timer = QTimer() self.timer.setSingleShot(True) self.connect(self.timer,SIGNAL("timeout()"),self.resetScreenResolution); self.connect(self.saveBtn, SIGNAL("clicked()"),self.slotSave)
class AddRemoveWidget(QWidget): """ A simple class that provides to vertically positioned buttons for adding and removing something. The addFunction and removeFunction functions must be provided. """ def __init__(self, addFunction=None, removeFunction=None, horizontal=False): QWidget.__init__(self) self.addButton = QToolButton(self) self.addButton.setIcon(resourceIcon("add")) self.addButton.setIconSize(QSize(16, 16)) self.connect(self.addButton, SIGNAL('clicked()'), addFunction) self.removeButton = QToolButton(self) self.removeButton.setIcon(resourceIcon("remove")) self.removeButton.setIconSize(QSize(16, 16)) self.connect(self.removeButton, SIGNAL('clicked()'), removeFunction) if horizontal: self.buttonLayout = QHBoxLayout() else: self.buttonLayout = QVBoxLayout() self.buttonLayout.setMargin(0) if horizontal: self.buttonLayout.addStretch(1) self.buttonLayout.addWidget(self.addButton) self.buttonLayout.addWidget(self.removeButton) if not horizontal: self.buttonLayout.addStretch(1) else: self.buttonLayout.addSpacing(2) self.setLayout(self.buttonLayout) def enableAddButton(self, state): """Enable or disable the add button""" self.addButton.setEnabled(state) def enableRemoveButton(self, state): """Enable or disable the remove button""" self.removeButton.setEnabled(state)
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() self._simulation_mode_combo = QComboBox() addHelpToWidget(self._simulation_mode_combo, "run/simulation_mode") self._simulation_mode_combo.currentIndexChanged.connect(self.toggleSimulationMode) simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_layout.addWidget(QLabel("Simulation mode:"), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(self._simulation_mode_combo, 0, Qt.AlignVCenter) simulation_mode_layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Simulation") self.run_button.setIcon(resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) addHelpToWidget(self.run_button, "run/start_simulation") simulation_mode_layout.addWidget(self.run_button) simulation_mode_layout.addStretch(1) layout.addSpacing(5) layout.addLayout(simulation_mode_layout) layout.addSpacing(10) self._simulation_stack = QStackedWidget() self._simulation_stack.setLineWidth(1) self._simulation_stack.setFrameStyle(QFrame.StyledPanel) layout.addWidget(self._simulation_stack) self._simulation_widgets = OrderedDict() """ :type: OrderedDict[BaseRunModel,SimulationConfigPanel]""" self.addSimulationConfigPanel(SingleTestRunPanel()) self.addSimulationConfigPanel(EnsembleExperimentPanel()) self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel()) self.addSimulationConfigPanel(MultipleDataAssimilationPanel()) self.setLayout(layout)
def addSeparator(self): widget = QWidget() layout = QVBoxLayout() widget.setLayout(layout) frame = QFrame() frame.setFrameShape(QFrame.HLine) frame.setFrameShadow(QFrame.Sunken) layout.addSpacing(5) layout.addWidget(frame) layout.addSpacing(5) self.__startNewRow() self.__layout.addWidget(widget, self.__row, 1, 1, 5) self.__rowFinished()
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_model = SimulationModeModel() simulation_mode_model.observable().attach( SimulationModeModel.CURRENT_CHOICE_CHANGED_EVENT, self.toggleSimulationMode ) simulation_mode_combo = ComboChoice(simulation_mode_model, "Simulation mode", "run/simulation_mode") simulation_mode_layout.addWidget(QLabel(simulation_mode_combo.getLabel()), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(simulation_mode_combo, 0, Qt.AlignVCenter) # simulation_mode_layout.addStretch() simulation_mode_layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Simulation") self.run_button.setIcon(util.resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) HelpedWidget.addHelpToWidget(self.run_button, "run/start_simulation") simulation_mode_layout.addWidget(self.run_button) simulation_mode_layout.addStretch(1) layout.addSpacing(5) layout.addLayout(simulation_mode_layout) layout.addSpacing(10) self.simulation_stack = QStackedWidget() self.simulation_stack.setLineWidth(1) self.simulation_stack.setFrameStyle(QFrame.StyledPanel) layout.addWidget(self.simulation_stack) self.simulation_widgets = {} self.addSimulationConfigPanel(EnsembleExperimentPanel()) self.addSimulationConfigPanel(SensitivityStudyPanel()) self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel()) self.setLayout(layout)
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() self.model = DataTypeKeysListModel() self.filter_model = DataTypeProxyModel(self.model) self.search_box = SearchBox() self.search_box.filterChanged.connect(self.setSearchString) layout.addWidget(self.search_box) data_type_model = QStandardItemModel(0, 1) item = QStandardItem("Select data types...") data_type_model.appendRow(item) self.__summary_item = QStandardItem("Summary") self.__summary_item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) self.__summary_item.setData(Qt.Checked, Qt.CheckStateRole) data_type_model.appendRow(self.__summary_item) self.__block_item = QStandardItem("Block") self.__block_item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEnabled) self.__block_item.setData(Qt.Checked, Qt.CheckStateRole) data_type_model.appendRow(self.__block_item) data_type_model.itemChanged.connect(self.onItemChanged) combo = QComboBox() combo.setModel(data_type_model) layout.addWidget(combo) self.data_type_keys_widget = QListView() self.data_type_keys_widget.setModel(self.filter_model) self.data_type_keys_widget.selectionModel().selectionChanged.connect(self.itemSelected) layout.addSpacing(15) layout.addWidget(self.data_type_keys_widget, 2) layout.addWidget(Legend("Default types", DataTypeKeysListModel.DEFAULT_DATA_TYPE)) layout.addWidget(Legend("Observations available", DataTypeKeysListModel.HAS_OBSERVATIONS)) self.setLayout(layout)
class AddRemoveWidget(QWidget): """ A simple class that provides to vertically positioned buttons for adding and removing something. The addFunction and removeFunction functions must be provided. """ def __init__(self, addFunction=None, removeFunction=None, horizontal=False): QWidget.__init__(self) self.addButton = QToolButton(self) self.addButton.setIcon(resourceIcon("add")) self.addButton.setIconSize(QSize(16, 16)) self.addButton.clicked.connect(addFunction) self.removeButton = QToolButton(self) self.removeButton.setIcon(resourceIcon("remove")) self.removeButton.setIconSize(QSize(16, 16)) self.removeButton.clicked.connect(removeFunction) if horizontal: self.buttonLayout = QHBoxLayout() else: self.buttonLayout = QVBoxLayout() self.buttonLayout.setContentsMargins(0, 0, 0, 0) if horizontal: self.buttonLayout.addStretch(1) self.buttonLayout.addWidget(self.addButton) self.buttonLayout.addWidget(self.removeButton) if not horizontal: self.buttonLayout.addStretch(1) else: self.buttonLayout.addSpacing(2) self.setLayout(self.buttonLayout) def enableAddButton(self, state): """Enable or disable the add button""" self.addButton.setEnabled(state) def enableRemoveButton(self, state): """Enable or disable the remove button""" self.removeButton.setEnabled(state)
def __init__(self): QWidget.__init__(self) layout = QVBoxLayout() simulation_mode_layout = QHBoxLayout() simulation_mode_layout.addSpacing(10) simulation_mode_model = SimulationModeModel() simulation_mode_model.observable().attach(SimulationModeModel.CURRENT_CHOICE_CHANGED_EVENT, self.toggleSimulationMode) simulation_mode_combo = ComboChoice(simulation_mode_model, "Simulation mode", "run/simulation_mode") simulation_mode_layout.addWidget(QLabel(simulation_mode_combo.getLabel()), 0, Qt.AlignVCenter) simulation_mode_layout.addWidget(simulation_mode_combo, 0, Qt.AlignVCenter) # simulation_mode_layout.addStretch() simulation_mode_layout.addSpacing(20) self.run_button = QToolButton() self.run_button.setIconSize(QSize(32, 32)) self.run_button.setText("Start Simulation") self.run_button.setIcon(util.resourceIcon("ide/gear_in_play")) self.run_button.clicked.connect(self.runSimulation) self.run_button.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) HelpedWidget.addHelpToWidget(self.run_button, "run/start_simulation") simulation_mode_layout.addWidget(self.run_button) simulation_mode_layout.addStretch(1) layout.addSpacing(5) layout.addLayout(simulation_mode_layout) layout.addSpacing(10) self.simulation_stack = QStackedWidget() self.simulation_stack.setLineWidth(1) self.simulation_stack.setFrameStyle(QFrame.StyledPanel) layout.addWidget(self.simulation_stack) self.simulation_widgets = {} self.addSimulationConfigPanel(EnsembleExperimentPanel()) self.addSimulationConfigPanel(EnsembleSmootherPanel()) self.addSimulationConfigPanel(MultipleDataAssimilationPanel()) self.addSimulationConfigPanel(IteratedEnsembleSmootherPanel()) self.setLayout(layout)
def addWidgets(self): layout = QVBoxLayout() self.setLayout(layout) preamble = QLabel(self) layout.addWidget(preamble) self.preamble = preamble layout.addSpacing(10) table = QTableWidget(self) layout.addWidget(table) table.setShowGrid(False) table.setSelectionBehavior(QTableWidget.SelectRows) table.setSelectionMode(QTableWidget.SingleSelection) table.setMinimumWidth(400) table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) table.setColumnCount(4) table.hideColumn(0) table.setHorizontalHeaderLabels( ['ID', 'Vault', '# of Items', '# of Peers']) table.setFocusPolicy(Qt.NoFocus) table.itemSelectionChanged.connect(self.rowSelected) hhead = table.horizontalHeader() hhead.setResizeMode(QHeaderView.Stretch) hhead.setHighlightSections(False) vhead = table.verticalHeader() vhead.hide() self.table = table hbox = QHBoxLayout() layout.addLayout(hbox) button = QPushButton('Create Vault', self) button.clicked.connect(self.createVault) hbox.addWidget(button) button = QPushButton('Connect to Vault', self) backend = QApplication.instance().backend() available = backend.locator_is_available() if available: button.clicked.connect(self.connectVault) else: button.setEnabled(False) hbox.addWidget(button) removebtn = QPushButton('Remove Vault', self) removebtn.setEnabled(False) removebtn.clicked.connect(self.removeVault) self.removebtn = removebtn hbox.addWidget(removebtn)
def __init__(self, parent=None, vectors="", rasters="", encodings=[]): QDialog.__init__(self, parent) self.contentsWidget = QListWidget() self.setWindowIcon(QIcon(":icon")) self.contentsWidget.setViewMode(QListView.IconMode) self.contentsWidget.setIconSize(QSize(76, 66)) self.contentsWidget.setMovement(QListView.Static) self.contentsWidget.setMaximumWidth(106) self.contentsWidget.setMinimumWidth(106) self.contentsWidget.setMinimumHeight(220) self.contentsWidget.setSpacing(12) self.__filePath = "" self.__encoding = "System" self.__type = 0 self.pagesWidget = QStackedWidget() vectorPage = self.VectorPage(self, vectors, encodings) self.pagesWidget.addWidget(vectorPage) rasterPage = self.RasterPage(self, rasters) self.pagesWidget.addWidget(rasterPage) buttons = QDialogButtonBox(QDialogButtonBox.Ok|QDialogButtonBox.Cancel, Qt.Horizontal, self) self.connect(buttons, SIGNAL("accepted()"), self.accept) self.connect(buttons, SIGNAL("rejected()"), self.reject) self.connect(vectorPage, SIGNAL("filePathChanged(QString)"), self.setFilePath) self.connect(vectorPage, SIGNAL("encodingChanged(QString)"), self.setEncoding) self.connect(rasterPage, SIGNAL("filePathChanged(QString)"), self.setFilePath) self.createIcons() self.contentsWidget.setCurrentRow(0) horizontalLayout = QHBoxLayout() horizontalLayout.addWidget(self.contentsWidget) horizontalLayout.addWidget(self.pagesWidget, 1) mainLayout = QVBoxLayout() mainLayout.addLayout(horizontalLayout) mainLayout.addStretch(1) mainLayout.addSpacing(12) mainLayout.addWidget(buttons) self.setLayout(mainLayout) self.setWindowTitle("manageR - Import Layer")
def __init__(self, app, parent = None): super(LanguageSettingWidget,self).__init__(parent) self.setStyleSheet("font-size : 16px") self.app = app self.languageLabel = QLabel(self.tr("Language setting")) languageList = [self.tr("中文简体"),"English"] self.languageCombox = QComboBox() self.languageCombox.addItems(languageList) self.languageCombox.setFixedSize(300, 30) self.saveBtn = QPushButton(self.tr("Save")) self.connect(self.saveBtn, SIGNAL("clicked()"),self.slotSave) self.saveBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 90px; height: 30px;font-size : 16px;") gridLayout = QGridLayout() gridLayout.setSpacing(15) gridLayout.setMargin(10) gridLayout.addWidget(self.languageLabel, 0, 0, 1, 1) gridLayout.addWidget(self.languageCombox, 0, 1, 1, 1) topLayout = QHBoxLayout() topLayout.addStretch() topLayout.addSpacing(50) topLayout.addLayout(gridLayout) topLayout.addStretch(1) bottomHLayout = QHBoxLayout() bottomHLayout.addStretch() bottomHLayout.addWidget(self.saveBtn) bottomHLayout.addStretch() vLayout = QVBoxLayout() vLayout.addStretch() vLayout.addSpacing(50) vLayout.addLayout(topLayout) vLayout.addStretch(2) vLayout.addSpacing(10) vLayout.addLayout(bottomHLayout) self.setLayout(vLayout) self.updateLanguageCombox()
def addWidgets(self): layout = QVBoxLayout() self.setLayout(layout) preamble = QLabel(self) layout.addWidget(preamble) self.preamble = preamble layout.addSpacing(10) table = QTableWidget(self) layout.addWidget(table) table.setShowGrid(False) table.setSelectionBehavior(QTableWidget.SelectRows) table.setSelectionMode(QTableWidget.SingleSelection) table.setMinimumWidth(400) table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) table.setColumnCount(4) table.hideColumn(0) table.setHorizontalHeaderLabels(['ID', 'Vault', '# of Items', '# of Peers']) table.setFocusPolicy(Qt.NoFocus) table.itemSelectionChanged.connect(self.rowSelected) hhead = table.horizontalHeader() hhead.setResizeMode(QHeaderView.Stretch) hhead.setHighlightSections(False) vhead = table.verticalHeader() vhead.hide() self.table = table hbox = QHBoxLayout() layout.addLayout(hbox) button = QPushButton('Create Vault', self) button.clicked.connect(self.createVault) hbox.addWidget(button) button = QPushButton('Connect to Vault', self) backend = QApplication.instance().backend() available = backend.locator_is_available() if available: button.clicked.connect(self.connectVault) else: button.setEnabled(False) hbox.addWidget(button) removebtn = QPushButton('Remove Vault', self) removebtn.setEnabled(False) removebtn.clicked.connect(self.removeVault) self.removebtn = removebtn hbox.addWidget(removebtn)
def initLayout(self): self.terminalTypeGroupbox = QGroupBox(u'终端类型') self.cDesktopRadioBtn = QRadioButton(u'桌面虚拟化') self.cTerminalRadioBtn = QRadioButton(u'终端虚拟化') self.settingBtn = QPushButton(u"设置") self.settingBtn.setStyleSheet("background: rgb(7,87,198); color: white; width: 90px; height: 30px;font-size : 16px;") topVLayout = QVBoxLayout() topVLayout.setSpacing(10) topVLayout.setMargin(10) topVLayout.addSpacing(30) topVLayout.addWidget(self.cDesktopRadioBtn) topVLayout.addSpacing(20) topVLayout.addWidget(self.cTerminalRadioBtn) topVLayout.addSpacing(50) topHLayout = QHBoxLayout() topHLayout.setSpacing(10) topHLayout.setMargin(10) topHLayout.addSpacing(40) topHLayout.addLayout(topVLayout) topHLayout.addSpacing(160) self.terminalTypeGroupbox.setLayout(topHLayout) bottomHLayout = QHBoxLayout() bottomHLayout.addStretch() bottomHLayout.addWidget(self.settingBtn) bottomHLayout.addStretch() #布局调整 vLayout = QVBoxLayout() vLayout.addStretch() vLayout.addWidget(self.terminalTypeGroupbox) vLayout.addSpacing(80) vLayout.addStretch() topMainLayout = QHBoxLayout() topMainLayout.addStretch() topMainLayout.addLayout(vLayout) topMainLayout.addStretch() mainHLayout = QVBoxLayout() mainHLayout.addLayout(topMainLayout) mainHLayout.addLayout(bottomHLayout) self.setLayout(mainHLayout)
def initUI(self): # Adding input part vbox = QVBoxLayout() topLabel = QLabel(self.tr("Choose a file to load")) topLabel.setWordWrap(True) vbox.addWidget(topLabel) vbox.addSpacing(20) # Add first horizontal box self.buttonbrowse = QPushButton("Browse") self.buttonbrowse.clicked.connect(self.handlebuttonbrowse) self.inputfilename = '' self.inputfile = QLabel(self.inputfilename) self.inputfile.setWordWrap(True) hbox1 = QHBoxLayout() hbox1.addWidget(self.buttonbrowse) hbox1.addWidget(self.inputfile) hbox1.addStretch() vbox.addLayout(hbox1) vbox.addSpacing(10) # Adding output part bottomLabel = QLabel(self.tr("Select an output format")) bottomLabel.setWordWrap(True) vbox.addWidget(bottomLabel) vbox.addWidget(bottomLabel) # Add second horizontal box self.rbuttonxls = QRadioButton(self.tr("xls")) self.rbuttoncsv = QRadioButton(self.tr("csv")) hbox2 = QHBoxLayout() hbox2.addWidget(self.rbuttonxls) hbox2.addSpacing(50) hbox2.addWidget(self.rbuttoncsv) hbox2.addStretch() vbox.addLayout(hbox2) vbox.addStretch() self.setLayout(vbox)
def addWidgets(self): layout = QVBoxLayout() layout.setSpacing(0) self.setLayout(layout) header = QFrame(self) header.setObjectName('header') hbox = QHBoxLayout() hbox.addSpacing(10) hbox.setContentsMargins(0, 0, 0, 0) header.setLayout(hbox) backbutton = QPushButton('< Back', header) backbutton.clicked.connect(self.back) hbox.addWidget(backbutton) hbox.addStretch(100) self.backbutton = backbutton layout.addWidget(header) layout.addSpacing(5) self.header = header stack = QStackedWidget(self) layout.addWidget(stack) self.stack = stack
def addWidgets(self): layout = QVBoxLayout() self.setLayout(layout) layout.addSpacing(10) preamble = QLabel('This vault is locked.', self) layout.addWidget(preamble) passwdedt = QLineEdit(self) passwdedt.setPlaceholderText('Type password to unlock') passwdedt.setEchoMode(QLineEdit.Password) passwdedt.textChanged.connect(self.passwordChanged) passwdedt.returnPressed.connect(self.unlockVault) layout.addSpacing(10) layout.addWidget(passwdedt) self.passwdedt = passwdedt unlockcb = QCheckBox('Try unlock other vaults too', self) unlockcb.stateChanged.connect(self.saveConfig) unlockcb.setVisible(False) layout.addWidget(unlockcb) self.unlockcb = unlockcb status = QLabel('', self) status.setVisible(False) status.setContentsMargins(0, 10, 0, 0) layout.addWidget(status) self.status = status hbox = QHBoxLayout() unlockbtn = QPushButton('Unlock', self) unlockbtn.setFixedSize(unlockbtn.sizeHint()) unlockbtn.clicked.connect(self.unlockVault) unlockbtn.setEnabled(False) hbox.addWidget(unlockbtn) self.unlockbtn = unlockbtn hbox.addStretch(100) layout.addSpacing(10) layout.addLayout(hbox) layout.addStretch(100)
def addWidgets(self): layout = QVBoxLayout() self.setLayout(layout) preamble = QLabel(self) preamble.setWordWrap(True) layout.addWidget(preamble) self.preamble = preamble layout.addSpacing(10) table = QTableWidget(self) layout.addWidget(table) table.setShowGrid(False) table.setSelectionBehavior(QTableWidget.SelectRows) table.setSelectionMode(QTableWidget.SingleSelection) table.setMinimumWidth(400) table.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff) table.setColumnCount(4) table.hideColumn(0) table.setHorizontalHeaderLabels(['ID', 'Vault', 'Source', 'On Node']) table.setFocusPolicy(Qt.NoFocus) table.itemSelectionChanged.connect(self.rowSelected) hhead = table.horizontalHeader() hhead.setResizeMode(QHeaderView.Stretch) hhead.setHighlightSections(False) vhead = table.verticalHeader() vhead.hide() self.table = table hbox = QHBoxLayout() layout.addLayout(hbox) cancelbtn = QPushButton('Cancel', self) cancelbtn.clicked.connect(self.vaultmgr.hide) hbox.addWidget(cancelbtn) self.cancelbtn = cancelbtn connectbtn = QPushButton('Connect', self) connectbtn.setEnabled(False) connectbtn.clicked.connect(self.connectVault) hbox.addWidget(connectbtn) self.connectbtn = connectbtn hbox.addStretch(100)
def __init__(self): QWidget.__init__(self) self.__filter_popup = FilterPopup(self) self.__filter_popup.filterSettingsChanged.connect(self.onItemChanged) layout = QVBoxLayout() self.model = DataTypeKeysListModel() self.filter_model = DataTypeProxyModel(self.model) filter_layout = QHBoxLayout() self.search_box = SearchBox() self.search_box.filterChanged.connect(self.setSearchString) filter_layout.addWidget(self.search_box) filter_popup_button = QToolButton() filter_popup_button.setIcon(util.resourceIcon("ide/cog_edit.png")) filter_popup_button.clicked.connect(self.showFilterPopup) filter_layout.addWidget(filter_popup_button) layout.addLayout(filter_layout) self.data_type_keys_widget = QListView() self.data_type_keys_widget.setModel(self.filter_model) self.data_type_keys_widget.selectionModel().selectionChanged.connect( self.itemSelected) layout.addSpacing(15) layout.addWidget(self.data_type_keys_widget, 2) layout.addStretch() # layout.addWidget(Legend("Default types", DataTypeKeysListModel.DEFAULT_DATA_TYPE)) layout.addWidget( Legend("Observations available", DataTypeKeysListModel.HAS_OBSERVATIONS)) self.setLayout(layout)
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setGeometry(300, 300, 1000, 1000) self.setWindowTitle('hello,pyqt4!') self.setToolTip('这是qt4程序') btok = QPushButton('ok', self) btcancel = QPushButton('cancel', self) btok.clicked.connect(self.close) hb = QHBoxLayout() hb.addStretch(1) hb.addWidget(btok) hb.addSpacing(20) hb.addWidget(btcancel) hb.addStretch(1) vb = QVBoxLayout() vb.addStretch(1) vb.addLayout(hb) vb.addSpacing(20) self.setLayout(vb)
def __init__(self, parent, app): super(QWidget, self).__init__() layout1 = QHBoxLayout() layout2 = QVBoxLayout() layout1.addStretch() layout1.addLayout(layout2) layout1.addStretch() label = QLabel(self) label.setText( "Simple Project: <b>Display Environment Measurements on LCD</b>. Simply displays all measured values on LCD. Sources in all programming languages can be found <a href=\"http://www.tinkerforge.com/en/doc/Kits/WeatherStation/WeatherStation.html#display-environment-measurements-on-lcd\">here</a>.<br>" ) label.setTextFormat(Qt.RichText) label.setTextInteractionFlags(Qt.TextBrowserInteraction) label.setOpenExternalLinks(True) label.setWordWrap(True) label.setAlignment(Qt.AlignJustify) layout2.addSpacing(10) layout2.addWidget(label) layout2.addSpacing(10) self.lcdwidget = LCDWidget(self, app) layout2.addWidget(self.lcdwidget) layout2.addStretch() self.setLayout(layout1) self.qtcb_update_illuminance.connect(self.update_illuminance_data_slot) self.qtcb_update_air_pressure.connect( self.update_air_pressure_data_slot) self.qtcb_update_temperature.connect(self.update_temperature_data_slot) self.qtcb_update_humidity.connect(self.update_humidity_data_slot) self.qtcb_button_pressed.connect(self.button_pressed_slot)
def addLabeledSeparator(self, label): """Adds a labeled separator line to the panel.""" widget = QWidget() layout = QVBoxLayout() widget.setLayout(layout) h_layout = QHBoxLayout() frame = QFrame() frame.setFrameShape(QFrame.HLine) frame.setFrameShadow(QFrame.Sunken) h_layout.addWidget(QLabel(label)) h_layout.addWidget(frame, 1, Qt.AlignBottom) layout.addSpacing(2) layout.addLayout(h_layout) layout.addSpacing(0) # widget.setStyleSheet("background-color: #ffff00") self.__startNewRow() self.__layout.addWidget(widget, self.__row, 0, 1, 7) self.__rowFinished()
def initializePage(self): super(PanelPage, self).initializePage() rootLayout = QVBoxLayout() rootLayout.setContentsMargins(20, 20, 10, 20) row0 = QHBoxLayout() lable0 = QLabel('依赖库:') lable0.setAlignment(Qt.AlignTop | Qt.AlignHCenter) self.lw_files = QListWidget() items0 = QStringList() for moudel in app.g_configurations.libs: items0.append(moudel['name']) self.lw_files.addItems(items0) row0.addWidget(lable0) row0.addSpacing(25) row0.addWidget(self.lw_files) row1 = QHBoxLayout() lable1 = QLabel('工程文件:') lable1.setAlignment(Qt.AlignTop | Qt.AlignHCenter) self.lw_files = QListWidget() self.lw_files.setStyleSheet("Height:66px;") items1 = QStringList() for file in app.g_configurations.config['files']: items1.append(file['target']) self.lw_files.addItems(items1) row1.addWidget(lable1) row1.addSpacing(10) row1.addWidget(self.lw_files) rootLayout.addLayout(row0) rootLayout.addSpacing(10) rootLayout.addLayout(row1) self.setLayout(rootLayout) self.setStyleSheet(stylesheet)
def addInitializeFromExistingTab(self): widget = QWidget() layout = QVBoxLayout() target_case = CaseSelector() row = createRow(QLabel("Target case:"), target_case) layout.addLayout(row) source_case = CaseSelector(update_ert=False, show_only_initialized=True, ignore_current=True) row = createRow(QLabel("Source case:"), source_case) layout.addLayout(row) row, history_length_spinner = self.createTimeStepRow() layout.addLayout(row) layout.addSpacing(10) check_list_layout, parameter_model, members_model = createCheckLists() layout.addLayout(check_list_layout) layout.addSpacing(10) initialize_button = QPushButton("Initialize") addHelpToWidget(initialize_button, "init/initialize_from_existing") initialize_button.setMinimumWidth(75) initialize_button.setMaximumWidth(150) def initializeFromExisting(): source_case_name = str(source_case.currentText()) target_case_name = str(target_case.currentText()) report_step = history_length_spinner.value() parameters = parameter_model.getSelectedItems() members = members_model.getSelectedItems() initializeCurrentCaseFromExisting(source_case_name, target_case_name, report_step, parameters, members) initialize_button.clicked.connect(initializeFromExisting) layout.addWidget(initialize_button, 0, Qt.AlignCenter) layout.addSpacing(10) layout.addStretch() widget.setLayout(layout) self.addTab(widget, "Initialize from existing")
def createDialog(self): """ Create dialog """ self.dockToolbar = QToolBar(self) self.dockToolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.setWindowTitle(WINDOW_TITLE) self.resize(500, 400) self.ipEdit = QLineEdit(self.defaultIp) ipRegExpVal = QRegExpValidator(self) ipRegExp = QRegExp("\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}") ipRegExpVal.setRegExp(ipRegExp) self.ipEdit.setValidator(ipRegExpVal) self.portEdit = QLineEdit(self.defaultPort) self.portEdit.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) validatorPort = QIntValidator(self) self.portEdit.setValidator(validatorPort) self.progressBar = QProgressBar(self) self.progressBar.setMaximum(100) self.progressBar.setProperty("value", 0) self.progressBar.setAlignment(Qt.AlignCenter) self.progressBar.setObjectName("progressBar") self.guiSikuliGroupBox = QGroupBox("") self.guiSikuliGroupBox.setFlat(True) self.automaticAdp = QRadioButton("Automatic") self.automaticAdp.setChecked(True) self.defaultAdp = QRadioButton("Default") self.genericAdp = QRadioButton("Generic") vbox = QHBoxLayout() vbox.addWidget(self.automaticAdp) vbox.addWidget(self.defaultAdp) vbox.addWidget(self.genericAdp) vbox.addStretch(1) self.guiSikuliGroupBox.setLayout(vbox) layout = QVBoxLayout() layout.addWidget(self.dockToolbar) layout.addSpacing(12) paramLayout = QGridLayout() paramLayout.addWidget(QLabel("Destination IP:"), 0, 0, Qt.AlignRight) paramLayout.addWidget(self.ipEdit, 0, 1) paramLayout.addWidget(QLabel("Destination Port:"), 1, 0, Qt.AlignRight) paramLayout.addWidget(self.portEdit, 1, 1) paramLayout.addWidget(QLabel(self.tr("Gui adapter selector:")), 2, 0, Qt.AlignRight) paramLayout.addWidget(self.guiSikuliGroupBox, 2, 1) layout.addLayout(paramLayout) self.logsEdit = QTextEdit() self.logsEdit.setReadOnly(True) self.logsEdit.setTextInteractionFlags(Qt.NoTextInteraction) layout.addSpacing(12) layout.addWidget(self.logsEdit) layout.addSpacing(12) layout.addWidget(self.progressBar) self.setLayout(layout)
class AttributeWidget(TraitWidget): """ @brief Das Widget, in welchem sämtliche Attribute angeordnet sind. Die Attribute werden in diesem Widget angeordnet. \todo Bonusattribut als tatsächlichen Attributspunkt einfügen. """ def __init__(self, template, character, parent=None): super(AttributeWidget, self).__init__(template, character, parent) self.__layout = QVBoxLayout() self.setLayout(self.__layout) self.__layoutAttributes = QGridLayout() self.__layout.addLayout(self.__layoutAttributes) self.__labelPower = QLabel("<b>" + self.tr("Power") + "</b>") self.__labelPower.setAlignment(Qt.AlignRight) self.__labelFinesse = QLabel("<b>" + self.tr("Finesse") + "</b>") self.__labelFinesse.setAlignment(Qt.AlignRight) self.__labelResistance = QLabel("<b>" + self.tr("Resistance") + "</b>") self.__labelResistance.setAlignment(Qt.AlignRight) actualRow = 1 actualColumn = 0 self.__layoutAttributes.addWidget(self.__labelPower, actualRow, actualColumn) actualRow += 1 self.__layoutAttributes.addWidget(self.__labelFinesse, actualRow, actualColumn) actualRow += 1 self.__layoutAttributes.addWidget(self.__labelResistance, actualRow, actualColumn) self.__labelStr = QLabel(self) self.__labelDex = QLabel(self) self.__labelSta = QLabel(self) self.__labelMan = QLabel(self) #connect( self, SIGNAL( speciesChanged( bool ) ), labelStr, SLOT( setHidden( bool ) ) ) #connect( self, SIGNAL( speciesChanged( bool ) ), labelDex, SLOT( setHidden( bool ) ) ) #connect( self, SIGNAL( speciesChanged( bool ) ), labelSta, SLOT( setHidden( bool ) ) ) #connect( self, SIGNAL( speciesChanged( bool ) ), labelMan, SLOT( setHidden( bool ) ) ) for item in Config.ATTRIBUTES: #Debug.debug(self._character.traits) actualColumn += 1 vLine = QFrame(self) vLine.setFrameStyle(QFrame.VLine) self.__layoutAttributes.addWidget(vLine, 1, actualColumn, len(item[1]), 1, Qt.AlignHCenter) self.__layoutAttributes.setColumnStretch(actualColumn, 1) # Jetzt sind wir in der Spalte für die tatsächlchen Attribute actualColumn += 1 # Aber zuerst kommt die Überschrift für die einzelnen Kategorien. header = QLabel() header.setAlignment(Qt.AlignHCenter) header.setText("<b>" + item[0] + "</b>") self.__layoutAttributes.addWidget(header, 0, actualColumn) # Einfügen der tatsächlichen Attribute i = 0 for subitem in item[1]: attrib = self._character.traits["Attribute"][item[0]][subitem] #Debug.debug(attrib) # Anlegen des Widgets, das diese Eigenschaft repräsentiert. traitWidget = CharaTrait(attrib, self) traitWidget.setSpecialtiesHidden(True) traitWidget.setDescriptionHidden(True) # An welcher Position sitzt dieses Attribut in der Config.ATTRIBUTES-Liste? self.__layoutAttributes.addWidget(traitWidget, i + 1, actualColumn) self.maxTraitChanged.connect(traitWidget.setMaximum) #if ( item == "Physical" ): #if ( attrib["name"] == "Strength" ): #self.__layoutAttributes.addWidget( self.__labelStr, j + 1, actualColumn + 1 ) #connect( trait, SIGNAL( valueChanged( int ) ), self, SLOT( updateshapeValuesStr( int ) ) ) #} else if ( trait.name() == "Dexterity" ) { #layoutAttributes.addWidget( self.__labelDex, j + 1, actualColumn + 1 ) #connect( trait, SIGNAL( valueChanged( int ) ), self, SLOT( updateshapeValuesDex( int ) ) ) #} else if ( trait.name() == "Stamina" ) { #layoutAttributes.addWidget( self.__labelSta, j + 1, actualColumn + 1 ) #connect( trait, SIGNAL( valueChanged( int ) ), self, SLOT( updateshapeValuesSta( int ) ) ) #} else if ( trait.category() == cv_AbstractTrait::Social ) { #if ( self.__trait.name() == "Manipulation" ) { #layoutAttributes.addWidget( labelMan, j + 1, actualColumn + 1 ) #connect( trait, SIGNAL( valueChanged( int ) ), self, SLOT( updateshapeValuesMan( int ) ) ) i += 1 # Bei Werwölfen erscheint hier Zusatztext. Und damit der Sparator richtig gesetzt wird, muß die aktuelle Spalte ein weitergezählt werden. actualColumn += 1 self.__layout.addSpacing(Config.SPACE_VERTICAL_STD) self.__layoutBonus = QGridLayout() self.__layout.addLayout(self.__layoutBonus) self.__labelBonus = QLabel(self) self.__labelBonus.setText(self.tr("Bonus Attribute:")) self.__layoutButtonsBonus = QVBoxLayout() self.__buttonsBonus = QButtonGroup(self) self.__layoutBonus.addWidget(self.__labelBonus, 0, 0, Qt.AlignTop | Qt.AlignLeft) self.__layoutBonus.addLayout(self.__layoutButtonsBonus, 0, 1) #// layoutBonus.addItem(new QSpacerItem(0,0), 0, 2) self.__layoutBonus.addWidget(QWidget(self), 0, 2) self.__layoutBonus.setColumnStretch(2, 1)
def __init__( self, ressource_directory, validation_callback: callable, exit_callback: callable, play_callback: callable, screen_id=-1, nb_player=1, nb_life=3, timer_proportions=(0.14, 0.25), life_proportions=(0.12, 0.75), player_proportions=(1, 0.7), player_spacing_proportion=0.33, border_proportion=0.03, multi_life_spacing_proportion=0.12, alpha_color="FF00FF", validate_keys=(65, 32, 16777220, 43), # keys : 'a', space, enter, '+' dev_mode=False): if dev_mode: # TODO utiliser logger print(" Initalisation TwistCanWindow (en mode développeur)") # ----- Init de la fenêtre ----- self.main_app = QApplication(sys.argv) self.main_app.setOverrideCursor(Qt.BlankCursor) # ----- Analyse des paramètres du constructeur ----- # Ajouter le '#' dans les html color if type(alpha_color) == str and len(alpha_color) == 6: alpha_color = "#" + alpha_color self.validate_keys = validate_keys self.validation_callback = validation_callback self.play_callback = play_callback self.exit_callback = exit_callback # récupérer les dimension de l'écran selectioné if screen_id < 0: screen_id = QDesktopWidget().screenCount() screen_size = QDesktopWidget().screenGeometry(screen_id).size() border_size = screen_size.width() * border_proportion timer_size = QSize( round((screen_size.width() - border_size * 2) * timer_proportions[0]), round((screen_size.height() - border_size * 2) * timer_proportions[1])) player_size = QSize( round(screen_size.width() * player_proportions[0]), round(screen_size.height() * player_proportions[1])) life_size = QSize( round( (screen_size.width() - border_size * 2) * life_proportions[0]), round((screen_size.height() - border_size * 2) * life_proportions[1])) # ----- Construction de l'interface ----- # Pose widget if dev_mode: print(" Initialisation Background") self.pose_widget = PoseWidget( ressource_directory, screen_size, player_size, player_spacing_proportion, alpha_color=alpha_color, key_press_event_callback=self.keyPressEventCallback, dev_mode=dev_mode) self.pose_widget.setWindowTitle("TwistCam") # self.setWindowIcon(QtGui.QIcon('web.png')) print("Déplacement du jeu sur l'écran le plus a droite [==>]") # TODO impove avec l'id du screen self.pose_widget.move(QDesktopWidget().width() - 1, 0) self.pose_widget.showFullScreen() # Pose Layout main_layout = QVBoxLayout() main_layout.setSpacing(0) main_layout.setContentsMargins(border_size, border_size, border_size, border_size) self.pose_widget.setLayout(main_layout) # Timer push_right_layout = QBoxLayout(QBoxLayout.RightToLeft) main_layout.addLayout(push_right_layout) self.timer = TimerWidget( ressource_directory, timer_size, dev_mode=dev_mode ) # TODO setup clock_dim and clock_color from config push_right_layout.addWidget(self.timer) push_right_layout.setSpacing(0) push_right_layout.addSpacing(screen_size.width() - 2 * border_size - timer_size.width()) # Lifes if nb_player == 1: # setup special pour 1 seul joueur push_right_layout_2 = QBoxLayout(QBoxLayout.RightToLeft) push_right_layout_2.setSpacing(0) main_layout.addLayout(push_right_layout_2) self.lifes = [ LifeWidget(ressource_directory, life_size, nb_life, dev_mode=dev_mode) ] push_right_layout_2.addWidget(self.lifes[0]) push_right_layout_2.addSpacing(screen_size.width() - 2 * border_size - life_size.width() - (timer_size.width() - life_size.width())) else: multi_life_layout = QHBoxLayout() life_size.setWidth(self.pose_widget.player_pixel_spacing * nb_player) life_offset = (screen_size.width() - 2 * border_size - life_size.width()) * 0.5 multi_life_layout.setContentsMargins(life_offset, 0, life_offset, 0) multi_life_layout.setSpacing( self.pose_widget.player_pixel_spacing * multi_life_spacing_proportion) self.lifes = [ LifeWidget(ressource_directory, QSize( self.pose_widget.player_pixel_spacing * (1 - multi_life_spacing_proportion), life_size.height()), nb_life, dev_mode=dev_mode) for k in range(nb_player) ] for life in self.lifes: multi_life_layout.addWidget(life) main_layout.addSpacing(screen_size.height() - 2 * border_size - timer_size.height() - life_size.height()) main_layout.addLayout(multi_life_layout) # ----- Signaux ----- self.s = self.Signaux(self)
def setup_page(self): run_dlg = _("Run Settings") run_menu = _("Run") about_label = QLabel(_("The following are the default <i>%s</i>. "\ "These options may be overriden using the "\ "<b>%s</b> dialog box (see the <b>%s</b> menu)"\ ) % (run_dlg, run_dlg, run_menu)) about_label.setWordWrap(True) interpreter_group = QGroupBox(_("Interpreter")) interpreter_bg = QButtonGroup(interpreter_group) self.current_radio = self.create_radiobutton( CURRENT_INTERPRETER, CURRENT_INTERPRETER_OPTION, True, button_group=interpreter_bg) self.dedicated_radio = self.create_radiobutton( DEDICATED_INTERPRETER, DEDICATED_INTERPRETER_OPTION, False, button_group=interpreter_bg) self.systerm_radio = self.create_radiobutton( SYSTERM_INTERPRETER, SYSTERM_INTERPRETER_OPTION, False, button_group=interpreter_bg) interpreter_layout = QVBoxLayout() interpreter_group.setLayout(interpreter_layout) interpreter_layout.addWidget(self.current_radio) interpreter_layout.addWidget(self.dedicated_radio) interpreter_layout.addWidget(self.systerm_radio) wdir_group = QGroupBox(_("Working directory")) wdir_bg = QButtonGroup(wdir_group) wdir_label = QLabel(_("Default working directory is:")) wdir_label.setWordWrap(True) dirname_radio = self.create_radiobutton(_("the script directory"), WDIR_USE_SCRIPT_DIR_OPTION, True, button_group=wdir_bg) thisdir_radio = self.create_radiobutton(_("the following directory:"), WDIR_USE_FIXED_DIR_OPTION, False, button_group=wdir_bg) thisdir_bd = self.create_browsedir("", WDIR_FIXED_DIR_OPTION, os.getcwdu()) self.connect(thisdir_radio, SIGNAL("toggled(bool)"), thisdir_bd.setEnabled) self.connect(dirname_radio, SIGNAL("toggled(bool)"), thisdir_bd.setDisabled) thisdir_layout = QHBoxLayout() thisdir_layout.addWidget(thisdir_radio) thisdir_layout.addWidget(thisdir_bd) wdir_layout = QVBoxLayout() wdir_layout.addWidget(wdir_label) wdir_layout.addWidget(dirname_radio) wdir_layout.addLayout(thisdir_layout) wdir_group.setLayout(wdir_layout) firstrun_cb = self.create_checkbox( ALWAYS_OPEN_FIRST_RUN % _("Run Settings dialog"), ALWAYS_OPEN_FIRST_RUN_OPTION, False) vlayout = QVBoxLayout() vlayout.addWidget(about_label) vlayout.addSpacing(10) vlayout.addWidget(interpreter_group) vlayout.addWidget(wdir_group) vlayout.addWidget(firstrun_cb) vlayout.addStretch(1) self.setLayout(vlayout)
def __init__(self): super(BaseInfoPage, self).__init__() self.setTitle('工程配置') self.setSubTitle('设置工程的参数') rootLayout = QVBoxLayout() rootLayout.setContentsMargins(20, 30, 20, 30) self.project_name = "" self.project_dir = "" self.completed = False row1 = QHBoxLayout() lable1 = QLabel('工程名称:') self.et_project_name = QLineEdit() self.et_project_name.setTextMargins(-6, 0, 0, 0) self.et_project_name.textChanged.connect(self.on_text_changed) row1.addWidget(lable1) row1.addWidget(self.et_project_name) # row2 = QHBoxLayout() # lable2 = QLabel('工程位置:') # self.et_project_location = QLineEdit() # self.et_project_location.textChanged.connect(self.on_text_changed) # self.et_project_location.setReadOnly(True) # btn_location = QPushButton('...') # btn_location.setFixedWidth(50) # btn_location.clicked.connect(self.getSavePath) # row2.addWidget(lable2) # row2.addWidget(self.et_project_location) # row2.addWidget(btn_location) row3 = QHBoxLayout() lable3 = QLabel('源模板: ') self.cb_wizard_type = QComboBox() items = QStringList() for key in app.g_templates: items.append(key) self.cb_wizard_type.addItems(items) row3.addWidget(lable3) row3.addWidget(self.cb_wizard_type) row4 = QHBoxLayout() lable4 = QLabel('平台类型:') checkboxLayout = QHBoxLayout() self.cb_pt_win = QCheckBox('Win') self.cb_pt_linux = QCheckBox('Linux') checkboxLayout.addWidget(self.cb_pt_win) checkboxLayout.addWidget(self.cb_pt_linux) row4.addWidget(lable4) row4.addLayout(checkboxLayout) row6 = QHBoxLayout() self.cb_pt_version = QComboBox() items_pt_version = QStringList() items_pt_version.append('x86') items_pt_version.append('x64') self.cb_pt_version.addItems(items_pt_version) row6.addWidget(QLabel('平台级别:')) row6.addWidget(self.cb_pt_version) row5 = QHBoxLayout() lable5 = QLabel('组件类型:') self.cb_component_type = QComboBox() items_component_type = QStringList() items_component_type.append('服务') items_component_type.append('窗口') self.cb_component_type.addItems(items_component_type) self.registerField('component_type*', self.cb_component_type) self.cb_component_type.currentIndexChanged.connect( self.on_currentIndex_Changed) row5.addWidget(lable5) row5.addWidget(self.cb_component_type) space1 = QSpacerItem(40, 28, QSizePolicy.Expanding) row7 = QHBoxLayout() lable7 = QLabel('翻译文件:') self.chkb_transFile = QCheckBox() row7.addWidget(lable7) row7.addWidget(self.chkb_transFile) row7.addSpacerItem(space1) space2 = QSpacerItem(40, 28, QSizePolicy.Expanding) row8 = QHBoxLayout() lable8 = QLabel('资源文件:') self.chkb_resourceFile = QCheckBox() row8.addWidget(lable8) row8.addWidget(self.chkb_resourceFile) row8.addSpacerItem(space2) rootLayout.addLayout(row1) rootLayout.addSpacing(10) rootLayout.addLayout(row3) rootLayout.addSpacing(10) rootLayout.addLayout(row5) rootLayout.addSpacing(10) rootLayout.addLayout(row6) rootLayout.addSpacing(10) rootLayout.addLayout(row7) rootLayout.addSpacing(10) rootLayout.addLayout(row8) rootLayout.addSpacing(31) self.setLayout(rootLayout) self.setStyleSheet(styleSheet)
def __init__(self, base): Window.__init__(self, base, i18n.get('user_profile')) self.account_id = None self.setFixedSize(380, 450) self.username = QLabel('') self.username.setTextFormat(Qt.RichText) self.fullname = QLabel('') self.options = ImageButton(base, 'action-status-menu.png', i18n.get('')) self.options.clicked.connect(self.__options_clicked) self.verified_icon = QLabel() self.verified_icon.setPixmap(base.load_image('mark-verified.png', True)) self.protected_icon = QLabel() self.protected_icon.setPixmap( base.load_image('mark-protected.png', True)) self.avatar = ClickableLabel() self.avatar.setPixmap(base.load_image('unknown.png', True)) self.avatar.clicked.connect(self.__show_avatar) self.you_label = QLabel(i18n.get('this_is_you')) self.you_label.setVisible(False) info_line1 = QHBoxLayout() info_line1.setSpacing(5) info_line1.addWidget(self.username) info_line1.addSpacing(5) info_line1.addWidget(self.verified_icon) info_line1.addWidget(self.protected_icon) info_line1.addStretch(0) info_line2 = QHBoxLayout() info_line2.addWidget(self.fullname, 1) info_line2.addWidget(self.options) info_line2.addWidget(self.you_label) user_info = QVBoxLayout() user_info.addLayout(info_line1) user_info.addLayout(info_line2) self.loader = BarLoadIndicator() self.loader.setVisible(False) self.error_message = ErrorLabel() self.error_message.setVisible(False) header = QHBoxLayout() header.setContentsMargins(5, 10, 5, 0) header.addWidget(self.avatar) header.addSpacing(10) header.addLayout(user_info) # User Info self.bio = UserField(base, 'bio', 'icon-bio.png') self.bio.set_word_wrap(True) self.bio.set_info('') self.location = UserField(base, 'location', 'icon-location.png') self.location.set_info('') self.web = UserField(base, 'web', 'icon-home.png') self.web.set_info('') self.tweets = StatInfoBox('tweets', '') self.following = StatInfoBox('following', '') self.followers = StatInfoBox('followers', '') self.favorites = StatInfoBox('favorites', '') footer_layout = QHBoxLayout() footer_layout.setContentsMargins(0, 5, 0, 10) footer_layout.setSpacing(0) footer_layout.addLayout(self.tweets) footer_layout.addWidget(VLine()) footer_layout.addLayout(self.following) footer_layout.addWidget(VLine()) footer_layout.addLayout(self.followers) footer_layout.addWidget(VLine()) footer_layout.addLayout(self.favorites) footer = QWidget() footer.setLayout(footer_layout) footer.setStyleSheet( "QWidget { background-color: #333; color: white; }") body_layout = QVBoxLayout() body_layout.setSpacing(15) body_layout.setContentsMargins(0, 0, 0, 0) body_layout.addLayout(self.bio) body_layout.addLayout(self.location) body_layout.addLayout(self.web) body_layout.addWidget(footer) body = QWidget() body.setLayout(body_layout) self.last_statuses = StatusesColumn(self.base, None, False) self.tabs = QTabWidget(self) self.tabs.setTabsClosable(False) self.tabs.setMovable(False) self.tabs.addTab(body, i18n.get('info')) self.tabs.addTab(self.last_statuses, i18n.get('recent')) self.hline = HLine() self.hline.setMinimumHeight(2) layout = QVBoxLayout() layout.addLayout(header) layout.addSpacing(10) layout.addWidget(self.hline) layout.addWidget(self.loader) layout.addWidget(self.error_message) layout.addSpacing(10) layout.addWidget(self.tabs, 1) layout.setSpacing(0) layout.setContentsMargins(5, 5, 5, 5) self.setLayout(layout) self.__clear()
def __init__(self, parent, app): super(QWidget, self).__init__() self.lcdwidget = LCDWidget(self, app) self.lcdwidget.hide() self.text_agent = QLineEdit(self) self.text_agent.setText(self.xively_agent) self.text_channel = QLineEdit(self) self.text_channel.setText(self.xively_channel) self.text_api_key = QLineEdit(self) self.text_api_key.setText(self.xively_api_key) self.number_update_rate = QSpinBox(self) self.number_update_rate.setRange(1, 1440) self.number_update_rate.setSuffix(' min') self.number_update_rate.setValue(self.xively_update_rate) layout1 = QHBoxLayout() layout2 = QVBoxLayout() layout1.addStretch() layout1.addLayout(layout2) layout1.addStretch() layout2.addSpacerItem(QSpacerItem(LCDWidget.FIXED_WIDGTH, 0)) label = QLabel(self) label.setText( "Project: <b>Connect to Xively</b>. This project uploads the measured values to Xively. Please find documentation how to configure it and program sources in Python <a href=\"http://www.tinkerforge.com/en/doc/Kits/WeatherStation/WeatherStation.html#connect-to-xively\">here</a>.<br>" ) label.setTextFormat(Qt.RichText) label.setTextInteractionFlags(Qt.TextBrowserInteraction) label.setOpenExternalLinks(True) label.setWordWrap(True) label.setAlignment(Qt.AlignJustify) layout2.addSpacing(10) layout2.addWidget(label) layout2.addSpacing(10) layout3a = QHBoxLayout() label = QLabel("Agent Description:") label.setMinimumWidth(150) layout3a.addWidget(label) layout3a.addWidget(self.text_agent, 1) layout2.addLayout(layout3a) layout2.addSpacing(10) layout3b = QHBoxLayout() label = QLabel("Feed:") label.setMinimumWidth(150) layout3b.addWidget(label) layout3b.addWidget(self.text_channel, 1) layout2.addLayout(layout3b) layout2.addSpacing(10) layout3c = QHBoxLayout() label = QLabel("API Key:") label.setMinimumWidth(150) layout3c.addWidget(label) layout3c.addWidget(self.text_api_key, 1) layout2.addLayout(layout3c) layout2.addSpacing(10) layout3d = QHBoxLayout() label = QLabel("Update Rate:") label.setMinimumWidth(150) layout3d.addWidget(label) layout3d.addWidget(self.number_update_rate, 1) layout2.addLayout(layout3d) layout2.addSpacing(10) self.label_upload_active = QLabel("Not Active", self) self.label_upload_active.setMinimumWidth(150) font = QFont() font.setPixelSize(20) self.label_upload_active.setFont(font) self.set_active_label(False) self.save_button = QPushButton("Save/Activate") layout4 = QHBoxLayout() layout4.addWidget(self.label_upload_active) layout4.addWidget(self.save_button, 1) layout2.addLayout(layout4) layout2.addStretch() self.setLayout(layout1) self.qtcb_update_illuminance.connect(self.update_illuminance_data_slot) self.qtcb_update_air_pressure.connect( self.update_air_pressure_data_slot) self.qtcb_update_temperature.connect(self.update_temperature_data_slot) self.qtcb_update_humidity.connect(self.update_humidity_data_slot) self.qtcb_button_pressed.connect(self.button_pressed_slot) self.save_button.clicked.connect(self.save_configuration) self.lcdwidget.clear(self) self.error_message = QErrorMessage(self)
def set_groups(self, keys, groups, relevant_keys, relevant_items, all_values, uniquepos): """Set the current data groups and update the Group widget """ layout = QVBoxLayout() header_widths = [] header_views = [] palette = self.palette() all_values = all_values.keys() def for_print(rd): attrs = [] for d in rd: attr = Orange.data.ContinuousVariable(next(inactive_name_gen)) attr.attributes.update(d) attrs.append(attr) return Orange.data.Domain(attrs, None) for separatev, domain in [(None, for_print(relevant_items))] + groups: label = None if separatev is not None: ann_vals = " <b>|</b> ".join(["<b>{0}</ b> = {1}".format(key,val) \ for key, val in zip(keys, separatev)]) label = QLabel(ann_vals) model = QStandardItemModel() for i, attr in enumerate(domain.attributes): item = QStandardItem() if separatev is not None: isunique = uniquepos[separatev][i] else: isunique = all(a[i] for a in uniquepos.values()) if str(attr.name).startswith( "!!missing " ): # TODO: Change this to not depend on name header_text = ["{0}={1}".format(key, attr.attributes.get(key, "?")) \ for key in all_values if key not in relevant_items[i]] header_text = "\n".join( header_text) if header_text else "Empty" item.setData(header_text, Qt.DisplayRole) item.setFlags(Qt.NoItemFlags) item.setData(QColor(Qt.red), Qt.ForegroundRole) item.setData( palette.color(QPalette.Disabled, QPalette.Window), Qt.BackgroundRole) item.setData("Missing feature.", Qt.ToolTipRole) elif str(attr.name).startswith("!!inactive "): header_text = ["{0}={1}".format(key, attr.attributes.get(key, "?")) \ for key in all_values if key in relevant_items[i]] header_text = "\n".join( header_text) if header_text else "No descriptor" item.setData(header_text, Qt.DisplayRole) item.setData( palette.color(QPalette.Disabled, QPalette.Window), Qt.BackgroundRole) else: header_text = ["{0}={1}".format(key, attr.attributes.get(key, "?")) \ for key in all_values if key not in relevant_items[i]] header_text = "\n".join( header_text) if header_text else "Empty" item.setData(header_text, Qt.DisplayRole) item.setData(attr.name, Qt.ToolTipRole) if not isunique: item.setData(QColor(Qt.red), Qt.ForegroundRole) model.setHorizontalHeaderItem(i, item) attr_count = len(domain.attributes) view = MyHeaderView(Qt.Horizontal) view.setResizeMode(QHeaderView.Fixed) view.setModel(model) hint = view.sizeHint() view.setMaximumHeight(hint.height()) widths = [view.sectionSizeHint(i) for i in range(attr_count)] header_widths.append(widths) header_views.append(view) if label: layout.addWidget(label) layout.addWidget(view) layout.addSpacing(8) # Make all header sections the same width width_sum = 0 max_header_count = max([h.count() for h in header_views]) for i in range(max_header_count): max_width = max([w[i] for w in header_widths if i < len(w)] or [0]) for view in header_views: if i < view.count(): view.resizeSection(i, max_width) width_sum += max_width + 2 for h in header_views: h.setMinimumWidth(h.length() + 4) widget = QWidget() widget.setLayout(layout) widget.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Maximum) layout.activate() max_width = max(h.length() for h in header_views) + 20 left, _, right, _ = self.getContentsMargins() widget.setMinimumWidth(width_sum) widget.setMinimumWidth(max_width + left + right) self.groups_scroll_area.setWidget(widget)