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, *args): PluginBase.__init__(self, BrickletLaserRangeFinder, *args) self.lrf = self.device self.cbe_distance = CallbackEmulator(self.lrf.get_distance, self.cb_distance, self.increase_error_count) self.cbe_velocity = CallbackEmulator(self.lrf.get_velocity, self.cb_velocity, self.increase_error_count) self.current_distance = None # int, cm self.current_velocity = None # float, m/s plots_distance = [('Distance', Qt.red, lambda: self.current_distance, format_distance)] plots_velocity = [('Velocity', Qt.red, lambda: self.current_velocity, '{:.2f} m/s'.format)] self.plot_widget_distance = PlotWidget('Distance [cm]', plots_distance) self.plot_widget_velocity = PlotWidget('Velocity [m/s]', plots_velocity) self.mode_label = QLabel('Mode:') self.mode_combo = QComboBox() self.mode_combo.addItem("Distance: 1cm resolution, 40m max") self.mode_combo.addItem("Velocity: 0.10 m/s resolution, 12.70m/s max") self.mode_combo.addItem("Velocity: 0.25 m/s resolution, 31.75m/s max") self.mode_combo.addItem("Velocity: 0.50 m/s resolution, 63.50m/s max") self.mode_combo.addItem("Velocity: 1.00 m/s resolution, 127.00m/s max") self.mode_combo.currentIndexChanged.connect(self.mode_changed) self.mode_combo.hide() self.label_average_distance = QLabel('Moving Average for Distance:') self.spin_average_distance = QSpinBox() self.spin_average_distance.setMinimum(0) self.spin_average_distance.setMaximum(50) self.spin_average_distance.setSingleStep(1) self.spin_average_distance.setValue(10) self.spin_average_distance.editingFinished.connect( self.spin_average_finished) self.label_average_velocity = QLabel('Moving Average for Velocity:') self.spin_average_velocity = QSpinBox() self.spin_average_velocity.setMinimum(0) self.spin_average_velocity.setMaximum(50) self.spin_average_velocity.setSingleStep(1) self.spin_average_velocity.setValue(10) self.spin_average_velocity.editingFinished.connect( self.spin_average_finished) self.enable_laser = QCheckBox("Enable Laser") self.enable_laser.stateChanged.connect(self.enable_laser_changed) self.label_acquisition_count = QLabel('Acquisition Count:') self.spin_acquisition_count = QSpinBox() self.spin_acquisition_count.setMinimum(1) self.spin_acquisition_count.setMaximum(255) self.spin_acquisition_count.setSingleStep(1) self.spin_acquisition_count.setValue(128) self.enable_qick_termination = QCheckBox("Quick Termination") self.label_threshold = QLabel('Threshold:') self.threshold = QCheckBox("Automatic Threshold") self.spin_threshold = QSpinBox() self.spin_threshold.setMinimum(1) self.spin_threshold.setMaximum(255) self.spin_threshold.setSingleStep(1) self.spin_threshold.setValue(1) self.label_frequency = QLabel('Frequency [Hz]:') self.frequency = QCheckBox( "Automatic Frequency (Disable for Velocity)") self.spin_frequency = QSpinBox() self.spin_frequency.setMinimum(10) self.spin_frequency.setMaximum(500) self.spin_frequency.setSingleStep(1) self.spin_frequency.setValue(10) self.spin_acquisition_count.editingFinished.connect( self.configuration_changed) self.enable_qick_termination.stateChanged.connect( self.configuration_changed) self.spin_threshold.editingFinished.connect(self.configuration_changed) self.threshold.stateChanged.connect(self.configuration_changed) self.spin_frequency.editingFinished.connect(self.configuration_changed) self.frequency.stateChanged.connect(self.configuration_changed) layout_h1 = QHBoxLayout() layout_h1.addWidget(self.plot_widget_distance) layout_h1.addWidget(self.plot_widget_velocity) layout_h2 = QHBoxLayout() layout_h2.addWidget(self.mode_label) layout_h2.addWidget(self.mode_combo) layout_h2.addWidget(self.label_average_distance) layout_h2.addWidget(self.spin_average_distance) layout_h2.addWidget(self.label_average_velocity) layout_h2.addWidget(self.spin_average_velocity) layout_h2.addStretch() layout_h2.addWidget(self.enable_laser) layout_h3 = QHBoxLayout() layout_h3.addWidget(self.label_frequency) layout_h3.addWidget(self.spin_frequency) layout_h3.addWidget(self.frequency) layout_h3.addStretch() layout_h3.addWidget(self.enable_qick_termination) layout_h4 = QHBoxLayout() layout_h4.addWidget(self.label_threshold) layout_h4.addWidget(self.spin_threshold) layout_h4.addWidget(self.threshold) layout_h4.addStretch() layout_h4.addWidget(self.label_acquisition_count) layout_h4.addWidget(self.spin_acquisition_count) self.widgets_distance = [ self.plot_widget_distance, self.spin_average_distance, self.label_average_distance ] self.widgets_velocity = [ self.plot_widget_velocity, self.spin_average_velocity, self.label_average_velocity ] for w in self.widgets_distance: w.hide() for w in self.widgets_velocity: w.hide() line = QFrame() line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout = QVBoxLayout(self) layout.addLayout(layout_h1) layout.addWidget(line) layout.addLayout(layout_h2) layout.addLayout(layout_h3) layout.addLayout(layout_h4) self.has_sensor_hardware_version_api = self.firmware_version >= (2, 0, 3) self.has_configuration_api = self.firmware_version >= (2, 0, 3)
def __init__(self, parent): super(GeneralConfiguration, self).__init__() self._preferences = parent vbox = QVBoxLayout(self) groupBoxStart = QGroupBox(translations.TR_PREFERENCES_GENERAL_START) groupBoxClose = QGroupBox(translations.TR_PREFERENCES_GENERAL_CLOSE) groupBoxWorkspace = QGroupBox( translations.TR_PREFERENCES_GENERAL_WORKSPACE) groupBoxNoti = QGroupBox(translations.TR_NOTIFICATION) groupBoxReset = QGroupBox(translations.TR_PREFERENCES_GENERAL_RESET) #Start vboxStart = QVBoxLayout(groupBoxStart) self._checkLastSession = QCheckBox( translations.TR_PREFERENCES_GENERAL_LOAD_LAST_SESSION) self._checkActivatePlugins = QCheckBox( translations.TR_PREFERENCES_GENERAL_ACTIVATE_PLUGINS) self._checkNotifyUpdates = QCheckBox( translations.TR_PREFERENCES_GENERAL_NOTIFY_UPDATES) self._checkShowStartPage = QCheckBox( translations.TR_PREFERENCES_GENERAL_SHOW_START_PAGE) vboxStart.addWidget(self._checkLastSession) vboxStart.addWidget(self._checkActivatePlugins) vboxStart.addWidget(self._checkNotifyUpdates) vboxStart.addWidget(self._checkShowStartPage) #Close vboxClose = QVBoxLayout(groupBoxClose) self._checkConfirmExit = QCheckBox( translations.TR_PREFERENCES_GENERAL_CONFIRM_EXIT) vboxClose.addWidget(self._checkConfirmExit) #Workspace and Project gridWorkspace = QGridLayout(groupBoxWorkspace) self._txtWorkspace = QLineEdit() ui_tools.LineEditButton( self._txtWorkspace, self._txtWorkspace.clear, self.style().standardPixmap(self.style().SP_TrashIcon)) self._txtWorkspace.setReadOnly(True) self._btnWorkspace = QPushButton(QIcon(':img/openFolder'), '') gridWorkspace.addWidget( QLabel(translations.TR_PREFERENCES_GENERAL_WORKSPACE), 0, 0, Qt.AlignRight) gridWorkspace.addWidget(self._txtWorkspace, 0, 1) gridWorkspace.addWidget(self._btnWorkspace, 0, 2) self._txtExtensions = QLineEdit() self._txtExtensions.setToolTip( translations.TR_PROJECT_EXTENSIONS_TOOLTIP) gridWorkspace.addWidget( QLabel(translations.TR_PREFERENCES_GENERAL_SUPPORTED_EXT), 1, 0, Qt.AlignRight) gridWorkspace.addWidget(self._txtExtensions, 1, 1) labelTooltip = QLabel(translations.TR_PROJECT_EXTENSIONS_INSTRUCTIONS) gridWorkspace.addWidget(labelTooltip, 2, 1) # Notification hboxNoti, self._notify_position = QHBoxLayout( groupBoxNoti), QComboBox() self._notify_position.addItems([ translations.TR_BOTTOM + "-" + translations.TR_LEFT, translations.TR_BOTTOM + "-" + translations.TR_RIGHT, translations.TR_TOP + "-" + translations.TR_LEFT, translations.TR_TOP + "-" + translations.TR_RIGHT ]) self._notify_color = QPushButton( translations.TR_EDITOR_SCHEME_PICK_COLOR) self._notification_choosed_color = settings.NOTIFICATION_COLOR hboxNoti.addWidget(QLabel(translations.TR_POSITION_ON_SCREEN)) hboxNoti.addWidget(self._notify_position) hboxNoti.addWidget(self._notify_color, 0, Qt.AlignRight) # Resetting preferences vboxReset = QVBoxLayout(groupBoxReset) self._btnReset = QPushButton( translations.TR_PREFERENCES_GENERAL_RESET_PREFERENCES) vboxReset.addWidget(self._btnReset, alignment=Qt.AlignLeft) #Settings qsettings = IDE.ninja_settings() qsettings.beginGroup('preferences') qsettings.beginGroup('general') self._checkLastSession.setChecked( qsettings.value('loadFiles', True, type=bool)) self._checkActivatePlugins.setChecked( qsettings.value('activatePlugins', defaultValue=True, type=bool)) self._checkNotifyUpdates.setChecked( qsettings.value('preferences/general/notifyUpdates', defaultValue=True, type=bool)) self._checkShowStartPage.setChecked(settings.SHOW_START_PAGE) self._checkConfirmExit.setChecked(settings.CONFIRM_EXIT) self._txtWorkspace.setText(settings.WORKSPACE) extensions = ', '.join(settings.SUPPORTED_EXTENSIONS) self._txtExtensions.setText(extensions) self._notify_position.setCurrentIndex(settings.NOTIFICATION_POSITION) qsettings.endGroup() qsettings.endGroup() vbox.addWidget(groupBoxStart) vbox.addWidget(groupBoxClose) vbox.addWidget(groupBoxWorkspace) vbox.addWidget(groupBoxNoti) vbox.addWidget(groupBoxReset) #Signals self.connect(self._btnWorkspace, SIGNAL("clicked()"), self._load_workspace) self.connect(self._notify_color, SIGNAL("clicked()"), self._pick_color) self.connect(self._btnReset, SIGNAL('clicked()'), self._reset_preferences) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
def __init__(self, result_widget, parent): super(FindInFilesDialog, self).__init__(parent) self._find_thread = FindInFilesThread() self.setWindowTitle(translations.TR_FIND_IN_FILES) self.resize(400, 300) #MAIN LAYOUT main_vbox = QVBoxLayout(self) self.pattern_line_edit = QLineEdit() self.pattern_line_edit.setPlaceholderText(translations.TR_FIND + "...") self.dir_name_root = None self.user_home = os.path.expanduser('~') self.dir_combo = QComboBox() self.dir_combo.addItem(self.user_home) self.dir_combo.setEditable(True) self.open_button = QPushButton(QIcon(":img/find"), translations.TR_OPEN) self.filters_line_edit = QLineEdit("*.py") self.filters_line_edit.setPlaceholderText("*.py") self.filters_line_edit.setCompleter(QCompleter( ["*{}".format(item) for item in settings.SUPPORTED_EXTENSIONS])) self.replace_line = QLineEdit() self.replace_line.setEnabled(False) self.replace_line.setPlaceholderText( translations.TR_TEXT_FOR_REPLACE + "...") self.check_replace = QCheckBox(translations.TR_REPLACE) self.case_checkbox = QCheckBox(translations.TR_CASE_SENSITIVE) self.type_checkbox = QCheckBox(translations.TR_REGULAR_EXPRESSION) self.recursive_checkbox = QCheckBox(translations.TR_RECURSIVE) self.recursive_checkbox.setCheckState(Qt.Checked) self.phrase_radio = QRadioButton(translations.TR_SEARCH_BY_PHRASE) self.phrase_radio.setChecked(True) self.words_radio = QRadioButton( translations.TR_SEARCH_FOR_ALL_THE_WORDS) self.find_button = QPushButton(translations.TR_FIND + "!") self.find_button.setMaximumWidth(150) self.cancel_button = QPushButton(translations.TR_CANCEL) self.cancel_button.setMaximumWidth(150) self.result_widget = result_widget hbox = QHBoxLayout() hbox.addWidget(self.find_button) hbox.addWidget(self.cancel_button) #main section find_group_box = QGroupBox(translations.TR_MAIN) grid = QGridLayout() grid.addWidget(QLabel(translations.TR_TEXT), 0, 0) grid.addWidget(self.pattern_line_edit, 0, 1) grid.addWidget(QLabel(translations.TR_DIRECTORY), 1, 0) grid.addWidget(self.dir_combo, 1, 1) grid.addWidget(self.open_button, 1, 2) grid.addWidget(QLabel(translations.TR_FILTER), 2, 0) grid.addWidget(self.filters_line_edit, 2, 1) grid.addWidget(self.check_replace, 3, 0) grid.addWidget(self.replace_line, 3, 1) find_group_box.setLayout(grid) #add main section to MAIN LAYOUT main_vbox.addWidget(find_group_box) #options sections options_group_box = QGroupBox(translations.TR_OPTIONS) gridOptions = QGridLayout() gridOptions.addWidget(self.case_checkbox, 0, 0) gridOptions.addWidget(self.type_checkbox, 1, 0) gridOptions.addWidget(self.recursive_checkbox, 2, 0) gridOptions.addWidget(self.phrase_radio, 0, 1) gridOptions.addWidget(self.words_radio, 1, 1) options_group_box.setLayout(gridOptions) #add options sections to MAIN LAYOUT main_vbox.addWidget(options_group_box) #add buttons to MAIN LAYOUT main_vbox.addLayout(hbox) #Focus self.pattern_line_edit.setFocus() self.open_button.setFocusPolicy(Qt.NoFocus) #signal self.connect(self.open_button, SIGNAL("clicked()"), self._select_dir) self.connect(self.find_button, SIGNAL("clicked()"), self._find_in_files) self.connect(self.cancel_button, SIGNAL("clicked()"), self._kill_thread) self.connect(self._find_thread, SIGNAL("found_pattern(PyQt_PyObject)"), self._found_match) self.connect(self._find_thread, SIGNAL("finished()"), self._find_thread_finished) self.connect(self.type_checkbox, SIGNAL("stateChanged(int)"), self._change_radio_enabled) self.connect(self.check_replace, SIGNAL("stateChanged(int)"), self._replace_activated) self.connect(self.words_radio, SIGNAL("clicked(bool)"), self._words_radio_pressed)
def createWidgets (self): """ QtWidgets creation QTreeWidget (Name, Running on address, Type, Sched at, Version, Description) _______________ | | |---------------| | | | | |_______________| """ layout = QHBoxLayout() self.deployBox = QGroupBox("Default probes") self.probesAvailable = QTreeWidget(self) self.probesAvailable.setIndentation(10) self.labelsAvail = [ self.tr("Installed") ] self.probesAvailable.setHeaderLabels(self.labelsAvail) self.runningBox = QGroupBox("Running") self.probesRegistered = QTreeWidget(self) self.probesRegistered.setIndentation(10) self.runningDockToolbar = QToolBar(self) self.runningDockToolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.availDockToolbar = QToolBar(self) self.availDockToolbar.setToolButtonStyle(Qt.ToolButtonTextBesideIcon) self.labels = [ self.tr("Name"), self.tr("Running on address"), self.tr("Started at"), self.tr("Type"), self.tr("Auto Startup"), self.tr("Description") ] self.probesRegistered.setHeaderLabels(self.labels) self.probesRegistered.setColumnWidth(0, 180) self.probesRegistered.setColumnWidth(1, 120) self.probesRegistered.setColumnWidth(2, 150) self.probesRegistered.setColumnWidth(3, 70) self.probesRegistered.setContextMenuPolicy(Qt.CustomContextMenu) self.probesDefault = QTreeWidget(self) self.probesDefault.setIndentation(10) self.labelsDefault = [ self.tr("Enabled"), self.tr("Name"), self.tr("Type"), self.tr("Description") ] self.probesDefault.setHeaderLabels(self.labelsDefault) self.probesDefault.setContextMenuPolicy(Qt.CustomContextMenu) self.probesDefault.setColumnWidth(1, 180) layoutRunning = QVBoxLayout() layoutRunning.addWidget(self.runningDockToolbar) layoutRunning.addWidget(self.probesRegistered) self.runningBox.setLayout(layoutRunning) self.probeNameEdit = QLineEdit('') self.probeNameEdit.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed ) self.probeDescEdit = QLineEdit('') self.probeDescEdit.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed ) self.probeTypeEdit = QLineEdit('') self.probeTypeEdit.setSizePolicy( QSizePolicy.Expanding, QSizePolicy.Fixed ) self.probeTypeEdit.setEnabled(False) self.probeDescrInstalledEdit = QTextEdit('') self.probeDescrInstalledEdit.setEnabled(False) self.checkAutoStartOption = QCheckBox() self.checkStartNowOption = QCheckBox() paramLayout = QGridLayout() paramLayout.addWidget(QLabel("Type:"), 0, 0, Qt.AlignRight) paramLayout.addWidget(self.probeTypeEdit, 0, 1) paramLayout.addWidget(QLabel("Name:"), 1, 0, Qt.AlignRight) paramLayout.addWidget(self.probeNameEdit, 1, 1) paramLayout.addWidget(QLabel("Description:"), 2, 0, Qt.AlignRight) paramLayout.addWidget(self.probeDescEdit, 2, 1) paramLayout.addWidget(QLabel("Startup on boot:"), 3, 0, Qt.AlignRight) paramLayout.addWidget(self.checkAutoStartOption, 3, 1) paramLayout.addWidget(QLabel("Start now:"), 4, 0, Qt.AlignRight) paramLayout.addWidget(self.checkStartNowOption, 4, 1) layoutLeft = QVBoxLayout() layoutAvail = QHBoxLayout() layoutAvail.addWidget(self.probesAvailable) layoutAvail.addWidget(self.probeDescrInstalledEdit) layoutLeft.addLayout(layoutAvail) layoutLeft.addWidget(self.runningBox) layoutDeploy = QVBoxLayout() layoutDeploy.addWidget(self.availDockToolbar) layoutDeploy.addLayout(paramLayout) layoutDeploy.addWidget(self.probesDefault) self.deployBox.setLayout(layoutDeploy) layoutRight = QVBoxLayout() layoutRight.addWidget(self.deployBox) layout.addLayout(layoutLeft) layout.addLayout(layoutRight) self.setLayout(layout)
def __init__(self, parent=None): super(LayerSelectionPage, self).__init__(parent) self.parent = parent #convenience link self.confconn_link = self.parent.parent.confconn #flag top prevent read read action on keyword delete. New logic makes this redundant #self.keywordbypass = False QToolTip.setFont(QFont('SansSerif', 10)) #label filterlabel = QLabel('Filter') availablelabel = QLabel('Available Layers') selectionlabel = QLabel('Layer Selections') keywordlabel = QLabel('Keyword') explainlabel = QLabel( "Edit Group assignments using this dialog or to simply initialise the Layer-Config just click 'Finish'" ) #selection buttons chooseallbutton = QPushButton('>>') chooseallbutton.setFixedWidth(self.XFER_BW) chooseallbutton.clicked.connect(self.doChooseAllClickAction) choosebutton = QPushButton('>') choosebutton.setFixedWidth(self.XFER_BW) choosebutton.clicked.connect(self.doChooseClickAction) rejectbutton = QPushButton('<') rejectbutton.setFixedWidth(self.XFER_BW) rejectbutton.clicked.connect(self.doRejectClickAction) rejectallbutton = QPushButton('<<') rejectallbutton.setFixedWidth(self.XFER_BW) rejectallbutton.clicked.connect(self.doRejectAllClickAction) #operation buttons finishbutton = QPushButton('Finish') finishbutton.setToolTip('Finish and Close layer selection dialog') finishbutton.clicked.connect(self.parent.close) resetbutton = QPushButton('Reset') resetbutton.font() resetbutton.setToolTip( 'Read Layer from LDS GetCapabilities request. Overwrites current Layer Config' ) resetbutton.clicked.connect(self.doResetClickAction) self.available_sfpm = LDSSFPAvailableModel(self) self.selection_sfpm = LDSSFPSelectionModel(self) self.available_sfpm.setSourceModel(self.parent.available_model) self.selection_sfpm.setSourceModel(self.parent.selection_model) #textedits filteredit = QLineEdit('') filteredit.setToolTip( 'Filter Available-Layers pane (filter operates across Name and Title fields and accepts Regex expressions)' ) filteredit.textChanged.connect(self.available_sfpm.setActiveFilter) self.keywordcombo = QComboBox() self.keywordcombo.setToolTip( 'Select or Add a unique identifier to be saved in layer config (keyword)' ) self.keywordcombo.addItems(list(self.confconn_link.assigned)) self.keywordcombo.setEditable(True) self.keywordcombo.activated.connect(self.doKeyComboChangeAction) lgindex = self.confconn_link.getLayerGroupIndex( self.confconn_link.lgval, col=1) lgentry = self.confconn_link.lglist[lgindex] if LU.assessNone( lgindex) else None #keywordedit = self.keywordcombo.lineEdit().text().toUtf8().data().decode('utf8')# for writing #if no entry or layer indicated then blank self.keywordcombo.lineEdit().setText( '' if lgentry is None or lgentry[0] == LORG.LAYER else lgentry[1]) #self.confconn_link.lgval)#TODO. group only #header headmodel = QStandardItemModel() headmodel.setHorizontalHeaderLabels([ i[2] for i in self.colparams ][:self.parent.available_model.columnCount()]) headview1 = QHeaderView(Qt.Horizontal) headview1.setModel(headmodel) headview1.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) headview2 = QHeaderView(Qt.Horizontal) headview2.setModel(headmodel) headview2.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) #table self.available = QTableView() self.available.setSelectionBehavior(QAbstractItemView.SelectRows) self.available.setSelectionMode(QAbstractItemView.MultiSelection) self.selection = QTableView() self.selection.setSelectionBehavior(QAbstractItemView.SelectRows) self.selection.setSelectionMode(QAbstractItemView.MultiSelection) #interesting, must set model after selection attributes but before headers else row selections/headers don't work properly self.available.setModel(self.available_sfpm) self.selection.setModel(self.selection_sfpm) self.available.setSortingEnabled(True) self.available.setHorizontalHeader(headview1) self.selection.setSortingEnabled(True) self.selection.setHorizontalHeader(headview2) for cp in self.colparams: self.available.setColumnWidth(cp[0], cp[1]) self.selection.setColumnWidth(cp[0], cp[1]) self.available.verticalHeader().setVisible(False) self.available.horizontalHeader().setVisible(True) self.selection.verticalHeader().setVisible(False) self.selection.horizontalHeader().setVisible(True) #layout vbox00 = QVBoxLayout() vbox00.addWidget(availablelabel) vbox00.addWidget(self.available) vbox01 = QVBoxLayout() vbox01.addWidget(chooseallbutton) vbox01.addWidget(choosebutton) vbox01.addWidget(rejectbutton) vbox01.addWidget(rejectallbutton) vbox02 = QVBoxLayout() vbox02.addWidget(selectionlabel) vbox02.addWidget(self.selection) vbox10 = QVBoxLayout() vbox10.addWidget(filterlabel) vbox10.addWidget(filteredit) hbox12 = QHBoxLayout() hbox12.addWidget(keywordlabel) hbox12.addStretch(1) #hbox12.addWidget(inspbutton) #hbox12.addWidget(addbutton) #hbox12.addWidget(delbutton) vbox12 = QVBoxLayout() vbox12.addLayout(hbox12) vbox12.addWidget(self.keywordcombo) #00|01|02 #10|11|12 grid0 = QGridLayout() grid0.addLayout(vbox00, 1, 0) grid0.addLayout(vbox01, 1, 1) grid0.addLayout(vbox02, 1, 2) grid0.addLayout(vbox10, 0, 0) grid0.addLayout(vbox12, 0, 2) hbox2 = QHBoxLayout() hbox2.addWidget(resetbutton) hbox2.addStretch(1) hbox2.addWidget(explainlabel) hbox2.addWidget(finishbutton) #gbox1.setLayout(hbox2) vbox3 = QVBoxLayout() vbox3.addLayout(grid0) #vbox3.addLayout(hbox3) #vbox3.addWidget(line0) vbox3.addLayout(hbox2) self.setLayout(vbox3)
def __init__(self, name, widget, parent=None): super(Labelled, self).__init__(parent) layout = QHBoxLayout(self) layout.addWidget(QLabel(name)) layout.addWidget(widget)
def createWidgets(self): """ Create all qt widgets """ self.setWindowTitle(self.tr("Extensive Testing Client - Web Browser")) self.setWindowIcon(QIcon(":/main.png")) self.dockToolbarWebBrowser = QToolBar(self) self.dockToolbarWebBrowser.setToolButtonStyle( Qt.ToolButtonTextBesideIcon) browserLayoutGroup = QVBoxLayout() browserLayoutGroup.addWidget(self.dockToolbarWebBrowser) toolbarBrowserLayoutGroup = QHBoxLayout() self.locationEdit = QLineEdit(self) self.locationEdit.setSizePolicy( QSizePolicy.Expanding, self.locationEdit.sizePolicy().verticalPolicy()) self.webCounter = QLabel("(0%)") toolbarBrowserLayoutGroup.addWidget(QLabel("Load URL:")) toolbarBrowserLayoutGroup.addWidget(self.webCounter) toolbarBrowserLayoutGroup.addWidget(self.locationEdit) self.webTitle = QLabel("Title:") self.webView = QWebView() if QtHelper.str2bool( Settings.instance().readValue(key='Server/proxy-web-active')): proxy = QNetworkProxy() proxy.setType(3) # http proxy.setHostName( Settings.instance().readValue(key='Server/addr-proxy-http')) proxy.setPort( int(Settings.instance().readValue( key='Server/port-proxy-http'))) self.webView.page().networkAccessManager().setProxy(proxy) if QT_VERSION_STR.startswith("4."): self.webInspector = QWebInspector() self.webView.settings().setAttribute( QWebSettings.DeveloperExtrasEnabled, True) self.webInspector.setPage(self.webView.page()) self.webView.setHtml( '<html><head></head><body>No content loaded</body></html>') self.webView.settings().setAttribute(QWebSettings.PluginsEnabled, True) self.webView.settings().setAttribute( QWebSettings.JavascriptCanOpenWindows, True) browserLayoutGroup.addLayout(toolbarBrowserLayoutGroup) browserLayoutGroup.addWidget(self.webTitle) self.webTab = QTabWidget() self.webTab.addTab(self.webView, "Web Page") if QT_VERSION_STR.startswith("4."): self.webTab.addTab(self.webInspector, "Source Inspector") browserLayoutGroup.addWidget(self.webTab) self.setLayout(browserLayoutGroup)
def initView(self): if self.impType == ImpDateType.SERVINGCELL: self.setWindowTitle(u'相邻小区数据导入') else: self.setWindowTitle(u'基站和小区数据导入') self.setWindowIcon(QIcon('images/logo.png')) self.resize(620, 480) # 数据表格 self.tableWidget = QTableWidget(self) self.tableWidget.setAlternatingRowColors(True) self.tableWidget.setRowCount(7) # 设置当前Table不能编辑 self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers) # 初始化表格上下文菜单 self.initTableContextMenu() # 初始化表头 self.initTableHeader() # 导入出错列表 self.listWidget = QListWidget(self) # 按钮组 impBtn = QPushButton(u"导入EXCEL表", self) yzBtn = QPushButton(u"数据检验", self) impdateBtn = QPushButton(u"导入数据", self) btnVBox = QVBoxLayout() btnVBox.addWidget(impBtn) btnVBox.addWidget(yzBtn) btnVBox.addWidget(impdateBtn) # 错误列表与按钮组 hBox = QHBoxLayout() hBox.setMargin(20) hBox.addWidget(self.listWidget) hBox.addLayout(btnVBox) self.mbar = QStatusBar(self) self.mbar.showMessage(u'准备就绪...') self.maction = QToolBar(self) self.editAction = QAction(u'编辑', self.maction) self.editAction.setCheckable(True) self.combox = QComboBox(self) self.combox.addItems(HeadsConfig.ImpExcelName) self.maction.addWidget(self.combox) self.maction.addAction(self.editAction) vBox = QVBoxLayout() vBox.addWidget(self.maction) vBox.addWidget(self.tableWidget) vBox.addLayout(hBox) vBox.addWidget(self.mbar) vBox.setStretchFactor(self.tableWidget, 9) vBox.setStretchFactor(hBox, 5) vBox.setStretchFactor(self.mbar, 1) self.setLayout(vBox) QObject.connect(impBtn, SIGNAL('clicked()'), self.impClick) QObject.connect(yzBtn, SIGNAL('clicked()'), self.yzClick) QObject.connect(impdateBtn, SIGNAL('clicked()'), self.impdateClick) QObject.connect(self.editAction, SIGNAL('triggered()'), self.editClick) QObject.connect(self.combox, SIGNAL('currentIndexChanged(int)'), self.comboxChange) self.listWidget.doubleClicked.connect(self.mlistClicked)
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)
def __init__(self, parent=None, **kwargs): super().__init__(parent, **kwargs) self.setLayout(QVBoxLayout()) self.layout().setContentsMargins(0, 0, 0, 0) self.addonwidget = AddonManagerWidget() self.layout().addWidget(self.addonwidget) info_bar = QWidget() info_layout = QHBoxLayout() info_bar.setLayout(info_layout) info_icon = QLabel() info_text = QLabel() info_layout.addWidget(info_icon) info_layout.addWidget(info_text) self.layout().addWidget(info_bar) buttons = QDialogButtonBox( orientation=Qt.Horizontal, standardButtons=QDialogButtonBox.Ok | QDialogButtonBox.Cancel ) buttons.accepted.connect(self.__accepted) buttons.rejected.connect(self.reject) self.layout().addWidget(buttons) if not os.access(sysconfig.get_path("purelib"), os.W_OK): if sysconfig.get_platform().startswith("macosx"): info = "You must install Orange by dragging it into" \ " Applications before installing add-ons." else: info = "You do not have permissions to write into Orange " \ "directory.\nYou may need to contact an administrator " \ "for assistance." info_text.setText(info) style = QApplication.instance().style() info_icon.setPixmap(style.standardIcon( QStyle.SP_MessageBoxCritical).pixmap(14, 14)) buttons.button(QDialogButtonBox.Ok ).setEnabled(False) self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=1) if AddonManagerDialog._packages is None: self._f_pypi_addons = self._executor.submit(list_pypi_addons) else: self._f_pypi_addons = concurrent.futures.Future() self._f_pypi_addons.set_result(AddonManagerDialog._packages) self._f_pypi_addons.add_done_callback( method_queued(self._set_packages, (object,)) ) self.__progress = QProgressDialog( self, Qt.Sheet, minimum=0, maximum=0, labelText=self.tr("Retrieving package list"), sizeGripEnabled=False, windowTitle="Progress" ) self.__progress.rejected.connect(self.reject) self.__thread = None self.__installer = None
def __init__(self, parent = None): QDialog.__init__(self, parent) self.resize(290, 136); self.setWindowTitle("Reference Positions") sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed); sizePolicy.setHorizontalStretch(0); sizePolicy.setVerticalStretch(0); sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()); self.setSizePolicy(sizePolicy); verticalLayoutDlg = QVBoxLayout(self) verticalLayoutDlg.setObjectName(("verticalLayoutDlg")); frameDate = QFrame(self); frameDate.setObjectName(("frameDate")); frameDate.setFrameShape(QFrame.StyledPanel); frameDate.setFrameShadow(QFrame.Raised); horizontalLayoutDate = QHBoxLayout(frameDate); horizontalLayoutDate.setObjectName(("horizontalLayoutDate")); labelDate = QLabel(frameDate); labelDate.setObjectName(("labelDate")); labelDate.setMinimumSize(QSize(70, 0)); labelDate.setMaximumSize(QSize(70, 16777215)); labelDate.setText("Date:") horizontalLayoutDate.addWidget(labelDate); self.dtpDate = QDateEdit(frameDate); self.dtpDate.setObjectName(("dtpDate")); horizontalLayoutDate.addWidget(self.dtpDate); self.btnDtpDate = QToolButton(frameDate); self.btnDtpDate.setObjectName(("btnDtpDate")); sizePolicy.setHeightForWidth(self.btnDtpDate.sizePolicy().hasHeightForWidth()); self.btnDtpDate.setSizePolicy(sizePolicy); self.btnDtpDate.setMinimumSize(QSize(25, 0)); self.btnDtpDate.setMaximumSize(QSize(25, 16777215)); icon = QIcon() icon.addPixmap(QPixmap(("Resource/calender.png")), QIcon.Normal, QIcon.Off) self.btnDtpDate.setIcon(icon) horizontalLayoutDate.addWidget(self.btnDtpDate); verticalLayoutDlg.addWidget(frameDate); frameModel = QFrame(self); frameModel.setObjectName(("frameModel")); frameModel.setFrameShape(QFrame.StyledPanel); frameModel.setFrameShadow(QFrame.Raised); horizontalLayoutModel = QHBoxLayout(frameModel); horizontalLayoutModel.setObjectName(("horizontalLayoutModel")); labelModel = QLabel(frameModel); labelModel.setObjectName(("labelModel")); labelModel.setMinimumSize(QSize(70, 0)); labelModel.setMaximumSize(QSize(70, 16777215)); labelModel.setText("Model:") horizontalLayoutModel.addWidget(labelModel); self.cmbModel = QComboBox(frameModel); self.cmbModel.setObjectName(("cmbModel")); horizontalLayoutModel.addWidget(self.cmbModel); verticalLayoutDlg.addWidget(frameModel); self.buttonBox = QDialogButtonBox(self); self.buttonBox.setObjectName(("buttonBox")); self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok); self.connect(self.buttonBox, SIGNAL("accepted()"), self.accept) self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject) verticalLayoutDlg.addWidget(self.buttonBox); self.calendar = QCalendarWidget() self.calendar.clicked.connect(self.calendar_clicked) self.menu = QMenu() layout = QVBoxLayout(self.menu) layout.addWidget(self.calendar) self.btnDtpDate.clicked.connect(self.btnDtpDate_clicked) self.cmbModel.addItems(["WMM2015", "WMM2010" , "WMM2005", "WMM2000", "WMM95", "WMM90", "WMM85", "IGRF2000", "IGRF95", "IGRF90"])
def __createLayout(self): """ Creates the dialog layout """ self.resize(600, 300) self.setSizeGripEnabled(True) verticalLayout = QVBoxLayout(self) gridLayout = QGridLayout() # Combo box for the text to search findLabel = QLabel(self) findLabel.setText("Find text:") self.findCombo = QComboBox(self) self.__tuneCombo(self.findCombo) self.findCombo.lineEdit().setToolTip( "Regular expression to search for") self.findCombo.editTextChanged.connect(self.__someTextChanged) gridLayout.addWidget(findLabel, 0, 0, 1, 1) gridLayout.addWidget(self.findCombo, 0, 1, 1, 1) verticalLayout.addLayout(gridLayout) # Check boxes horizontalCBLayout = QHBoxLayout() self.caseCheckBox = QCheckBox(self) self.caseCheckBox.setText("Match &case") horizontalCBLayout.addWidget(self.caseCheckBox) self.wordCheckBox = QCheckBox(self) self.wordCheckBox.setText("Match whole &word") horizontalCBLayout.addWidget(self.wordCheckBox) self.regexpCheckBox = QCheckBox(self) self.regexpCheckBox.setText("Regular &expression") horizontalCBLayout.addWidget(self.regexpCheckBox) verticalLayout.addLayout(horizontalCBLayout) # Files groupbox filesGroupbox = QGroupBox(self) filesGroupbox.setTitle("Find in") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( filesGroupbox.sizePolicy().hasHeightForWidth()) filesGroupbox.setSizePolicy(sizePolicy) gridLayoutFG = QGridLayout(filesGroupbox) self.projectRButton = QRadioButton(filesGroupbox) self.projectRButton.setText("&Project") gridLayoutFG.addWidget(self.projectRButton, 0, 0) self.projectRButton.clicked.connect(self.__projectClicked) self.openFilesRButton = QRadioButton(filesGroupbox) self.openFilesRButton.setText("&Opened files only") gridLayoutFG.addWidget(self.openFilesRButton, 1, 0) self.openFilesRButton.clicked.connect(self.__openFilesOnlyClicked) self.dirRButton = QRadioButton(filesGroupbox) self.dirRButton.setText("&Directory tree") gridLayoutFG.addWidget(self.dirRButton, 2, 0) self.dirRButton.clicked.connect(self.__dirClicked) self.dirEditCombo = QComboBox(filesGroupbox) self.__tuneCombo(self.dirEditCombo) self.dirEditCombo.lineEdit().setToolTip("Directory to search in") gridLayoutFG.addWidget(self.dirEditCombo, 2, 1) self.dirEditCombo.editTextChanged.connect(self.__someTextChanged) self.dirSelectButton = QPushButton(filesGroupbox) self.dirSelectButton.setText("...") gridLayoutFG.addWidget(self.dirSelectButton, 2, 2) self.dirSelectButton.clicked.connect(self.__selectDirClicked) filterLabel = QLabel(filesGroupbox) filterLabel.setText("Files filter:") gridLayoutFG.addWidget(filterLabel, 3, 0) self.filterCombo = QComboBox(filesGroupbox) self.__tuneCombo(self.filterCombo) self.filterCombo.lineEdit().setToolTip("File names regular expression") gridLayoutFG.addWidget(self.filterCombo, 3, 1) self.filterCombo.editTextChanged.connect(self.__someTextChanged) verticalLayout.addWidget(filesGroupbox) # File label self.fileLabel = FitPathLabel(self) self.fileLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed) verticalLayout.addWidget(self.fileLabel) # Progress bar self.progressBar = QProgressBar(self) self.progressBar.setValue(0) self.progressBar.setOrientation(Qt.Horizontal) verticalLayout.addWidget(self.progressBar) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Cancel) self.findButton = buttonBox.addButton("Find", QDialogButtonBox.AcceptRole) self.findButton.setDefault(True) self.findButton.clicked.connect(self.__process) verticalLayout.addWidget(buttonBox) buttonBox.rejected.connect(self.__onClose) return
def __init__(self, parent=None): super(VirtualKeyboard, self).__init__(parent) self.globalLayout = QVBoxLayout(self) self.keysLayout = QGridLayout() self.buttonLayout = QHBoxLayout() self.dictOfButtons = {} self.setStyleSheet("QWidget {" "background-color: rgb(118, 118, 118);" "color: rgb(240, 240, 240);" "}" "" "QLabel{" "color: rgb(240, 240, 240);" "}" "QPushButton{" "background-color: rgb(42, 42, 42);" "color: rgb(255, 255, 255);" "border-style: solid;" "border-color: black;" "border-width: 5px;" "border-radius: 10px;" "font: 63 20pt 'Ubuntu';" "}") self.keyListByLines = [ ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', u'ß', '?'], # comment this line if you dont want numbers ['q', 'w', 'e', 'r', 't', 'z', 'u', 'i', 'o', 'p', u'ü', '+'], ['a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', u'ö', u'ä', '#'], ['y', 'x', 'c', 'v', 'b', 'n', 'm', '_', '-', '/', '.', ':'], ] self.inputString = "" self.state = InputState.LOWER self.stateButton = QPushButton() self.stateButton.setText('Shift') self.backButton = QPushButton() self.backButton.setText(self.tr('Delete')) self.backButton.setFocusPolicy(Qt.NoFocus) self.okButton = QPushButton() self.okButton.setText('OK') self.okButton.setFocusPolicy(Qt.NoFocus) self.cancelButton = QPushButton() self.cancelButton.setText(self.tr("Abort")) self.cancelButton.setFocusPolicy(Qt.NoFocus) self.spaceButton = SpaceKeyButton(" ") self.spaceButton.setText(self.tr("Space")) self.dictOfButtons.update({"keyButton ": self.spaceButton}) self.connect(self.spaceButton, SIGNAL("sigKeyButtonClicked"), self.addInputByKey) self.inputLine = QLineEdit() self.inputLine.setFont(font) for lineIndex, line in enumerate(self.keyListByLines): for keyIndex, key in enumerate(line): buttonName = "keyButton" + key.capitalize() self.dictOfButtons.update({buttonName: KeyButton(key)}) self.keysLayout.addWidget(self.getButtonByKey(key), self.keyListByLines.index(line), line.index(key)) self.getButtonByKey(key).setText(key) self.connect(self.getButtonByKey(key), SIGNAL("sigKeyButtonClicked"), self.addInputByKey) self.keysLayout.setColumnMinimumWidth(keyIndex, 50) self.keysLayout.setRowMinimumHeight(lineIndex, 50) self.connect(self.stateButton, SIGNAL("clicked()"), self.switchState) self.connect(self.backButton, SIGNAL("clicked()"), self.backspace) self.connect(self.okButton, SIGNAL("clicked()"), self.emitInputString) self.connect(self.cancelButton, SIGNAL("clicked()"), self.emitCancel) self.buttonLayout.addWidget(self.cancelButton) self.buttonLayout.addWidget(self.backButton) self.buttonLayout.addWidget(self.stateButton) self.buttonLayout.addWidget(self.okButton) self.globalLayout.addWidget(self.inputLine) self.globalLayout.addLayout(self.keysLayout) self.globalLayout.addWidget(self.spaceButton) self.globalLayout.addLayout(self.buttonLayout) self.setSizePolicy(QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed))
def __init__(self, parent=None): QWidget.__init__(self, parent) self.setMinimumWidth(500) self.setMinimumHeight(200) self.__dynamic = False self.setWindowTitle("Export data") self.activateWindow() layout = QFormLayout() current_case = CaseSelectorModel().getCurrentChoice() self.__case_model = AllCasesModel() self.__case_combo = QComboBox() self.__case_combo.setSizeAdjustPolicy( QComboBox.AdjustToMinimumContentsLength) self.__case_combo.setMinimumContentsLength(20) self.__case_combo.setModel(self.__case_model) self.__case_combo.setCurrentIndex( self.__case_model.indexOf(current_case)) layout.addRow("Select case:", self.__case_combo) self.__export_keyword_model = ExportKeywordModel() self.__kw_model = self.__export_keyword_model.getKeyWords() self.__keywords = QComboBox() self.__keywords.addItems(self.__kw_model) layout.addRow("Select keyword:", self.__keywords) self.__active_realizations_model = ExportRealizationsModel( EnsembleSizeModel().getValue()) self.__active_realizations_field = StringBox( self.__active_realizations_model, "Active realizations", "config/simulation/active_realizations") self.__active_realizations_field.setValidator(RangeStringArgument()) self.__active_realizations_field.validationChanged.connect( self.validateExportDialog) layout.addRow(self.__active_realizations_field.getLabel(), self.__active_realizations_field) file_name_button = QToolButton() file_name_button.setText("Browse") file_name_button.clicked.connect(self.selectFileDirectory) self.__defaultPath = QDir.currentPath() + "/export" self.__file_name = QLineEdit() self.__file_name.setEnabled(False) self.__file_name.setText(self.__defaultPath) self.__file_name.textChanged.connect(self.validateExportDialog) self.__file_name.setMinimumWidth(250) file_name_layout = QHBoxLayout() file_name_layout.addWidget(self.__file_name) file_name_layout.addWidget(file_name_button) layout.addRow("Select directory to save files to:", file_name_layout) self.__gen_kw_file_types = ["Parameter list", "Template based"] self.__field_kw_file_types = ["Eclipse GRDECL", "RMS roff"] self.__gen_data_file_types = ["Gen data"] self.__file_type_model = self.__field_kw_file_types self.__file_type_combo = QComboBox() self.__file_type_combo.setSizeAdjustPolicy(QComboBox.AdjustToContents) self.__file_type_combo.addItems(self.__file_type_model) layout.addRow("Select file format:", self.__file_type_combo) self.__report_step = QLineEdit() layout.addRow("Report step:", self.__report_step) self.__gen_data_report_step_model = [] self.__gen_data_report_step = QComboBox() layout.addRow("Report step:", self.__gen_data_report_step) self.setLayout(layout) self.__keywords.currentIndexChanged.connect(self.keywordSelected) self.keywordSelected()
def initUI(self): u"""Build the dialog box.""" language_help = _(u'''<h4>Language code.</h4> <p>This will be transmitted as part of the requst sent to the sites. As some sites only support one language, this is also used to decide where to send the requests. Use a standard language code here. Using invalid values or codes of unsupported languages will result in no downloads. Do <em>not</em> use domain codes (E.g. use <code>zh</code> rather than <code>cn</code> for Chinese.)</p>''') self.setWindowTitle(_(u'Anki – Download audio')) self.setWindowIcon(QIcon(":/icons/anki.png")) layout = QVBoxLayout() self.setLayout(layout) edit_word_head = QLabel() kanji_et = _('''\ <h4>Requests to send to the download sites</h4> <p>In the split edit fields, set the kanji on the left, the kana on the right.</p> ''') base_et = _('''\ <h4>Requests to send to the download sites</h4> <p>In split edit fields, set the expression (base) on the left, the reading (ruby) on the right.</p> ''') single_et = _('''\ <h4>Requests to send to the download sites</h4> ''') # Now decide which help text to show. # First, decide if we have any split fields. if any(f_data.split for f_data in self.field_data_list): if self.language_code and self.language_code.startswith('ja'): # Japanese edit_word_head.setText(kanji_et) else: # Chinese should not happen at the moment edit_word_head.setText(base_et) else: edit_word_head.setText(single_et) layout.addWidget(edit_word_head) self.create_data_rows(layout) line = QFrame(self) line.setFrameShape(QFrame.HLine) line.setFrameShadow(QFrame.Sunken) layout.addWidget(line) lcode_head = QLabel(_('''<h4>Language code</h4>''')) layout.addWidget(lcode_head) lang_hlayout = QHBoxLayout() lc_label = QLabel(_(u'Language code:'), self) lang_hlayout.addWidget(lc_label) lc_label.setToolTip(language_help) self.language_code_lineedit = QLineEdit(self) try: self.language_code_lineedit.setText(self.language_code) except: self.language_code_lineedit.setText(default_audio_language_code) lang_hlayout.addWidget(self.language_code_lineedit) self.language_code_lineedit.setToolTip(language_help) layout.addLayout(lang_hlayout) dialog_buttons = QDialogButtonBox(self) dialog_buttons.addButton(QDialogButtonBox.Cancel) dialog_buttons.addButton(QDialogButtonBox.Ok) self.connect(dialog_buttons, SIGNAL("accepted()"), self, SLOT("accept()")) self.connect(dialog_buttons, SIGNAL("rejected()"), self, SLOT("reject()")) layout.addWidget(dialog_buttons)
def __init__(self, name_string, definition_file): global MOD_STATES, MOD_SHIFT, MOD_CTL, MOD_ALT global KEYS_ALL, KEYS_ROW0, KEYS_ROW1, KEYS_ROW2, KEYS_ROW3, KEY_STYLE super(KeyPalette, self).__init__(parent=None) # Recall (or establish) the dialog geometry from global settings self.name = name_string # DO WE WANT THE FOLLOWING CONSOLE OUTPUT? print('Loading palette "' + unicode(self.name) + '"') self.windowTitle = QString(self.name).append(u' Text Entry') self.size_key = QString(self.name).append("/size") self.pos_key = QString(self.name).append("/position") self.resize( IMC.settings.value(self.size_key, QVariant(QSize(800, 300))).toSize()) self.move(IMC.settings.value(self.pos_key, QPoint(100, 100)).toPoint()) # # Here we keep track of the keyboard modifier state. self.mod_state = 0 # Create the magic LineEdit which we have to pass to each key. # See its class definition below. self.the_magic = MagicLineEdit(parent=self) # Direct that when keyboard focus enters this dialog in general, # that the magic lineEdit gets the focus. All keystroke events # are routed through its keyEvent handler. self.setFocusProxy(self.the_magic) # Build the key objects, saved in a dict keyed by the key letter. # # Make a dict of 8 values indexed by mod status, initialized to Nones. # One of these will be passed to each key object after we load them # from the palette file. value_dict = dict((m, None) for m in MOD_STATES) # Make one of those for each key object, indexed by key letter key_values = dict((char, value_dict.copy()) for char in KEYS_ALL) # Ready to read the CSV file. The csv.reader returns a list of # bytestrings. (Python 2.7 - might change in 3!) We need to convert # bytes to UTF-8. For some fields, force uppercase. For some, strip # possible whitespace and quotes. key_rdr = csv.reader(definition_file) for row in key_rdr: if len(row) != 3: continue # not a valid row, ignore it key = row[0].decode('UTF-8') if len(key) != 1: continue # not a single-letter key, skip the row if key not in KEYS_ALL: continue # not a key letter, skip the row # Convert second item into 0-7. Bring to Unicode, strip # any blanks or quotes (so, "LC" is ok), make uppercase. mod_code = row[1].decode('UTF-8').strip(' "').upper() # This will just ignore a bad mode-letter. If they are all # bad, it defaults to mode 0. Also treats UL as U. mod = 0 if 'U' in mod_code: mod |= MOD_SHIFT if 'C' in mod_code: mod |= MOD_CTL if 'A' in mod_code: mod |= MOD_ALT # Isolate the character value as Unicode, take off any # spaces or quotes. char_value = row[2].decode('UTF-8').strip(' "') char = None if char_value.isdigit(): # Value is all-decimal-digits, convert to a Unicode character try: char = unichr(int(char_value)) except ValueError: # invalid unicode number, diagnose & leave char as None print('bad unicode number: ' + row.__repr__()) elif len(char_value) < 6: # take 1-5 non-numeric characters as-is for the key value, # assuming one character perhaps with combining diacriticals char = char_value else: # 6 or more characters, assume it is a name like GREEK RHO try: char = unicodedata.lookup(char_value) except KeyError: # Unknown name, diagnose and leave char as None print('bad unicode name: ' + row.__repr__()) if char is None: continue # could not decode the value, toss the line # Stow the value in the key's dict under the mod value key_values[key][mod] = char # Ready to create the 36 key objects. Connect the .shift slot of # each to the ModStateChange signal out of the magic lineedit. self.key_objects = {} for key in KEYS_ALL: key_object = KeyButton(key_values[key], self.the_magic) self.key_objects[key] = key_object self.connect(self, SIGNAL("ModStateChange"), key_object.shift) # Style the key-objects. It doesn't work to have each KeyButton set # its own style sheet (why??) but this does. self.setStyleSheet(KEY_STYLE) # Ready to lay the dialog out. It is a stack of things in a VBox. # The top 4 things are the rows of the keys. layout = QVBoxLayout() layout.addLayout(self.keyRow(KEYS_ROW0, 0, 30), stretch=1) layout.addLayout(self.keyRow(KEYS_ROW1, 30, 0), stretch=1) layout.addLayout(self.keyRow(KEYS_ROW2, 0, 30), stretch=1) layout.addLayout(self.keyRow(KEYS_ROW3, 0, 0), stretch=1) # Make the strip of controls for the bottom: # Three action buttons: btn_insert = QPushButton('Insert') btn_clear = QPushButton('Clear') btn_copy = QPushButton('Copy') # A two-button radio set, [x]Unicode [ ]HTML radio_frame = QFrame() radio_frame.setFrameStyle(QFrame.StyledPanel) radio_frame.setFrameShadow(QFrame.Sunken) radio_frame.setLineWidth(3) btn_unicode = QRadioButton('Unicode') btn_unicode.setChecked(True) #start with unicode selected btn_html = QRadioButton('HTML') radio_hb = QHBoxLayout() radio_hb.addWidget(btn_unicode) radio_hb.addWidget(btn_html) radio_frame.setLayout(radio_hb) # Lay out the bottom section hbox = QHBoxLayout() hbox.addWidget(btn_insert, stretch=0) hbox.addWidget(self.the_magic, stretch=1) hbox.addWidget(btn_copy, stretch=0) hbox.addWidget(btn_clear, stretch=0) hbox.addWidget(radio_frame, stretch=0) layout.addLayout(hbox) self.setLayout(layout) # Save a reference to the HTML radio button so we can query it # when doing Insert. self.html_button = btn_html # Set up signals from the buttons to our methods below self.connect(btn_insert, SIGNAL("clicked()"), self.doInsert) self.connect(btn_copy, SIGNAL("clicked()"), self.doCopy) self.connect(btn_clear, SIGNAL("clicked()"), self.the_magic.clear)
def insertLayout(self): def createPixmapWidget(self, parent, iconName): w = QLabel(parent) parent.layout().addWidget(w) w.setFixedSize(16, 16) w.hide() if os.path.exists(iconName): w.setPixmap(QPixmap(iconName)) return w self.setLayout(QVBoxLayout()) self.layout().setMargin(2) self.warning_bar = gui.widgetBox(self, orientation="horizontal", margin=0, spacing=0) self.warning_icon = gui.widgetLabel(self.warning_bar, "") self.warning_label = gui.widgetLabel(self.warning_bar, "") self.warning_label.setStyleSheet("padding-top: 5px") self.warning_bar.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Maximum) gui.rubber(self.warning_bar) self.warning_bar.setVisible(False) self.want_main_area = self.graph_name is not None or self.want_main_area splitter = self.Splitter(Qt.Horizontal, self) self.layout().addWidget(splitter) if self.want_control_area: self.controlArea = gui.widgetBox(splitter, orientation="vertical", margin=0) splitter.setSizes([1]) # Results in smallest size allowed by policy if self.graph_name is not None or hasattr(self, "send_report"): leftSide = self.controlArea self.controlArea = gui.widgetBox(leftSide, margin=0) if self.graph_name is not None: self.graphButton = gui.button(leftSide, None, "&Save Graph") self.graphButton.clicked.connect(self.save_graph) self.graphButton.setAutoDefault(0) if hasattr(self, "send_report"): self.report_button = gui.button(leftSide, None, "&Report", callback=self.show_report) self.report_button.setAutoDefault(0) if self.want_main_area: self.controlArea.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.MinimumExpanding) self.controlArea.layout().setContentsMargins(4, 4, 0 if self.want_main_area else 4, 4) if self.want_main_area: self.mainArea = gui.widgetBox(splitter, orientation="vertical", margin=4, sizePolicy=QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) splitter.setCollapsible(1, False) self.mainArea.layout().setContentsMargins(0 if self.want_control_area else 4, 4, 4, 4) if self.want_status_bar: self.widgetStatusArea = QFrame(self) self.statusBarIconArea = QFrame(self) self.widgetStatusBar = QStatusBar(self) self.layout().addWidget(self.widgetStatusArea) self.widgetStatusArea.setLayout(QHBoxLayout(self.widgetStatusArea)) self.widgetStatusArea.layout().addWidget(self.statusBarIconArea) self.widgetStatusArea.layout().addWidget(self.widgetStatusBar) self.widgetStatusArea.layout().setMargin(0) self.widgetStatusArea.setFrameShape(QFrame.StyledPanel) self.statusBarIconArea.setLayout(QHBoxLayout()) self.widgetStatusBar.setSizeGripEnabled(0) self.statusBarIconArea.hide() self._warningWidget = createPixmapWidget( self.statusBarIconArea, gui.resource_filename("icons/triangle-orange.png")) self._errorWidget = createPixmapWidget( self.statusBarIconArea, gui.resource_filename("icons/triangle-red.png")) if not self.resizing_enabled: self.layout().setSizeConstraint(QVBoxLayout.SetFixedSize)
def __init__(self, parent): QFrame.__init__(self, parent) while not isinstance(parent, QDialog): parent = parent.parent() self.setObjectName("WindPanel" + str(len(parent.findChildren(WindPanel)))) # self.frame_WindIA = QFrame(parent) sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.setFrameShape(QFrame.StyledPanel) self.setFrameShadow(QFrame.Raised) self.setObjectName(("frame_WindIA")) self.hLayout = QHBoxLayout(self) self.hLayout.setSpacing(0) self.hLayout.setMargin(0) self.hLayout.setObjectName(("hLayout")) self.basicFrame = Frame(self, "HL") self.hLayout.addWidget(self.basicFrame) self.lblIA = QLabel(self.basicFrame) self.lblIA.setMinimumSize(QSize(200, 0)) self.lblIA.setMaximumSize(QSize(200, 16777215)) font = QFont() font.setFamily(("Arial")) font.setBold(False) font.setWeight(50) self.lblIA.setFont(font) self.lblIA.setObjectName(("lblIA")) self.basicFrame.Add = self.lblIA self.comboBox = QComboBox(self.basicFrame) # sizePolicy = QSizePolicy(QSizePolicy.Minimum, QSizePolicy.Fixed) # sizePolicy.setHorizontalStretch(0) # sizePolicy.setVerticalStretch(0) # sizePolicy.setHeightForWidth(self.comboBox.sizePolicy().hasHeightForWidth()) # self.comboBox.setSizePolicy(sizePolicy) # self.comboBox.setMinimumSize(QSize(60, 0)) font = QFont() font.setFamily(("Arial")) font.setBold(False) font.setWeight(50) self.comboBox.setFont(font) self.comboBox.setObjectName(("comboBox")) self.basicFrame.Add = self.comboBox self.speedBox = QLineEdit(self.basicFrame) # sizePolicy = QSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Fixed) # sizePolicy.setHorizontalStretch(0) # sizePolicy.setVerticalStretch(0) # sizePolicy.setHeightForWidth(self.speedBox.sizePolicy().hasHeightForWidth()) # self.speedBox.setSizePolicy(sizePolicy) # self.speedBox.setMinimumSize(QSize(70, 0)) # self.speedBox.setMaximumSize(QSize(16777215, 16777215)) font = QFont() font.setFamily(("Arial")) font.setBold(False) font.setWeight(50) self.speedBox.setFont(font) self.speedBox.setObjectName(("speedBox")) self.speedBox.setMinimumSize(QSize(60, 0)) self.speedBox.setMaximumSize(QSize(60, 16777215)) self.basicFrame.Add = self.speedBox spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) self.basicFrame.layoutBoxPanel.addItem(spacerItem) self.altitude = Altitude.NaN() self.customValue = Speed(30).Knots self.comboBox.addItems(["ICAO", "UK", "Custom"]) self.comboBox.currentIndexChanged.connect(self.changeWindType) self.comboBox.setCurrentIndex(0) self.lblIA.setText("Wind (kts):") self.speedBox.setEnabled(False)
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 __init__(self, *args, **kwargs): super(ShortcutManagerDlg, self).__init__(*args, **kwargs) self.setWindowTitle("Shortcut Preferences") self.setMinimumWidth(500) self.setMinimumHeight(500) mgr = ShortcutManager() # Singleton scrollWidget = QWidget(parent=self) tempLayout = QVBoxLayout(scrollWidget) scrollWidget.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) treeWidget = QTreeWidget(parent=scrollWidget) treeWidget.setHeaderLabels(["Action", "Shortcut"]) treeWidget.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) treeWidget.setColumnWidth(0, 300) treeWidget.setColumnWidth(1, 50) action_descriptions = mgr.get_all_action_descriptions() target_keyseqs = mgr.get_keyseq_reversemap() # Create a LineEdit for each shortcut, # and keep track of them in a dict shortcutEdits = collections.OrderedDict() for group, targets in action_descriptions.items(): groupItem = QTreeWidgetItem(treeWidget, QStringList(group)) for (name, description) in targets: edit = QLineEdit(target_keyseqs[(group, name)]) shortcutEdits[(group, name)] = edit item = QTreeWidgetItem(groupItem, QStringList(description)) item.setText(0, description) treeWidget.setItemWidget(item, 1, edit) tempLayout.addWidget(treeWidget) # Add ok and cancel buttons buttonLayout = QHBoxLayout() cancelButton = QPushButton("Cancel") cancelButton.clicked.connect(self.reject) okButton = QPushButton("OK") okButton.clicked.connect(self.accept) okButton.setDefault(True) buttonLayout.addSpacerItem(QSpacerItem(10, 0, QSizePolicy.Expanding)) buttonLayout.addWidget(cancelButton) buttonLayout.addWidget(okButton) tempLayout.addLayout(buttonLayout) scroll = QScrollArea(parent=self) scroll.setWidget(scrollWidget) scroll.setWidgetResizable(True) scroll.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred) dlgLayout = QVBoxLayout() dlgLayout.addWidget(scroll) self.setLayout(dlgLayout) # Show the window result = self.exec_() # Did the user hit 'cancel'? if result != QDialog.Accepted: return for (group, name), edit in shortcutEdits.items(): oldKey = target_keyseqs[(group, name)] newKey = str(edit.text()) if oldKey.lower() != newKey.lower() and newKey != "": mgr.change_keyseq(group, name, oldKey, newKey) mgr.store_to_preferences()
def __init__(self, *args): PluginBase.__init__(self, BrickletPiezoSpeaker, *args) self.ps = self.device self.qtcb_beep_finished.connect(self.cb_beep) self.ps.register_callback(self.ps.CALLBACK_BEEP_FINISHED, self.qtcb_beep_finished.emit) self.qtcb_morse_finished.connect(self.cb_morse) self.ps.register_callback(self.ps.CALLBACK_MORSE_CODE_FINISHED, self.qtcb_morse_finished.emit) self.has_stoppable_beep = self.firmware_version >= (2, 0, 2) self.frequency_label = QLabel('Frequency (585Hz-7100Hz): ') self.frequency_box = QSpinBox() self.frequency_box.setMinimum(585) self.frequency_box.setMaximum(7100) self.frequency_box.setValue(1000) self.frequency_layout = QHBoxLayout() self.frequency_layout.addWidget(self.frequency_label) self.frequency_layout.addWidget(self.frequency_box) self.frequency_layout.addStretch() self.beep_box = QSpinBox() self.beep_box.setMinimum(0) self.beep_box.setMaximum(2147483647) self.beep_box.setValue(1000) self.beep_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self.beep_label = QLabel('Duration (ms): ') self.beep_button = QPushButton('Send Beep') self.beep_layout = QHBoxLayout() self.beep_layout.addWidget(self.beep_label) self.beep_layout.addWidget(self.beep_box) self.beep_layout.addWidget(self.beep_button) self.morse_edit = QLineEdit() self.morse_edit.setText('- .. -. -.- . .-. ..-. --- .-. --. .') self.morse_edit.setMaxLength(60) self.morse_label = QLabel('Morse Code: ') self.morse_button = QPushButton('Send Morse Code') self.morse_layout = QHBoxLayout() self.morse_layout.addWidget(self.morse_label) self.morse_layout.addWidget(self.morse_edit) self.morse_layout.addWidget(self.morse_button) self.calibrate_button = QPushButton('Calibrate') self.scale_button = QPushButton('Play Scale') self.scale_layout = QHBoxLayout() self.scale_layout.addWidget(self.scale_button) self.scale_layout.addWidget(self.calibrate_button) self.scale_layout.addStretch() self.calibrate_layout = QHBoxLayout() self.calibrate_layout.addStretch() self.scale_timer = QTimer() self.scale_timer.setInterval(25) self.scale_time = 585 self.status_label = QLabel('') self.beep_button.clicked.connect(self.beep_clicked) self.morse_button.clicked.connect(self.morse_clicked) self.scale_button.clicked.connect(self.scale_clicked) self.scale_timer.timeout.connect(self.scale_timeout) self.calibrate_button.clicked.connect(self.calibrate_clicked) layout = QVBoxLayout(self) layout.addLayout(self.frequency_layout) layout.addLayout(self.beep_layout) layout.addLayout(self.morse_layout) layout.addLayout(self.scale_layout) layout.addWidget(self.status_label) # layout.addLayout(self.calibrate_layout) layout.addStretch()
def __init__(self, parent=None): super(RecordingWidget, self).__init__(parent) icon = QIcon() icon.addPixmap(QPixmap(":/freeseer/logo.png"), QIcon.Normal, QIcon.Off) self.setWindowIcon(icon) self.resize(400, 400) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) self.setStyleSheet(""" QToolButton { background-color: #D1D1D1; border-style: solid; border-width: 1px; border-radius: 10px; border-color: #969696; padding: 6px; } QToolButton:pressed { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:checked { background-color: #A3A2A2; border-width: 2px; border-color: #707070; } QToolButton:disabled { background-color: #EDEDED; border-color: #BFBDBD; } QToolButton:hover { border-width: 2px; } """) boldFont = QFont() boldFont.setBold(True) fontSize = self.font().pixelSize() fontUnit = "px" if fontSize == -1: # Font is set as points, not pixels. fontUnit = "pt" fontSize = self.font().pointSize() # Control bar self.controlRow = QHBoxLayout() self.mainLayout.addLayout(self.controlRow) self.recordIcon = QIcon(":/multimedia/record.png") self.stopIcon = QIcon(":/multimedia/stop.png") pauseIcon = QIcon(":/multimedia/pause.png") playIcon = QIcon(":/multimedia/play.png") self.headphoneIcon = QIcon() self.headphoneIcon.addPixmap(QPixmap(":/multimedia/headphones.png"), QIcon.Normal, QIcon.Off) self.is_recording = False self.recordButton = QToolButtonWithDpi() self.recordButton.setToolTip("Record") self.recordButton.setFixedSize(QSize(60, 40)) self.recordButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.recordButton.setIcon(self.recordIcon) self.recordButton.setEnabled(False) self.recordButton.setObjectName("recordButton") self.controlRow.addWidget(self.recordButton, 0, Qt.AlignLeft) self.connect(self.recordButton, SIGNAL("clicked()"), self.setRecordIcon) self.playButton = QToolButtonWithDpi() self.playButton.setToolTip("Play last recorded Video") self.playButton.setFixedSize(QSize(60, 40)) self.playButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.playButton.setIcon(playIcon) self.playButton.setEnabled(False) self.controlRow.addWidget(self.playButton, 0, Qt.AlignLeft) self.pauseButton = QToolButtonWithDpi() self.pauseButton.setToolTip("Pause") self.pauseButton.setIcon(pauseIcon) self.pauseButton.setFixedSize(QSize(60, 40)) self.pauseButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.pauseButton.setEnabled(False) self.pauseButton.setCheckable(True) self.controlRow.addWidget(self.pauseButton, 0, Qt.AlignLeft) self.controlRow.addSpacerItem(self.qspacer_item_with_dpi(30, 40)) self.controlRow.addStretch(1) self.standbyButton = QPushButtonWithDpi("Standby") self.standbyButton.setStyleSheet(""" QPushButton {{ color: white; background-color: #47a447; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #398439; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #3E8A3E; border-color: #327532; }} QPushButton:hover {{ border-width: 2px; }} """.format(fontSize + 3, fontUnit)) self.standbyButton.setToolTip("Standby") self.standbyButton.setFixedSize(QSize(180, 40)) self.standbyButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.standbyButton.setCheckable(True) self.standbyButton.setObjectName("standbyButton") self.controlRow.addWidget(self.standbyButton) self.disengageButton = QPushButtonWithDpi("Leave record-mode") self.disengageButton.setStyleSheet(""" QPushButton {{ color: white; background-color: #D14343; border-style: solid; border-width: 0px; border-radius: 10px; border-color: #B02C2C; font: bold {}{}; padding: 6px; }} QPushButton:pressed {{ background-color: #AD2B2B; border-color: #8C2929; }} QPushButton:hover {{ border-width: 2px; }} QPushButton:disabled {{ background-color: #B89E9E; }} """.format(fontSize + 3, fontUnit)) self.disengageButton.setToolTip("Leave record-mode") self.disengageButton.setFixedSize(QSize(180, 40)) self.disengageButton.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.disengageButton.setHidden(True) self.disengageButton.setObjectName("disengageButton") self.controlRow.addWidget(self.disengageButton) # Filter bar self.filterBarLayout = QVBoxLayout() self.mainLayout.addLayout(self.filterBarLayout) self.filterBarLayoutRow_1 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_1) self.eventLabel = QLabel("Event") self.eventLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.eventComboBox = QComboBox() self.eventLabel.setBuddy(self.eventComboBox) self.roomLabel = QLabel("Room") self.roomLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.roomComboBox = QComboBox() self.roomLabel.setBuddy(self.roomComboBox) self.dateLabel = QLabel("Date") self.dateLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.dateComboBox = QComboBox() self.dateLabel.setBuddy(self.dateComboBox) self.filterBarLayoutRow_1.addWidget(self.eventLabel) self.filterBarLayoutRow_1.addWidget(self.eventComboBox) self.filterBarLayoutRow_1.addWidget(self.roomLabel) self.filterBarLayoutRow_1.addWidget(self.roomComboBox) self.filterBarLayoutRow_1.addWidget(self.dateLabel) self.filterBarLayoutRow_1.addWidget(self.dateComboBox) self.filterBarLayoutRow_2 = QHBoxLayout() self.filterBarLayout.addLayout(self.filterBarLayoutRow_2) self.talkLabel = QLabel("Talk ") self.talkLabel.setSizePolicy(QSizePolicy.Maximum, QSizePolicy.Fixed) self.talkComboBox = QComboBox() self.talkComboBox.setFont(boldFont) self.talkComboBox.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Maximum) self.talkComboBox.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self.filterBarLayoutRow_2.addWidget(self.talkLabel) self.filterBarLayoutRow_2.addWidget(self.talkComboBox) # Preview Layout self.previewLayout = QHBoxLayout() self.mainLayout.addLayout(self.previewLayout) self.previewWidget = QWidget() self.audioSlider = QSlider() self.audioSlider.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Expanding) self.audioSlider.setEnabled(False) self.previewLayout.addWidget(self.previewWidget) self.previewLayout.addWidget(self.audioSlider) self.statusLabel = QLabel() self.mainLayout.addWidget(self.statusLabel) # Audio Feedback Checkbox self.audioFeedbackCheckbox = QCheckBox() self.audioFeedbackCheckbox.setLayoutDirection(Qt.RightToLeft) self.audioFeedbackCheckbox.setIcon(self.headphoneIcon) self.audioFeedbackCheckbox.setToolTip("Enable Audio Feedback") self.mainLayout.addWidget(self.audioFeedbackCheckbox)
def initShape(self): self.hbox = QHBoxLayout() self.hbox.setSpacing(0) self.hbox.setContentsMargins(0, 0, 0, 0) self.tabWidget = QTabWidget() self.setLayout(self.hbox)
def __createLayout(self, action): """ Creates the dialog layout """ self.resize(650, 300) self.setSizeGripEnabled(True) # Top level layout layout = QVBoxLayout(self) # Cmd line arguments argsLabel = QLabel("Command line arguments") self.__argsEdit = QLineEdit() self.__argsEdit.textChanged.connect(self.__argsChanged) argsLayout = QHBoxLayout() argsLayout.addWidget(argsLabel) argsLayout.addWidget(self.__argsEdit) layout.addLayout(argsLayout) # Working directory workDirGroupbox = QGroupBox(self) workDirGroupbox.setTitle("Working directory") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( \ workDirGroupbox.sizePolicy().hasHeightForWidth() ) workDirGroupbox.setSizePolicy(sizePolicy) gridLayoutWD = QGridLayout(workDirGroupbox) self.__scriptWDRButton = QRadioButton(workDirGroupbox) self.__scriptWDRButton.setText("&Use script location") gridLayoutWD.addWidget(self.__scriptWDRButton, 0, 0) self.__scriptWDRButton.clicked.connect(self.__scriptWDirClicked) self.__dirRButton = QRadioButton(workDirGroupbox) self.__dirRButton.setText("Select &directory") gridLayoutWD.addWidget(self.__dirRButton, 1, 0) self.__dirRButton.clicked.connect(self.__dirClicked) self.__dirEdit = QLineEdit(workDirGroupbox) gridLayoutWD.addWidget(self.__dirEdit, 1, 1) self.__dirEdit.textChanged.connect(self.__workingDirChanged) self.__dirSelectButton = QPushButton(workDirGroupbox) self.__dirSelectButton.setText("...") gridLayoutWD.addWidget(self.__dirSelectButton, 1, 2) self.__dirSelectButton.clicked.connect(self.__selectDirClicked) layout.addWidget(workDirGroupbox) # Environment envGroupbox = QGroupBox(self) envGroupbox.setTitle("Environment") sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( \ envGroupbox.sizePolicy().hasHeightForWidth() ) envGroupbox.setSizePolicy(sizePolicy) layoutEnv = QVBoxLayout(envGroupbox) self.__inheritParentRButton = QRadioButton(envGroupbox) self.__inheritParentRButton.setText("Inherit &parent") self.__inheritParentRButton.clicked.connect(self.__inhClicked) layoutEnv.addWidget(self.__inheritParentRButton) self.__inheritParentPlusRButton = QRadioButton(envGroupbox) self.__inheritParentPlusRButton.setText( "Inherit parent and add/&modify") self.__inheritParentPlusRButton.clicked.connect(self.__inhPlusClicked) layoutEnv.addWidget(self.__inheritParentPlusRButton) hInhPlusLayout = QHBoxLayout() self.__inhPlusEnvTable = QTreeWidget() self.__inhPlusEnvTable.itemActivated.connect( self.__inhPlusItemActivated) self.__tuneTable(self.__inhPlusEnvTable) hInhPlusLayout.addWidget(self.__inhPlusEnvTable) vInhPlusLayout = QVBoxLayout() self.__addInhButton = QPushButton() self.__addInhButton.clicked.connect(self.__addInhClicked) self.__addInhButton.setText('Add') vInhPlusLayout.addWidget(self.__addInhButton) self.__delInhButton = QPushButton() self.__delInhButton.clicked.connect(self.__delInhClicked) self.__delInhButton.setText('Delete') vInhPlusLayout.addWidget(self.__delInhButton) self.__editInhButton = QPushButton() self.__editInhButton.clicked.connect(self.__editInhClicked) self.__editInhButton.setText("Edit") vInhPlusLayout.addWidget(self.__editInhButton) hInhPlusLayout.addLayout(vInhPlusLayout) layoutEnv.addLayout(hInhPlusLayout) self.__specificRButton = QRadioButton(envGroupbox) self.__specificRButton.setText("&Specific") self.__specificRButton.clicked.connect(self.__specClicked) layoutEnv.addWidget(self.__specificRButton) hSpecLayout = QHBoxLayout() self.__specEnvTable = QTreeWidget() self.__specEnvTable.itemActivated.connect(self.__specItemActivated) self.__tuneTable(self.__specEnvTable) hSpecLayout.addWidget(self.__specEnvTable) vSpecLayout = QVBoxLayout() self.__addSpecButton = QPushButton() self.__addSpecButton.clicked.connect(self.__addSpecClicked) self.__addSpecButton.setText('Add') vSpecLayout.addWidget(self.__addSpecButton) self.__delSpecButton = QPushButton() self.__delSpecButton.clicked.connect(self.__delSpecClicked) self.__delSpecButton.setText('Delete') vSpecLayout.addWidget(self.__delSpecButton) self.__editSpecButton = QPushButton() self.__editSpecButton.clicked.connect(self.__editSpecClicked) self.__editSpecButton.setText("Edit") vSpecLayout.addWidget(self.__editSpecButton) hSpecLayout.addLayout(vSpecLayout) layoutEnv.addLayout(hSpecLayout) layout.addWidget(envGroupbox) # Terminal and profile limits if self.__action in ["profile", "debug"]: layout.addWidget(self.__getIDEWideGroupbox()) else: termGroupbox = self.__getTermGroupbox() termGroupbox.setTitle("Terminal to run in (IDE wide setting)") layout.addWidget(termGroupbox) # Close checkbox self.__closeCheckBox = QCheckBox("&Close terminal upon " "successful completion") self.__closeCheckBox.stateChanged.connect(self.__onCloseChanged) layout.addWidget(self.__closeCheckBox) # Buttons at the bottom buttonBox = QDialogButtonBox(self) buttonBox.setOrientation(Qt.Horizontal) buttonBox.setStandardButtons(QDialogButtonBox.Cancel) self.__runButton = buttonBox.addButton(action, QDialogButtonBox.AcceptRole) self.__runButton.setDefault(True) self.__runButton.clicked.connect(self.onAccept) layout.addWidget(buttonBox) buttonBox.rejected.connect(self.close) return
def initUi(self): """初始化界面""" self.setWindowTitle(u'交易') self.setMaximumWidth(500) self.setFrameShape(self.Box) # 设置边框 self.setLineWidth(1) # 左边部分 labelSymbol = QLabel(u'代码') labelName = QLabel(u'名称') labelDirection = QLabel(u'方向类型') labelOffset = QLabel(u'开平') labelPrice = QLabel(u'价格') labelVolume = QLabel(u'数量') labelPriceType = QLabel(u'价格类型') labelExchange = QLabel(u'交易所') labelCurrency = QLabel(u'货币') labelProductClass = QLabel(u'产品类型') labelUrgency = QLabel(u'紧急度') self.lineSymbol = QLineEdit() self.lineName = QLineEdit() self.comboDirection = QComboBox() self.comboDirection.addItems(self.directionList) self.comboOffset = QComboBox() self.comboOffset.addItem('') self.comboOffset.addItems(self.offsetList) self.comboOffset.setEnabled(False) self.tickOffset = QCheckBox(u'指定') self.spinPrice = QDoubleSpinBox() self.spinPrice.setDecimals(4) self.spinPrice.setMinimum(0) self.spinPrice.setMaximum(100000) self.spinVolume = QSpinBox() self.spinVolume.setMinimum(0) self.spinVolume.setMaximum(1000000) self.comboPriceType = QComboBox() self.comboPriceType.addItems(self.priceTypeList) self.comboExchange = QComboBox() self.comboExchange.addItems(self.exchangeList) self.comboExchange.setEnabled(False) self.comboCurrency = QComboBox() self.comboCurrency.addItems(self.currencyList) self.comboCurrency.setEnabled(False) self.comboProductClass = QComboBox() self.comboProductClass.addItems(self.productClassList) self.comboProductClass.setEnabled(False) self.spinUrgency = QSpinBox() self.spinUrgency.setMinimum(1) self.spinUrgency.setMaximum(9) self.spinUrgency.setSingleStep(1) self.spinUrgency.setValue(5) gridleft = QGridLayout() gridleft.addWidget(labelSymbol, 0, 0) gridleft.addWidget(labelName, 1, 0) gridleft.addWidget(labelDirection, 2, 0) gridleft.addWidget(labelOffset, 3, 0) gridleft.addWidget(labelPrice, 4, 0) gridleft.addWidget(labelVolume, 5, 0) gridleft.addWidget(labelPriceType, 6, 0) gridleft.addWidget(labelUrgency, 7, 0) gridleft.addWidget(labelExchange, 8, 0) gridleft.addWidget(labelProductClass, 9, 0) gridleft.addWidget(labelCurrency, 10, 0) gridleft.addWidget(self.lineSymbol, 0, 1) gridleft.addWidget(self.lineName, 1, 1) gridleft.addWidget(self.comboDirection, 2, 1) hbox1 = QHBoxLayout() hbox1.addWidget(self.comboOffset) lable1 = QLabel() hbox1.addWidget(lable1) hbox1.addWidget(self.tickOffset) hbox1.setStretchFactor(self.comboOffset, 4) hbox1.setStretchFactor(lable1, 1) hbox1.setStretchFactor(self.tickOffset, 3) gridleft.addItem(hbox1, 3, 1) gridleft.addWidget(self.spinPrice, 4, 1) gridleft.addWidget(self.spinVolume, 5, 1) gridleft.addWidget(self.comboPriceType, 6, 1) gridleft.addWidget(self.spinUrgency, 7, 1) gridleft.addWidget(self.comboExchange, 8, 1) gridleft.addWidget(self.comboProductClass, 9, 1) gridleft.addWidget(self.comboCurrency, 10, 1) # 右边部分 labelBid1 = QLabel(u'买一') labelBid2 = QLabel(u'买二') labelBid3 = QLabel(u'买三') labelBid4 = QLabel(u'买四') labelBid5 = QLabel(u'买五') labelAsk1 = QLabel(u'卖一') labelAsk2 = QLabel(u'卖二') labelAsk3 = QLabel(u'卖三') labelAsk4 = QLabel(u'卖四') labelAsk5 = QLabel(u'卖五') self.labelBidPrice1 = QLabel() self.labelBidPrice2 = QLabel() self.labelBidPrice3 = QLabel() self.labelBidPrice4 = QLabel() self.labelBidPrice5 = QLabel() self.labelBidVolume1 = QLabel() self.labelBidVolume2 = QLabel() self.labelBidVolume3 = QLabel() self.labelBidVolume4 = QLabel() self.labelBidVolume5 = QLabel() self.labelAskPrice1 = QLabel() self.labelAskPrice2 = QLabel() self.labelAskPrice3 = QLabel() self.labelAskPrice4 = QLabel() self.labelAskPrice5 = QLabel() self.labelAskVolume1 = QLabel() self.labelAskVolume2 = QLabel() self.labelAskVolume3 = QLabel() self.labelAskVolume4 = QLabel() self.labelAskVolume5 = QLabel() labelLast = QLabel(u'最新') self.labelLastPrice = QLabel() self.labelReturn = QLabel() self.labelLastPrice.setMinimumWidth(60) self.labelReturn.setMinimumWidth(60) gridRight = QGridLayout() gridRight.addWidget(labelAsk5, 0, 0) gridRight.addWidget(labelAsk4, 1, 0) gridRight.addWidget(labelAsk3, 2, 0) gridRight.addWidget(labelAsk2, 3, 0) gridRight.addWidget(labelAsk1, 4, 0) gridRight.addWidget(labelLast, 5, 0) gridRight.addWidget(labelBid1, 6, 0) gridRight.addWidget(labelBid2, 7, 0) gridRight.addWidget(labelBid3, 8, 0) gridRight.addWidget(labelBid4, 9, 0) gridRight.addWidget(labelBid5, 10, 0) gridRight.addWidget(self.labelAskPrice5, 0, 1) gridRight.addWidget(self.labelAskPrice4, 1, 1) gridRight.addWidget(self.labelAskPrice3, 2, 1) gridRight.addWidget(self.labelAskPrice2, 3, 1) gridRight.addWidget(self.labelAskPrice1, 4, 1) gridRight.addWidget(self.labelLastPrice, 5, 1) gridRight.addWidget(self.labelBidPrice1, 6, 1) gridRight.addWidget(self.labelBidPrice2, 7, 1) gridRight.addWidget(self.labelBidPrice3, 8, 1) gridRight.addWidget(self.labelBidPrice4, 9, 1) gridRight.addWidget(self.labelBidPrice5, 10, 1) gridRight.addWidget(self.labelAskVolume5, 0, 2) gridRight.addWidget(self.labelAskVolume4, 1, 2) gridRight.addWidget(self.labelAskVolume3, 2, 2) gridRight.addWidget(self.labelAskVolume2, 3, 2) gridRight.addWidget(self.labelAskVolume1, 4, 2) gridRight.addWidget(self.labelReturn, 5, 2) gridRight.addWidget(self.labelBidVolume1, 6, 2) gridRight.addWidget(self.labelBidVolume2, 7, 2) gridRight.addWidget(self.labelBidVolume3, 8, 2) gridRight.addWidget(self.labelBidVolume4, 9, 2) gridRight.addWidget(self.labelBidVolume5, 10, 2) # 发单按钮 buttonSendOrder = QPushButton(u'发单') buttonCancelAll = QPushButton(u'全撤') size = buttonSendOrder.sizeHint() buttonSendOrder.setMinimumHeight(size.height() * 2) # 把按钮高度设为默认两倍 buttonCancelAll.setMinimumHeight(size.height() * 2) # 整合布局 hbox = QHBoxLayout() hbox.addLayout(gridleft) hbox.addLayout(gridRight) vbox = QVBoxLayout() vbox.addLayout(hbox) vbox.addWidget(buttonSendOrder) vbox.addWidget(buttonCancelAll) vbox.addStretch() self.setLayout(vbox) # 关联更新 buttonSendOrder.clicked.connect(self.sendOrder) buttonCancelAll.clicked.connect(self.cancelAll) self.lineSymbol.returnPressed.connect(self.updateSymbol) self.comboDirection.currentIndexChanged.connect(self.updateOffset) self.tickOffset.stateChanged.connect(self.updateOffset) self.labelAskPrice1.mouseDoubleClickEvent = self.ask1clicked self.labelAskPrice2.mouseDoubleClickEvent = self.ask2clicked self.labelAskPrice3.mouseDoubleClickEvent = self.ask3clicked self.labelAskPrice4.mouseDoubleClickEvent = self.ask4clicked self.labelAskPrice5.mouseDoubleClickEvent = self.ask5clicked self.labelBidPrice1.mouseDoubleClickEvent = self.bid1clicked self.labelBidPrice2.mouseDoubleClickEvent = self.bid2clicked self.labelBidPrice3.mouseDoubleClickEvent = self.bid3clicked self.labelBidPrice4.mouseDoubleClickEvent = self.bid4clicked self.labelBidPrice5.mouseDoubleClickEvent = self.bid5clicked self.labelLastPrice.mouseDoubleClickEvent = self.lastclicked
def __init__(self, run_model): QDialog.__init__(self) self.setWindowFlags(self.windowFlags() & ~Qt.WindowContextHelpButtonHint) self.setWindowFlags(self.windowFlags() & ~Qt.WindowCloseButtonHint) self.setModal(True) self.setWindowTitle("Simulations") assert isinstance(run_model, RunModelMixin) self.__run_model = run_model layout = QVBoxLayout() layout.setSizeConstraint(QLayout.SetFixedSize) self.simulations_tracker = SimulationsTracker() states = self.simulations_tracker.getList() self.total_progress = SimpleProgress() layout.addWidget(self.total_progress) status_layout = QHBoxLayout() status_layout.addStretch() self.__status_label = QLabel() status_layout.addWidget(self.__status_label) status_layout.addStretch() layout.addLayout(status_layout) self.progress = Progress() self.progress.setIndeterminateColor(self.total_progress.color) for state in states: self.progress.addState(state.state, QColor(*state.color), 100.0 * state.count / state.total_count) layout.addWidget(self.progress) legend_layout = QHBoxLayout() self.legends = {} for state in states: self.legends[state] = Legend("%s (%d/%d)", QColor(*state.color)) self.legends[state].updateLegend(state.name, 0, 0) legend_layout.addWidget(self.legends[state]) layout.addLayout(legend_layout) self.running_time = QLabel("") self.kill_button = QPushButton("Kill simulations") self.done_button = QPushButton("Done") self.done_button.setHidden(True) button_layout = QHBoxLayout() size = 20 spin_movie = util.resourceMovie("ide/loading.gif") spin_movie.setSpeed(60) spin_movie.setScaledSize(QSize(size, size)) spin_movie.start() self.processing_animation = QLabel() self.processing_animation.setMaximumSize(QSize(size, size)) self.processing_animation.setMinimumSize(QSize(size, size)) self.processing_animation.setMovie(spin_movie) button_layout.addWidget(self.processing_animation) button_layout.addWidget(self.running_time) button_layout.addStretch() button_layout.addWidget(self.kill_button) button_layout.addWidget(self.done_button) layout.addStretch() layout.addLayout(button_layout) self.setLayout(layout) self.kill_button.clicked.connect(self.killJobs) self.done_button.clicked.connect(self.accept) self.__updating = False self.__update_queued = False self.__simulation_started = False self.__update_timer = QTimer(self) self.__update_timer.setInterval(500) self.__update_timer.timeout.connect(self.updateRunStatus)
def __init__(self, parent, isArea=False): QWidget.__init__(self, parent) while not isinstance(parent, QDialog): parent = parent.parent() self.setObjectName("TextBoxPanel" + str(len(parent.findChildren(TextBoxPanel)))) self.hLayoutBoxPanel = QHBoxLayout(self) self.hLayoutBoxPanel.setSpacing(0) self.hLayoutBoxPanel.setContentsMargins(0, 0, 0, 0) self.hLayoutBoxPanel.setObjectName(("hLayoutBoxPanel")) self.frameBoxPanel = QFrame(self) sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frameBoxPanel.sizePolicy().hasHeightForWidth()) self.frameBoxPanel.setSizePolicy(sizePolicy) self.frameBoxPanel.setFrameShape(QFrame.NoFrame) self.frameBoxPanel.setFrameShadow(QFrame.Raised) self.frameBoxPanel.setObjectName(("frameBoxPanel")) self.hLayoutframeBoxPanel = QHBoxLayout(self.frameBoxPanel) self.hLayoutframeBoxPanel.setSpacing(0) self.hLayoutframeBoxPanel.setMargin(0) self.hLayoutframeBoxPanel.setObjectName(("hLayoutframeBoxPanel")) self.captionLabel = QLabel(self.frameBoxPanel) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.captionLabel.sizePolicy().hasHeightForWidth()) self.captionLabel.setSizePolicy(sizePolicy) self.captionLabel.setMinimumSize(QSize(200, 0)) self.captionLabel.setMaximumSize(QSize(200, 16777215)) font = QFont() font.setBold(False) font.setWeight(50) self.captionLabel.setFont(font) self.captionLabel.setObjectName(("captionLabel")) self.hLayoutframeBoxPanel.addWidget(self.captionLabel) if not isArea: self.textBox = QLineEdit(self.frameBoxPanel) self.textBox.setEnabled(True) font = QFont() font.setBold(False) font.setWeight(50) self.textBox.setFont(font) self.textBox.setObjectName(("textBox")) self.textBox.setMinimumWidth(70) self.textBox.setMaximumWidth(70) # self.textBox.setText("0.0") self.hLayoutframeBoxPanel.addWidget(self.textBox) else: self.textBox = QTextEdit(self.frameBoxPanel) self.textBox.setEnabled(True) font = QFont() font.setBold(False) font.setWeight(50) self.textBox.setFont(font) self.textBox.setObjectName(("textBox")) # self.textBox.setText("0.0") self.textBox.setMaximumHeight(60) self.hLayoutframeBoxPanel.addWidget(self.textBox) self.imageButton = QPushButton(self.frameBoxPanel) self.imageButton.setText(("")) icon = QIcon() icon.addPixmap(QPixmap(("Resource/convex_hull.png")), QIcon.Normal, QIcon.Off) self.imageButton.setIcon(icon) self.imageButton.setObjectName(("imageButton")) self.imageButton.setVisible(False) self.hLayoutframeBoxPanel.addWidget(self.imageButton) self.hLayoutBoxPanel.addWidget(self.frameBoxPanel) self.spacerItem = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) self.hLayoutframeBoxPanel.addItem(self.spacerItem) self.textBox.textChanged.connect(self.textBoxChanged) self.imageButton.clicked.connect(self.imageButtonClicked) self.textBox.setText("") self.captionUnits = "" self.isArea = isArea
def __init__(self, parent=None): ''' Constructor ''' QWidget.__init__(self, parent) self.mainLayout = QVBoxLayout() self.setLayout(self.mainLayout) # # Import Layout # self.importLayout = QHBoxLayout() self.mainLayout.addLayout(self.importLayout) self.importTypeComboBox = QComboBox() self.importTypeComboBox.addItem("RSS") self.importTypeComboBox.addItem("CSV") self.importLayout.addWidget(self.importTypeComboBox) # # RSS Layout # self.rssWidget = QWidget() self.rssLayout = QHBoxLayout() self.rssWidget.setLayout(self.rssLayout) self.rssLabel = QLabel("URL") self.rssLineEdit = QLineEdit() if hasattr(QLineEdit(), 'setPlaceholderText'): self.rssLineEdit.setPlaceholderText("http://www.example.com/rss") self.rssLabel.setBuddy(self.rssLineEdit) self.rssPushButton = QPushButton("Load talks from RSS") rss_icon = QIcon() rss_icon.addPixmap(QPixmap(":/multimedia/rss.png"), QIcon.Normal, QIcon.Off) self.rssPushButton.setIcon(rss_icon) self.rssLayout.addWidget(self.rssLabel) self.rssLayout.addWidget(self.rssLineEdit) self.rssLayout.addWidget(self.rssPushButton) self.importLayout.addWidget(self.rssWidget) # # CSV Layout # self.csvWidget = QWidget() self.csvWidget.hide() self.csvLayout = QHBoxLayout() self.csvWidget.setLayout(self.csvLayout) self.csvLabel = QLabel("File") self.csvLineEdit = QLineEdit() if sys.platform == 'win32': if hasattr(QLineEdit(), 'setPlaceholderText'): self.csvLineEdit.setPlaceholderText("C:\Example\Freeseer2011.csv") else: if hasattr(QLineEdit(), 'setPlaceholderText'): self.csvLineEdit.setPlaceholderText("/home/freeseer/Example/Freeseer2011.csv") self.csvLabel.setBuddy(self.csvLineEdit) self.csvFileSelectButton = QToolButton() self.csvFileSelectButton.setText("...") self.csvPushButton = QPushButton("Load talks from CSV") self.csvLayout.addWidget(self.csvLabel) self.csvLayout.addWidget(self.csvLineEdit) self.csvLayout.addWidget(self.csvFileSelectButton) self.csvLayout.addWidget(self.csvPushButton) self.importLayout.addWidget(self.csvWidget) # # Editor Layout # self.editorLayout = QHBoxLayout() self.mainLayout.addLayout(self.editorLayout) self.buttonsLayout = QVBoxLayout() self.editorLayout.addLayout(self.buttonsLayout) addIcon = QIcon.fromTheme("list-add") removeIcon = QIcon.fromTheme("list-remove") clearIcon = QIcon.fromTheme("edit-clear") closeIcon = QIcon.fromTheme("application-exit") self.addButton = QPushButton("Add") self.addButton.setIcon(addIcon) self.removeButton = QPushButton("Remove") self.removeButton.setIcon(removeIcon) self.clearButton = QPushButton("Clear") self.clearButton.setIcon(clearIcon) self.closeButton = QPushButton("Close") self.closeButton.setIcon(closeIcon) self.buttonsLayout.addWidget(self.addButton) self.buttonsLayout.addWidget(self.removeButton) self.buttonsLayout.addWidget(self.clearButton) self.buttonsLayout.addStretch(0) self.buttonsLayout.addWidget(self.closeButton) self.editor = QTableView() self.editor.setAlternatingRowColors(True) self.editor.setSortingEnabled(True) self.editorLayout.addWidget(self.editor) # # Widget Connections # self.connect(self.importTypeComboBox, SIGNAL('currentIndexChanged(const QString&)'), self.switch_import_plugin)
def setup_ui(self): vbox = QVBoxLayout(self) vbox.setContentsMargins(0, 0, 0, 0) vbox.setSpacing(0) self.__toolbar = QToolBar() self.__toolbar.setObjectName('custom') hbox = QHBoxLayout() vbox.addLayout(hbox) self.stack = StackedWidget() vbox.addWidget(self.stack) self._console = console_widget.ConsoleWidget() self.stack.addWidget(self._console) self._runWidget = run_widget.RunWidget() self.stack.addWidget(self._runWidget) self._web = web_render.WebRender() self.stack.addWidget(self._web) self._findInFilesWidget = find_in_files.FindInFilesWidget( self.parent()) self.stack.addWidget(self._findInFilesWidget) #Last Element in the Stacked widget self._results = results.Results(self) self.stack.addWidget(self._results) self._btnConsole = QPushButton(QIcon(":img/console"), '') self._btnConsole.setToolTip(self.tr("Console")) self._btnRun = QPushButton(QIcon(":img/play"), '') self._btnRun.setToolTip(self.tr("Output")) self._btnWeb = QPushButton(QIcon(":img/web"), '') self._btnWeb.setToolTip(self.tr("Web Preview")) self._btnFind = QPushButton(QIcon(":img/find"), '') self._btnFind.setToolTip(self.tr("Find in Files")) #Toolbar hbox.addWidget(self.__toolbar) self.__toolbar.addWidget(self._btnConsole) self.__toolbar.addWidget(self._btnRun) self.__toolbar.addWidget(self._btnWeb) self.__toolbar.addWidget(self._btnFind) self.__toolbar.addSeparator() hbox.addSpacerItem(QSpacerItem(1, 0, QSizePolicy.Expanding)) btn_close = QPushButton( self.style().standardIcon(QStyle.SP_DialogCloseButton), '') btn_close.setObjectName('navigation_button') btn_close.setToolTip(self.tr('F4: Show/Hide')) hbox.addWidget(btn_close) # Not Configurable Shortcuts shortEscMisc = QShortcut(QKeySequence(Qt.Key_Escape), self) self.connect(shortEscMisc, SIGNAL("activated()"), self.hide) self.connect(self._btnConsole, SIGNAL("clicked()"), lambda: self._item_changed(0)) self.connect(self._btnRun, SIGNAL("clicked()"), lambda: self._item_changed(1)) self.connect(self._btnWeb, SIGNAL("clicked()"), lambda: self._item_changed(2)) self.connect(self._btnFind, SIGNAL("clicked()"), lambda: self._item_changed(3)) self.connect(btn_close, SIGNAL('clicked()'), self.hide)