def add_to_layout(layout, *items): """Add items to QVBox and QHBox layouts easily. Keyword arguments: layout -- a layout oject (QVBoxLayout or QHBoxLayout) or a string if "v" or "h" create a QVBox or QHBox respectively *items -- list with items to be added """ if isinstance(layout, str): if layout == "v": layout = QVBoxLayout() elif layout == "h": layout = QHBoxLayout() else: raise TypeError("Invalid layout!") for item in items: if isinstance(item, QWidget): layout.addWidget(item) elif isinstance(item, QLayout): layout.addLayout(item) elif isinstance(item, QSpacerItem): layout.addItem(item) elif item is None: layout.addStretch() else: raise TypeError("Argument of wrong type!") return layout
def createWidgets(self, window): self.widget = QWidget() layout = QVBoxLayout() self.widget.setLayout(layout) grid = QGridLayout() grid.addWidget(QLabel(tr("Label:")), 0, 0) self.label = QLineEdit(u"label") grid.addWidget(self.label, 0, 1) grid.addWidget(QLabel(tr("Type:")), 1, 0) self.game_types = QComboBox() grid.addWidget(self.game_types, 1, 1) layout.addLayout(grid) spacer = createVerticalSpacer() layout.addItem(spacer) button_box = QHBoxLayout() layout.addLayout(button_box) refresh = QPushButton('&Create') button_box.addWidget(refresh) window.connect(refresh, SIGNAL('clicked()'), self.create) leave = QPushButton('&Leave') button_box.addWidget(leave) window.connect(leave, SIGNAL('clicked()'), self.abort)
def __init__(self): super(AboutTab, self).__init__() box = QVBoxLayout(self) box.setContentsMargins(0, 0, 0, 0) lbl_version = QLabel(self.tr("Versión: %s") % ui.__version__) label_descripcion = QLabel(self.tr( "a simple cross-platform IDE for C")) lbl_link = QLabel("Web: <a href='%s'><span style='color: #dedede;'>" "%s</span></a>" % (ui.__web__, ui.__web__)) lbl_sc = QLabel(self.tr("Código fuente: <a href='%s'><span style=" "'color: #dedede;'>%s</span></a>" % (ui.__codigo_fuente__, ui.__codigo_fuente__))) logo = QPixmap(paths.ICONOS['icon']) label_logo = QLabel() label_logo.setAlignment(Qt.AlignCenter) label_logo.setPixmap(logo) box.addWidget(label_descripcion) box.addWidget(lbl_version) box.addWidget(lbl_link) box.addWidget(lbl_sc) box.addItem(QSpacerItem(1, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) lbl_link.linkActivated.connect(lambda link: webbrowser.open(link)) lbl_sc.linkActivated.connect(lambda link: webbrowser.open(link))
def __init__(self, parent, layer): ''' Constructor ''' QDialog.__init__(self, parent) self.ui = Ui_VectorLayerProPertyDialog() self.ui.setupUi(self) self.ui.txtLayerName.setText(layer.name()) self.ui.txtLayerSource.setText(layer.source()) self.ui.txtCrs.setText(layer.crs().authid() + " - " + layer.crs().description()) self.ui.btnCrsSelect.clicked.connect(self.selectCrs) self.mCrs = layer.crs() self.vLayer = layer self.ui.mOptionsListWidget.currentRowChanged.connect( self.changeStackWidget) ''' init RenderV2 Widget''' self.mRendererDialog = QgsRendererV2PropertiesDialog( self.vLayer, QgsStyleV2.defaultStyle(), True) self.ui.stackedWidget.insertWidget(1, self.mRendererDialog) self.ui.buttonBox.accepted.connect(self.OK) frame_Label = QFrame() verticalLayout_Label = QVBoxLayout(frame_Label) self.mLabelWidget = QgsFieldExpressionWidget() self.mLabelWidget.setLayer(layer) verticalLayout_Label.addWidget(self.mLabelWidget) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) verticalLayout_Label.addItem(spacerItem) frame_Label.setLayout(verticalLayout_Label) self.ui.stackedWidget.insertWidget(2, frame_Label)
def setupUi(self): """layout the window""" self.setWindowTitle(m18n('Customize rulesets') + ' - Kajongg') self.setObjectName('Rulesets') hlayout = QHBoxLayout(self) v1layout = QVBoxLayout() self.v1widget = QWidget() v1layout = QVBoxLayout(self.v1widget) v2layout = QVBoxLayout() hlayout.addWidget(self.v1widget) hlayout.addLayout(v2layout) for widget in [self.v1widget, hlayout, v1layout, v2layout]: widget.setContentsMargins(0, 0, 0, 0) hlayout.setStretchFactor(self.v1widget, 10) self.btnCopy = QPushButton() self.btnRemove = QPushButton() self.btnCompare = QPushButton() self.btnClose = QPushButton() self.rulesetView = RuleTreeView(m18nc('kajongg','Rule'), self.btnCopy, self.btnRemove, self.btnCompare) v1layout.addWidget(self.rulesetView) self.rulesetView.setWordWrap(True) self.rulesetView.setMouseTracking(True) spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) v2layout.addWidget(self.btnCopy) v2layout.addWidget(self.btnRemove) v2layout.addWidget(self.btnCompare) self.btnCopy.clicked.connect(self.rulesetView.copyRow) self.btnRemove.clicked.connect(self.rulesetView.removeRow) self.btnCompare.clicked.connect(self.rulesetView.compareRow) self.btnClose.clicked.connect(self.hide) v2layout.addItem(spacerItem) v2layout.addWidget(self.btnClose) self.retranslateUi() StateSaver(self) self.show()
def __init__(self, parent): super(EditorCompletion, self).__init__() vbox = QVBoxLayout(self) groupBoxClose = QGroupBox(translations.TR_PREF_EDITOR_COMPLETE) formClose = QGridLayout(groupBoxClose) formClose.setContentsMargins(5, 15, 5, 5) self._checkParentheses = QCheckBox( translations.TR_PREF_EDITOR_PARENTHESES + " ()") self._checkParentheses.setChecked('(' in settings.BRACES) self._checkKeys = QCheckBox(translations.TR_PREF_EDITOR_KEYS + " {}") self._checkKeys.setChecked('{' in settings.BRACES) self._checkBrackets = QCheckBox(translations.TR_PREF_EDITOR_BRACKETS + " []") self._checkBrackets.setChecked('[' in settings.BRACES) self._checkSimpleQuotes = QCheckBox( translations.TR_PREF_EDITOR_SIMPLE_QUOTES) self._checkSimpleQuotes.setChecked("'" in settings.QUOTES) self._checkDoubleQuotes = QCheckBox( translations.TR_PREF_EDITOR_DOUBLE_QUOTES) self._checkDoubleQuotes.setChecked('"' in settings.QUOTES) self._checkCompleteDeclarations = QCheckBox( translations.TR_PREF_EDITOR_COMPLETE_DECLARATIONS.format( resources.get_shortcut("Complete-Declarations").toString( QKeySequence.NativeText))) self._checkCompleteDeclarations.setChecked( settings.COMPLETE_DECLARATIONS) formClose.addWidget(self._checkParentheses, 1, 1, alignment=Qt.AlignTop) formClose.addWidget(self._checkKeys, 1, 2, alignment=Qt.AlignTop) formClose.addWidget(self._checkBrackets, 2, 1, alignment=Qt.AlignTop) formClose.addWidget(self._checkSimpleQuotes, 2, 2, alignment=Qt.AlignTop) formClose.addWidget(self._checkDoubleQuotes, 3, 1, alignment=Qt.AlignTop) vbox.addWidget(groupBoxClose) groupBoxCode = QGroupBox(translations.TR_PREF_EDITOR_CODE_COMPLETION) formCode = QGridLayout(groupBoxCode) formCode.setContentsMargins(5, 15, 5, 5) self._checkCodeDot = QCheckBox( translations.TR_PREF_EDITOR_ACTIVATE_COMPLETION) self._checkCodeDot.setChecked(settings.CODE_COMPLETION) formCode.addWidget(self._checkCompleteDeclarations, 5, 1, alignment=Qt.AlignTop) formCode.addWidget(self._checkCodeDot, 6, 1, alignment=Qt.AlignTop) vbox.addWidget(groupBoxCode) vbox.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding))
def _init_widgets(self): self._ui.setupUi(self) layout = QVBoxLayout() layout.setSpacing(1) self._ui.input_canvas.setLayout(layout) layout = QVBoxLayout() layout.setContentsMargins(1, 0, 1, 1) self._ui.output_canvas.setLayout(layout) layout.addWidget(self._output_widget) spacer = QSpacerItem(5, 5, QSizePolicy.Minimum, QSizePolicy.Expanding) layout.addItem(spacer)
def __init__(self, parent): super(EditorCompletion, self).__init__() self._preferences = parent vbox = QVBoxLayout(self) groupBoxClose = QGroupBox(translations.TR_PREF_EDITOR_COMPLETE) formClose = QGridLayout(groupBoxClose) formClose.setContentsMargins(5, 15, 5, 5) self._checkParentheses = QCheckBox( translations.TR_PREF_EDITOR_PARENTHESES + " ()") self._checkParentheses.setChecked('(' in settings.BRACES) self._checkKeys = QCheckBox(translations.TR_PREF_EDITOR_KEYS + " {}") self._checkKeys.setChecked('{' in settings.BRACES) self._checkBrackets = QCheckBox( translations.TR_PREF_EDITOR_BRACKETS + " []") self._checkBrackets.setChecked('[' in settings.BRACES) self._checkSimpleQuotes = QCheckBox( translations.TR_PREF_EDITOR_SIMPLE_QUOTES) self._checkSimpleQuotes.setChecked("'" in settings.QUOTES) self._checkDoubleQuotes = QCheckBox( translations.TR_PREF_EDITOR_DOUBLE_QUOTES) self._checkDoubleQuotes.setChecked('"' in settings.QUOTES) self._checkCompleteDeclarations = QCheckBox( translations.TR_PREF_EDITOR_COMPLETE_DECLARATIONS.format( resources.get_shortcut("Complete-Declarations").toString( QKeySequence.NativeText))) self._checkCompleteDeclarations.setChecked( settings.COMPLETE_DECLARATIONS) formClose.addWidget(self._checkParentheses, 1, 1, alignment=Qt.AlignTop) formClose.addWidget(self._checkKeys, 1, 2, alignment=Qt.AlignTop) formClose.addWidget(self._checkBrackets, 2, 1, alignment=Qt.AlignTop) formClose.addWidget(self._checkSimpleQuotes, 2, 2, alignment=Qt.AlignTop) formClose.addWidget(self._checkDoubleQuotes, 3, 1, alignment=Qt.AlignTop) vbox.addWidget(groupBoxClose) groupBoxCode = QGroupBox(translations.TR_PREF_EDITOR_CODE_COMPLETION) formCode = QGridLayout(groupBoxCode) formCode.setContentsMargins(5, 15, 5, 5) self._checkCodeDot = QCheckBox( translations.TR_PREF_EDITOR_ACTIVATE_COMPLETION) self._checkCodeDot.setChecked(settings.CODE_COMPLETION) formCode.addWidget(self._checkCompleteDeclarations, 5, 1, alignment=Qt.AlignTop) formCode.addWidget(self._checkCodeDot, 6, 1, alignment=Qt.AlignTop) vbox.addWidget(groupBoxCode) vbox.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
class RegDemoDialog(QDialog): def __init__(self, parent, reg, prompt): flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint QDialog.__init__(self, parent, flags) self.reg = reg self._setupUi() self.descLabel.setText(prompt) self.enterCodeButton.clicked.connect(self.enterCodeClicked) self.buyButton.clicked.connect(self.buyClicked) self.tryButton.clicked.connect(self.accept) self.moreInfoButton.clicked.connect(self.moreInfoClicked) def _setupUi(self): appname = QCoreApplication.instance().applicationName() title = tr("$appname is Fairware") title = title.replace('$appname', appname) self.setWindowTitle(title) # Workaround for bug at http://bugreports.qt.nokia.com/browse/QTBUG-8212 dlg_height = 370 if ISLINUX else 240 self.resize(400, dlg_height) self.verticalLayout = QVBoxLayout(self) self.descLabel = QLabel(self) self.descLabel.setWordWrap(True) self.verticalLayout.addWidget(self.descLabel) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout = QHBoxLayout() self.tryButton = QPushButton(self) self.tryButton.setText(tr("Try")) self.horizontalLayout.addWidget(self.tryButton) self.enterCodeButton = QPushButton(self) self.enterCodeButton.setText(tr("Enter Key")) self.horizontalLayout.addWidget(self.enterCodeButton) self.buyButton = QPushButton(self) self.buyButton.setText(tr("Buy")) self.horizontalLayout.addWidget(self.buyButton) self.moreInfoButton = QPushButton(tr("Fairware?")) self.horizontalLayout.addWidget(self.moreInfoButton) self.verticalLayout.addLayout(self.horizontalLayout) #--- Events def enterCodeClicked(self): if self.reg.ask_for_code(): self.accept() def buyClicked(self): self.reg.app.buy() def moreInfoClicked(self): self.reg.app.about_fairware()
class PageDialog(QDialog): okClicked = pyqtSignal() cancelClicked = pyqtSignal() settingsCancelled = pyqtSignal() def __init__(self, parent = None): QDialog.__init__(self, parent) self.prnt = parent self.tr = Translator() self.setWindowTitle(self.tr._translate('M@il Checker : Settings')) self.tabWidget = QTabWidget(self) self.tabWidget.setTabPosition(QTabWidget.North) self.layout = QVBoxLayout() self.buttonLayout = QHBoxLayout() self.ok = QPushButton(QIcon.fromTheme("dialog-ok"), "", self) self.cancel = QPushButton(QIcon.fromTheme("dialog-cancel"), "", self) self.buttonLayout.addWidget(self.ok) self.buttonLayout.addWidget(self.cancel) self.layout.addWidget(self.tabWidget) self.layout.addItem(self.buttonLayout) self.setLayout(self.layout) self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) self.setMinimumWidth(100) self.ok.clicked.connect(self.accepted) self.cancel.clicked.connect(self.rejected) QTimer.singleShot(100, self._restoreGeometry) def _restoreGeometry(self): self.restoreGeometry(self.prnt.Settings.value('SettingsGeometry').toByteArray()) def addPage(self, wdg, wdgName): self.tabWidget.addTab(wdg, wdgName) def accepted(self): self.okClicked.emit() def rejected(self): self.settingsCancelled.emit() self.cancelClicked.emit() def closeEvent(self, ev): ev.ignore() self.rejected() def _close(self): self.prnt.Settings.setValue('SettingsGeometry', self.saveGeometry()) if not self.prnt.isVisible() : self.prnt.show() self.prnt.autoHide(3) if self.prnt.isMinimized() : self.prnt.showNormal() self.done(0)
class AccountReassignPanel(Panel): def __init__(self, mainwindow): Panel.__init__(self, mainwindow) self._setupUi() self.model = mainwindow.model.account_reassign_panel self.model.view = self self.accountComboBox = ComboboxModel(model=self.model.account_list, view=self.accountComboBoxView) self.continueButton.clicked.connect(self.accept) self.cancelButton.clicked.connect(self.reject) def _setupUi(self): if ISWINDOWS: self.resize(250, 140) else: self.resize(340, 165) self.setWindowTitle(tr("Re-assign Account")) self.verticalLayout = QVBoxLayout(self) self.label = QLabel(self) self.label.setWordWrap(True) self.label.setText(tr( "You\'re about to delete a non-empty account. Select an account to re-assign its " "transactions to." )) self.verticalLayout.addWidget(self.label) self.accountComboBoxView = QComboBox(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.accountComboBoxView.sizePolicy().hasHeightForWidth()) self.accountComboBoxView.setSizePolicy(sizePolicy) self.accountComboBoxView.setMinimumSize(QSize(200, 0)) self.verticalLayout.addWidget(self.accountComboBoxView) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout = QHBoxLayout() spacerItem1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem1) self.cancelButton = QPushButton(self) self.cancelButton.setText(tr("Cancel")) self.cancelButton.setShortcut("Esc") self.horizontalLayout.addWidget(self.cancelButton) self.continueButton = QPushButton(self) self.continueButton.setDefault(True) self.continueButton.setText(tr("Continue")) self.horizontalLayout.addWidget(self.continueButton) self.verticalLayout.addLayout(self.horizontalLayout)
def __init__(self, parent=None): super(MiniCalculation, self).__init__(parent) self.btnHelpState = False self.setWindowTitle(MiniCalculation.AppName) self.txtBrower = QTextBrowser() self.txtLine = QLineEdit() self.txtLine.setPlaceholderText(u"请输入表达式,按回车结束...") self.btnCal = QPushButton(u"计算") self.btnClear = QPushButton(u"清空") self.btnHelp = QPushButton(u"特殊函数表>>") self.btnHelp.setCheckable(True) self.btnHelp.setChecked(True) mathList = [s for s in dir(math) if not s.startswith("__")] self.listWidget = QListWidget() self.listWidget.addItems(mathList) for i in range(len(mathList)): item = self.listWidget.item(i) strFun = item.text() + '.__doc__' item.setToolTip(eval(str(strFun))) self.listWidget.setMaximumWidth(100) midLay = QHBoxLayout() midLay.addWidget(self.btnCal) midLay.addWidget(self.btnClear) midLay.addStretch() midLay.addWidget(self.btnHelp) bottomLay = QHBoxLayout() bottomLay.addWidget(self.txtBrower) bottomLay.addWidget(self.listWidget) lay = QVBoxLayout() lay.addWidget(self.txtLine) lay.addItem(midLay) lay.addItem(bottomLay) self.resize(450, 300) self.setLayout(lay) self.updateUI() self.btnCal.clicked.connect(self.btnCalClicked) self.btnClear.clicked.connect(self.txtLine.clear) self.btnClear.clicked.connect(self.txtBrower.clear) self.btnHelp.clicked.connect(self.updateUI) self.listWidget.itemDoubleClicked.connect(self.listItemDoubleClicked)
def createWidgets(self, window): self.widget = QWidget() layout = QHBoxLayout() self.widget.setLayout(layout) left_layout = QVBoxLayout() layout.addLayout(left_layout) pick_button = QPushButton("Pick a card") left_layout.addWidget(pick_button) window.connect(pick_button, SIGNAL("clicked()"), self.pick) def createPlay(card_index): def clicked(): self.play(card_index) return clicked def createDiscard(button, card_index): def mouseReleaseEvent(event): QPushButton.mouseReleaseEvent(button, event) if event.button() == Qt.RightButton: self.discard(card_index) return mouseReleaseEvent self.hand_buttons = [] for card_index in xrange(6): button = QPushButton("#") self.hand_buttons.append(button) window.connect(button, SIGNAL('clicked()'), createPlay(card_index)) button.mouseReleaseEvent = createDiscard(button, card_index) left_layout.addWidget(button) spacer = createVerticalSpacer() left_layout.addItem(spacer) leave = QPushButton('&Leave') left_layout.addWidget(leave) window.connect(leave, SIGNAL('clicked()'), self.leave) right_layout = QVBoxLayout() layout.addLayout(right_layout) self.player_views = [] for player_index in xrange(4): view = PlayerView() right_layout.addWidget(view.frame) self.player_views.append(view)
def setupUi(self): """layout the window""" self.setContentsMargins(0, 0, 0, 0) vlayout = QVBoxLayout(self) vlayout.setContentsMargins(0, 0, 0, 0) sliderLayout = QHBoxLayout() self.kcfg_showShadows = QCheckBox(m18n('Show tile shadows'), self) self.kcfg_showShadows.setObjectName('kcfg_showShadows') self.kcfg_rearrangeMelds = QCheckBox( m18n('Rearrange undisclosed tiles to melds'), self) self.kcfg_rearrangeMelds.setObjectName('kcfg_rearrangeMelds') self.kcfg_showOnlyPossibleActions = QCheckBox( m18n('Show only possible actions')) self.kcfg_showOnlyPossibleActions.setObjectName( 'kcfg_showOnlyPossibleActions') self.kcfg_propose = QCheckBox(m18n('Propose what to do')) self.kcfg_propose.setObjectName('kcfg_propose') self.kcfg_animationSpeed = QSlider(self) self.kcfg_animationSpeed.setObjectName('kcfg_animationSpeed') self.kcfg_animationSpeed.setOrientation(Qt.Horizontal) self.kcfg_animationSpeed.setSingleStep(1) lblSpeed = QLabel(m18n('Animation speed:')) lblSpeed.setBuddy(self.kcfg_animationSpeed) sliderLayout.addWidget(lblSpeed) sliderLayout.addWidget(self.kcfg_animationSpeed) self.kcfg_useSounds = QCheckBox(m18n('Use sounds if available'), self) self.kcfg_useSounds.setObjectName('kcfg_useSounds') self.kcfg_uploadVoice = QCheckBox(m18n('Let others hear my voice'), self) self.kcfg_uploadVoice.setObjectName('kcfg_uploadVoice') pol = QSizePolicy() pol.setHorizontalPolicy(QSizePolicy.Expanding) pol.setVerticalPolicy(QSizePolicy.Expanding) spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) vlayout.addWidget(self.kcfg_showShadows) vlayout.addWidget(self.kcfg_rearrangeMelds) vlayout.addWidget(self.kcfg_showOnlyPossibleActions) vlayout.addWidget(self.kcfg_propose) vlayout.addWidget(self.kcfg_useSounds) vlayout.addWidget(self.kcfg_uploadVoice) vlayout.addLayout(sliderLayout) vlayout.addItem(spacerItem) self.setSizePolicy(pol) self.retranslateUi()
def createWidgets(self, window): self.widget = QWidget() layout = QVBoxLayout() self.widget.setLayout(layout) self.turn_label = QLabel() layout.addWidget(self.turn_label) grid = QGridLayout() layout.addLayout(grid) def createSow(home): def clicked(): self.sow(home) return clicked self.buttons = [None for home in xrange(12)] for row in xrange(2): for col in xrange(6): if row == 0: home = 11 - col else: home = col button = QPushButton("#%s" % home) grid.addWidget(button, row, col) self.buttons[home] = button if row == 1: window.connect(button, SIGNAL("clicked()"), createSow(1 + col)) else: button.setEnabled(False) spacer = createVerticalSpacer() layout.addItem(spacer) button_layout = QHBoxLayout() layout.addLayout(button_layout) refresh = QPushButton("&Refresh") button_layout.addWidget(refresh) window.connect(refresh, SIGNAL("clicked()"), self.refresh) leave = QPushButton("&Leave") button_layout.addWidget(leave) window.connect(leave, SIGNAL("clicked()"), self.leave)
def __init__(self): super(ReportarBugTab, self).__init__() box = QVBoxLayout(self) box.setContentsMargins(0, 0, 0, 0) lbl_issues = QLabel(self.tr("Detalla el bug o sugerencia en:")) lbl_link_issues = QLabel("<a href='%s'><span style='color: #dedede;'>" "%s</span></a>" % (ui.__reportar_bug__, ui.__reportar_bug__)) lbl_email = QLabel(self.tr("O puedes mandar un e-mail a:")) lbl_link_email = QLabel("<a href='%s'><span style='color: #dedede;'>%s" "</span></a>" % (ui.__email_autor__, ui.__email_autor__)) box.addWidget(lbl_issues) box.addWidget(lbl_link_issues) box.addWidget(lbl_email) box.addWidget(lbl_link_email) box.addItem(QSpacerItem(1, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) lbl_link_issues.linkActivated.connect(lambda l: webbrowser.open(l))
def setupUi(self): """layout the window""" self.setContentsMargins(0, 0, 0, 0) vlayout = QVBoxLayout(self) vlayout.setContentsMargins(0, 0, 0, 0) sliderLayout = QHBoxLayout() self.kcfg_showShadows = QCheckBox(m18n('Show tile shadows'), self) self.kcfg_showShadows.setObjectName('kcfg_showShadows') self.kcfg_rearrangeMelds = QCheckBox(m18n('Rearrange undisclosed tiles to melds'), self) self.kcfg_rearrangeMelds.setObjectName('kcfg_rearrangeMelds') self.kcfg_showOnlyPossibleActions = QCheckBox(m18n('Show only possible actions')) self.kcfg_showOnlyPossibleActions.setObjectName('kcfg_showOnlyPossibleActions') self.kcfg_propose = QCheckBox(m18n('Propose what to do')) self.kcfg_propose.setObjectName('kcfg_propose') self.kcfg_animationSpeed = QSlider(self) self.kcfg_animationSpeed.setObjectName('kcfg_animationSpeed') self.kcfg_animationSpeed.setOrientation(Qt.Horizontal) self.kcfg_animationSpeed.setSingleStep(1) lblSpeed = QLabel(m18n('Animation speed:')) lblSpeed.setBuddy(self.kcfg_animationSpeed) sliderLayout.addWidget(lblSpeed) sliderLayout.addWidget(self.kcfg_animationSpeed) self.kcfg_useSounds = QCheckBox(m18n('Use sounds if available'), self) self.kcfg_useSounds.setObjectName('kcfg_useSounds') self.kcfg_uploadVoice = QCheckBox(m18n('Let others hear my voice'), self) self.kcfg_uploadVoice.setObjectName('kcfg_uploadVoice') pol = QSizePolicy() pol.setHorizontalPolicy(QSizePolicy.Expanding) pol.setVerticalPolicy(QSizePolicy.Expanding) spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) vlayout.addWidget(self.kcfg_showShadows) vlayout.addWidget(self.kcfg_rearrangeMelds) vlayout.addWidget(self.kcfg_showOnlyPossibleActions) vlayout.addWidget(self.kcfg_propose) vlayout.addWidget(self.kcfg_useSounds) vlayout.addWidget(self.kcfg_uploadVoice) vlayout.addLayout(sliderLayout) vlayout.addItem(spacerItem) self.setSizePolicy(pol) self.retranslateUi()
def createWidgets(self, window): self.widget = QWidget() layout = QVBoxLayout() self.widget.setLayout(layout) if self.window.options.debug: self.id_label = QLabel() layout.addWidget(self.id_label) self.type_label = QLabel() layout.addWidget(self.type_label) self.players_label = QLabel() layout.addWidget(self.players_label) self.state_label = QLabel() layout.addWidget(self.state_label) self.autostart_checkbox = QCheckBox(tr("Autostart")) window.connect(self.autostart_checkbox, SIGNAL("stateChanged(int)"), self.autostartChanged) layout.addWidget(self.autostart_checkbox) spacer = createVerticalSpacer() layout.addItem(spacer) button_layout = QHBoxLayout() layout.addLayout(button_layout) self.start_button = QPushButton('&Start') button_layout.addWidget(self.start_button) window.connect(self.start_button, SIGNAL('clicked()'), self.start) refresh = QPushButton('&Refresh') button_layout.addWidget(refresh) window.connect(refresh, SIGNAL('clicked()'), self.refresh) leave = QPushButton('&Leave') button_layout.addWidget(leave) window.connect(leave, SIGNAL('clicked()'), self.leave)
def __init__(self): super(ControllerGui, self).__init__() self.setupUi(self) self.m_clear.clicked.connect(self.clear_plot) self.m_send.clicked.connect(self.send_start) self.m_stop.clicked.connect(self.send_stop) self.interface = SerialInterface() self.interface.received.connect(self.show_received) self.m_interval.setValidator(QIntValidator(0, 10000)) self.m_interval.returnPressed.connect(self.send_start) brush = QBrush(QColor(255, 255, 255)) box = QVBoxLayout(self.m_list) self.temperature_plot = PlotWidget(self) self.temperature_plot.setBackgroundBrush(brush) self.temperature_plot.setFixedHeight(300) box.addWidget(self.temperature_plot) self.temperature_curves = {} self.humidity_plot = PlotWidget(self) self.humidity_plot.setBackgroundBrush(brush) self.humidity_plot.setFixedHeight(300) box.addWidget(self.humidity_plot) self.humidity_curves = {} self.illumination_plot = PlotWidget(self) self.illumination_plot.setBackgroundBrush(brush) self.illumination_plot.setFixedHeight(300) box.addWidget(self.illumination_plot) self.illumination_curves = {} box.addItem(QSpacerItem(40, 20, QSizePolicy.Maximum, QSizePolicy.Expanding)) self.m_list.setLayout(box) box = QVBoxLayout(self.m_devices) box.addItem(QSpacerItem(40, 20, QSizePolicy.Maximum, QSizePolicy.Expanding)) self.m_devices.setLayout(box) self.file = open('result.txt', 'w')
def __init__(self): super(SendView, self).__init__() layout = QVBoxLayout() dest_address_label = QLabel(u"目标地址") layout.addWidget(dest_address_label) self.dest_address_tb = QLineEdit() self.dest_address_tb.setMaximumWidth(300) self.dest_address_tb.setMaximumHeight(40) layout.addWidget(self.dest_address_tb) output_value_label = QLabel(u'发送金额') layout.addWidget(output_value_label) self.output_value_edit = QLineEdit() layout.addWidget(self.output_value_edit) self.send_btn = FuncView(u'发送') layout.addWidget(self.send_btn) layout.addItem( QSpacerItem(0, 0, QSizePolicy.Minimum, QSizePolicy.Expanding)) self.setLayout(layout)
def setup_dynamically(self): font = QFont() font.setBold(False) lineEdit_list = [] Layout = QGridLayout() row = 0 col = 0 values = self.sheet.row_values(3, 1) for x in range(1, len(values)): if values[x-1] == "!": break else: cell = self.sheet.cell_value(1, x) tool_tip = self.sheet.cell_value(2, x) Layout2 = QVBoxLayout() label = QLabel(str(cell)) label.setFont(font) lineedit = QLineEdit() lineedit.setFont(font) lineedit.setToolTip(str(tool_tip)) lineedit.setEnabled(0) Layout2.addWidget(label) Layout2.addWidget(lineedit) vert_spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Maximum) Layout2.addItem(vert_spacer) Layout.addLayout(Layout2, row, col) lineEdit_list.append(lineedit) if x > 0: if x % 5 == 0: row += 1 col = 0 vert_spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Maximum) Layout.addItem(vert_spacer) else: col += 1 self.groupBox2.setLayout(Layout) return lineEdit_list
def setupUi(self): """layout the window""" self.setWindowTitle(m18n('Customize rulesets') + ' - Kajongg') self.setObjectName('Rulesets') hlayout = QHBoxLayout(self) v1layout = QVBoxLayout() self.v1widget = QWidget() v1layout = QVBoxLayout(self.v1widget) v2layout = QVBoxLayout() hlayout.addWidget(self.v1widget) hlayout.addLayout(v2layout) for widget in [self.v1widget, hlayout, v1layout, v2layout]: widget.setContentsMargins(0, 0, 0, 0) hlayout.setStretchFactor(self.v1widget, 10) self.btnCopy = QPushButton() self.btnRemove = QPushButton() self.btnCompare = QPushButton() self.btnClose = QPushButton() self.rulesetView = RuleTreeView(m18nc('kajongg', 'Rule'), self.btnCopy, self.btnRemove, self.btnCompare) v1layout.addWidget(self.rulesetView) self.rulesetView.setWordWrap(True) self.rulesetView.setMouseTracking(True) spacerItem = QSpacerItem(20, 20, QSizePolicy.Minimum, QSizePolicy.Expanding) v2layout.addWidget(self.btnCopy) v2layout.addWidget(self.btnRemove) v2layout.addWidget(self.btnCompare) self.btnCopy.clicked.connect(self.rulesetView.copyRow) self.btnRemove.clicked.connect(self.rulesetView.removeRow) self.btnCompare.clicked.connect(self.rulesetView.compareRow) self.btnClose.clicked.connect(self.hide) v2layout.addItem(spacerItem) v2layout.addWidget(self.btnClose) self.retranslateUi() StateSaver(self) self.show()
class EvtControlPannel(QWidget): def __init__(self, evt_widget, parent=None): QWidget.__init__(self, parent) self.evt_widget = evt_widget self.verticalLayout = QVBoxLayout(self) spacerItem = QSpacerItem(20, 259, QSizePolicy.Minimum, QSizePolicy.Expanding) tmp_widget = QWidget() self.verticalLayout.addWidget(tmp_widget) hor_layout = QHBoxLayout(tmp_widget) hor_layout.addWidget(QLabel("Display :")) self.admin_events = QPushButton(QIcon(":/green_configure.png"), "Admin. events") self.choose_event_type = QComboBox() self.choose_event_type.addItem(QIcon(":/internet_explorer"), "All", 42) self.choose_event_type.addItem(QIcon(":/audit_success"), "Audit success", EVENTLOG_AUDIT_SUCCESS) self.choose_event_type.addItem(QIcon(":/audit_failure"), "Audit failure", EVENTLOG_AUDIT_FAILURE) self.choose_event_type.addItem(QIcon(":/error"), "Error", EVENTLOG_ERROR_TYPE) self.choose_event_type.addItem(QIcon(":/warning"), "Warning", EVENTLOG_WARNING_TYPE) self.choose_event_type.addItem(QIcon(":/info"), "Information", EVENTLOG_INFORMATION_TYPE) self.choose_event_type.addItem(QIcon(":/chat.png"), "Comment", 5) hor_layout.addWidget(self.choose_event_type) tmp_widget = QWidget() self.verticalLayout.addWidget(tmp_widget) hor_layout = QHBoxLayout(tmp_widget) self.id = QLineEdit() hor_layout.addWidget(QLabel("Id :")) self.cb = QComboBox() self.cbs = QComboBox() self.init() hor_layout.addWidget(self.cb) tmp_widget = QWidget() self.verticalLayout.addWidget(tmp_widget) hor_layout = QHBoxLayout(tmp_widget) self.source = QLineEdit() hor_layout.addWidget(QLabel("Source :")) hor_layout.addWidget(self.cbs) self.verticalLayout.addWidget(QLabel("Start date :")) self.select_date_b = QDateTimeEdit() self.select_date_b.setDisplayFormat("MMM dd yyyy hh:mm AP") self.verticalLayout.addWidget(self.select_date_b) self.verticalLayout.addWidget(QLabel("End date:")) self.select_date_e = QDateTimeEdit() self.select_date_e.setDisplayFormat("MMM dd yyyy hh:mm AP") self.verticalLayout.addWidget(self.select_date_e) self.search_date = QPushButton("Go") self.verticalLayout.addWidget(self.search_date) self.verticalLayout.addItem(spacerItem) self.search_date.clicked.connect(self.filterByDate) self.cb.activated.connect(self.filterById) self.cbs.activated.connect(self.filterBySource) self.choose_event_type.activated.connect(self.filterByLvl) def filterByDate(self, checked): date_begin = self.select_date_b.dateTime() date_end = self.select_date_e.dateTime() date_begin_str = str(date_begin.toString('yyyy-MM-dd hh:mm:ss')) date_end_str = str(date_end.toString('yyyy-MM-dd hh:mm:ss')) if date_begin > date_end: message = QMessageBox() message.setText('Date mismatch.') message.exec_() else: for i in range(self.evt_widget.rowCount()): data = self.evt_widget.item(i, 2) if data.text() >= date_begin_str and data.text( ) <= date_end_str: self.evt_widget.showRow(i) else: self.evt_widget.hideRow(i) def filterById(self, index): lvl = self.cb.currentText() for i in range(self.evt_widget.rowCount()): item = self.evt_widget.item(i, 1) data = item.text() if data != lvl: self.evt_widget.hideRow(i) else: self.evt_widget.showRow(i) def dispAll(self): for i in range(self.evt_widget.rowCount()): self.evt_widget.showRow(i) def filterByLvl(self, index): type_e = self.choose_event_type.currentText() if type_e == 'All': self.dispAll() else: for i in range(self.evt_widget.rowCount()): item = self.evt_widget.item(i, 0) data = item.text() if data != type_e: self.evt_widget.hideRow(i) else: self.evt_widget.showRow(i) def reload(self, item): self.init() def filterBySource(self, index): lvl = self.cbs.currentText() for i in range(self.evt_widget.rowCount()): item = self.evt_widget.item(i, 3) data = item.text() if data != lvl: self.evt_widget.hideRow(i) else: self.evt_widget.showRow(i) def init(self): tmp_list = [] tmp_list2 = [] self.cb.clear() self.cbs.clear() for i in range(self.evt_widget.rowCount()): item = self.evt_widget.item(i, 1).text() tmp_list.append(item) item = self.evt_widget.item(i, 3).text() tmp_list2.append(item) tmp_list = self.unique(tmp_list) tmp_list2 = self.unique(tmp_list2) self.cb.addItems(tmp_list) self.cbs.addItems(tmp_list2) def unique(self, seq, idfun=None): # order preserving if idfun is None: def idfun(x): return x seen = {} result = [] for item in seq: marker = idfun(item) if marker in seen: continue seen[marker] = 1 if item is not None: result.append(item) return sorted(result)
class InfoComp(QDialog): ''' A dialog to give complementary information on the member of the household: - activity - invalidity status - shared custody for children ''' def __init__(self, scenario, parent=None): super(InfoComp, self).__init__(parent) self.resize(300, 223) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.setWindowTitle(u"Informations complémentaires") icon = get_icon(":/images/people.png") self.setWindowIcon(icon) self.verticalLayout = QVBoxLayout(self) self.gridLayout = QGridLayout() self.gridLayout.setHorizontalSpacing(10) self.setStyleSheet(OfSs.bold_center) self.label_0 = QLabel(u'n°', self) self.gridLayout.addWidget(self.label_0, 0, 0, 1, 1) self.label_1 = QLabel(u'Activité', self) self.gridLayout.addWidget(self.label_1, 0, 1, 1, 1) self.label_2 = QLabel(u"Invalide", self) self.gridLayout.addWidget(self.label_2, 0, 2, 1, 1) self.label_3 = QLabel(u'Garde\nalternée', self) self.gridLayout.addWidget(self.label_3, 0, 3, 1, 1) self.gridLayout.setColumnStretch(1, 1) self.gridLayout.setColumnStretch(2, 1) self.gridLayout.setColumnStretch(3, 1) self.verticalLayout.addLayout(self.gridLayout) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Cancel | QDialogButtonBox.Ok, parent=self) self.verticalLayout.addWidget(self.buttonBox) self.connect(self.buttonBox, SIGNAL('accepted()'), self.accept) self.connect(self.buttonBox, SIGNAL('rejected()'), self.reject) self.parent = parent self.scenario = scenario self.inv_list = [] self.alt_list = [] self.act_list = [] for noi, vals in self.scenario.indiv.iteritems(): self.gridLayout.addWidget(QLabel('%d' % (noi + 1), self), noi + 1, 0) # Acitivité cb_act = QComboBox(self) cb_act.addItems([ u'Actif occupé', u'Chômeur', u'Étudiant, élève', u'Retraité', u'Autre inactif' ]) cb_act.setCurrentIndex(vals['activite']) self.act_list.append(cb_act) self.gridLayout.addWidget(cb_act, noi + 1, 1) # Invalide cb_inv = QCheckBox(self) cb_inv.setChecked(vals['inv']) layout1 = QHBoxLayout() layout1.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) layout1.addWidget(cb_inv) layout1.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.inv_list.append(cb_inv) self.gridLayout.addLayout(layout1, noi + 1, 2) # Garde alternée cb_alt = QCheckBox(self) if vals['quifoy'][:3] != 'pac': vals['alt'] = 0 cb_alt.setEnabled(False) cb_alt.setChecked(vals['alt']) layout2 = QHBoxLayout() layout2.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) layout2.addWidget(cb_alt) layout2.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum)) self.alt_list.append(cb_alt) self.gridLayout.addLayout(layout2, noi + 1, 3) def accept(self): for noi, vals in self.scenario.indiv.iteritems(): vals['inv'] = self.inv_list[noi].checkState() >= 1 vals['alt'] = self.alt_list[noi].checkState() >= 1 vals['activite'] = self.act_list[noi].currentIndex() QDialog.accept(self)
class PrioritizeDialog(QDialog): def __init__(self, parent, app): flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint QDialog.__init__(self, parent, flags) self._setupUi() self.model = PrioritizeDialogModel(app=app.model) self.categoryList = ComboboxModel(model=self.model.category_list, view=self.categoryCombobox) self.criteriaList = ListviewModel(model=self.model.criteria_list, view=self.criteriaListView) self.prioritizationList = PrioritizationList(model=self.model.prioritization_list, view=self.prioritizationListView) self.model.view = self self.addCriteriaButton.clicked.connect(self.model.add_selected) self.removeCriteriaButton.clicked.connect(self.model.remove_selected) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) def _setupUi(self): self.setWindowTitle(tr("Re-Prioritize duplicates")) self.resize(700, 400) #widgets msg = tr("Add criteria to the right box and click OK to send the dupes that correspond the " "best to these criteria to their respective group's " "reference position. Read the help file for more information.") self.promptLabel = QLabel(msg) self.promptLabel.setWordWrap(True) self.categoryCombobox = QComboBox() self.criteriaListView = QListView() self.addCriteriaButton = QPushButton(self.style().standardIcon(QStyle.SP_ArrowRight), "") self.removeCriteriaButton = QPushButton(self.style().standardIcon(QStyle.SP_ArrowLeft), "") self.prioritizationListView = QListView() self.prioritizationListView.setAcceptDrops(True) self.prioritizationListView.setDragEnabled(True) self.prioritizationListView.setDragDropMode(QAbstractItemView.InternalMove) self.prioritizationListView.setSelectionBehavior(QAbstractItemView.SelectRows) self.buttonBox = QDialogButtonBox() self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) # layout self.mainLayout = QVBoxLayout(self) self.mainLayout.addWidget(self.promptLabel) self.splitter = QSplitter() sp = self.splitter.sizePolicy() sp.setVerticalPolicy(QSizePolicy.Expanding) self.splitter.setSizePolicy(sp) self.leftSide = QWidget() self.leftWidgetsLayout = QVBoxLayout() self.leftWidgetsLayout.addWidget(self.categoryCombobox) self.leftWidgetsLayout.addWidget(self.criteriaListView) self.leftSide.setLayout(self.leftWidgetsLayout) self.splitter.addWidget(self.leftSide) self.rightSide = QWidget() self.rightWidgetsLayout = QHBoxLayout() self.addRemoveButtonsLayout = QVBoxLayout() self.addRemoveButtonsLayout.addItem(verticalSpacer()) self.addRemoveButtonsLayout.addWidget(self.addCriteriaButton) self.addRemoveButtonsLayout.addWidget(self.removeCriteriaButton) self.addRemoveButtonsLayout.addItem(verticalSpacer()) self.rightWidgetsLayout.addLayout(self.addRemoveButtonsLayout) self.rightWidgetsLayout.addWidget(self.prioritizationListView) self.rightSide.setLayout(self.rightWidgetsLayout) self.splitter.addWidget(self.rightSide) self.mainLayout.addWidget(self.splitter) self.mainLayout.addWidget(self.buttonBox)
class OrderSelectorView(QObject): """""" #---------------------------------------------------------------------- def __init__(self, parentWidget, label_text_NotSelected, label_text_Selected, model): """Constructor""" QObject.__init__(self) self.model = model self.gridLayout = QGridLayout(parentWidget) self.verticalLayout_left_list = QVBoxLayout() self.label_NotSelected = QLabel(parentWidget) self.label_NotSelected.setText(label_text_NotSelected) self.verticalLayout_left_list.addWidget(self.label_NotSelected) self.listView_NotSelected = QListView(parentWidget) self.verticalLayout_left_list.addWidget(self.listView_NotSelected) self.gridLayout.addLayout(self.verticalLayout_left_list, 0, 0, 1, 2) self.verticalLayout_right_left = QVBoxLayout() spacerItem = QSpacerItem(20, 178, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_right_left.addItem(spacerItem) self.pushButton_right_arrow = QPushButton(parentWidget) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalPolicy(0) sizePolicy.setHeightForWidth( self.pushButton_right_arrow.sizePolicy().hasHeightForWidth()) self.pushButton_right_arrow.setSizePolicy(sizePolicy) self.pushButton_right_arrow.setMinimumSize(QSize(50, 50)) self.pushButton_right_arrow.setMaximumSize(QSize(50, 50)) self.pushButton_right_arrow.setIcon(QIcon(':/right_arrow.png')) self.pushButton_right_arrow.setIconSize(QSize(50, 50)) self.pushButton_right_arrow.setText('') self.verticalLayout_right_left.addWidget(self.pushButton_right_arrow) self.pushButton_left_arrow = QPushButton(parentWidget) sizePolicy.setHeightForWidth( self.pushButton_left_arrow.sizePolicy().hasHeightForWidth()) self.pushButton_left_arrow.setSizePolicy(sizePolicy) self.pushButton_left_arrow.setMinimumSize(QSize(50, 50)) self.pushButton_left_arrow.setMaximumSize(QSize(50, 50)) self.pushButton_left_arrow.setIcon(QIcon(':/left_arrow.png')) self.pushButton_left_arrow.setIconSize(QSize(50, 50)) self.pushButton_left_arrow.setText('') self.verticalLayout_right_left.addWidget(self.pushButton_left_arrow) spacerItem = QSpacerItem(20, 178, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_right_left.addItem(spacerItem) self.gridLayout.addLayout(self.verticalLayout_right_left, 0, 2, 1, 1) self.verticalLayout_right_list = QVBoxLayout() self.label_Selected = QLabel(parentWidget) self.label_Selected.setText(label_text_Selected) self.verticalLayout_right_list.addWidget(self.label_Selected) self.listView_Selected = QListView(parentWidget) self.verticalLayout_right_list.addWidget(self.listView_Selected) self.gridLayout.addLayout(self.verticalLayout_right_list, 0, 3, 1, 2) self.verticalLayout_up_down = QVBoxLayout() spacerItem = QSpacerItem(20, 178, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_up_down.addItem(spacerItem) self.pushButton_up_arrow = QPushButton(parentWidget) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalPolicy(0) sizePolicy.setHeightForWidth( self.pushButton_up_arrow.sizePolicy().hasHeightForWidth()) self.pushButton_up_arrow.setSizePolicy(sizePolicy) self.pushButton_up_arrow.setMinimumSize(QSize(50, 50)) self.pushButton_up_arrow.setMaximumSize(QSize(50, 50)) self.pushButton_up_arrow.setIcon(QIcon(':/up_arrow.png')) self.pushButton_up_arrow.setIconSize(QSize(50, 50)) self.pushButton_up_arrow.setText('') self.verticalLayout_up_down.addWidget(self.pushButton_up_arrow) self.pushButton_down_arrow = QPushButton(parentWidget) sizePolicy.setHeightForWidth( self.pushButton_down_arrow.sizePolicy().hasHeightForWidth()) self.pushButton_down_arrow.setSizePolicy(sizePolicy) self.pushButton_down_arrow.setMinimumSize(QSize(50, 50)) self.pushButton_down_arrow.setMaximumSize(QSize(50, 50)) self.pushButton_down_arrow.setIcon(QIcon(':/down_arrow.png')) self.pushButton_down_arrow.setIconSize(QSize(50, 50)) self.pushButton_down_arrow.setText('') self.verticalLayout_up_down.addWidget(self.pushButton_down_arrow) spacerItem = QSpacerItem(20, 178, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_up_down.addItem(spacerItem) self.gridLayout.addLayout(self.verticalLayout_up_down, 0, 5, 1, 1) self.listView_NotSelected.setSelectionMode( QAbstractItemView.ExtendedSelection) self.listView_Selected.setSelectionMode( QAbstractItemView.ExtendedSelection) self.listView_NotSelected.setModel(self.model.model_NotSelected) self.listView_Selected.setModel(self.model.model_Selected) #---------------------------------------------------------------------- def on_right_arrow_press(self): """""" NSMod = self.listView_NotSelected.model() NSSelMod = self.listView_NotSelected.selectionModel() SMod = self.listView_Selected.model() SSelMod = self.listView_Selected.selectionModel() mod_ind_list = NSSelMod.selectedRows(0) if mod_ind_list == []: return else: SSelMod.clearSelection() while mod_ind_list != []: mod_ind = mod_ind_list[0] item = NSMod.itemFromIndex(mod_ind) new_item = item.clone() SMod.appendRow(new_item) SSelMod.select(SMod.indexFromItem(new_item), QItemSelectionModel.Select) NSMod.removeRow(mod_ind.row()) mod_ind_list = NSSelMod.selectedRows(0) #---------------------------------------------------------------------- def on_left_arrow_press(self): """""" SMod = self.listView_Selected.model() SSelMod = self.listView_Selected.selectionModel() NSMod = self.listView_NotSelected.model() NSSelMod = self.listView_NotSelected.selectionModel() mod_ind_list = SSelMod.selectedRows(0) if mod_ind_list == []: return else: NSSelMod.clearSelection() while mod_ind_list != []: mod_ind = mod_ind_list[0] item = SMod.itemFromIndex(mod_ind) text = item.text() if text in self.model.permanently_selected_string_list: print '"' + text + '"' + ' cannot be unselected.' return else: new_item = item.clone() NSMod.appendRow(new_item) NSSelMod.select(NSMod.indexFromItem(new_item), QItemSelectionModel.Select) SMod.removeRow(mod_ind.row()) mod_ind_list = SSelMod.selectedRows(0) #---------------------------------------------------------------------- def on_up_arrow_press(self): """""" SMod = self.listView_Selected.model() SSelMod = self.listView_Selected.selectionModel() mod_ind_list = SSelMod.selectedRows(0) if mod_ind_list == []: return else: sorted_row_ind_list = sorted( [mod_ind.row() for mod_ind in mod_ind_list]) for row_ind in sorted_row_ind_list: try: upper_item = SMod.item(row_ind - 1).clone() lower_item = SMod.item(row_ind).clone() SMod.removeRow(row_ind - 1) SMod.insertRow(row_ind - 1, lower_item) SMod.removeRow(row_ind) SMod.insertRow(row_ind, upper_item) SSelMod.select(SMod.indexFromItem(lower_item), QItemSelectionModel.Select) except: break #---------------------------------------------------------------------- def on_down_arrow_press(self): """""" SMod = self.listView_Selected.model() SSelMod = self.listView_Selected.selectionModel() mod_ind_list = SSelMod.selectedRows(0) if mod_ind_list == []: return else: sorted_row_ind_list = sorted( [mod_ind.row() for mod_ind in mod_ind_list], reverse=True) for row_ind in sorted_row_ind_list: try: upper_item = SMod.item(row_ind).clone() lower_item = SMod.item(row_ind + 1).clone() SMod.removeRow(row_ind) SMod.insertRow(row_ind, lower_item) SMod.removeRow(row_ind + 1) SMod.insertRow(row_ind + 1, upper_item) SSelMod.select(SMod.indexFromItem(upper_item), QItemSelectionModel.Select) except: break
class DisplayAequilibraEFormatsDialog(QtGui.QDialog, FORM_CLASS): def __init__(self, iface): QDialog.__init__(self) self.iface = iface self.setupUi(self) self.error = None self.error = None self.data_path, self.data_type = GetOutputFileName( self, 'AequilibraE custom formats', ["Aequilibrae dataset(*.aed)", "Aequilibrae matrix(*.aem)"], '.aed', standard_path()) self.data_type = self.data_type.upper() if self.data_path is None: self.error = 'Path provided is not a valid dataset' self.exit_with_error() if self.data_type == 'AED': self.data_to_show = AequilibraEData() elif self.data_type == 'AEM': self.data_to_show = AequilibraeMatrix() try: self.data_to_show.load(self.data_path) except: self.error = 'Could not load dataset' self.exit_with_error() # Elements that will be used during the displaying self._layout = QVBoxLayout() self.table = QTableView() self._layout.addWidget(self.table) # Settings for displaying self.show_layout = QHBoxLayout() # Thousand separator self.thousand_separator = QCheckBox() self.thousand_separator.setChecked(True) self.thousand_separator.setText('Thousands separator') self.thousand_separator.toggled.connect(self.format_showing) self.show_layout.addWidget(self.thousand_separator) self.spacer = QSpacerItem(5, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) self.show_layout.addItem(self.spacer) # Decimals txt = QLabel() txt.setText('Decimal places') self.show_layout.addWidget(txt) self.decimals = QSpinBox() self.decimals.valueChanged.connect(self.format_showing) self.decimals.setMinimum(0) self.decimals.setValue(4) self.decimals.setMaximum(10) self.show_layout.addWidget(self.decimals) self._layout.addItem(self.show_layout) # differentiates between matrix and dataset if self.data_type == 'AEM': self.data_to_show.computational_view([self.data_to_show.names[0]]) # Matrices need cores and indices to be set as well self.mat_layout = QHBoxLayout() self.mat_list = QComboBox() for n in self.data_to_show.names: self.mat_list.addItem(n) self.mat_list.currentIndexChanged.connect(self.change_matrix_cores) self.mat_layout.addWidget(self.mat_list) self.idx_list = QComboBox() for i in self.data_to_show.index_names: self.idx_list.addItem(i) self.idx_list.currentIndexChanged.connect(self.change_matrix_cores) self.mat_layout.addWidget(self.idx_list) self._layout.addItem(self.mat_layout) self.change_matrix_cores() self.but_export = QPushButton() self.but_export.setText('Export') self.but_export.clicked.connect(self.export) self.but_close = QPushButton() self.but_close.clicked.connect(self.exit_procedure) self.but_close.setText('Close') self.but_layout = QHBoxLayout() self.but_layout.addWidget(self.but_export) self.but_layout.addWidget(self.but_close) self._layout.addItem(self.but_layout) # We chose to use QTableView. However, if we want to allow the user to edit the dataset # The we need to allow them to switch to the slower QTableWidget # Code below # self.table = QTableWidget(self.data_to_show.entries, self.data_to_show.num_fields) # self.table.setHorizontalHeaderLabels(self.data_to_show.fields) # self.table.setObjectName('data_viewer') # # self.table.setVerticalHeaderLabels([str(x) for x in self.data_to_show.index[:]]) # self.table.clearContents() # # for i in range(self.data_to_show.entries): # for j, f in enumerate(self.data_to_show.fields): # item1 = QTableWidgetItem(str(self.data_to_show.data[f][i])) # item1.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable) # self.table.setItem(i, j, item1) self.resize(700, 500) self.setLayout(self._layout) self.format_showing() def format_showing(self): decimals = self.decimals.value() separator = self.thousand_separator.isChecked() if isinstance(self.data_to_show, AequilibraeMatrix): m = NumpyModel(self.data_to_show, separator, decimals) else: m = DatabaseModel(self.data_to_show, separator, decimals) self.table.clearSpans() self.table.setModel(m) def change_matrix_cores(self): self.data_to_show.computational_view([self.mat_list.currentText()]) self.data_to_show.set_index(0) self.format_showing() def export(self): new_name, file_type = GetOutputFileName( self, self.data_type, ["Comma-separated file(*.csv)"], ".csv", self.data_path) if new_name is not None: self.data_to_show.export(new_name) def exit_with_error(self): qgis.utils.iface.messageBar().pushMessage("Error:", self.error, level=1) self.exit_procedure() def exit_procedure(self): self.close()
def __init__(self): super(FlagsSection, self).__init__() container = QVBoxLayout(self) group_flags = QGroupBox(self.tr("Flags:")) box = QGridLayout(group_flags) box.setContentsMargins(20, 5, 20, 5) compiler_flags = settings.COMPILER_FLAGS.split() # -Wall self.check_wall = QCheckBox( self.tr("Habilitar todas las advertencias comunes [-Wall]")) if '-Wall' in compiler_flags: self.check_wall.setChecked(True) box.addWidget(self.check_wall, 0, 0) # -Wextra self.check_wextra = QCheckBox( self.tr("Habilitar advertencias extras [-Wextra]")) if '-Wextra' in compiler_flags: self.check_wextra.setChecked(True) box.addWidget(self.check_wextra, 0, 1) # -Wfatal-errors self.check_wfatal_error = QCheckBox( self.tr("Frenar compilación después del primer error " "[-Wfatal-errors]")) if '-Wfatal-erros' in compiler_flags: self.check_wfatal_error.setChecked(True) box.addWidget(self.check_wfatal_error, 1, 0) # -w self.check_w = QCheckBox( self.tr("Inhibir todos los mensajes de advertencia [-w]")) if '-w' in compiler_flags: self.check_w.setChecked(True) box.addWidget(self.check_w, 1, 1) group_optimization = QGroupBox(self.tr("Optimización:")) box = QGridLayout(group_optimization) box.setContentsMargins(20, 5, 20, 5) # -O self.check_o = QCheckBox( self.tr("Optimizar código para velocidad [-O]")) if '-O' in compiler_flags: self.check_o.setChecked(True) box.addWidget(self.check_o, 0, 0) # -O1 self.check_o1 = QCheckBox( self.tr("Optimizar más el código para velocidad [-O1]")) if '-O1' in compiler_flags: self.check_o1.setChecked(True) box.addWidget(self.check_o1, 0, 1) # -O2 self.check_o2 = QCheckBox( self.tr("Optimizar aún más el código para velocidad [-O2]")) if '-O2' in compiler_flags: self.check_o2.setChecked(True) box.addWidget(self.check_o2, 1, 0) # -O3 self.check_o3 = QCheckBox( self.tr("Optimizar totalmente el código para velocidad [-O3]")) if '-O3' in compiler_flags: self.check_o3.setChecked(True) box.addWidget(self.check_o3, 1, 1) # -Os self.check_os = QCheckBox( self.tr("Optimizar el código para tamaño [-Os]")) if '-Os' in compiler_flags: self.check_os.setChecked(True) box.addWidget(self.check_os, 2, 0) container.addWidget(group_flags) container.addWidget(group_optimization) container.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) CompilerConfiguration.install_widget( self.tr("Opciones del Compilador"), self)
def __init__(self, parent): super(EditorConfiguration, self).__init__() self._preferences = parent vbox = QVBoxLayout(self) #Indentation groupBoxFeatures = QGroupBox( translations.TR_PREFERENCES_EDITOR_CONFIG_FEATURES) formFeatures = QGridLayout(groupBoxFeatures) formFeatures.addWidget(QLabel( translations.TR_PREFERENCES_EDITOR_CONFIG_INDENTATION), 1, 0, Qt.AlignRight) self._spin = QSpinBox() self._spin.setAlignment(Qt.AlignRight) self._spin.setMinimum(1) self._spin.setValue(settings.INDENT) formFeatures.addWidget(self._spin, 1, 1, alignment=Qt.AlignTop) self._checkUseTabs = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_USE_TABS) self._checkUseTabs.setChecked(settings.USE_TABS) self.connect(self._checkUseTabs, SIGNAL("stateChanged(int)"), self._change_tab_spaces) formFeatures.addWidget(self._checkUseTabs, 1, 2, alignment=Qt.AlignTop) if settings.USE_TABS: self._spin.setSuffix( translations.TR_PREFERENCES_EDITOR_CONFIG_TAB_SIZE) else: self._spin.setSuffix( translations.TR_PREFERENCES_EDITOR_CONFIG_SPACES) #Margin Line formFeatures.addWidget(QLabel( translations.TR_PREFERENCES_EDITOR_CONFIG_MARGIN_LINE), 2, 0, Qt.AlignRight) self._spinMargin = QSpinBox() self._spinMargin.setMaximum(200) self._spinMargin.setValue(settings.MARGIN_LINE) formFeatures.addWidget(self._spinMargin, 2, 1, alignment=Qt.AlignTop) self._checkShowMargin = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MARGIN_LINE) self._checkShowMargin.setChecked(settings.SHOW_MARGIN_LINE) formFeatures.addWidget(self._checkShowMargin, 2, 2, alignment=Qt.AlignTop) #End of line self._checkEndOfLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_END_OF_LINE) self._checkEndOfLine.setChecked(settings.USE_PLATFORM_END_OF_LINE) formFeatures.addWidget(self._checkEndOfLine, 3, 1, alignment=Qt.AlignTop) #Find Errors self._checkHighlightLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_HIGHLIGHTING) self._checkHighlightLine.setChecked(settings.UNDERLINE_NOT_BACKGROUND) formFeatures.addWidget(self._checkHighlightLine, 4, 1, 1, 2, alignment=Qt.AlignTop) self._checkErrors = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_FIND_ERRORS) self._checkErrors.setChecked(settings.FIND_ERRORS) formFeatures.addWidget(self._checkErrors, 5, 1, 1, 2, alignment=Qt.AlignTop) self.connect(self._checkErrors, SIGNAL("stateChanged(int)"), self._disable_show_errors) self._showErrorsOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_ERRORS) self._showErrorsOnLine.setChecked(settings.ERRORS_HIGHLIGHT_LINE) self.connect(self._showErrorsOnLine, SIGNAL("stateChanged(int)"), self._enable_errors_inline) formFeatures.addWidget(self._showErrorsOnLine, 6, 2, 1, 1, Qt.AlignTop) #Find Check Style self._checkStyle = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_PEP8) self._checkStyle.setChecked(settings.CHECK_STYLE) formFeatures.addWidget(self._checkStyle, 7, 1, 1, 2, alignment=Qt.AlignTop) self.connect(self._checkStyle, SIGNAL("stateChanged(int)"), self._disable_check_style) self._checkStyleOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_PEP8) self._checkStyleOnLine.setChecked(settings.CHECK_HIGHLIGHT_LINE) self.connect(self._checkStyleOnLine, SIGNAL("stateChanged(int)"), self._enable_check_inline) formFeatures.addWidget(self._checkStyleOnLine, 8, 2, 1, 1, Qt.AlignTop) # Python3 Migration self._showMigrationTips = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MIGRATION) self._showMigrationTips.setChecked(settings.SHOW_MIGRATION_TIPS) formFeatures.addWidget(self._showMigrationTips, 9, 1, 1, 2, Qt.AlignTop) #Center On Scroll self._checkCenterScroll = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_CENTER_SCROLL) self._checkCenterScroll.setChecked(settings.CENTER_ON_SCROLL) formFeatures.addWidget(self._checkCenterScroll, 10, 1, 1, 2, alignment=Qt.AlignTop) #Remove Trailing Spaces add Last empty line automatically self._checkTrailing = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_REMOVE_TRAILING) self._checkTrailing.setChecked(settings.REMOVE_TRAILING_SPACES) formFeatures.addWidget(self._checkTrailing, 11, 1, 1, 2, alignment=Qt.AlignTop) #Show Tabs and Spaces self._checkShowSpaces = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TABS_AND_SPACES) self._checkShowSpaces.setChecked(settings.SHOW_TABS_AND_SPACES) formFeatures.addWidget(self._checkShowSpaces, 12, 1, 1, 2, alignment=Qt.AlignTop) self._allowWordWrap = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_WORD_WRAP) self._allowWordWrap.setChecked(settings.ALLOW_WORD_WRAP) formFeatures.addWidget(self._allowWordWrap, 13, 1, 1, 2, alignment=Qt.AlignTop) self._checkForDocstrings = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_CHECK_FOR_DOCSTRINGS) self._checkForDocstrings.setChecked(settings.CHECK_FOR_DOCSTRINGS) formFeatures.addWidget(self._checkForDocstrings, 14, 1, 1, 2, alignment=Qt.AlignTop) vbox.addWidget(groupBoxFeatures) vbox.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
class Ui_ViewEvtx(object): def setupUi(self, ViewEvtx): ViewEvtx.setObjectName(_fromUtf8("ViewEvtx")) ViewEvtx.resize(600, 480) ViewEvtx.setWindowTitle( QApplication.translate("ViewEvtx", "Dialog", None, QApplication.UnicodeUTF8)) self.mainLayout = QHBoxLayout(ViewEvtx) self.buttonLayout = QVBoxLayout() spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.buttonLayout.addItem(spacerItem) self.next_evtx = QPushButton(QIcon(":/next.png"), "") self.next_evtx.setToolTip("Next record") self.prev_evtx = QPushButton(QIcon(":/previous.png"), "") self.prev_evtx.setToolTip("Previous record") self.buttonLayout.addWidget(self.prev_evtx) self.buttonLayout.addWidget(self.next_evtx) self.verticalLayout_2 = QVBoxLayout() self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2")) self.verticalLayout = QVBoxLayout() self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.tabWidget = QTabWidget(ViewEvtx) self.tabWidget.setObjectName(_fromUtf8("tabWidget")) self.ViewSimple = QWidget() self.ViewSimple.setObjectName(_fromUtf8("ViewSimple")) self.verticalLayout_3 = QVBoxLayout(self.ViewSimple) self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3")) self.view = QTreeView(self.ViewSimple) self.view.setObjectName(_fromUtf8("view")) self.view.setWordWrap(True) self.verticalLayout_3.addWidget(self.view) self.tabWidget.addTab(self.ViewSimple, _fromUtf8("")) self.ViewXml = QWidget() self.ViewXml.setObjectName(_fromUtf8("ViewXml")) self.horizontalLayout = QHBoxLayout(self.ViewXml) self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.textEdit = QTextEdit(self.ViewXml) self.textEdit.setReadOnly(True) self.textEdit.setObjectName(_fromUtf8("textEdit")) self.horizontalLayout.addWidget(self.textEdit) self.tabWidget.addTab(self.ViewXml, _fromUtf8("")) self.verticalLayout.addWidget(self.tabWidget) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.buttonLayout.addItem(spacerItem) self.buttonBox = QDialogButtonBox(ViewEvtx) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.setObjectName(_fromUtf8("buttonBox")) self.verticalLayout.addWidget(self.buttonBox) self.verticalLayout_2.addLayout(self.verticalLayout) self.mainLayout.addLayout(self.verticalLayout_2) self.mainLayout.addLayout(self.buttonLayout) self.retranslateUi(ViewEvtx) self.tabWidget.setCurrentIndex(1) QObject.connect(self.buttonBox, SIGNAL(_fromUtf8("accepted()")), ViewEvtx.accept) QObject.connect(self.buttonBox, SIGNAL(_fromUtf8("rejected()")), ViewEvtx.reject) QMetaObject.connectSlotsByName(ViewEvtx) def retranslateUi(self, ViewEvtx): self.tabWidget.setTabText( self.tabWidget.indexOf(self.ViewSimple), QApplication.translate("ViewEvtx", "Simple view", None, QApplication.UnicodeUTF8)) self.tabWidget.setTabText( self.tabWidget.indexOf(self.ViewXml), QApplication.translate("ViewEvtx", "XmlView", None, QApplication.UnicodeUTF8))
def buildMixer(self): log.debug("Building mixer") self.MatrixButtonControls={} self.MatrixRotaryControls={} self.MatrixVolumeControls={} self.VolumeControls={} self.SelectorControls={} self.SPDIFmodeControls={} self.TriggerControls={} nb_pys_out = self.hw.getDiscrete("/HwInfo/PhysicalAudioOutCount") nb_pys_in = self.hw.getDiscrete("/HwInfo/PhysicalAudioInCount") outputtabslayout = QHBoxLayout( self ) outputtabs = QTabWidget(self) outputtabslayout.addWidget( outputtabs, 1 ) for outpair in range(nb_pys_out/2): tab = QWidget( outputtabs ) tablayout = QHBoxLayout( tab ) grpMonitor = QGroupBox(tab) tablayout.addWidget(grpMonitor) grpPlayback = QGroupBox(tab) tablayout.addWidget(grpPlayback) grpOutput = QGroupBox(tab) tablayout.addWidget(grpOutput) grpMonitor.setTitle("Monitor") grpPlayback.setTitle("Playback") grpOutput.setTitle("Output") # monitor controls grpMonitorLayout = QHBoxLayout() grpMonitor.setLayout(grpMonitorLayout); output_id = outpair * 2 for inpair in range(nb_pys_in/2): # create GUI elements strip = AfMonitorWidget( grpMonitor ) grpMonitorLayout.addWidget( strip, 1 ) input_id = inpair*2 strip.lblName.setText("In %d/%d" % (input_id+1, input_id+2)) # add the elements to the control structure self.MatrixButtonControls[strip.btnMute0] = ['/Mixer/MonitorMute', input_id, output_id] self.MatrixButtonControls[strip.btnMute1] = ['/Mixer/MonitorMute', input_id + 1, output_id + 1] self.MatrixButtonControls[strip.btnSolo0] = ['/Mixer/MonitorSolo', input_id, output_id] self.MatrixButtonControls[strip.btnSolo1] = ['/Mixer/MonitorSolo', input_id + 1, output_id + 1] self.MatrixRotaryControls[strip.rotPan0] = ['/Mixer/MonitorPan', input_id, output_id] self.MatrixRotaryControls[strip.rotPan1] = ['/Mixer/MonitorPan', input_id + 1, output_id + 1] self.MatrixVolumeControls[strip.sldGain0] = ['/Mixer/MonitorGain', input_id, output_id] self.MatrixVolumeControls[strip.sldGain1] = ['/Mixer/MonitorGain', input_id + 1, output_id + 1] # playback grpPlaybackLayout = QHBoxLayout() grpPlayback.setLayout(grpPlaybackLayout); strip = AfMonitorWidget( grpPlayback ) grpPlaybackLayout.addWidget(strip, 1) strip.lblName.setText("Playback %d/%d" % (output_id+1, output_id+2)) self.VolumeControls[strip.sldGain0] = ["/Mixer/PC%dGain" % (output_id)] self.VolumeControls[strip.sldGain1] = ["/Mixer/PC%dGain" % (output_id+1)] self.SelectorControls[strip.btnMute0] = ["/Mixer/PC%dMute" % (output_id)] self.SelectorControls[strip.btnMute1] = ["/Mixer/PC%dMute" % (output_id+1)] self.SelectorControls[strip.btnSolo0] = ["/Mixer/PC%dSolo" % (output_id)] self.SelectorControls[strip.btnSolo1] = ["/Mixer/PC%dSolo" % (output_id+1)] # fix up mixer strip gui strip.rotPan0.hide() strip.rotPan1.hide() # output grpOutputLayout = QHBoxLayout() grpOutput.setLayout(grpOutputLayout); strip = AfMonitorWidget( grpOutput ) grpOutputLayout.addWidget(strip, 1) strip.lblName.setText("Output %d/%d" % (output_id+1, output_id+2)) self.VolumeControls[strip.sldGain0] = ["/Mixer/OUT%dGain" % (output_id)] self.VolumeControls[strip.sldGain1] = ["/Mixer/OUT%dGain" % (output_id+1)] self.SelectorControls[strip.btnMute0] = ["/Mixer/OUT%dMute" % (output_id)] self.SelectorControls[strip.btnMute1] = ["/Mixer/OUT%dMute" % (output_id+1)] self.SelectorControls[strip.btnSolo0] = ["/Mixer/OUT%dNominal" % (output_id)] self.SelectorControls[strip.btnSolo1] = ["/Mixer/OUT%dNominal" % (output_id+1)] # fix up mixer strip gui strip.btnSolo0.setText("Pad") strip.btnSolo1.setText("Pad") strip.rotPan0.hide() strip.rotPan1.hide() # add the tab outputtabs.addTab( tab, "Out %d/%d" % (output_id+1, output_id+2)) # add an input config tab tab = QWidget( outputtabs ) tablayout = QHBoxLayout( tab ) for inpair in range(nb_pys_in): # create GUI elements log.debug("strip") grpInput = QGroupBox(tab) tablayout.addWidget(grpInput) grpInput.setTitle("In %d" % (inpair+1)) grpInputLayout = QVBoxLayout() grpInput.setLayout(grpInputLayout); label = QLabel( grpInput ) grpInputLayout.addWidget( label ) label.setText("In %d" % (inpair+1)) label.setAlignment(Qt.AlignCenter) btn = QToolButton( grpInput ) grpInputLayout.addWidget( btn ) btn.setText("Pad") btn.setCheckable(True) self.SelectorControls[btn] = ["/Mixer/IN%dNominal" % (inpair)] spacer = QSpacerItem(1,1,QSizePolicy.Minimum,QSizePolicy.Expanding) grpInputLayout.addItem(spacer) outputtabs.addTab( tab, "Input") # add an settings tab tab = QWidget( outputtabs ) tablayout = QHBoxLayout( tab ) outputtabs.addTab( tab, "Settings") settings = AfSettingsWidget( tab ) has_sw_phantom = self.hw.getDiscrete("/HwInfo/PhantomPower") if has_sw_phantom: self.SelectorControls[settings.btnPhantom] = ["/PhantomPower"] else: settings.btnPhantom.hide() self.TriggerControls[settings.btnSaveSettings] = ["/SaveSettings"] self.TriggerControls[settings.btnIdentify] = ["/Identify"] self.SPDIFmodeControls[settings.radioConsumer] = ["/SpdifMode", 0] self.SPDIFmodeControls[settings.radioProfessional] = ["/SpdifMode", 1] # Store a reference to the "save" button for later manipulation self.btnSaveSettings = settings.btnSaveSettings
def runInputDialog(self, title, c1Text, c2Text, opText, outText, cell1, cell2, outCell): rows = [] cols = [] for r in range(self.table.rowCount()): rows.append(str(r + 1)) for c in range(self.table.columnCount()): cols.append(chr(ord('A') + c)) addDialog = QDialog(self) addDialog.setWindowTitle(title) group = QGroupBox(title, addDialog) group.setMinimumSize(250, 100) cell1Label = QLabel(c1Text, group) cell1RowInput = QComboBox(group) c1Row, c1Col = decode_pos(cell1) cell1RowInput.addItems(rows) cell1RowInput.setCurrentIndex(c1Row) cell1ColInput = QComboBox(group) cell1ColInput.addItems(cols) cell1ColInput.setCurrentIndex(c1Col) operatorLabel = QLabel(opText, group) operatorLabel.setAlignment(Qt.AlignHCenter) cell2Label = QLabel(c2Text, group) cell2RowInput = QComboBox(group) c2Row, c2Col = decode_pos(cell2) cell2RowInput.addItems(rows) cell2RowInput.setCurrentIndex(c2Row) cell2ColInput = QComboBox(group) cell2ColInput.addItems(cols) cell2ColInput.setCurrentIndex(c2Col) equalsLabel = QLabel("=", group) equalsLabel.setAlignment(Qt.AlignHCenter) outLabel = QLabel(outText, group) outRowInput = QComboBox(group) outRow, outCol = decode_pos(outCell) outRowInput.addItems(rows) outRowInput.setCurrentIndex(outRow) outColInput = QComboBox(group) outColInput.addItems(cols) outColInput.setCurrentIndex(outCol) cancelButton = QPushButton("Cancel", addDialog) cancelButton.clicked.connect(addDialog.reject) okButton = QPushButton("OK", addDialog) okButton.setDefault(True) okButton.clicked.connect(addDialog.accept) buttonsLayout = QHBoxLayout() buttonsLayout.addStretch(1) buttonsLayout.addWidget(okButton) buttonsLayout.addSpacing(10) buttonsLayout.addWidget(cancelButton) dialogLayout = QVBoxLayout(addDialog) dialogLayout.addWidget(group) dialogLayout.addStretch(1) dialogLayout.addItem(buttonsLayout) cell1Layout = QHBoxLayout() cell1Layout.addWidget(cell1Label) cell1Layout.addSpacing(10) cell1Layout.addWidget(cell1ColInput) cell1Layout.addSpacing(10) cell1Layout.addWidget(cell1RowInput) cell2Layout = QHBoxLayout() cell2Layout.addWidget(cell2Label) cell2Layout.addSpacing(10) cell2Layout.addWidget(cell2ColInput) cell2Layout.addSpacing(10) cell2Layout.addWidget(cell2RowInput) outLayout = QHBoxLayout() outLayout.addWidget(outLabel) outLayout.addSpacing(10) outLayout.addWidget(outColInput) outLayout.addSpacing(10) outLayout.addWidget(outRowInput) vLayout = QVBoxLayout(group) vLayout.addItem(cell1Layout) vLayout.addWidget(operatorLabel) vLayout.addItem(cell2Layout) vLayout.addWidget(equalsLabel) vLayout.addStretch(1) vLayout.addItem(outLayout) if addDialog.exec_(): cell1 = cell1ColInput.currentText() + cell1RowInput.currentText() cell2 = cell2ColInput.currentText() + cell2RowInput.currentText() outCell = outColInput.currentText() + outRowInput.currentText() return True, cell1, cell2, outCell return False, None, None, None
def createPrefPage(self): self.pref_page = QWidget() self.pref_page.setObjectName("pref_page") page_layout = QVBoxLayout(self.pref_page) page_layout.setSpacing(7) page_layout.setContentsMargins(10, 20, 0, 10) textBox = QGroupBox() textBox.setTitle(QApplication.translate("option", "Text inserted")) text_layout = QGridLayout(textBox) text_layout.setSpacing(7) text_layout.setContentsMargins(10, 10, 10, 10) self.echo_color_button = QPushButton() self.echo_color_button.setFixedHeight(28) self.echo_color_button.setIcon(QIcon(":/images/button-color.png")) self.echo_color_button.setText(QApplication.translate("option", "Echo Color")) text_layout.addWidget(self.echo_color_button, 0, 0) self.echo_color = self.createSquareLabel() self.echo_color.setProperty('label_color', QVariant(True)) text_layout.addWidget(self.echo_color, 0, 3) horiz_spacer = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) text_layout.addItem(horiz_spacer, 0, 4) self.label_cmd_separator = QLabel() self.label_cmd_separator.setText(QApplication.translate("option", "Command separator")) text_layout.addWidget(self.label_cmd_separator, 1, 0, 1, 2) self.cmd_separator = QLineEdit() self.cmd_separator.setFixedSize(24, 24) font = QtGui.QFont() font.setWeight(75) font.setBold(True) self.cmd_separator.setFont(font) self.cmd_separator.setMaxLength(1) self.cmd_separator.setAlignment(Qt.AlignCenter) text_layout.addWidget(self.cmd_separator, 1, 3) horiz_spacer2 = QSpacerItem(20, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) text_layout.addItem(horiz_spacer2, 1, 4) self.keep_text = QCheckBox() self.keep_text.setText(QApplication.translate("option", "Keep text entered")) text_layout.addWidget(self.keep_text, 2, 0, 1, 4, Qt.AlignLeft) page_layout.addWidget(textBox) generalBox = QGroupBox() generalBox.setTitle(QApplication.translate("option", "General")) general_layout = QVBoxLayout(generalBox) general_layout.setSpacing(7) general_layout.setContentsMargins(10, 10, 10, 10) self.save_log = QCheckBox() self.save_log.setText(QApplication.translate("option", "Save log")) general_layout.addWidget(self.save_log, 0, Qt.AlignLeft) horiz_spacer = QSpacerItem(20, 20, QSizePolicy.Fixed, QSizePolicy.Minimum) general_layout.addItem(horiz_spacer) page_layout.addWidget(generalBox) horiz_spacer2 = QSpacerItem(20, 20, QSizePolicy.Fixed, QSizePolicy.Minimum) page_layout.addItem(horiz_spacer2) self.save_preferences = QPushButton() self.save_preferences.setFixedHeight(28) self.save_preferences.setIcon(QIcon(":/images/button-save.png")) self.save_preferences.setText(QApplication.translate("option", "Save")) page_layout.addWidget(self.save_preferences, 0, Qt.AlignRight) return self.pref_page
def __init__(self): super(FlagsSection, self).__init__() container = QVBoxLayout(self) group_flags = QGroupBox(self.tr("Flags:")) box = QGridLayout(group_flags) box.setContentsMargins(20, 5, 20, 5) compiler_flags = settings.COMPILER_FLAGS.split() # -Wall self.check_wall = QCheckBox( self.tr("Habilitar todas las advertencias comunes [-Wall]")) if '-Wall' in compiler_flags: self.check_wall.setChecked(True) box.addWidget(self.check_wall, 0, 0) # -Wextra self.check_wextra = QCheckBox( self.tr("Habilitar advertencias extras [-Wextra]")) if '-Wextra' in compiler_flags: self.check_wextra.setChecked(True) box.addWidget(self.check_wextra, 0, 1) # -Wfatal-errors self.check_wfatal_error = QCheckBox( self.tr("Frenar compilación después del primer error " "[-Wfatal-errors]")) if '-Wfatal-erros' in compiler_flags: self.check_wfatal_error.setChecked(True) box.addWidget(self.check_wfatal_error, 1, 0) # -w self.check_w = QCheckBox( self.tr("Inhibir todos los mensajes de advertencia [-w]")) if '-w' in compiler_flags: self.check_w.setChecked(True) box.addWidget(self.check_w, 1, 1) group_optimization = QGroupBox(self.tr("Optimización:")) box = QGridLayout(group_optimization) box.setContentsMargins(20, 5, 20, 5) # -O self.check_o = QCheckBox( self.tr("Optimizar código para velocidad [-O]")) if '-O' in compiler_flags: self.check_o.setChecked(True) box.addWidget(self.check_o, 0, 0) # -O1 self.check_o1 = QCheckBox( self.tr("Optimizar más el código para velocidad [-O1]")) if '-O1' in compiler_flags: self.check_o1.setChecked(True) box.addWidget(self.check_o1, 0, 1) # -O2 self.check_o2 = QCheckBox( self.tr("Optimizar aún más el código para velocidad [-O2]")) if '-O2' in compiler_flags: self.check_o2.setChecked(True) box.addWidget(self.check_o2, 1, 0) # -O3 self.check_o3 = QCheckBox( self.tr("Optimizar totalmente el código para velocidad [-O3]")) if '-O3' in compiler_flags: self.check_o3.setChecked(True) box.addWidget(self.check_o3, 1, 1) # -Os self.check_os = QCheckBox( self.tr("Optimizar el código para tamaño [-Os]")) if '-Os' in compiler_flags: self.check_os.setChecked(True) box.addWidget(self.check_os, 2, 0) container.addWidget(group_flags) container.addWidget(group_optimization) container.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) CompilerConfiguration.install_widget( self.tr("Opciones del Compilador"), self)
def dispSingleEvent(self, row, column): box = QDialog() main_layout = QHBoxLayout(box) main_widget = QWidget() main_layout.addWidget(main_widget) layout = QVBoxLayout(main_widget) node_ptr = self.item(row, 4).text() index = int(self.item(row, 5).text()) processus_manager = ModuleProcessusManager() evt = processus_manager.get('evt') record = evt.evts[long(node_ptr)][index] self.label1 = QLabel("Date : " + record.getTimeGenerated()) self.label2 = QLabel("Source : " + record.sourceName()) self.label3 = QLabel("Type : " + record.getSingleType()) self.lab_icon = QLabel() self.lab_icon.setPixmap( QPixmap(record.getIcon()).scaled(32, 32, Qt.KeepAspectRatio)) weed = QWidget() l = QHBoxLayout(weed) l.addWidget(self.lab_icon) l.addWidget(self.label3) self.label4 = QLabel("Category : " + str(record.EventCategory)) self.label5 = QLabel("EventId : " + str(record.EventID)) self.label6 = QLabel("Computer : " + record.computerName()) layout.addWidget(self.subWidget(self.label1, self.label2)) layout.addWidget(self.subWidget(weed, self.label4)) layout.addWidget(self.subWidget(self.label5, self.label6)) layout.addWidget(QLabel('Messages :')) self.log_strings = QTextEdit('') self.log_strings.setReadOnly(True) self.log_strings.setLineWrapMode(QTextEdit.WidgetWidth) for log in record.getStrings(): if log is not None: self.log_strings.setPlainText(self.log_strings.toPlainText() + log + "\n\n") layout.addWidget(self.log_strings) button_widget = QWidget() main_layout.addWidget(button_widget) self.next_evt = QPushButton(QIcon(":/next.png"), "") self.next_evt.setToolTip("Next record") self.prev_evt = QPushButton(QIcon(":/previous.png"), "") self.prev_evt.setToolTip("Previous record") self.next_evt.clicked.connect(self.dispNextEvent) self.prev_evt.clicked.connect(self.dispPrevEvent) if row == 0: self.prev_evt.setEnabled(False) elif row + 1 == self.rowCount(): self.next_evt.setEnabled(False) else: self.hideOrDipsButton() button_layout = QVBoxLayout(button_widget) button_layout.addWidget(self.prev_evt) button_layout.addWidget(self.next_evt) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) button_layout.addItem(spacerItem) close_button = QPushButton("Close") close_button.clicked.connect(box.done) button_layout.addWidget(close_button) box.exec_()
def buildMixer(self): log.debug("Building mixer") self.MatrixButtonControls={} self.MatrixRotaryControls={} self.MatrixVolumeControls={} self.VolumeControls={} self.SelectorControls={} self.SPDIFmodeControls={} self.TriggerControls={} nb_pys_out = self.hw.getDiscrete("/HwInfo/PhysicalAudioOutCount") nb_pys_in = self.hw.getDiscrete("/HwInfo/PhysicalAudioInCount") outputtabslayout = QHBoxLayout( self ) outputtabs = QTabWidget(self) outputtabslayout.addWidget( outputtabs, 1 ) for outpair in range(nb_pys_out/2): tab = QWidget( outputtabs ) tablayout = QHBoxLayout( tab ) grpMonitor = QGroupBox(tab) tablayout.addWidget(grpMonitor) grpPlayback = QGroupBox(tab) tablayout.addWidget(grpPlayback) grpOutput = QGroupBox(tab) tablayout.addWidget(grpOutput) grpMonitor.setTitle("Monitor") grpPlayback.setTitle("Playback") grpOutput.setTitle("Output") # monitor controls grpMonitorLayout = QHBoxLayout() grpMonitor.setLayout(grpMonitorLayout); output_id = outpair * 2 for inpair in range(nb_pys_in/2): # create GUI elements strip = AfMonitorWidget( grpMonitor ) grpMonitorLayout.addWidget( strip, 1 ) input_id = inpair*2 strip.lblName.setText("IN %d/%d" % (input_id+1, input_id+2)) # add the elements to the control structure self.MatrixButtonControls[strip.btnMute0] = ['/Mixer/MonitorMute', input_id, output_id] self.MatrixButtonControls[strip.btnMute1] = ['/Mixer/MonitorMute', input_id + 1, output_id + 1] self.MatrixButtonControls[strip.btnSolo0] = ['/Mixer/MonitorSolo', input_id, output_id] self.MatrixButtonControls[strip.btnSolo1] = ['/Mixer/MonitorSolo', input_id + 1, output_id + 1] self.MatrixRotaryControls[strip.rotPan0] = ['/Mixer/MonitorPan', input_id, output_id] self.MatrixRotaryControls[strip.rotPan1] = ['/Mixer/MonitorPan', input_id + 1, output_id + 1] self.MatrixVolumeControls[strip.sldGain0] = ['/Mixer/MonitorGain', input_id, output_id] self.MatrixVolumeControls[strip.sldGain1] = ['/Mixer/MonitorGain', input_id + 1, output_id + 1] # playback grpPlaybackLayout = QHBoxLayout() grpPlayback.setLayout(grpPlaybackLayout); strip = AfMonitorWidget( grpPlayback ) grpPlaybackLayout.addWidget(strip, 1) strip.lblName.setText("Playback %d/%d" % (output_id+1, output_id+2)) self.VolumeControls[strip.sldGain0] = ["/Mixer/PC%dGain" % (output_id)] self.VolumeControls[strip.sldGain1] = ["/Mixer/PC%dGain" % (output_id+1)] self.SelectorControls[strip.btnMute0] = ["/Mixer/PC%dMute" % (output_id)] self.SelectorControls[strip.btnMute1] = ["/Mixer/PC%dMute" % (output_id+1)] self.SelectorControls[strip.btnSolo0] = ["/Mixer/PC%dSolo" % (output_id)] self.SelectorControls[strip.btnSolo1] = ["/Mixer/PC%dSolo" % (output_id+1)] # fix up mixer strip gui strip.rotPan0.hide() strip.rotPan1.hide() # output grpOutputLayout = QHBoxLayout() grpOutput.setLayout(grpOutputLayout); strip = AfMonitorWidget( grpOutput ) grpOutputLayout.addWidget(strip, 1) strip.lblName.setText("Output %d/%d" % (output_id+1, output_id+2)) self.VolumeControls[strip.sldGain0] = ["/Mixer/OUT%dGain" % (output_id)] self.VolumeControls[strip.sldGain1] = ["/Mixer/OUT%dGain" % (output_id+1)] self.SelectorControls[strip.btnMute0] = ["/Mixer/OUT%dMute" % (output_id)] self.SelectorControls[strip.btnMute1] = ["/Mixer/OUT%dMute" % (output_id+1)] self.SelectorControls[strip.btnSolo0] = ["/Mixer/OUT%dNominal" % (output_id)] self.SelectorControls[strip.btnSolo1] = ["/Mixer/OUT%dNominal" % (output_id+1)] # fix up mixer strip gui strip.btnSolo0.setText("Pad") strip.btnSolo1.setText("Pad") strip.rotPan0.hide() strip.rotPan1.hide() # add the tab outputtabs.addTab( tab, "OUT %d/%d" % (output_id+1, output_id+2)) # add an input config tab tab = QWidget( outputtabs ) tablayout = QHBoxLayout( tab ) for inpair in range(nb_pys_in): # create GUI elements log.debug("strip") grpInput = QGroupBox(tab) tablayout.addWidget(grpInput) grpInput.setTitle("IN %d" % (inpair+1)) grpInputLayout = QVBoxLayout() grpInput.setLayout(grpInputLayout); label = QLabel( grpInput ) grpInputLayout.addWidget( label ) label.setText("frienlyname %d" % (inpair+1)) label.setAlignment(Qt.AlignCenter) btn = QPushButton( grpInput ) grpInputLayout.addWidget( btn ) btn.setText("Pad") btn.setCheckable(True) self.SelectorControls[btn] = ["/Mixer/IN%dNominal" % (inpair)] spacer = QSpacerItem(1,1,QSizePolicy.Minimum,QSizePolicy.Expanding) grpInputLayout.addItem(spacer) outputtabs.addTab( tab, "INPUT") # add an settings tab tab = QWidget( outputtabs ) tablayout = QHBoxLayout( tab ) outputtabs.addTab( tab, "SETTINGS") settings = AfSettingsWidget( tab ) has_sw_phantom = self.hw.getDiscrete("/HwInfo/PhantomPower") if has_sw_phantom: self.SelectorControls[settings.btnPhantom] = ["/PhantomPower"] else: settings.btnPhantom.hide() self.TriggerControls[settings.btnSaveSettings] = ["/SaveSettings"] self.TriggerControls[settings.btnIdentify] = ["/Identify"] self.SPDIFmodeControls[settings.radioConsumer] = ["/SpdifMode", 0] self.SPDIFmodeControls[settings.radioProfessional] = ["/SpdifMode", 1]
class previewDlg(QMainWindow): ''' classdocs ''' def __init__(self, parent, comp, basePMCheck, model): ''' Constructor ''' QMainWindow.__init__(self, parent) self.basePMCheck = basePMCheck # self.ui = Ui_Previewself.grbPageProperty() # self.ui.setupUi(self) self.resize(1000, 700) self.setWindowTitle("Preview Dialog") self.view = QgsComposerView(self) viewLayout = QGridLayout() viewLayout.setSpacing(0) viewLayout.setMargin(0) mHorizontalRuler = QgsComposerRuler(QgsComposerRuler.Horizontal) mVerticalRuler = QgsComposerRuler(QgsComposerRuler.Vertical) mRulerLayoutFix = QWidget() mRulerLayoutFix.setAttribute(Qt.WA_NoMousePropagation) mRulerLayoutFix.setBackgroundRole(QPalette.Window) mRulerLayoutFix.setFixedSize(mVerticalRuler.rulerSize(), mHorizontalRuler.rulerSize()) viewLayout.addWidget(mRulerLayoutFix, 0, 0) viewLayout.addWidget(mHorizontalRuler, 0, 1) viewLayout.addWidget(mVerticalRuler, 1, 0) self.view.setContentsMargins(0, 0, 0, 0) self.view.setHorizontalRuler(mHorizontalRuler) self.view.setVerticalRuler(mVerticalRuler) viewLayout.addWidget(self.view, 1, 1) # self.scene = comp self.view.setZoomLevel(1.0) self.view.setComposition(comp) self.scene = self.view.composition() layout = QVBoxLayout() hLayout = QHBoxLayout() hLayout.addLayout(viewLayout) self.mapItem = self.scene.getComposerMapById(0) self.view.scale(2.8, 2.8) self.view.setPreviewModeEnabled(True) self.toolBarAction = self.addToolBar("composer action") self.actionMapRefresh = QAction(self) self.actionMapRefresh.setObjectName("actionMapRefresh") icon3 = QIcon("Resource/Refresh.png") self.actionMapRefresh.setIcon(icon3) self.actionMapRefresh.setToolTip("Refresh") # self.textItemAction.setCheckable(True) self.connect(self.actionMapRefresh, SIGNAL("triggered()"), self.actionMapRefresh_triggered) self.toolBarAction.addAction(self.actionMapRefresh) # # self.templeteCreateAction = QAction(self) # # self.templeteCreateAction.setObjectName("createTempleteAction") # # icon4 = QIcon("Resource\\templetepointer.png") # # self.templeteCreateAction.setIcon(icon4) # # self.templeteCreateAction.setToolTip("Create Templete") # # self.templeteCreateAction.setCheckable(True) # # self.connect(self.templeteCreateAction, SIGNAL("triggered()"), self.createTempleteAction) # # self.toolBar.addAction(self.templeteCreateAction) # layout.insertWidget(0, self.toolBar) # self.scene.selectedItemChanged.connect(self.selectedItemDisplay) self.view.selectedItemChanged.connect(self.selectedItemDisplay) self.view.cursorPosChanged.connect(self.cursorPosChangedEvent) # self.connect(self.view, SIGNAL("selectedItemChanged(QgsComposerItem)"),self, SLOT("selectedItemDisplay(QgsComposerItem)")) # self.scene.composerLabelAdded.connect(self.composerLabelAddedEvent) self.view.itemRemoved.connect(self.deleteItem) # self.connect( self.view, SIGNAL( "actionFinished()" ), self.setSelectionTool) #listen out for position updates from the QgsComposerView self.propertyWidget = QWidget(self) hLayout.addWidget(self.propertyWidget) self.propertyWidget.setObjectName("propertyWidget") self.propertyWidget.resize(222, 302) self.vLayout_3 = QVBoxLayout(self.propertyWidget) self.vLayout_3.setObjectName("vLayout_3") self.groupBox = QGroupBox(self.propertyWidget) self.groupBox.setObjectName("groupBox") self.horizontalLayout_2 = QHBoxLayout(self.groupBox) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.frame = QFrame(self.groupBox) self.frame.setFrameShape(QFrame.StyledPanel) self.frame.setFrameShadow(QFrame.Raised) self.frame.setObjectName("frame") self.verticalLayout = QVBoxLayout(self.frame) self.verticalLayout.setObjectName("verticalLayout") self.label = QLabel(self.frame) self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.labelText = QPlainTextEdit(self.frame) self.labelText.setObjectName("labelText") self.verticalLayout.addWidget(self.labelText) self.btnLabelFont = QPushButton(self.frame) self.btnLabelFont.setObjectName("btnLabelFont") self.verticalLayout.addWidget(self.btnLabelFont) self.btnLabelColor = QPushButton(self.frame) self.btnLabelColor.setObjectName("btnLabelColor") self.verticalLayout.addWidget(self.btnLabelColor) self.frame_2 = QFrame(self.frame) self.frame_2.setFrameShape(QFrame.StyledPanel) self.frame_2.setFrameShadow(QFrame.Raised) self.frame_2.setObjectName("frame_2") self.horizontalLayout = QHBoxLayout(self.frame_2) self.horizontalLayout.setObjectName("horizontalLayout") self.label_2 = QLabel(self.frame_2) self.label_2.setObjectName("label_2") self.horizontalLayout.addWidget(self.label_2) self.spinLabelRotation = QSpinBox(self.frame_2) self.spinLabelRotation.setObjectName("spinLabelRotation") self.spinLabelRotation.setMinimum(-360) self.spinLabelRotation.setMaximum(360) self.horizontalLayout.addWidget(self.spinLabelRotation) self.verticalLayout.addWidget(self.frame_2) self.chbBackgroundEnable = QCheckBox(self.frame) self.chbBackgroundEnable.setChecked(True) self.chbBackgroundEnable.setObjectName("chbBackgroundEnable") self.verticalLayout.addWidget(self.chbBackgroundEnable) self.horizontalLayout_2.addWidget(self.frame) self.vLayout_3.addWidget(self.groupBox) self.resolutionFrame = QFrame(self.frame) self.resolutionFrame.setFrameShape(QFrame.StyledPanel) self.resolutionFrame.setFrameShadow(QFrame.Raised) self.resolutionFrame.setObjectName("resolutionFrame") self.horizontalLayout4 = QHBoxLayout(self.resolutionFrame) self.horizontalLayout4.setObjectName("horizontalLayout4") self.label_resolution = QLabel(self.resolutionFrame) self.label_resolution.setObjectName("label_resolution") self.label_resolution.setText("Print Resolution (dpi):") self.horizontalLayout4.addWidget(self.label_resolution) self.spinResolution = QSpinBox(self.resolutionFrame) self.spinResolution.setObjectName("spinResolution") self.spinResolution.setMinimum(0) self.spinResolution.setMaximum(1000) self.spinResolution.setValue(300) self.horizontalLayout4.addWidget(self.spinResolution) # self.verticalLayout.addWidget(self.frame_2) self.vLayout_3.addWidget(self.resolutionFrame) self.gbTable = GroupBox(self.propertyWidget) self.gbTable.Caption = "Table" self.vLayout_3.addWidget(self.gbTable) self.mTableView = QTableView(self.gbTable) self.gbTable.Add = self.mTableView hHeder = self.mTableView.horizontalHeader() hHeder.setVisible(False) vHeder = self.mTableView.verticalHeader() vHeder.setVisible(False) # self.mTableView.setFixedHeight(70) # self.mTableView.setFixedWidth(comp.paperWidth() - 40) # self.stdItemModel = QStandardItemModel() # self. self.spaceItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.vLayout_3.addItem(self.spaceItem) self.groupBox.setTitle("Label Property") self.label.setText("Label Text:") self.btnLabelFont.setText("Label Font") self.btnLabelColor.setText("Label Color") self.label_2.setText("Label Rotation:") self.chbBackgroundEnable.setText("Background Enable") self.groupBox.setEnabled(False) self.connect(self.btnLabelFont, SIGNAL("clicked()"), self.btnLabelFontClick) self.connect(self.btnLabelColor, SIGNAL("clicked()"), self.btnLabelColorClick) self.connect(self.chbBackgroundEnable, SIGNAL("clicked()"), self.chbBackgroundEnableClick) self.labelText.textChanged.connect(self.labelTextChanged) self.spinLabelRotation.valueChanged.connect( self.spinLabelRotationValueChanged) layout.addLayout(hLayout) # self.btnBack = QPushButton() self.btnBack.setText("back") footerLayout = QHBoxLayout() footerLayout.addWidget(self.btnBack) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel | QDialogButtonBox.Ok) self.buttonBox.setObjectName("buttonBox") footerLayout.addWidget(self.buttonBox) layout.addLayout(footerLayout) self.setLayout(layout) deleteItemKey = QShortcut(QKeySequence(Qt.Key_Delete), self) deleteItemKey.activated.connect(self.deleteItem) # self.btnBack.clicked.connect(self.back) self.connect(self.buttonBox, SIGNAL("accepted()"), self.acceptMethod) self.connect(self.buttonBox, SIGNAL("rejected()"), self.reject) self.btnCancel = self.buttonBox.button(QDialogButtonBox.Cancel) self.view.setCurrentTool(QgsComposerView.Select) self.btnLabelColor.setVisible(False) # self.btnBack.setVisible(False) self.chbBackgroundEnable.setVisible(False) # self.view.emit(SIGNAL("actionFinished")) # if self.scene.plotStyle() != QgsComposition.Preview: # self.scene.setPlotStyle(QgsComposition.Preview) # self.mapItem.setPreviewMode(QgsComposerMap.Render) # self.mapItem.updateCachedImage() # self.mapItem.setSelected(True) self.mComposition = comp self.composerMapItem = self.mComposition.composerMapItems()[0] self.composerMapItem.setUpdatesEnabled(True) self.mStdModel = model self.mTableView.setModel(self.mStdModel) self.mTableView.setSpan(0, 0, 1, 6) self.mTableView.setSpan(1, 0, 1, 2) self.mTableView.setSpan(2, 0, 2, 1) self.mTableView.setSpan(4, 0, 1, 2) self.mTableView.setSpan(5, 0, 1, 2) self.mTableView.setSpan(6, 0, 1, 2) self.mTableView.setSpan(0, 6, 1, 8) self.mTableView.setSpan(1, 7, 1, 4) self.mTableView.setSpan(1, 11, 1, 3) self.mTableView.setSpan(2, 7, 1, 4) self.mTableView.setSpan(2, 11, 1, 3) def acceptMethod(self): # self.mStdModel.setItem(0, QStandardItem("nnnnnnnn")) filePath = QFileDialog.getSaveFileName( self, "Save PDF File", QCoreApplication.applicationDirPath(), "pdf files(*.pdf )") if filePath == "": return self.mComposition.clearSelection() self.mComposition.setPrintResolution(self.spinResolution.value()) resultPdf = self.mComposition.exportAsPDF(filePath) if resultPdf: message = QMessageBox.information(self, "Result", "Successful export PDF") else: message = QMessageBox.information(self, "Result", "Don't export PDF") def rePresent(self, comp, model): self.mComposition = comp self.mStdModel = model self.view.setComposition(comp) self.scene = self.view.composition() def back(self): self.done(2) def spinLabelRotationValueChanged(self, rotationValue): self.selectedLabelItem.setItemRotation(rotationValue) def cursorPosChangedEvent(self, scenePointF): self.scenePoint = scenePointF # i = 100 def labelTextChanged(self): self.selectedLabelItem.beginCommand( "Label text changed", QgsComposerMergeCommand.ComposerLabelSetText) self.selectedLabelItem.blockSignals(True) self.selectedLabelItem.setText(self.labelText.toPlainText()) self.selectedLabelItem.update() self.selectedLabelItem.blockSignals(False) self.selectedLabelItem.endCommand() def chbBackgroundEnableClick(self): if self.chbBackgroundEnable.isChecked(): self.selectedLabelItem.setBackgroundEnabled(True) self.mapItem.updateCachedImage() else: self.selectedLabelItem.setBackgroundEnabled(False) self.mapItem.updateCachedImage() def btnLabelFontClick(self): dlgFont = QFontDialog(self) dlgFont.setCurrentFont(self.selectedLabelItem.font()) result = dlgFont.exec_() if result == 1: self.labelFont = dlgFont.selectedFont() else: self.labelFont = QFont() self.selectedLabelItem.setFont(self.labelFont) def btnLabelColorClick(self): dlgColor = QColorDialog(self) dlgColor.setCurrentColor(self.selectedLabelItem.fontColor()) result = dlgColor.exec_() if result == 1: self.labelColor = dlgColor.selectedColor() self.selectedLabelItem.setFontColor(self.labelColor) def createTempleteAction(self): if self.templeteCreateAction.isChecked() and self.basePMCheck: font = QFont("Arial", 13) font.setItalic(True) self.compLabel1 = QgsComposerLabel(self.scene) self.compLabel1.setFont(font) self.compLabel1.setText("South China Sea") self.compLabel1.setBackgroundEnabled(False) self.compLabel1.setItemPosition(156, 100) self.compLabel1.adjustSizeToText() self.compLabel1.setItemRotation(60) # mapitem = self.scene.composerMapItems() # mapitem[0].addItem(self.compLabel1) self.scene.addItem(self.compLabel1) self.compLabel2 = QgsComposerLabel(self.scene) self.compLabel2.setFont(font) self.compLabel2.setText("Straits Of Malacca") self.compLabel2.setBackgroundEnabled(False) self.compLabel2.setItemPosition(35, 100) self.compLabel2.adjustSizeToText() self.compLabel2.setItemRotation(60) self.scene.addItem(self.compLabel2) font.setItalic(False) self.compLabel3 = QgsComposerLabel(self.scene) self.compLabel3.setFont(font) self.compLabel3.setBackgroundEnabled(False) self.compLabel3.setText("THAILAND") self.compLabel3.setItemPosition(68, 60) self.compLabel3.adjustSizeToText() # self.compLabel3.setItemRotation(0.5) self.scene.addItem(self.compLabel3) # self.templeteCreateAction.setChecked(False) self.compLabel4 = QgsComposerLabel(self.scene) self.compLabel4.setFont(font) self.compLabel4.setBackgroundEnabled(False) self.compLabel4.setText("SINGAPORE") self.compLabel4.setItemPosition(141, 218) self.compLabel4.adjustSizeToText() # self.compLabel3.setItemRotation(0.5) self.scene.addItem(self.compLabel4) self.templeteCreateAction.setChecked(False) self.compLabel4.setSelected(True) elif self.templeteCreateAction.isChecked( ) and self.basePMCheck == False: font = QFont("Arial", 14) font.setItalic(True) self.compLabel5 = QgsComposerLabel(self.scene) self.compLabel5.setFont(font) self.compLabel5.setText("South China Sea") self.compLabel5.setBackgroundEnabled(False) self.compLabel5.setItemPosition(108, 86) self.compLabel5.adjustSizeToText() self.compLabel5.setItemRotation(-45) # mapitem = self.scene.composerMapItems() # mapitem[0].addItem(self.compLabel1) self.scene.addItem(self.compLabel5) self.compLabel6 = QgsComposerLabel(self.scene) self.compLabel6.setFont(font) self.compLabel6.setText("Sulu Sea") self.compLabel6.setBackgroundEnabled(False) self.compLabel6.setItemPosition(236, 38) self.compLabel6.adjustSizeToText() self.compLabel6.setItemRotation(45) self.scene.addItem(self.compLabel6) font.setItalic(False) self.compLabel7 = QgsComposerLabel(self.scene) self.compLabel7.setFont(font) self.compLabel7.setBackgroundEnabled(False) self.compLabel7.setText("Celebes Sea") self.compLabel7.setItemPosition(242, 112) self.compLabel7.adjustSizeToText() self.compLabel7.setItemRotation(-45) # self.compLabel3.setItemRotation(0.5) self.scene.addItem(self.compLabel7) # self.templeteCreateAction.setChecked(False) self.compLabel8 = QgsComposerLabel(self.scene) self.compLabel8.setFont(font) self.compLabel8.setBackgroundEnabled(False) self.compLabel8.setText("INDONESIA\n(Kalimantan)") self.compLabel8.setItemPosition(172, 148, 32, 16) # self.compLabel8.setHAlign(Qt.AlignHCenter) # self.compLabel8.setVAlign(Qt.AlignVCenter) # self.compLabel8.setFrameEnabled(False) # self.compLabel8.setItemPosition() # self.compLabel8.adjustSizeToText() # self.compLabl3.setItemRotation(0.5) self.scene.addItem(self.compLabel8) self.compLabel9 = QgsComposerLabel(self.scene) self.compLabel9.setFont(font) self.compLabel9.setBackgroundEnabled(False) self.compLabel9.setText("BRUNEI") self.compLabel9.setItemPosition(136, 83) self.compLabel9.adjustSizeToText() # self.compLabl3.setItemRotation(0.5) self.scene.addItem(self.compLabel9) self.templeteCreateAction.setChecked(False) pass def actionMapRefresh_triggered(self): self.view.setCurrentTool(QgsComposerView.AddRectangle) def setSelectionTool(self): self.view.deleteSelectedItems() font = QFont("Arial", 14) newLabelItem = QgsComposerLabel(self.scene) newLabelItem.setText("QGIS") newLabelItem.setFont(font) newLabelItem.setItemPosition(self.scenePoint.x(), self.scenePoint.y()) newLabelItem.adjustSizeToText() self.scene.addItem(newLabelItem) # selectItemPoint = self.scene.composerItemAt(self.scenePoint) newLabelItem.setSelected(True) self.groupBox.setEnabled(True) self.selectedLabelItem = newLabelItem # txt = self.selectedLabelItem.text() # textDoc = QTextDocument(txt) self.labelText.setPlainText(self.selectedLabelItem.text()) # self.scene.setSelectedItem(self.newLabelItem) self.view.setCurrentTool(QgsComposerView.Select) # self.selectedLabelItem = self.view.currentTool() self.textItemAction.setChecked(False) def selectedItemDisplay(self, item): if self.scene.plotStyle() != QgsComposition.Preview: self.scene.setPlotStyle(QgsComposition.Preview) self.mapItem.setPreviewMode(QgsComposerMap.Render) self.mapItem.updateCachedImage() item._class_ = QgsComposerLabel # selectedItems = self.scene.selectedComposerItems(True) # if isinstance(item, QgsComposerItem): # self.selectedLabelItem = item # if isinstance(item, QGraphicsRectItem): # self.selectedLabelItem = item if isinstance(item, QgsComposerLabel): self.selectedLabelItem = item self.groupBox.setEnabled(True) self.labelText.setPlainText(self.selectedLabelItem.text()) self.spinLabelRotation.setValue(self.selectedLabelItem.rotation()) else: self.groupBox.setEnabled(False) # print "debug" itemName = self.view.currentTool() if itemName == 5: item.setText("label") pass def deleteItem(self): self.view.deleteSelectedItems()
def buildMixer(self): log.debug("Building mixer") self.MatrixButtonControls = {} self.MatrixRotaryControls = {} self.MatrixVolumeControls = {} self.VolumeControls = {} self.SelectorControls = {} self.SPDIFmodeControls = {} self.TriggerControls = {} self.DigIfaceControls = {} self.PlbkRouteControls = {} self.StreamMonitors = [] nb_pys_out = self.hw.getDiscrete("/HwInfo/PhysicalAudioOutCount") nb_pys_in = self.hw.getDiscrete("/HwInfo/PhysicalAudioInCount") outputtabslayout = QHBoxLayout(self) outputtabs = QTabWidget(self) outputtabslayout.addWidget(outputtabs, 1) for outpair in range(int(nb_pys_out / 2)): tab = QWidget(outputtabs) tablayout = QHBoxLayout(tab) grpMonitor = QGroupBox(tab) tablayout.addWidget(grpMonitor) grpPlayback = QGroupBox(tab) tablayout.addWidget(grpPlayback) grpOutput = QGroupBox(tab) tablayout.addWidget(grpOutput) grpMonitor.setTitle("Monitor") grpPlayback.setTitle("Playback") grpOutput.setTitle("Output") # monitor controls grpMonitorLayout = QHBoxLayout() grpMonitor.setLayout(grpMonitorLayout) output_id = outpair * 2 for inpair in range(int(nb_pys_in / 2)): # create GUI elements strip = AfMonitorWidget(grpMonitor) grpMonitorLayout.addWidget(strip, 1) input_id = inpair * 2 strip.lblName.setText("In %d/%d" % (input_id + 1, input_id + 2)) # add the elements to the control structure self.MatrixButtonControls[strip.btnMute0] = [ '/Mixer/MonitorMute', input_id, output_id ] self.MatrixButtonControls[strip.btnMute1] = [ '/Mixer/MonitorMute', input_id + 1, output_id + 1 ] self.MatrixButtonControls[strip.btnSolo0] = [ '/Mixer/MonitorSolo', input_id, output_id ] self.MatrixButtonControls[strip.btnSolo1] = [ '/Mixer/MonitorSolo', input_id + 1, output_id + 1 ] self.MatrixRotaryControls[strip.rotPan0] = [ '/Mixer/MonitorPan', input_id, output_id ] self.MatrixRotaryControls[strip.rotPan1] = [ '/Mixer/MonitorPan', input_id + 1, output_id + 1 ] self.MatrixVolumeControls[strip.sldGain0] = [ '/Mixer/MonitorGain', input_id, output_id ] self.MatrixVolumeControls[strip.sldGain1] = [ '/Mixer/MonitorGain', input_id + 1, output_id + 1 ] # playback grpPlaybackLayout = QHBoxLayout() grpPlayback.setLayout(grpPlaybackLayout) strip = AfMonitorWidget(grpPlayback) grpPlaybackLayout.addWidget(strip, 1) strip.lblName.setText("Playback %d/%d" % (output_id + 1, output_id + 2)) self.StreamMonitors.append(strip) self.VolumeControls[strip.sldGain0] = [ "/Mixer/PC%dGain" % (output_id) ] self.VolumeControls[strip.sldGain1] = [ "/Mixer/PC%dGain" % (output_id + 1) ] self.SelectorControls[strip.btnMute0] = [ "/Mixer/PC%dMute" % (output_id) ] self.SelectorControls[strip.btnMute1] = [ "/Mixer/PC%dMute" % (output_id + 1) ] self.SelectorControls[strip.btnSolo0] = [ "/Mixer/PC%dSolo" % (output_id) ] self.SelectorControls[strip.btnSolo1] = [ "/Mixer/PC%dSolo" % (output_id + 1) ] # fix up mixer strip gui strip.rotPan0.hide() strip.rotPan1.hide() # output grpOutputLayout = QHBoxLayout() grpOutput.setLayout(grpOutputLayout) strip = AfMonitorWidget(grpOutput) grpOutputLayout.addWidget(strip, 1) strip.lblName.setText("Output %d/%d" % (output_id + 1, output_id + 2)) self.VolumeControls[strip.sldGain0] = [ "/Mixer/OUT%dGain" % (output_id) ] self.VolumeControls[strip.sldGain1] = [ "/Mixer/OUT%dGain" % (output_id + 1) ] self.SelectorControls[strip.btnMute0] = [ "/Mixer/OUT%dMute" % (output_id) ] self.SelectorControls[strip.btnMute1] = [ "/Mixer/OUT%dMute" % (output_id + 1) ] self.SelectorControls[strip.btnSolo0] = [ "/Mixer/OUT%dNominal" % (output_id) ] self.SelectorControls[strip.btnSolo1] = [ "/Mixer/OUT%dNominal" % (output_id + 1) ] # fix up mixer strip gui strip.btnSolo0.setText("Pad") strip.btnSolo1.setText("Pad") strip.rotPan0.hide() strip.rotPan1.hide() # add the tab outputtabs.addTab(tab, "Out %d/%d" % (output_id + 1, output_id + 2)) # add an input config tab tab = QWidget(outputtabs) tablayout = QHBoxLayout(tab) for inpair in range(nb_pys_in): # create GUI elements log.debug("strip") grpInput = QGroupBox(tab) tablayout.addWidget(grpInput) grpInput.setTitle("In %d" % (inpair + 1)) grpInputLayout = QVBoxLayout() grpInput.setLayout(grpInputLayout) label = QLabel(grpInput) grpInputLayout.addWidget(label) label.setText("In %d" % (inpair + 1)) label.setAlignment(Qt.AlignCenter) btn = QToolButton(grpInput) grpInputLayout.addWidget(btn) btn.setText("Pad") btn.setCheckable(True) self.SelectorControls[btn] = ["/Mixer/IN%dNominal" % (inpair)] spacer = QSpacerItem(1, 1, QSizePolicy.Minimum, QSizePolicy.Expanding) grpInputLayout.addItem(spacer) outputtabs.addTab(tab, "Input") # add an settings tab tab = QWidget(outputtabs) tablayout = QHBoxLayout(tab) outputtabs.addTab(tab, "Settings") settings = AfSettingsWidget(tab) has_sw_phantom = self.hw.getDiscrete("/HwInfo/PhantomPower") if has_sw_phantom: self.SelectorControls[settings.btnPhantom] = ["/PhantomPower"] else: settings.btnPhantom.hide() has_opt_iface = self.hw.getDiscrete('/HwInfo/OpticalInterface') if has_opt_iface: self.DigIfaceControls[settings.cmbDigIface] = ['/DigitalInterface'] else: settings.DigIface.hide() has_plbk_route = self.hw.getDiscrete('/HwInfo/PlaybackRouting') if has_plbk_route: self.PlbkRouteControls[settings.cmbRoute1] = [ '/PlaybackRouting', 0 ] self.PlbkRouteControls[settings.cmbRoute2] = [ '/PlaybackRouting', 1 ] self.PlbkRouteControls[settings.cmbRoute3] = [ '/PlaybackRouting', 2 ] if self.configrom.getModelId() == 0x0AF2: label_route2 = 'Headphone Out 1/2' else: label_route2 = 'Analog Out 3/4' settings.labelRoute2.setText(label_route2) else: settings.PlbkRoute.hide() self.TriggerControls[settings.btnSaveSettings] = ["/SaveSettings"] self.TriggerControls[settings.btnIdentify] = ["/Identify"] if self.configrom.getModelId() == 0x0AF12: settings.spdifMode.hide() else: self.SPDIFmodeControls[settings.radioConsumer] = ["/SpdifMode", 0] self.SPDIFmodeControls[settings.radioProfessional] = [ "/SpdifMode", 1 ] # Store a reference to the "save" button for later manipulation self.btnSaveSettings = settings.btnSaveSettings
def __init__(self, G=None, pos=None, parent=None): QWidget.__init__(self, parent) self.scene = GraphGraphicsScene(G, pos, self) self.view = QGraphicsView(self.scene, self) self.button = QPushButton("Quit", self) self.nodeButton = QPushButton("Node", self) self.edgeButton = QPushButton("Edge", self) self.addButton = QPushButton("Add", self) self.deleteButton = QPushButton("Delete", self) self.printButton = QPushButton("Print", self) self.eulerButton = QPushButton("Euler", self) self.generateFullButton = QPushButton("Full", self) self.generateHalfButton = QPushButton("Half", self) self.infoButton = QPushButton("Info", self) # self.testButton = QPushButton('Test', self) self.nodesInputLabel = QLabel("Nodes", self) self.edgesInputLabel = QLabel("Edges", self) self.saveButton = QPushButton("Save", self) self.loadButton = QPushButton("Load", self) self.saveAsButton = QPushButton("SaveAs", self) self.bridgeButton = QPushButton("Bridge", self) self.stepSlider = QSlider(self) self.cursorLabelX = QLabel("X:", self) self.cursorLabelY = QLabel("Y:", self) self.nodeNumberLabel = QLabel("Nr:", self) self.fileLabel = QLabel("File:", self) self.nodeInfo = QLabel("N:", self) self.edgeInfo = QLabel("E:", self) self.eulerInfo = QLabel("None", self) # self.fileInput = QLineEdit(self) self.fileInput = QLabel("", self) self.euler = Euler() self.eulerStep = 0 self.eulerPath = [] validator = QIntValidator(0, 10000) self.nodesNumberInput = QLineEdit(self) self.nodesNumberInput.setValidator(validator) self.edgesNumberInput = QLineEdit(self) self.edgesNumberInput.setValidator(validator) self.cursorLabelX.setMinimumSize(150, 25) self.cursorLabelY.setMinimumSize(150, 25) self.nodeNumberLabel.setMinimumSize(150, 25) self.labelsGroup = QVBoxLayout() self.labelsGroup.addWidget(self.cursorLabelX) self.labelsGroup.addWidget(self.cursorLabelY) self.labelsGroup.addWidget(self.nodeNumberLabel) HEIGHT = 50 WIDTH = 50 self.nodeButton.setFixedSize(HEIGHT, WIDTH) self.edgeButton.setFixedSize(HEIGHT, WIDTH) self.addButton.setFixedSize(HEIGHT, WIDTH) self.button.setFixedSize(HEIGHT, WIDTH) self.deleteButton.setFixedSize(HEIGHT, WIDTH) self.printButton.setFixedSize(HEIGHT, WIDTH) self.eulerButton.setFixedSize(HEIGHT, WIDTH) self.generateFullButton.setFixedSize(HEIGHT, WIDTH) self.generateHalfButton.setFixedSize(HEIGHT, WIDTH) self.saveButton.setFixedSize(HEIGHT, WIDTH) self.loadButton.setFixedSize(HEIGHT, WIDTH) self.saveAsButton.setFixedSize(HEIGHT, WIDTH) self.infoButton.setFixedSize(HEIGHT, WIDTH) self.bridgeButton.setFixedSize(HEIGHT, WIDTH) self.nodesNumberInput.setFixedSize(HEIGHT * 2, 28) self.edgesNumberInput.setFixedSize(HEIGHT * 2, 28) self.stepSlider.setFixedSize(HEIGHT * 2, 28) # self.testButton.setFixedSize(HEIGHT, WIDTH) self.disableSlider() self.stepSlider.setOrientation(Qt.Horizontal) horizontal_expanding_spacer1 = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) self.fileGroup = QHBoxLayout() self.fileGroup.addWidget(self.fileLabel) self.fileGroup.addWidget(self.fileInput) self.fileGroup.addItem(horizontal_expanding_spacer1) self.actionsButtonGroup = QHBoxLayout() self.actionsButtonGroup.addWidget(self.addButton) self.actionsButtonGroup.addWidget(self.deleteButton) self.actionsButtonGroup.addWidget(self.printButton) self.actionsButtonGroup.addWidget(self.eulerButton) self.actionsButtonGroup.addWidget(self.generateFullButton) self.actionsButtonGroup.addWidget(self.generateHalfButton) self.actionsButtonGroup.addWidget(self.saveButton) self.actionsButtonGroup.addWidget(self.loadButton) self.actionsButtonGroup.addWidget(self.saveAsButton) self.actionsButtonGroup.addWidget(self.infoButton) self.actionsButtonGroup.addWidget(self.bridgeButton) # self.actionsButtonGroup.addWidget(self.testButton) self.actionsButtonGroup.addWidget(self.button) self.topGroup = QVBoxLayout() self.topGroup.addItem(self.fileGroup) self.topGroup.addItem(self.actionsButtonGroup) horizontal_expanding_spacer = QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) self.actionsButtonGroup.addItem(horizontal_expanding_spacer) self.actionsButtonGroup.addItem(self.labelsGroup) self.modeButtonGroup = QVBoxLayout() self.modeButtonGroup.addWidget(self.nodeButton) self.modeButtonGroup.addWidget(self.edgeButton) self.modeButtonGroup.addWidget(self.nodesInputLabel) self.modeButtonGroup.addWidget(self.nodesNumberInput) self.modeButtonGroup.addWidget(self.edgesInputLabel) self.modeButtonGroup.addWidget(self.edgesNumberInput) self.modeButtonGroup.addWidget(self.stepSlider) vertical_expanding_spacer = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.modeButtonGroup.addItem(vertical_expanding_spacer) self.infoGroup = QVBoxLayout() self.infoGroup.addWidget(self.edgeInfo) self.infoGroup.addWidget(self.nodeInfo) self.infoGroup.addWidget(self.eulerInfo) self.modeButtonGroup.addItem(self.infoGroup) self.button.clicked.connect(QCoreApplication.instance().quit) self.addButton.clicked.connect(self.add) self.deleteButton.clicked.connect(self.delete) self.nodeButton.clicked.connect(self.nodeButtonEvent) self.edgeButton.clicked.connect(self.edgeButtonEvent) self.printButton.clicked.connect(self.printButtonEvent) self.eulerButton.clicked.connect(self.findEulerPath) self.generateFullButton.clicked.connect(self.generateFull) self.generateHalfButton.clicked.connect(self.generateHalf) # self.testButton.clicked.connect(self.scene.changeColor) self.saveAsButton.clicked.connect(self.saveAsFile) self.saveButton.clicked.connect(self.saveFile) self.loadButton.clicked.connect(self.loadFile) self.scene.cursorPositionSignal.connect(self.setLabels) self.scene.nodeNumberSignal.connect(self.setLabelNumber) self.stepSlider.sliderMoved.connect(self.setEulerStep) self.bridgeButton.clicked.connect(self.findBridges) self.infoButton.clicked.connect(self.setInfo) self.view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) layoutH = QHBoxLayout() layoutH.addWidget(self.view) layoutH.addItem(self.modeButtonGroup) layoutV = QVBoxLayout() layoutV.addItem(self.topGroup) layoutV.addItem(layoutH) self.setLayout(layoutV) self.setWindowTitle("Example") self.scene.setSceneRect(0, 0, 1, 1) self.view.setMouseTracking(True) self.showMaximized() self.graphFile = GraphFile("file.txt")
def __init__(self): super(DisplaySection, self).__init__() EditorConfiguration.install_widget(self.tr("Visualización"), self) container = QVBoxLayout(self) # Text wrapping group_wrapping = QGroupBox(self.tr("Ajuste de Texto:")) box = QGridLayout(group_wrapping) self.check_wrap = QCheckBox(self.tr("Activar ajuste de texto")) box.addWidget(self.check_wrap, 0, 0) self.check_margin = QCheckBox(self.tr("Mostrar márgen derecho:")) box.addWidget(self.check_margin, 1, 0) self.slider_margin = QSlider(Qt.Horizontal) self.slider_margin.setMaximum(180) self.slider_margin.setFixedWidth(350) box.addWidget(self.slider_margin, 1, 1, Qt.AlignLeft) lcd_margin = QLCDNumber() lcd_margin.setSegmentStyle(QLCDNumber.Flat) box.addWidget(lcd_margin, 1, 2, Qt.AlignLeft) box.setAlignment(Qt.AlignLeft) container.addWidget(group_wrapping) # Add group # Extras: line number, markers, whitespace, etc group_extras = QGroupBox(self.tr("Visualización:")) box = QGridLayout(group_extras) self.check_line_numbers = QCheckBox( self.tr("Mostrar números de líneas")) box.addWidget(self.check_line_numbers, 0, 0) self.check_current_line = QCheckBox(self.tr("Resaltar línea actual")) box.addWidget(self.check_current_line, 0, 1) self.check_mark_change = QCheckBox(self.tr("Marcar línea modificada")) box.addWidget(self.check_mark_change, 1, 0) self.check_match_brace = QCheckBox(self.tr("Resaltar [], {}, (), <>")) box.addWidget(self.check_match_brace, 1, 1) self.check_whitespace = QCheckBox( self.tr("Mostrar espacios en blanco")) box.addWidget(self.check_whitespace, 2, 0) self.check_guides = QCheckBox(self.tr("Mostrar guías de indentación")) box.addWidget(self.check_guides, 2, 1) self.check_eof = QCheckBox(self.tr("Mostrar EOF")) box.addWidget(self.check_eof, 3, 0) container.addWidget(group_extras) # Add group # Spacer container.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Connections self.slider_margin.valueChanged[int].connect(lcd_margin.display) # Configuration self.check_wrap.setChecked(settings.get_setting('editor/wrap-mode')) self.check_line_numbers.setChecked( settings.get_setting('editor/show-line-number')) self.check_mark_change.setChecked( settings.get_setting('editor/mark-change')) self.check_match_brace.setChecked( settings.get_setting('editor/match-brace')) self.check_current_line.setChecked( settings.get_setting('editor/show-caret-line')) self.check_eof.setChecked(settings.get_setting('editor/eof')) self.check_margin.setChecked( settings.get_setting('editor/show-margin')) self.slider_margin.setValue( settings.get_setting('editor/width-margin')) self.check_whitespace.setChecked( settings.get_setting('editor/show-tabs-spaces')) self.check_guides.setChecked( settings.get_setting('editor/show-guides'))
def __init__(self, parent): super(EditorConfiguration, self).__init__() self._preferences = parent vbox = QVBoxLayout(self) #Indentation groupBoxFeatures = QGroupBox( translations.TR_PREFERENCES_EDITOR_CONFIG_FEATURES) formFeatures = QGridLayout(groupBoxFeatures) formFeatures.addWidget( QLabel(translations.TR_PREFERENCES_EDITOR_CONFIG_INDENTATION), 1, 0, Qt.AlignRight) self._spin = QSpinBox() self._spin.setAlignment(Qt.AlignRight) self._spin.setMinimum(1) self._spin.setValue(settings.INDENT) formFeatures.addWidget(self._spin, 1, 1, alignment=Qt.AlignTop) self._checkUseTabs = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_USE_TABS) self._checkUseTabs.setChecked(settings.USE_TABS) self.connect(self._checkUseTabs, SIGNAL("stateChanged(int)"), self._change_tab_spaces) formFeatures.addWidget(self._checkUseTabs, 1, 2, alignment=Qt.AlignTop) if settings.USE_TABS: self._spin.setSuffix( translations.TR_PREFERENCES_EDITOR_CONFIG_TAB_SIZE) else: self._spin.setSuffix( translations.TR_PREFERENCES_EDITOR_CONFIG_SPACES) #Margin Line formFeatures.addWidget( QLabel(translations.TR_PREFERENCES_EDITOR_CONFIG_MARGIN_LINE), 2, 0, Qt.AlignRight) self._spinMargin = QSpinBox() self._spinMargin.setMaximum(200) self._spinMargin.setValue(settings.MARGIN_LINE) formFeatures.addWidget(self._spinMargin, 2, 1, alignment=Qt.AlignTop) self._checkShowMargin = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MARGIN_LINE) self._checkShowMargin.setChecked(settings.SHOW_MARGIN_LINE) formFeatures.addWidget(self._checkShowMargin, 2, 2, alignment=Qt.AlignTop) #End of line self._checkEndOfLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_END_OF_LINE) self._checkEndOfLine.setChecked(settings.USE_PLATFORM_END_OF_LINE) formFeatures.addWidget(self._checkEndOfLine, 3, 1, alignment=Qt.AlignTop) #Find Errors self._checkHighlightLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_HIGHLIGHTING) self._checkHighlightLine.setChecked(settings.UNDERLINE_NOT_BACKGROUND) formFeatures.addWidget(self._checkHighlightLine, 4, 1, 1, 2, alignment=Qt.AlignTop) self._checkErrors = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_FIND_ERRORS) self._checkErrors.setChecked(settings.FIND_ERRORS) formFeatures.addWidget(self._checkErrors, 5, 1, 1, 2, alignment=Qt.AlignTop) self.connect(self._checkErrors, SIGNAL("stateChanged(int)"), self._disable_show_errors) self._showErrorsOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_ERRORS) self._showErrorsOnLine.setChecked(settings.ERRORS_HIGHLIGHT_LINE) self.connect(self._showErrorsOnLine, SIGNAL("stateChanged(int)"), self._enable_errors_inline) formFeatures.addWidget(self._showErrorsOnLine, 6, 2, 1, 1, Qt.AlignTop) #Find Check Style self._checkStyle = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_PEP8) self._checkStyle.setChecked(settings.CHECK_STYLE) formFeatures.addWidget(self._checkStyle, 7, 1, 1, 2, alignment=Qt.AlignTop) self.connect(self._checkStyle, SIGNAL("stateChanged(int)"), self._disable_check_style) self._checkStyleOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_PEP8) self._checkStyleOnLine.setChecked(settings.CHECK_HIGHLIGHT_LINE) self.connect(self._checkStyleOnLine, SIGNAL("stateChanged(int)"), self._enable_check_inline) formFeatures.addWidget(self._checkStyleOnLine, 8, 2, 1, 1, Qt.AlignTop) # Python3 Migration self._showMigrationTips = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MIGRATION) self._showMigrationTips.setChecked(settings.SHOW_MIGRATION_TIPS) formFeatures.addWidget(self._showMigrationTips, 9, 1, 1, 2, Qt.AlignTop) #Center On Scroll self._checkCenterScroll = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_CENTER_SCROLL) self._checkCenterScroll.setChecked(settings.CENTER_ON_SCROLL) formFeatures.addWidget(self._checkCenterScroll, 10, 1, 1, 2, alignment=Qt.AlignTop) #Remove Trailing Spaces add Last empty line automatically self._checkTrailing = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_REMOVE_TRAILING) self._checkTrailing.setChecked(settings.REMOVE_TRAILING_SPACES) formFeatures.addWidget(self._checkTrailing, 11, 1, 1, 2, alignment=Qt.AlignTop) #Show Tabs and Spaces self._checkShowSpaces = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TABS_AND_SPACES) self._checkShowSpaces.setChecked(settings.SHOW_TABS_AND_SPACES) formFeatures.addWidget(self._checkShowSpaces, 12, 1, 1, 2, alignment=Qt.AlignTop) self._allowWordWrap = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_WORD_WRAP) self._allowWordWrap.setChecked(settings.ALLOW_WORD_WRAP) formFeatures.addWidget(self._allowWordWrap, 13, 1, 1, 2, alignment=Qt.AlignTop) self._checkForDocstrings = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_CHECK_FOR_DOCSTRINGS) self._checkForDocstrings.setChecked(settings.CHECK_FOR_DOCSTRINGS) formFeatures.addWidget(self._checkForDocstrings, 14, 1, 1, 2, alignment=Qt.AlignTop) vbox.addWidget(groupBoxFeatures) vbox.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
def __init__(self): super(CompletionSection, self).__init__() EditorConfiguration.install_widget(self.tr("Autocompletado"), self) container = QVBoxLayout(self) group_complete = QGroupBox(self.tr("Completar:")) box = QGridLayout(group_complete) box.setContentsMargins(20, 5, 20, 5) self.check_bracket = QCheckBox(self.tr("Corchetes []")) box.addWidget(self.check_bracket, 0, 0) self.check_paren = QCheckBox(self.tr("Paréntesis ()")) box.addWidget(self.check_paren, 0, 1) self.check_key = QCheckBox(self.tr("Llaves {}")) box.addWidget(self.check_key, 1, 0) self.check_quote = QCheckBox(self.tr("Comillas Dobles \" \"")) box.addWidget(self.check_quote, 1, 1) self.check_single_quote = QCheckBox(self.tr("Comillas Simples ' '")) box.addWidget(self.check_single_quote, 2, 0) group_completion = QGroupBox(self.tr("Completado de Código:")) box = QGridLayout(group_completion) box.setContentsMargins(20, 5, 20, 5) self.check_completion = QCheckBox(self.tr("Activar Completado")) box.addWidget(self.check_completion, 0, 0) self.check_document = QCheckBox(self.tr("Basado en el código")) box.addWidget(self.check_document, 0, 1) self.check_keywords = QCheckBox(self.tr("Palabras Claves")) box.addWidget(self.check_keywords, 1, 0) self.check_cs = QCheckBox( self.tr("Sensitivo a mayúsculas y minúsculas")) box.addWidget(self.check_cs, 1, 1) self.check_replace_word = QCheckBox(self.tr("Reemplazar Palabra")) box.addWidget(self.check_replace_word, 2, 0) self.check_show_single = QCheckBox(self.tr("Mostrar Simple")) box.addWidget(self.check_show_single, 2, 1) hbox = QHBoxLayout() hbox.addWidget( QLabel(self.tr("Número de caractéres para mostrar lista:"))) self.spin_threshold = QSpinBox() self.spin_threshold.setMinimum(1) self.spin_threshold.setFixedWidth(100) hbox.addWidget(self.spin_threshold) box.addLayout(hbox, 3, 0, Qt.AlignLeft) # Agrupo al contenedor principal container.addWidget(group_complete) container.addWidget(group_completion) container.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self._state_change(self.check_completion.isChecked()) # Conexiones self.check_completion.stateChanged[int].connect(self._state_change) # Configuration self.check_key.setChecked( settings.get_setting('editor/complete-brace')) self.check_bracket.setChecked("[" in settings.BRACES) self.check_paren.setChecked("(" in settings.BRACES) self.check_quote.setChecked('""' in settings.QUOTES) #settings.get_setting('editor/complete-double-quote')) self.check_single_quote.setChecked("''" in settings.QUOTES) #settings.get_setting('editor/complete-single-quote')) self.check_completion.setChecked( settings.get_setting('editor/completion')) self.spin_threshold.setValue( settings.get_setting('editor/completion-threshold')) self.check_keywords.setChecked( settings.get_setting('editor/completion-keywords')) self.check_document.setChecked( settings.get_setting('editor/completion-document')) self.check_cs.setChecked(settings.get_setting('editor/completion-cs')) self.check_replace_word.setChecked( settings.get_setting('editor/completion-replace-word')) self.check_show_single.setChecked( settings.get_setting('editor/completion-single'))
class mainWin(QMainWindow): def __init__(self, parent=None): QMainWindow.__init__(self, parent) screen = QDesktopWidget().screenGeometry() self.setGeometry(80, 100, int((1/2)*screen.width()), int((4/10)*screen.height())) self.main_frame = QFrame() self.cw = QFrame() self.cw.setFrameStyle(QFrame.StyledPanel|QFrame.Sunken) self.main_sizer = QVBoxLayout() self.hbox1_sizer = QHBoxLayout() self.setWindowTitle(self.tr("Consonance Rating")) ## self.sessionRunning = False self.listenerID = "" self.currentTrial = 1 self.intervals_db = pd.read_csv(os.path.abspath(os.path.dirname(__file__)) + "/resources/intervals_database.csv", sep=";") # self.rootNotes = np.array([110, 130.81, 185]) # self.intervalsCents = np.array([100, # 500, # 600, # 700, # 800, # 1100]) #self.rootNotes = np.array([110, 185]) self.rootNotes = np.array([146.83, 155.56, 164.81, 174.61, 185, 196, 207.65, 220]) self.intervalsCents = np.array([600, 700 ]) self.diadDur = 1980 self.diadRamps = 10 self.diadTotLev = np.array([40, 80]) self.diadFilterType = "lowpass" self.diadFilterCutoffs = (2500,) self.diadLowHarm = 1 self.diadHighHarm = 50 self.diadNote1Chan = "Both" self.diadNote2Chan = "Both" self.fs = 48000 self.maxLevel = self.getPhonesCal() self.noise1SL = -200 self.noise1LowFreq = 0 self.noise1HighFreq = 2000 self.noise1Type = "Pink" self.noise2Type = "Pink" self.noise2SL = np.array([0, 40]) self.noise2LowFreq = 4000 self.noise2HighFreq = 8000 self.noise1RefHz = 100 self.noise2RefHz = 4000 self.preTrialNoiseRefHz = 1000 self.preTrialNoiseLowFreq = 20 self.preTrialNoiseHighFreq = 8000 self.preTrialNoiseDur = 1980 self.preTrialNoiseRamps = 10 self.preTrialNoiseSL = np.array([0, 40]) self.preTrialNoiseType = "Pink" self.preTrialNoiseChannel = "Both" self.preTrialNoiseDiadISI = 500 self.noiseChannel = "Both" self.nPracticeTrialsXStim = 4 self.nTrialsXStim = 2 self.nTrials = len(self.rootNotes)*len(self.intervalsCents)*len(self.diadTotLev)*(self.nTrialsXStim) + self.nPracticeTrialsXStim*len(self.intervalsCents)*len(self.diadTotLev) print(self.nTrials) practiceTrials = [] mainTrials = [] for rootNote in self.rootNotes: for intervalCents in self.intervalsCents: for n in range(self.nTrialsXStim): mainTrials.append((rootNote, intervalCents, "main", self.diadTotLev[0], self.noise2SL[0], self.preTrialNoiseSL[0])) for intervalCents in self.intervalsCents: for n in range(self.nPracticeTrialsXStim): practiceTrials.append((random.choice(self.rootNotes), intervalCents, "practice", self.diadTotLev[0], self.noise2SL[0], self.preTrialNoiseSL[0])) random.shuffle(practiceTrials) random.shuffle(mainTrials) practiceTrials2 = [] mainTrials2 = [] for rootNote in self.rootNotes: for intervalCents in self.intervalsCents: for n in range(self.nTrialsXStim): mainTrials2.append((rootNote, intervalCents, "main", self.diadTotLev[1], self.noise2SL[1], self.preTrialNoiseSL[1])) for intervalCents in self.intervalsCents: for n in range(self.nPracticeTrialsXStim): practiceTrials2.append((random.choice(self.rootNotes), intervalCents, "practice", self.diadTotLev[1], self.noise2SL[1], self.preTrialNoiseSL[1])) random.shuffle(practiceTrials2) random.shuffle(mainTrials2) #root note #interval cents #practice or main #dialTotLev #noise2SL #preTrialNoiseSL #remove some practice trials #practiceTrials = practiceTrials[0:4] #practiceTrials2 = practiceTrials2[0:4] self.trialList = [] if random.choice([0,1]) == 0: self.trialList.extend(practiceTrials) self.trialList.extend(practiceTrials2) else: self.trialList.extend(practiceTrials2) self.trialList.extend(practiceTrials) if random.choice([0,1]) == 0: self.trialList.extend(mainTrials) self.trialList.extend(mainTrials2) else: self.trialList.extend(mainTrials2) self.trialList.extend(mainTrials) print(len(self.trialList)) self.menubar = self.menuBar() self.fileMenu = self.menubar.addMenu(self.tr('-')) self.editPhonesAction = QAction(self.tr('Phones Calibration'), self) self.fileMenu.addAction(self.editPhonesAction) self.editPhonesAction.triggered.connect(self.onEditPhones) self.setupListenerButton = QPushButton(self.tr("Setup Listener"), self) self.setupListenerButton.clicked.connect(self.onClickSetupListenerButton) self.setupListenerButton.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) # self.setupListenerButton.setToolTip(self.tr("Choose file to save results")) # self.setupListenerButton.setWhatsThis(self.tr("Choose where to save the result files")) self.setupListenerButton.setStyleSheet('font-size: 32pt; font-weight: bold') self.hbox1_sizer.addWidget(self.setupListenerButton) self.main_sizer.addLayout(self.hbox1_sizer) #statusButtonFont = QFont("Arial", 26); self.statusButton = QPushButton(self.tr("Start"), self) self.statusButton.clicked.connect(self.onClickStatusButton) self.statusButton.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)) self.main_sizer.addWidget(self.statusButton) #self.statusButton.setFont(statusButtonFont) self.statusButton.setStyleSheet('font-size: 32pt; font-weight: bold') self.statusButton.hide() self.cw.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) borderWidth = 4 self.main_sizer.addItem(QSpacerItem(20, 60, QSizePolicy.Fixed)) self.overallRatingSliderValue = QLabel(self.tr("0"), self) self.main_sizer.addWidget(self.overallRatingSliderValue) self.overallRatingSliderValue.setStyleSheet('font-size: 22pt; font-weight: normal') self.overallRatingSliderValue.setAlignment(Qt.AlignCenter) self.main_sizer.addItem(QSpacerItem(20,60, QSizePolicy.Fixed)) sliderFont = QFont("Ubuntu", 18) self.overallRatingSlider = Qwt.QwtSlider(self, Qt.Horizontal, Qwt.QwtSlider.BottomScale) self.overallRatingSlider.setFont(sliderFont) self.overallRatingSlider.setScale(-3.0,3.0, 1) self.overallRatingSlider.setRange(-3.0,3.0) self.overallRatingSlider.valueChanged[float].connect(self.sliderChanged) self.overallRatingSlider.setMinimumSize(800, 20) self.overallRatingSlider.setBorderWidth(borderWidth) self.main_sizer.addWidget(self.overallRatingSlider) self.main_sizer.addItem(QSpacerItem(20,30, QSizePolicy.Fixed)) self.gauge = QProgressBar(self) self.gauge.setRange(0, 100) self.main_sizer.addWidget(self.gauge) self.cw.setLayout(self.main_sizer) self.setCentralWidget(self.cw) self.show() def onClickStatusButton(self): if self.statusButton.text() == self.tr("Finished"): return self.sessionRunning = True self.statusButton.setText(self.tr("Running")) QApplication.processEvents() if self.listenerID == "": text, ok = QInputDialog.getText(self, "" , "Listener ID: ") if ok: self.listenerID = text self.statusButton.setText(self.tr("Start")) return if self.currentTrial == 1: self.setupListenerButton.hide() self.overallRatingSlider.setValue(0) self.overallRatingSliderValue.setText("") self.doTrial() return if self.overallRatingSliderValue.text() == "": ret = QMessageBox.warning(self, self.tr("Warning"), self.tr("You need to move the slider before going to the next trial.\nIf you want to assign a score of zero move the slider forth and then back to the zero position."), QMessageBox.Ok) return if self.currentTrial > 1: self.storeRating() self.gauge.setValue((self.currentTrial-1)/self.nTrials*100) #self.sliderChanged(0) self.sliderLabelReset() self.statusButton.setText(self.tr("Running")) QApplication.processEvents() if self.currentTrial <= self.nTrials : self.doTrial() else: self.statusButton.setText(self.tr("Finished")) def doTrial(self): self.statusButton.setText(self.tr("Running")) QApplication.processEvents() #root note rootNote = self.trialList[self.currentTrial-1][0] #interval cents intervalCents = self.trialList[self.currentTrial-1][1] #practice or main trialMode = self.trialList[self.currentTrial-1][2] #dialTotLev diadTotLev = self.trialList[self.currentTrial-1][3] #noise2SL noise2SL = self.trialList[self.currentTrial-1][4] #preTrialNoiseSL preTrialNoiseSL = self.trialList[self.currentTrial-1][5] try: intervalName = self.intervals_db["name"][self.intervals_db["cents"] == self.trialList[self.currentTrial-1][1]].values[0] except: intervalName = str(self.trialList[self.currentTrial-1][1]) print(intervalName) preTrialNoise = broadbandNoise(spectrumLevel=preTrialNoiseSL, duration=self.preTrialNoiseDur, ramp=self.preTrialNoiseRamps, channel=self.preTrialNoiseChannel, fs=self.fs, maxLevel=self.maxLevel) if self.preTrialNoiseType == "Pink": preTrialNoise = makePinkRef(preTrialNoise, self.fs, self.preTrialNoiseRefHz) preTrialNoise = fir2Filter2(preTrialNoise, filterType="bandpass", nTaps=256, cutoffs=(self.preTrialNoiseLowFreq, self.preTrialNoiseHighFreq), transitionWidth=0.2, fs=self.fs) diad = makeDiad(rootNote, intervalCents, filterType=self.diadFilterType, filterCutoffs=self.diadFilterCutoffs, lowHarm=self.diadLowHarm, highHarm=self.diadHighHarm, diadTotLev=diadTotLev, duration=self.diadDur, ramp=self.diadRamps, note1Channel=self.diadNote1Chan, note2Channel=self.diadNote2Chan, fs=self.fs, maxLevel=self.maxLevel) noise1 = broadbandNoise(spectrumLevel=self.noise1SL, duration=self.diadDur, ramp=self.diadRamps*6, channel=self.noiseChannel, fs=self.fs, maxLevel=self.maxLevel) if self.noise1Type == "Pink": noise1 = makePinkRef(noise1, self.fs, self.noise1RefHz) noise1 = fir2Filter2(noise1, filterType="bandpass", nTaps=256, cutoffs=(self.noise1LowFreq, self.noise1HighFreq), transitionWidth=0.2, fs=self.fs) noise1 = noise1[0:diad.shape[0],:] noise1 = gate(self.diadRamps, noise1, self.fs) noise2 = broadbandNoise(spectrumLevel=noise2SL, duration=self.diadDur, ramp=self.diadRamps*6, channel=self.noiseChannel, fs=self.fs, maxLevel=self.maxLevel) if self.noise2Type == "Pink": noise2 = makePinkRef(noise2, self.fs, self.noise2RefHz) noise2 = fir2Filter2(noise2, filterType="bandpass", nTaps=256, cutoffs=(self.noise2LowFreq, self.noise2HighFreq), transitionWidth=0.2, fs=self.fs) noise2 = noise2[0:diad.shape[0],:] noise2 = gate(self.diadRamps, noise2, self.fs) stim = diad+noise1+noise2 noiseDiadSilence = makeSilence(self.preTrialNoiseDiadISI) snd = np.concatenate((preTrialNoise, noiseDiadSilence, stim), axis=0) wavwrite(snd, self.fs, 32, "snd.wav") wavwrite(diad, self.fs, 32, "diad.wav") wavwrite(diad+noise1+noise2, self.fs, 32, "diad_in_noise.wav") sound(snd) self.currentTrial = self.currentTrial+1 def storeRating(self): try: intervalName = self.intervals_db["name"][self.intervals_db["cents"] == self.trialList[self.currentTrial-2][1]].values[0] except: intervalName = str(self.trialList[self.currentTrial-2][1]) #rootNote = str(self.trialList[self.currentTrial-2][0]) #root note rootNote = self.trialList[self.currentTrial-2][0] #interval cents intervalCents = self.trialList[self.currentTrial-2][1] #practice or main trialMode = self.trialList[self.currentTrial-2][2] #dialTotLev diadTotLev = self.trialList[self.currentTrial-2][3] #noise2SL noise2SL = self.trialList[self.currentTrial-2][4] #preTrialNoiseSL preTrialNoiseSL = self.trialList[self.currentTrial-2][5] # if self.currentTrial-1 <= len(self.rootNotes)*len(self.intervalsCents)*self.nPracticeTrialsXStim: # trialMode = "practice" # else: # trialMode = "main" self.thisPageFile.write(self.listenerID + ';') self.thisPageFile.write(str(rootNote) + ';') self.thisPageFile.write(intervalName + ';') self.thisPageFile.write(str(intervalCents) + ';') self.thisPageFile.write(trialMode + ';') self.thisPageFile.write(str(diadTotLev) + ';') #self.thisPageFile.write(str(noise2SL) + ';') self.thisPageFile.write(self.overallRatingSliderValue.text() + '\n') self.thisPageFile.flush() self.overallRatingSlider.setValue(0) self.overallRatingSliderValue.setText("") def sliderChanged(self, value): self.overallRatingSliderValue.setText(str(round(value,1))) if self.currentTrial > 1 and self.statusButton.text() != self.tr("Finished"): self.statusButton.setText(self.tr("Next")) def sliderLabelReset(self): self.overallRatingSliderValue.setText("0") def onClickSetupListenerButton(self): text, ok = QInputDialog.getText(self, "" , "Listener ID: ") if ok: self.listenerID = text else: return ftow = QFileDialog.getSaveFileName(self, self.tr('Choose file to write results'), "", self.tr('All Files (*)'), "", QFileDialog.DontConfirmOverwrite)[0] if len(ftow) > 0: self.thisPagePath = ftow self.thisPageFile = open(self.thisPagePath, "a") self.thisPageFile.write("listener;root_note;interval;intervalCents;trial_type;totLev;rating\n") self.setupListenerButton.hide() self.statusButton.show() else: return def getPhonesCal(self): fHandle = open(phonesCalFile, 'r') currCal = float(fHandle.readline().strip()) fHandle.close() return currCal def writePhonesCal(self, val): fHandle = open(phonesCalFile, 'w') fHandle.write(str(val)) fHandle.close() def onEditPhones(self): currCal = self.getPhonesCal() val, ok = QInputDialog.getDouble(self, self.tr('Phones Calibration'), self.tr('Phones Max. Level'), currCal) self.writePhonesCal(val) self.maxLevel = val
def __init__(self): super(GeneralSection, self).__init__() main_container = QVBoxLayout(self) # Tabs and indentation group_indentation = QGroupBox(self.tr("Indentación y Tabs:")) box = QGridLayout(group_indentation) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Política:")), 0, 0) self.combo_tabs = QComboBox() self.combo_tabs.setFixedWidth(350) self.combo_tabs.addItems([ self.tr("Solo Espacios"), self.tr("Solo Tabulaciones"), ]) box.addWidget(self.combo_tabs, 0, 1) self.combo_tabs.setCurrentIndex( int(settings.get_setting('editor/usetabs'))) # Auto indent self.check_autoindent = QCheckBox(self.tr("Indentación Automática")) box.addWidget(self.check_autoindent, 1, 0) box.setAlignment(Qt.AlignLeft) self.check_autoindent.setChecked(settings.get_setting('editor/indent')) # Minimap group_minimap = QGroupBox(self.tr("Minimapa:")) box = QGridLayout(group_minimap) box.setContentsMargins(20, 5, 20, 5) self.check_minimap = QCheckBox( self.tr("Activar Minimapa (requiere reiniciar el Editor)")) self.check_minimap.setChecked(settings.get_setting('editor/minimap')) box.addWidget(self.check_minimap, 0, 0) #self.check_minimap_animation = QCheckBox(self.tr("Enable animation")) #self.check_minimap_animation.setChecked( #settings.get_setting('editor/minimap-animation')) #box.addWidget(self.check_minimap_animation, 1, 0) #box.addWidget(QLabel(self.tr("Size Area:")), 2, 0) #self.spin_area_minimap = QSpinBox() #self.spin_area_minimap.setFixedWidth(350) #box.addWidget(self.spin_area_minimap, 2, 1) box.setAlignment(Qt.AlignLeft) # Cursor group_caret = QGroupBox(self.tr("Cursor:")) box = QGridLayout(group_caret) box.setContentsMargins(20, 5, 20, 5) box.setAlignment(Qt.AlignLeft) # Type box.addWidget(QLabel(self.tr("Tipo:")), 0, 0) self.combo_caret = QComboBox() self.combo_caret.setFixedWidth(300) caret_types = [ self.tr('Invisible'), self.tr('Línea'), self.tr('Bloque') ] self.combo_caret.addItems(caret_types) index = settings.get_setting('editor/cursor') self.combo_caret.setCurrentIndex(index) box.addWidget(self.combo_caret, 0, 1) # Width box.addWidget(QLabel(self.tr("Ancho:")), 1, 0) self.spin_caret_width = QSpinBox() self.spin_caret_width.setFixedWidth(300) if index != 1: self.spin_caret_width.setEnabled(False) self.spin_caret_width.setRange(1, 3) self.spin_caret_width.setValue( settings.get_setting('editor/caret-width')) box.addWidget(self.spin_caret_width, 1, 1, Qt.AlignLeft) # Period box.addWidget(QLabel(self.tr("Período (ms):")), 2, 0) self.slider_caret_period = QSlider(Qt.Horizontal) self.slider_caret_period.setMaximum(500) self.slider_caret_period.setFixedWidth(300) box.addWidget(self.slider_caret_period, 2, 1, Qt.AlignLeft) lcd_caret = QLCDNumber() lcd_caret.setSegmentStyle(QLCDNumber.Flat) box.addWidget(lcd_caret, 2, 3) # Font group_typo = QGroupBox(self.tr("Fuente:")) box = QGridLayout(group_typo) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Familia:")), 0, 0) self.combo_font = QFontComboBox() self.combo_font.setFixedWidth(350) box.addWidget(self.combo_font, 0, 1) self._load_font() box.addWidget(QLabel(self.tr("Tamaño:")), 1, 0) self.spin_size_font = QSpinBox() self.spin_size_font.setValue(settings.get_setting('editor/size-font')) self.spin_size_font.setFixedWidth(350) box.addWidget(self.spin_size_font, 1, 1) box.setAlignment(Qt.AlignLeft) # Scheme group_scheme = QGroupBox(self.tr("Tema:")) box = QVBoxLayout(group_scheme) box.setContentsMargins(20, 5, 20, 5) self.combo_scheme = QComboBox() self.combo_scheme.setFixedWidth(350) self.combo_scheme.addItems(['Dark Edis', 'White Edis']) scheme = settings.get_setting('editor/scheme') index = 0 if scheme != 'dark': index = 1 self.combo_scheme.setCurrentIndex(index) box.addWidget(self.combo_scheme) box.addWidget(QLabel(self.tr("Requiere reiniciar Edis"))) ## Agrupación main_container.addWidget(group_indentation) main_container.addWidget(group_minimap) main_container.addWidget(group_caret) main_container.addWidget(group_typo) main_container.addWidget(group_scheme) main_container.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) EditorConfiguration.install_widget(self.tr("General"), self) # Conexiones self.combo_scheme.currentIndexChanged['const QString&'].connect( self._change_scheme) self.combo_caret.currentIndexChanged[int].connect( self._caret_type_changed) self.slider_caret_period.valueChanged[int].connect(lcd_caret.display) self.slider_caret_period.setValue( settings.get_setting('editor/cursor-period'))
class PreferencesPanel(QDialog): def __init__(self, parent, app): # The flags we pass are that so we don't get the "What's this" button in the title bar QDialog.__init__(self, parent, Qt.WindowTitleHint | Qt.WindowSystemMenuHint) self.app = app self._setupUi() self.dateFormatEdit.editingFinished.connect(self.dateFormatEdited) self.buttonBox.accepted.connect(self.accept) self.buttonBox.rejected.connect(self.reject) def _setupUi(self): self.setWindowTitle(tr("Preferences")) self.resize(332, 170) self.verticalLayout = QVBoxLayout(self) self.formLayout = QFormLayout() self.autoSaveIntervalSpinBox = QSpinBox(self) self.autoSaveIntervalSpinBox.setMaximumSize(QSize(70, 0xffffff)) self.label_5 = QLabel(tr("minute(s) (0 for none)"), self) self.formLayout.addRow( tr("Auto-save interval:"), horizontalWrap([self.autoSaveIntervalSpinBox, self.label_5]) ) self.dateFormatEdit = QLineEdit(self) self.dateFormatEdit.setMaximumSize(QSize(140, 0xffffff)) self.formLayout.addRow(tr("Date format:"), self.dateFormatEdit) self.fontSizeSpinBox = QSpinBox() self.fontSizeSpinBox.setMinimum(5) self.fontSizeSpinBox.setMaximumSize(QSize(70, 0xffffff)) self.formLayout.addRow(tr("Font size:"), self.fontSizeSpinBox) self.languageComboBox = QComboBox(self) for lang in SUPPORTED_LANGUAGES: self.languageComboBox.addItem(LANGNAMES[lang]) self.languageComboBox.setMaximumSize(QSize(140, 0xffffff)) self.formLayout.addRow(tr("Language:"), self.languageComboBox) self.verticalLayout.addLayout(self.formLayout) self.scopeDialogCheckBox = QCheckBox(tr("Show scope dialog when modifying a scheduled transaction"), self) self.verticalLayout.addWidget(self.scopeDialogCheckBox) self.autoDecimalPlaceCheckBox = QCheckBox(tr("Automatically place decimals when typing"), self) self.verticalLayout.addWidget(self.autoDecimalPlaceCheckBox) self.debugModeCheckBox = QCheckBox(tr("Debug mode (restart required)"), self) self.verticalLayout.addWidget(self.debugModeCheckBox) self.verticalLayout.addItem(verticalSpacer()) self.buttonBox = QDialogButtonBox(self) self.buttonBox.setOrientation(Qt.Horizontal) self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Ok) self.verticalLayout.addWidget(self.buttonBox) def load(self): appm = self.app.model self.autoSaveIntervalSpinBox.setValue(appm.autosave_interval) self.dateFormatEdit.setText(self.app.prefs.dateFormat) self.fontSizeSpinBox.setValue(self.app.prefs.tableFontSize) self.scopeDialogCheckBox.setChecked(appm.show_schedule_scope_dialog) self.autoDecimalPlaceCheckBox.setChecked(appm.auto_decimal_place) self.debugModeCheckBox.setChecked(self.app.prefs.debugMode) try: langindex = SUPPORTED_LANGUAGES.index(self.app.prefs.language) except ValueError: langindex = 0 self.languageComboBox.setCurrentIndex(langindex) def save(self): restartRequired = False appm = self.app.model appm.autosave_interval = self.autoSaveIntervalSpinBox.value() if self.dateFormatEdit.text() != self.app.prefs.dateFormat: restartRequired = True self.app.prefs.dateFormat = self.dateFormatEdit.text() self.app.prefs.tableFontSize = self.fontSizeSpinBox.value() appm.show_schedule_scope_dialog = self.scopeDialogCheckBox.isChecked() appm.auto_decimal_place = self.autoDecimalPlaceCheckBox.isChecked() self.app.prefs.debugMode = self.debugModeCheckBox.isChecked() lang = SUPPORTED_LANGUAGES[self.languageComboBox.currentIndex()] oldlang = self.app.prefs.language if oldlang not in SUPPORTED_LANGUAGES: oldlang = 'en' if lang != oldlang: restartRequired = True self.app.prefs.language = lang if restartRequired: QMessageBox.information(self, "", tr("moneyGuru has to restart for these changes to take effect")) #--- Signals def dateFormatEdited(self): self.dateFormatEdit.setText(clean_format(self.dateFormatEdit.text()))
def __init__(self, parent): super(EditorConfiguration, self).__init__() self._preferences, vbox = parent, QVBoxLayout(self) # groups group1 = QGroupBox(translations.TR_PREFERENCES_EDITOR_CONFIG_INDENT) group2 = QGroupBox(translations.TR_PREFERENCES_EDITOR_CONFIG_MARGIN) group3 = QGroupBox(translations.TR_LINT_DIRTY_TEXT) group4 = QGroupBox(translations.TR_PEP8_DIRTY_TEXT) group5 = QGroupBox(translations.TR_HIGHLIGHTER_EXTRAS) group6 = QGroupBox(translations.TR_TYPING_ASSISTANCE) group7 = QGroupBox(translations.TR_DISPLAY) # groups container container_widget_with_all_preferences = QWidget() formFeatures = QGridLayout(container_widget_with_all_preferences) # Indentation hboxg1 = QHBoxLayout(group1) hboxg1.setContentsMargins(5, 15, 5, 5) self._spin, self._checkUseTabs = QSpinBox(), QComboBox() self._spin.setRange(1, 10) self._spin.setValue(settings.INDENT) hboxg1.addWidget(self._spin) self._checkUseTabs.addItems([ translations.TR_PREFERENCES_EDITOR_CONFIG_SPACES.capitalize(), translations.TR_PREFERENCES_EDITOR_CONFIG_TABS.capitalize()]) self._checkUseTabs.setCurrentIndex(int(settings.USE_TABS)) hboxg1.addWidget(self._checkUseTabs) formFeatures.addWidget(group1, 0, 0) # Margin Line hboxg2 = QHBoxLayout(group2) hboxg2.setContentsMargins(5, 15, 5, 5) self._checkShowMargin = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MARGIN_LINE) self._checkShowMargin.setChecked(settings.SHOW_MARGIN_LINE) hboxg2.addWidget(self._checkShowMargin) self._spinMargin = QSpinBox() self._spinMargin.setRange(50, 100) self._spinMargin.setSingleStep(2) self._spinMargin.setValue(settings.MARGIN_LINE) hboxg2.addWidget(self._spinMargin) hboxg2.addWidget(QLabel(translations.TR_CHARACTERS)) formFeatures.addWidget(group2, 0, 1) # Display Errors vboxDisplay = QVBoxLayout(group7) vboxDisplay.setContentsMargins(5, 15, 5, 5) self._checkHighlightLine = QComboBox() self._checkHighlightLine.addItems([ translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_USE_BACKGROUND, translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_USE_UNDERLINE]) self._checkHighlightLine.setCurrentIndex( int(settings.UNDERLINE_NOT_BACKGROUND)) hboxDisplay1 = QHBoxLayout() hboxDisplay1.addWidget(QLabel(translations.TR_DISPLAY_ERRORS)) hboxDisplay1.addWidget(self._checkHighlightLine) hboxDisplay2 = QHBoxLayout() self._checkDisplayLineNumbers = QCheckBox( translations.TR_DISPLAY_LINE_NUMBERS) self._checkDisplayLineNumbers.setChecked(settings.SHOW_LINE_NUMBERS) hboxDisplay2.addWidget(self._checkDisplayLineNumbers) vboxDisplay.addLayout(hboxDisplay1) vboxDisplay.addLayout(hboxDisplay2) formFeatures.addWidget(group7, 1, 0, 1, 0) # Find Lint Errors (highlighter) vboxg3 = QVBoxLayout(group3) self._checkErrors = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_FIND_ERRORS) self._checkErrors.setChecked(settings.FIND_ERRORS) self.connect(self._checkErrors, SIGNAL("stateChanged(int)"), self._disable_show_errors) self._showErrorsOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_ERRORS) self._showErrorsOnLine.setChecked(settings.ERRORS_HIGHLIGHT_LINE) self.connect(self._showErrorsOnLine, SIGNAL("stateChanged(int)"), self._enable_errors_inline) vboxg3.addWidget(self._checkErrors) vboxg3.addWidget(self._showErrorsOnLine) vboxg3.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding)) formFeatures.addWidget(group3, 2, 0) # Find PEP8 Errors (highlighter) vboxg4 = QHBoxLayout(group4) vboxg4.setContentsMargins(5, 15, 5, 5) vvbox = QVBoxLayout() self._checkStyle = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_PEP8) self._checkStyle.setChecked(settings.CHECK_STYLE) self.connect(self._checkStyle, SIGNAL("stateChanged(int)"), self._disable_check_style) vvbox.addWidget(self._checkStyle) self._checkStyleOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_PEP8) self._checkStyleOnLine.setChecked(settings.CHECK_HIGHLIGHT_LINE) self.connect(self._checkStyleOnLine, SIGNAL("stateChanged(int)"), self._enable_check_inline) vvbox.addWidget(self._checkStyleOnLine) vvbox.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) vboxg4.addLayout(vvbox) # Container for tree widget and buttons widget = QWidget() hhbox = QHBoxLayout(widget) hhbox.setContentsMargins(0, 0, 0, 0) # Tree Widget with custom item delegate # always adds uppercase text self._listIgnoreViolations = QTreeWidget() self._listIgnoreViolations.setObjectName("ignore_pep8") self._listIgnoreViolations.setItemDelegate(ui_tools.CustomDelegate()) self._listIgnoreViolations.setMaximumHeight(80) self._listIgnoreViolations.setHeaderLabel( translations.TR_PREFERENCES_EDITOR_CONFIG_IGNORE_PEP8) for ic in settings.IGNORE_PEP8_LIST: self._listIgnoreViolations.addTopLevelItem(QTreeWidgetItem([ic])) hhbox.addWidget(self._listIgnoreViolations) box = QVBoxLayout() box.setContentsMargins(0, 0, 0, 0) btn_add = QPushButton(QIcon(":img/add_small"), '') btn_add.setMaximumSize(26, 24) btn_add.clicked.connect(self._add_code_pep8) box.addWidget(btn_add) btn_remove = QPushButton(QIcon(":img/delete_small"), '') btn_remove.setMaximumSize(26, 24) btn_remove.clicked.connect(self._remove_code_pep8) box.addWidget(btn_remove) box.addItem(QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)) hhbox.addLayout(box) vboxg4.addWidget(widget) formFeatures.addWidget(group4) # Show Python3 Migration, DocStrings and Spaces (highlighter) vboxg5 = QVBoxLayout(group5) vboxg5.setContentsMargins(5, 15, 5, 5) self._showMigrationTips = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MIGRATION) self._showMigrationTips.setChecked(settings.SHOW_MIGRATION_TIPS) vboxg5.addWidget(self._showMigrationTips) self._checkForDocstrings = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_CHECK_FOR_DOCSTRINGS) self._checkForDocstrings.setChecked(settings.CHECK_FOR_DOCSTRINGS) vboxg5.addWidget(self._checkForDocstrings) self._checkShowSpaces = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TABS_AND_SPACES) self._checkShowSpaces.setChecked(settings.SHOW_TABS_AND_SPACES) vboxg5.addWidget(self._checkShowSpaces) self._checkIndentationGuide = QCheckBox( translations.TR_SHOW_INDENTATION_GUIDE) self._checkIndentationGuide.setChecked(settings.SHOW_INDENTATION_GUIDE) vboxg5.addWidget(self._checkIndentationGuide) formFeatures.addWidget(group5, 3, 0) # End of line, Stop Scrolling At Last Line, Trailing space, Word wrap vboxg6 = QVBoxLayout(group6) vboxg6.setContentsMargins(5, 15, 5, 5) self._checkEndOfLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_END_OF_LINE) self._checkEndOfLine.setChecked(settings.USE_PLATFORM_END_OF_LINE) vboxg6.addWidget(self._checkEndOfLine) self._checkEndAtLastLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_END_AT_LAST_LINE) self._checkEndAtLastLine.setChecked(settings.END_AT_LAST_LINE) vboxg6.addWidget(self._checkEndAtLastLine) self._checkTrailing = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_REMOVE_TRAILING) self._checkTrailing.setChecked(settings.REMOVE_TRAILING_SPACES) vboxg6.addWidget(self._checkTrailing) self._allowWordWrap = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_WORD_WRAP) self._allowWordWrap.setChecked(settings.ALLOW_WORD_WRAP) vboxg6.addWidget(self._allowWordWrap) formFeatures.addWidget(group6, 3, 1) # pack all the groups vbox.addWidget(container_widget_with_all_preferences) vbox.addItem(QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)
def process_item(self, data, last_dent_id, username, server, dent_type): if data["in_reply_to_screen_name"]: nickname = data["nickname"] + " " + u"\u2794" + " " + data[ "in_reply_to_screen_name"] if data["in_reply_to_screen_name"] == username: dent_type = "mentions" context_button = QPushButton() context_button.setFixedHeight(20) context_button.setText("Context") context_button.setObjectName("context_button_" + str(data["conversation_id"])) context_button.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed) context_button.hide() else: nickname = data["nickname"] read_state = "not" #if int(data["id"]) < int(last_dent_id): if int(data["id"]) < int(last_dent_id) or int( data["id"]) == int(last_dent_id): read_state = "read" post_data_info = QLabel() post_data = QLabel() post_data.setText( QString.fromUtf8( "<b>{0}</b> <span style='font-size:8pt;'>{2}</span><p style='padding:0;'>{1}</p>" .format(nickname, data["text"], data["date"]))) post_data.setWordWrap(True) post_data.setAlignment(Qt.AlignTop) post_data.setOpenExternalLinks(True) post_height = post_data.sizeHint().height() post_data.setMinimumWidth(300) post_data.setMaximumWidth(6000) post_data.setMaximumHeight(post_height) post_data.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.MinimumExpanding) post_data_layout = QVBoxLayout() post_data_layout.addWidget(post_data) post_data_layout.setContentsMargins(3, 0, 0, 0) post_data_layout.setAlignment(Qt.AlignTop) # Poster avatar and post actions avatar_data = QLabel() extension = data["avatar"].split(".")[-1:][0] avatar = os.path.expanduser("~/.local/share/qtdenter/avatars/" ) + "%s.%s" % (data["nickname"], extension) avatar_data.setText( "<img src='{0}' height=48 width=48 />".format(avatar)) avatar_data.setMinimumSize(0, 0) avatar_data.setMaximumSize(48, 48) avatar_data.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.MinimumExpanding) #reply_button = QPushButton() #reply_button.setText("Reply") destroy_button = QPushButton() destroy_button.setText("Delete") destroy_button.setFixedHeight(20) #destroy_button.setFlat(True) destroy_button.setObjectName("destroy_button_" + str(data["id"])) destroy_button.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Fixed) spacer = QSpacerItem(0, 1, QSizePolicy.Fixed, QSizePolicy.Expanding) post_avatar_layout = QVBoxLayout() post_avatar_layout.addWidget(avatar_data) #post_avatar_layout.addWidget(reply_button) post_avatar_layout.addWidget(destroy_button) post_avatar_layout.addItem(spacer) post_avatar_widget = QWidget() post_avatar_widget.setLayout(post_avatar_layout) # Like button like_button = QPushButton() if data["in_favorites"]: like_button.setText("X") like_button.setToolTip("De-Favoritize") else: like_button.setText(u"\u2665") like_button.setToolTip("Favoritize") #like_button.setFlat(True) like_button.setFixedSize(32, 32) like_button.setObjectName("like_button_" + str(data["id"])) redent_button = QPushButton() redent_button.setText(u"\u267a") #redent_button.setFlat(True) redent_button.setFixedSize(32, 32) redent_button.setObjectName("redent_button_" + str(data["id"])) buttons_layout = QHBoxLayout() buttons_layout.addWidget(like_button) buttons_layout.addWidget(redent_button) buttons_layout.setContentsMargins(0, 0, 0, 0) buttons_widget = QWidget() buttons_widget.setLayout(buttons_layout) post_data_widget = QWidget() post_data_widget.setLayout(post_data_layout) # Some underpost buttons dentid_button = QPushButton() dentid_button.setText("#" + str(data["id"])) dentid_button.setObjectName("dentid_button_" + str(data["id"])) dentid_button.setFixedHeight(20) dentid_button.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) source = QLabel() source.setText("<span style='font-size:8pt;'>from {0}".format( data["source"])) source.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.MinimumExpanding) source.setWordWrap(True) spacer2 = QSpacerItem(0, 1, QSizePolicy.Fixed, QSizePolicy.Expanding) post_info_layout = QVBoxLayout() post_info_layout.addWidget(dentid_button) post_info_layout.addWidget(source) post_info_layout.addWidget(buttons_widget) if data["in_reply_to_screen_name"]: post_info_layout.addWidget(context_button) post_info_layout.addItem(spacer2) post_info_layout.setAlignment(Qt.AlignTop) post_info_layout.setContentsMargins(9, 0, 9, 0) post_info_widget = QWidget() post_info_widget.setLayout(post_info_layout) post_info_widget.setFixedWidth(100) # Final post widget post_layout = QHBoxLayout() post_layout.addWidget(post_data_widget) post_layout.addWidget(post_info_widget) post_widget = QWidget() post_widget.setLayout(post_layout) item = QTreeWidgetItem() item.setText( 2, str(data["id"]) + ":" + data["nickname"] + ":" + str(data["conversation_id"]) + ":" + read_state) if data["in_favorites"]: item.setText(3, "favorited") else: item.setText(3, "not") item.setText(4, data["text"]) item.setText(5, server + ":" + dent_type) return (item, post_avatar_widget, post_widget)
class Screensaver_Overlay(QWidget): ''' Overlay for a window or widget below, just to display some content without blocking clicks to the window below. Just like a Screensaver. ''' def __init__(self, cwd, weather_active=True, parent=None): super(Screensaver_Overlay, self).__init__(parent) self.cwd = cwd self.weather_active = weather_active self.setAttribute(Qt.WA_StyledBackground) #want a styled Background self.setAttribute(Qt.WA_TransparentForMouseEvents, True) self.setupUI() # setup layout and widgets if parent is None: self.setFixedSize(600, 400) else: self.setFixedSize(parent.size()) # adapt size to parent (noramly the window) logger.info("Start Update-Cycle for Standby-Screensaver") self.startUpdate() # start counters to periodically update conditions def setupUI(self): ''' Setup of GUI Elements ''' #setup Layout self.setStyleSheet("Screensaver_Overlay { background-color: black } " "QLabel { color : white; }") font_max_time = QFont() font_max_time.setPointSize(94) font_max_date = QFont() font_max_date.setPointSize(34) self.horizontalLayout_3 = QHBoxLayout(self) self.horizontalLayout_2 = QHBoxLayout() self.verticalLayout = QVBoxLayout() spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.lbl_time = Scaling_QLabel(self) self.lbl_time.setFont(font_max_time) self.lbl_time.setTextFormat(Qt.AutoText) self.lbl_time.setScaledContents(False) self.lbl_time.setWordWrap(True) self.lbl_time.maxFont = font_max_time self.lbl_time.setAlignment(Qt.AlignCenter) self.verticalLayout.addWidget(self.lbl_time) self.horizontalLayout = QHBoxLayout() self.lbl_day = Scaling_QLabel(self) self.lbl_day.setFont(font_max_date) self.lbl_day.setTextFormat(Qt.AutoText) self.lbl_day.setScaledContents(False) self.lbl_day.setWordWrap(True) self.lbl_day.maxFont = font_max_date self.lbl_day.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.horizontalLayout.addWidget(self.lbl_day) self.lbl_date = Scaling_QLabel(self) self.lbl_date.setFont(font_max_date) self.lbl_date.setTextFormat(Qt.AutoText) self.lbl_date.setScaledContents(False) self.lbl_date.setWordWrap(True) self.lbl_date.maxFont = font_max_date self.lbl_date.setAlignment(Qt.AlignLeading | Qt.AlignLeft | Qt.AlignVCenter) self.horizontalLayout.addWidget(self.lbl_date) self.verticalLayout.addLayout(self.horizontalLayout) spacerItem1 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem1) self.horizontalLayout_2.addLayout(self.verticalLayout) spacerItem2 = QSpacerItem(14, 51, QSizePolicy.Preferred, QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem2) self.verticalLayout_2 = QVBoxLayout() spacerItem3 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem3) #self.lbl_weather_icon = Scaling_QLabel_pixmap(self) self.lbl_weather_icon = weatherIcon(self) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.lbl_weather_icon.sizePolicy().hasHeightForWidth()) self.lbl_weather_icon.setSizePolicy(sizePolicy) self.lbl_weather_icon.setScaledContents(False) self.lbl_weather_icon.setAlignment(Qt.AlignCenter) self.verticalLayout_2.addWidget(self.lbl_weather_icon) self.lbl_temperature = Scaling_QLabel(self) self.lbl_temperature.setFont(font_max_date) self.lbl_temperature.setTextFormat(Qt.AutoText) self.lbl_temperature.setScaledContents(False) self.lbl_temperature.setWordWrap(True) self.lbl_temperature.maxFont = font_max_date self.lbl_temperature.setAlignment(Qt.AlignCenter) self.lbl_temperature.setAlignment(Qt.AlignCenter) self.verticalLayout_2.addWidget(self.lbl_temperature) spacerItem4 = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout_2.addItem(spacerItem4) self.horizontalLayout_2.addLayout(self.verticalLayout_2) self.horizontalLayout_2.setStretch(0, 2) self.horizontalLayout_2.setStretch(2, 1) self.horizontalLayout_3.addLayout(self.horizontalLayout_2) self.lbl_time.setText("") self.lbl_day.setText("") self.lbl_date.setText("") self.lbl_temperature.setText(QString.fromUtf8("")) #self.lbl_weather_icon.setPixmap(QPixmap("../res/weather/icon/na.png")) self.setLayout(self.horizontalLayout_3) def startUpdate(self): ''' This is called during initialisation and updates the content of the lables for time and weather ''' timerclock = QTimer(self) timerclock.timeout.connect(self.updateTime) timerclock.start(1000) # every second update the time if self.weather_active: timerclock2 = QTimer(self) timerclock2.timeout.connect(self.updateWeather) self.updateWeather() # initially make a call to the API to get the current condition timerclock2.start(300000) #every 5 Minutes update the weather icon (this will cause an API call...) def updateTime(self): ''' This function is called by a QTimer with 1 sec. interval, Updates the current Time, Day and Date ''' self.lbl_time.setText(self.tr(time.strftime("%H:%M"))) self.lbl_day.setText(self.tr(date.today().strftime("%A")) + ", ") self.lbl_date.setText(self.tr(date.today().strftime("%d.%b.%Y").decode("utf-8"))) # avoid uft-8 problem with "März" def updateWeather(self): ''' This function is called by a QTimer with 5 min. interval, Updates the weather-icon and the temperature ''' location_ID = global_vars.configuration.get("GENERAL").get("weather_locationid") if location_ID is None: return #return if no location ID can be loaded... temp_condition = weather.get_weather_from_weather_com(location_ID) self.lbl_weather_icon.setPicturePath(os.path.join(self.cwd, "res/weather/icon", temp_condition['current_conditions']['icon'], "static")) self.lbl_temperature.setText(temp_condition['current_conditions']['temperature']+QString.fromUtf8("°C"))
class PeakMapExplorer(QDialog): def __init__(self, parent=None): super(PeakMapExplorer, self).__init__(parent) self.setWindowFlags(Qt.Window) self.setAttribute(Qt.WA_DeleteOnClose) self.setWindowFlags(Qt.Window) def keyPressEvent(self, e): if e.key() != Qt.Key_Escape: super(PeakMapExplorer, self).keyPressEvent(e) def setup(self, peakmap, peakmap2=None, extra_items=None): self.setup_widgets_and_layout() self.connect_signals_and_slots() self.setup_peakmap_plotter(peakmap, peakmap2, extra_items) self.setup_processing_parameters() self.plot_peakmap() def connect_signals_and_slots(self): self.params.paramsChanged.connect(self.peakmap_plotter.set_processing_parameters) def setup_processing_parameters(self): self.params.setup_initial_values(gamma_min=0.05, gamma_max=10.0, gamma_start=4.0, log_scale=True, imin=self.imin, imax=self.imax) def setup_peakmap_plotter(self, peakmap, peakmap2, extra_items): self.peakmap = peakmap # .getDominatingPeakmap() self.dual_mode = peakmap2 is not None self.peakmap2 = peakmap2 if self.dual_mode: self.peakmap2 = peakmap2.getDominatingPeakmap() (self.rtmin, self.rtmax, self.mzmin, self.mzmax, self.imin, self.imax) = get_range(peakmap, peakmap2) # jparam = PeakMapProcessingParameters(self.params.gamma_start, True, 0, self.imax) # self.peakmap_plotter.set_processing_parameters(param) def plot_peakmap(self): # includes replot: self.peakmap_plotter.update_image_limits(self.rtmin, self.rtmax, self.mzmin, self.mzmax) def setup_widgets_and_layout(self): sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(1) sizePolicy.setVerticalStretch(1) sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth()) self.setSizePolicy(sizePolicy) self.gridLayout = QGridLayout(self) self.splitter = QSplitter(self) self.splitter.setOrientation(Qt.Horizontal) self.peakmap_plotter = PeakmapPlotter(self.splitter) self.verticalLayoutWidget = QWidget(self.splitter) self.verticalLayout = QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setMargin(0) self.params = PeakMapScalingParameters(self.verticalLayoutWidget) sizePolicy = QSizePolicy(QSizePolicy.Maximum, QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.params.sizePolicy().hasHeightForWidth()) self.params.setSizePolicy(sizePolicy) self.verticalLayout.addWidget(self.params) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.MinimumExpanding) self.verticalLayout.addItem(spacerItem) self.gridLayout.addWidget(self.splitter, 0, 0, 1, 1)
class EvtxAdminPannel(QWidget): def __init__(self, parent=None, chunks=[]): super(EvtxAdminPannel, self).__init__(parent) self.verticalLayout = QVBoxLayout(self) spacerItem = QSpacerItem(20, 259, QSizePolicy.Minimum, QSizePolicy.Expanding) self.verticalLayout.setMargin(3) self.verticalLayout.addWidget( QLabel("Number of chunk(s) : " + str(len(chunks)))) nb_rec = 0 for i in chunks: nb_rec += i.nbRecord() self.nb_rec = nb_rec self.verticalLayout.addWidget( QLabel("Number of record(s) : " + str(nb_rec))) tmp_widget = QWidget() self.verticalLayout.addWidget(tmp_widget) hor_layout = QHBoxLayout(tmp_widget) hor_layout.addWidget(QLabel("Display :")) self.admin_events = QPushButton(QIcon(":/green_configure.png"), "Admin. events") hor_layout.addWidget(self.admin_events) self.choose_event_type = QComboBox() self.choose_event_type.addItem(QIcon(":/internet_explorer"), "All", 42) self.choose_event_type.addItem(QIcon(":/audit_success"), "Audit success", 0) self.choose_event_type.addItem(QIcon(":/audit_failure"), "Audit failure", 1) self.choose_event_type.addItem(QIcon(":/error"), "Error", 2) self.choose_event_type.addItem(QIcon(":/warning"), "Warning", 3) self.choose_event_type.addItem(QIcon(":/info"), "Information", 4) self.choose_event_type.addItem(QIcon(":/chat.png"), "Comment", 5) hor_layout.addWidget(self.choose_event_type) tmp_widget = QWidget() self.verticalLayout.addWidget(tmp_widget) hor_layout = QHBoxLayout(tmp_widget) self.id = QLineEdit() hor_layout.addWidget(QLabel("Id :")) self.cb = self.initId(chunks, 'id') self.cb.setMaxVisibleItems(15) hor_layout.addWidget(self.cb) hor_layout.addWidget(self.id) self.search_id = QPushButton("Go") hor_layout.addWidget(self.search_id) tmp_widget = QWidget() self.verticalLayout.addWidget(tmp_widget) hor_layout = QHBoxLayout(tmp_widget) self.source = QLineEdit() hor_layout.addWidget(QLabel("Source :")) self.cbs = self.initId(chunks, 'source') hor_layout.addWidget(self.cbs) hor_layout.addWidget(self.source) self.search_source = QPushButton("Go") hor_layout.addWidget(self.search_source) self.verticalLayout.addWidget(QLabel("Date debut :")) self.select_date_b = QDateTimeEdit() self.select_date_b.setDisplayFormat("MMM dd yyyy hh:mm AP") self.verticalLayout.addWidget(self.select_date_b) self.verticalLayout.addWidget(QLabel("date fin:")) self.select_date_e = QDateTimeEdit() self.select_date_e.setDisplayFormat("MMM dd yyyy hh:mm AP") self.verticalLayout.addWidget(self.select_date_e) self.search_date = QPushButton("Go") self.verticalLayout.addWidget(self.search_date) self.verticalLayout.addItem(spacerItem) def initId(self, chunks, param): cb = QComboBox() tmp_list = [] for chunk in chunks: events = chunk.events() for event in events: tmp_list.append(str(events[event][param])) tmp_list = self.unique(tmp_list) cb.addItems(tmp_list) return cb def unique(self, seq, idfun=None): # order preserving if idfun is None: def idfun(x): return x seen = {} result = [] for item in seq: marker = idfun(item) if marker in seen: continue seen[marker] = 1 if item is not None: result.append(item) return sorted(result)
class EkdMessage(QDialog): ''' EkdMessage : Classe représentant une boite de dialogue avec un texte, des bouton et une icone permettant d'avertir l'utilisateur ''' def __init__(self, titre, texte="", min_w=320, min_h=250, max_w=500, max_h=600, icone="Icones/messagebox_info.png", checkbox=False, parent=None): """Boite de message standard pour ekd. Usage : 1. initialisation en spécifiant la taille, le titre et éventuellement le texte de la fenêtre. l'icone est également paramétrable 2. Ajout du text avec la fonction setAideText. 3. Affichage de la fenêtre en appelant la fonction show(). Facilité : 1. Redimensionnement de la fenêtre par appel de la fonction setSize(w, h) 2. Ajout automatique des bars de défilement.""" super(EkdMessage, self).__init__(parent) self.setWindowTitle(titre) self.setMaximumHeight(max_h) self.setMaximumWidth(max_w) self.setMinimumHeight(min_h) self.setMinimumWidth(min_w) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) sizePolicy.setVerticalStretch(1) self.setSizePolicy(sizePolicy) self.w = min_w self.h = min_h self.verticalLayout = QVBoxLayout(self) self.hbox1 = QHBoxLayout() self.vbox1 = QVBoxLayout() # Icone self.iconeI = QLabel(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.iconeI.sizePolicy().hasHeightForWidth()) self.iconeI.setSizePolicy(sizePolicy) self.iconeI.setPixmap(QPixmap(icone)) self.vbox1.addWidget(self.iconeI) spacerItem = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) self.vbox1.addItem(spacerItem) self.hbox1.addLayout(self.vbox1) ## # Definition de la zone de texte self.text = QTextEdit(self) ## On utilise le même thème que la fenêtre pour la zone de texte ## On force les couleur ici, on ne laisse pas le Thème s'en charger palette = self.text.palette() palette.setBrush(QPalette.Active, QPalette.Base, self.palette().window()) palette.setBrush(QPalette.Inactive, QPalette.Base, self.palette().window()) palette.setBrush(QPalette.Disabled, QPalette.Base, self.palette().window()) palette.setBrush(QPalette.Active, QPalette.Text, self.palette().windowText()) palette.setBrush(QPalette.Inactive, QPalette.Text, self.palette().windowText()) palette.setBrush(QPalette.Disabled, QPalette.Text, self.palette().windowText()) self.text.setPalette(palette) self.text.setFrameShape(QFrame.NoFrame) self.text.setFrameShadow(QFrame.Plain) self.text.setLineWidth(0) self.text.setReadOnly(True) self.text.setAlignment(Qt.AlignLeft | Qt.AlignTop) sizePolicy = QSizePolicy(QSizePolicy.Expanding,QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.text.sizePolicy().hasHeightForWidth()) self.text.setSizePolicy(sizePolicy) self.hbox1.addWidget(self.text) ## self.verticalLayout.addLayout(self.hbox1) self.hbox2 = QHBoxLayout() self.ok = QPushButton(self) self.ok.setText(_("Ok")) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.ok.sizePolicy().hasHeightForWidth()) self.ok.setSizePolicy(sizePolicy) self.hbox2.addWidget(self.ok) self.verticalLayout.addLayout(self.hbox2) self.setText(texte) ''' Checkbox pour savoir si l'utilisateur veut oui ou non revoir l'avertissement ''' if checkbox : self.checkbox = QCheckBox(_(u"Voir ce message la prochaine fois"), self) self.hbox2.addWidget(self.checkbox) try : self.checkbox.setCheckState(int(EkdConfig.get("general", "show_warning_messages"))) except Exception, e: #print "First time launched" EkdPrint(u"First time launched") self.connect(self.checkbox, SIGNAL("stateChanged(int)"), self.setDontShow) self.connect(self.ok, SIGNAL("clicked()"), self.close)
def __init__(self, iface, parent, params): QDialog.__init__(self, parent) self.iface = iface self.parent = parent self.params = params self.output_reader = None self.tool = None self.element_ids_nodes = None self.element_ids_links = None self.nodes_lay = None self.links_lay = None self.setWindowTitle(Parameters.plug_in_name) # Selection changed listeners self.params.junctions_vlay.selectionChanged.connect( self.feature_sel_changed) self.params.reservoirs_vlay.selectionChanged.connect( self.feature_sel_changed) self.params.tanks_vlay.selectionChanged.connect( self.feature_sel_changed) self.params.pipes_vlay.selectionChanged.connect( self.feature_sel_changed) self.params.pumps_vlay.selectionChanged.connect( self.feature_sel_changed) self.params.valves_vlay.selectionChanged.connect( self.feature_sel_changed) # self.setMinimumWidth(min_width) # self.setMinimumHeight(min_height) fra_main_lay = QVBoxLayout(self) self.fra_out_file = QFrame(self) fra_out_file_lay = QHBoxLayout(self.fra_out_file) self.lbl_out_file = QLabel('Simulation output file:') self.txt_out_file = QLineEdit('') self.txt_out_file.setReadOnly(True) self.btn_out_file = QToolButton() self.btn_out_file.setText('...') self.btn_out_file.clicked.connect(self.btn_out_file_clicked) fra_out_file_lay.addWidget(self.lbl_out_file) fra_out_file_lay.addWidget(self.txt_out_file) fra_out_file_lay.addWidget(self.btn_out_file) self.tab_widget = QTabWidget(self) # Graphs tab --------------------------------------------------------------------------------------------------- self.tab_graphs = QWidget() tab_graphs_lay = QHBoxLayout(self.tab_graphs) # Left frame self.fra_graphs_left = QFrame() self.fra_graphs_left.setMaximumWidth(100) fra_graphs_left_lay = QVBoxLayout(self.fra_graphs_left) self.btn_sel_element = QPushButton('Pick') self.btn_sel_element.clicked.connect(self.btn_sel_element_clicked) fra_graphs_left_lay.addWidget(self.btn_sel_element) # Nodes self.grb_nodes = QGroupBox(u'Nodes') lay_grb_nodes = QVBoxLayout(self.grb_nodes) self.chk_node_demand = QCheckBox('Demand') lay_grb_nodes.addWidget(self.chk_node_demand) self.chk_node_head = QCheckBox('Head') lay_grb_nodes.addWidget(self.chk_node_head) self.chk_node_pressure = QCheckBox('Pressure') lay_grb_nodes.addWidget(self.chk_node_pressure) self.chk_node_quality = QCheckBox('Quality') lay_grb_nodes.addWidget(self.chk_node_quality) fra_graphs_left_lay.addWidget(self.grb_nodes) # Links self.grb_links = QGroupBox(u'Links') lay_grb_links = QVBoxLayout(self.grb_links) self.chk_link_flow = QCheckBox('Flow') lay_grb_links.addWidget(self.chk_link_flow) self.chk_link_velocity = QCheckBox('Velocity') lay_grb_links.addWidget(self.chk_link_velocity) self.chk_link_headloss = QCheckBox('Headloss') lay_grb_links.addWidget(self.chk_link_headloss) self.chk_link_quality = QCheckBox('Quality') lay_grb_links.addWidget(self.chk_link_quality) fra_graphs_left_lay.addWidget(self.grb_links) self.btn_draw_graph = QPushButton('Draw') self.btn_draw_graph.clicked.connect(self.draw_graphs) fra_graphs_left_lay.addWidget(self.btn_draw_graph) self.spacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding) fra_graphs_left_lay.addItem(self.spacer) tab_graphs_lay.addWidget(self.fra_graphs_left) # Right frame self.fra_graphs_right = QFrame() fra_graphs_right_lay = QVBoxLayout(self.fra_graphs_right) fra_graphs_right_lay.setContentsMargins(0, 0, 0, 0) self.static_canvas = StaticMplCanvas(self.fra_graphs_right, width=5, height=4, dpi=100) fra_graphs_right_lay.addWidget(self.static_canvas) tab_graphs_lay.addWidget(self.fra_graphs_right) # lay.addWidget(self.button) self.tab_widget.addTab(self.tab_graphs, 'Graphs') # Maps tab ----------------------------------------------------------------------------------------------------- self.tab_maps = QWidget() tab_maps_lay = QHBoxLayout(self.tab_maps) # Left frame self.fra_maps_left = QFrame() self.fra_maps_left.setMaximumWidth(200) fra_maps_left_lay = QVBoxLayout(self.fra_maps_left) self.grb_maps = QGroupBox(u'Variable') grb_maps_lay = QVBoxLayout(self.grb_maps) self.rad_maps_node_demand = QRadioButton(u'Node demand') grb_maps_lay.addWidget(self.rad_maps_node_demand) self.rad_maps_node_head = QRadioButton(u'Node head') grb_maps_lay.addWidget(self.rad_maps_node_head) self.rad_maps_node_pressure = QRadioButton(u'Node pressure') grb_maps_lay.addWidget(self.rad_maps_node_pressure) self.rad_maps_node_quality = QRadioButton(u'Node quality') grb_maps_lay.addWidget(self.rad_maps_node_quality) self.rad_maps_link_flow = QRadioButton(u'Link flow') grb_maps_lay.addWidget(self.rad_maps_link_flow) self.rad_maps_link_velocity = QRadioButton(u'Link velocity') grb_maps_lay.addWidget(self.rad_maps_link_velocity) self.rad_maps_link_headloss = QRadioButton(u'Link headloss') grb_maps_lay.addWidget(self.rad_maps_link_headloss) self.rad_maps_link_quality = QRadioButton(u'Link quality') grb_maps_lay.addWidget(self.rad_maps_link_quality) fra_maps_left_lay.addWidget(self.grb_maps) fra_maps_left_lay.addItem(self.spacer) tab_maps_lay.addWidget(self.fra_maps_left) # Right maps frame self.fra_maps_right = QFrame() fra_maps_right_lay = QVBoxLayout(self.fra_maps_right) self.fra_maps_right_time = QFrame() fra_maps_right_time_lay = QFormLayout(self.fra_maps_right_time) self.lbl_map_times = QLabel(u'Period [h]:') self.cbo_map_times = QComboBox() fra_maps_right_time_lay.addRow(self.lbl_map_times, self.cbo_map_times) fra_maps_right_lay.addWidget(self.fra_maps_right_time) self.btn_draw_map = QPushButton(u'Draw map') self.btn_draw_map.clicked.connect(self.draw_maps) fra_maps_right_lay.addWidget(self.btn_draw_map) fra_maps_right_lay.addItem(self.spacer) tab_maps_lay.addWidget(self.fra_maps_right) self.tab_widget.addTab(self.tab_maps, 'Maps') # # Add to main fra_main_lay.addWidget(self.fra_out_file) fra_main_lay.addWidget(self.tab_widget) self.setup() self.initialize() # self.read_outputs() # Set size self.setMinimumWidth(self.tab_graphs.width()) self.setMinimumHeight(self.tab_graphs.height())
def __init__(self): super(GeneralSection, self).__init__() container = QVBoxLayout(self) # Inicio group_on_start = QGroupBox(self.tr("Al Iniciar:")) box = QVBoxLayout(group_on_start) box.setContentsMargins(20, 5, 20, 5) self.check_splash = QCheckBox(self.tr("Mostrar Splash")) self.check_splash.setChecked( settings.get_setting('general/show-splash')) box.addWidget(self.check_splash) self.check_on_start = QCheckBox(self.tr("Mostrar Página de Inicio")) show_start_page = settings.get_setting('general/show-start-page') self.check_on_start.setChecked(show_start_page) box.addWidget(self.check_on_start) self.check_load_files = QCheckBox( self.tr("Cargar archivos desde la " "última sesión")) load_files = settings.get_setting('general/load-files') self.check_load_files.setChecked(load_files) box.addWidget(self.check_load_files) container.addWidget(group_on_start) # Al salir group_on_exit = QGroupBox(self.tr("Al Salir:")) box = QVBoxLayout(group_on_exit) box.setContentsMargins(20, 5, 20, 5) self.check_on_exit = QCheckBox(self.tr("Confirmar Salida")) self.check_on_exit.setChecked( settings.get_setting('general/confirm-exit')) box.addWidget(self.check_on_exit) self.check_geometry = QCheckBox( self.tr("Guardar posición y tamaño de la ventana")) self.check_geometry.setChecked( settings.get_setting('window/store-size')) box.addWidget(self.check_geometry) container.addWidget(group_on_exit) # Notificaciones group_notifications = QGroupBox(self.tr("Notificaciones:")) box = QVBoxLayout(group_notifications) box.setContentsMargins(20, 5, 20, 5) self.check_updates = QCheckBox(self.tr("Buscar Actualizaciones")) self.check_updates.setChecked( settings.get_setting('general/check-updates')) box.addWidget(self.check_updates) container.addWidget(group_notifications) # Sistema if settings.IS_LINUX: group_terminal = QGroupBox(self.tr("Sistema:")) box = QHBoxLayout(group_terminal) box.addWidget(QLabel(self.tr("Ejecutar programa con:"))) self.line_terminal = QLineEdit() self.line_terminal.setAlignment(Qt.AlignLeft) self.line_terminal.setFixedWidth(300) self.line_terminal.setText(settings.get_setting('terminal')) box.addWidget(self.line_terminal, 1, Qt.AlignLeft) container.addWidget(group_terminal) # User Interface group_ui = QGroupBox(self.tr("Interfáz de Usuario:")) box = QGridLayout(group_ui) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Tema:")), 0, 0) self.combo_theme = QComboBox() self.combo_theme.setFixedWidth(200) self._update_combo() index = self.combo_theme.findText( settings.get_setting('window/style-sheet')) self.combo_theme.setCurrentIndex(index) box.addWidget(self.combo_theme, 0, 1) self.combo_lang = QComboBox() self.combo_lang.setFixedWidth(200) box.addWidget(QLabel(self.tr("Idioma:")), 1, 0) box.addWidget(self.combo_lang, 1, 1) langs = os.listdir(os.path.join(paths.PATH, "extras", "i18n")) self.combo_lang.addItems(["Spanish"] + [lang[:-3] for lang in langs]) lang = settings.get_setting('general/language') index = 0 if not lang else self.combo_lang.findText(lang) self.combo_lang.setCurrentIndex(index) container.addWidget(group_ui) box.setAlignment(Qt.AlignLeft) # Reestablecer group_restart = QGroupBox(self.tr("Reestablecer:")) box = QHBoxLayout(group_restart) box.setContentsMargins(20, 5, 20, 5) btn_restart = QPushButton(self.tr("Reiniciar configuraciones")) btn_restart.setObjectName("custom") box.addWidget(btn_restart) box.addStretch(1) container.addWidget(group_restart) container.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Conexiones btn_restart.clicked.connect(self._restart_configurations) self.combo_theme.currentIndexChanged[int].connect( self._change_style_sheet) # Install EnvironmentConfiguration.install_widget(self.tr("General"), self)
class GraphGui(QWidget): def __init__(self, G=None, pos=None, parent=None): QWidget.__init__(self, parent) self.scene = GraphGraphicsScene(G, pos, self) self.view = QGraphicsView(self.scene, self) self.button = QPushButton("Quit", self) self.nodeButton = QPushButton("Node", self) self.edgeButton = QPushButton("Edge", self) self.addButton = QPushButton("Add", self) self.deleteButton = QPushButton("Delete", self) self.printButton = QPushButton("Print", self) self.eulerButton = QPushButton("Euler", self) self.generateFullButton = QPushButton("Full", self) self.generateHalfButton = QPushButton("Half", self) self.infoButton = QPushButton("Info", self) # self.testButton = QPushButton('Test', self) self.nodesInputLabel = QLabel("Nodes", self) self.edgesInputLabel = QLabel("Edges", self) self.saveButton = QPushButton("Save", self) self.loadButton = QPushButton("Load", self) self.saveAsButton = QPushButton("SaveAs", self) self.bridgeButton = QPushButton("Bridge", self) self.stepSlider = QSlider(self) self.cursorLabelX = QLabel("X:", self) self.cursorLabelY = QLabel("Y:", self) self.nodeNumberLabel = QLabel("Nr:", self) self.fileLabel = QLabel("File:", self) self.nodeInfo = QLabel("N:", self) self.edgeInfo = QLabel("E:", self) self.eulerInfo = QLabel("None", self) # self.fileInput = QLineEdit(self) self.fileInput = QLabel("", self) self.euler = Euler() self.eulerStep = 0 self.eulerPath = [] validator = QIntValidator(0, 10000) self.nodesNumberInput = QLineEdit(self) self.nodesNumberInput.setValidator(validator) self.edgesNumberInput = QLineEdit(self) self.edgesNumberInput.setValidator(validator) self.cursorLabelX.setMinimumSize(150, 25) self.cursorLabelY.setMinimumSize(150, 25) self.nodeNumberLabel.setMinimumSize(150, 25) self.labelsGroup = QVBoxLayout() self.labelsGroup.addWidget(self.cursorLabelX) self.labelsGroup.addWidget(self.cursorLabelY) self.labelsGroup.addWidget(self.nodeNumberLabel) HEIGHT = 50 WIDTH = 50 self.nodeButton.setFixedSize(HEIGHT, WIDTH) self.edgeButton.setFixedSize(HEIGHT, WIDTH) self.addButton.setFixedSize(HEIGHT, WIDTH) self.button.setFixedSize(HEIGHT, WIDTH) self.deleteButton.setFixedSize(HEIGHT, WIDTH) self.printButton.setFixedSize(HEIGHT, WIDTH) self.eulerButton.setFixedSize(HEIGHT, WIDTH) self.generateFullButton.setFixedSize(HEIGHT, WIDTH) self.generateHalfButton.setFixedSize(HEIGHT, WIDTH) self.saveButton.setFixedSize(HEIGHT, WIDTH) self.loadButton.setFixedSize(HEIGHT, WIDTH) self.saveAsButton.setFixedSize(HEIGHT, WIDTH) self.infoButton.setFixedSize(HEIGHT, WIDTH) self.bridgeButton.setFixedSize(HEIGHT, WIDTH) self.nodesNumberInput.setFixedSize(HEIGHT * 2, 28) self.edgesNumberInput.setFixedSize(HEIGHT * 2, 28) self.stepSlider.setFixedSize(HEIGHT * 2, 28) # self.testButton.setFixedSize(HEIGHT, WIDTH) self.disableSlider() self.stepSlider.setOrientation(Qt.Horizontal) horizontal_expanding_spacer1 = QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Minimum) self.fileGroup = QHBoxLayout() self.fileGroup.addWidget(self.fileLabel) self.fileGroup.addWidget(self.fileInput) self.fileGroup.addItem(horizontal_expanding_spacer1) self.actionsButtonGroup = QHBoxLayout() self.actionsButtonGroup.addWidget(self.addButton) self.actionsButtonGroup.addWidget(self.deleteButton) self.actionsButtonGroup.addWidget(self.printButton) self.actionsButtonGroup.addWidget(self.eulerButton) self.actionsButtonGroup.addWidget(self.generateFullButton) self.actionsButtonGroup.addWidget(self.generateHalfButton) self.actionsButtonGroup.addWidget(self.saveButton) self.actionsButtonGroup.addWidget(self.loadButton) self.actionsButtonGroup.addWidget(self.saveAsButton) self.actionsButtonGroup.addWidget(self.infoButton) self.actionsButtonGroup.addWidget(self.bridgeButton) # self.actionsButtonGroup.addWidget(self.testButton) self.actionsButtonGroup.addWidget(self.button) self.topGroup = QVBoxLayout() self.topGroup.addItem(self.fileGroup) self.topGroup.addItem(self.actionsButtonGroup) horizontal_expanding_spacer = QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Minimum) self.actionsButtonGroup.addItem(horizontal_expanding_spacer) self.actionsButtonGroup.addItem(self.labelsGroup) self.modeButtonGroup = QVBoxLayout() self.modeButtonGroup.addWidget(self.nodeButton) self.modeButtonGroup.addWidget(self.edgeButton) self.modeButtonGroup.addWidget(self.nodesInputLabel) self.modeButtonGroup.addWidget(self.nodesNumberInput) self.modeButtonGroup.addWidget(self.edgesInputLabel) self.modeButtonGroup.addWidget(self.edgesNumberInput) self.modeButtonGroup.addWidget(self.stepSlider) vertical_expanding_spacer = QSpacerItem(10, 10, QSizePolicy.Minimum, QSizePolicy.Expanding) self.modeButtonGroup.addItem(vertical_expanding_spacer) self.infoGroup = QVBoxLayout() self.infoGroup.addWidget(self.edgeInfo) self.infoGroup.addWidget(self.nodeInfo) self.infoGroup.addWidget(self.eulerInfo) self.modeButtonGroup.addItem(self.infoGroup) self.button.clicked.connect(QCoreApplication.instance().quit) self.addButton.clicked.connect(self.add) self.deleteButton.clicked.connect(self.delete) self.nodeButton.clicked.connect(self.nodeButtonEvent) self.edgeButton.clicked.connect(self.edgeButtonEvent) self.printButton.clicked.connect(self.printButtonEvent) self.eulerButton.clicked.connect(self.findEulerPath) self.generateFullButton.clicked.connect(self.generateFull) self.generateHalfButton.clicked.connect(self.generateHalf) # self.testButton.clicked.connect(self.scene.changeColor) self.saveAsButton.clicked.connect(self.saveAsFile) self.saveButton.clicked.connect(self.saveFile) self.loadButton.clicked.connect(self.loadFile) self.scene.cursorPositionSignal.connect(self.setLabels) self.scene.nodeNumberSignal.connect(self.setLabelNumber) self.stepSlider.sliderMoved.connect(self.setEulerStep) self.bridgeButton.clicked.connect(self.findBridges) self.infoButton.clicked.connect(self.setInfo) self.view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding) layoutH = QHBoxLayout() layoutH.addWidget(self.view) layoutH.addItem(self.modeButtonGroup) layoutV = QVBoxLayout() layoutV.addItem(self.topGroup) layoutV.addItem(layoutH) self.setLayout(layoutV) self.setWindowTitle("Example") self.scene.setSceneRect(0, 0, 1, 1) self.view.setMouseTracking(True) self.showMaximized() self.graphFile = GraphFile("file.txt") def findBridges(self): bridges = self.euler.find_bridges(self.scene.G) print bridges def generate(self, h_or_f): generator = Generator() nodesNumberStr = self.nodesNumberInput.text() edgesNumberStr = self.edgesNumberInput.text() if nodesNumberStr == "" or edgesNumberStr == "": return nodeNumber = int(nodesNumberStr) edgesNumber = int(edgesNumberStr) G = None if h_or_f == "FULL": G = generator.generate_full_euler_graph(nodeNumber, edgesNumber) elif h_or_f == "HALF": G = generator.generate_half_euler_graph(nodeNumber, edgesNumber) if G is not None: self.scene.clear() self.scene.drawGraph(G) self.setInfo() def setInfo(self): self.edgeInfo.setText("E: " + str(len(self.scene.G.edges()))) self.nodeInfo.setText("N: " + str(len(self.scene.G.nodes()))) info, odds = self.euler.checkGraph(self.scene.G) self.eulerInfo.setText(info) def generateHalf(self): self.generate("HALF") def generateFull(self): self.generate("FULL") def add(self): self.scene.add() self.setInfo() def delete(self): self.scene.delete() self.setInfo() def findEulerPath(self): eulerPath = self.euler.start(self.scene.getGraph()) print eulerPath if eulerPath is not None and len(eulerPath) > 0: self.enableSlider(len(eulerPath)) self.eulerPath = eulerPath def setEulerStep(self, stepNum): self.scene.setColorForAllEdges(QColor.fromRgb(0, 0, 0)) if stepNum > 0: for i in range(stepNum): node1 = self.eulerPath[i] node2 = self.eulerPath[i + 1] self.scene.setColorForEdge(node1, node2, QColor.fromRgb(0, 255, 0)) def resizeEvent(self, event): w = self.view.width() - 10 h = self.view.height() - 10 transform = QTransform.fromScale(w, h) self.view.setTransform(transform) QWidget.resizeEvent(self, event) def enableSlider(self, maximum): self.stepSlider.setEnabled(True) self.stepSlider.setMinimum(0) self.stepSlider.setMaximum(maximum - 1) def disableSlider(self): self.stepSlider.setDisabled(False) def setLabels(self, x, y): self.cursorLabelX.setText("X:" + str(x)) self.cursorLabelY.setText("Y:" + str(y)) def setLabelNumber(self, number): self.nodeNumberLabel.setText("Nr:" + str(number)) def nodeButtonEvent(self): if self.scene.getMode() == "None": self.scene.changeMode("Node") self.nodeButton.setFlat(True) elif self.scene.getMode() == "Node": self.nodeButton.setFlat(False) self.scene.changeMode("None") elif self.scene.getMode() == "Edge": self.edgeButton.setFlat(False) self.scene.changeMode("Node") self.nodeButton.setFlat(True) def edgeButtonEvent(self): if self.scene.getMode() == "None": self.scene.changeMode("Edge") self.edgeButton.setFlat(True) elif self.scene.getMode() == "Edge": self.scene.changeMode("None") self.edgeButton.setFlat(False) elif self.scene.getMode() == "Node": self.scene.changeMode("Edge") self.nodeButton.setFlat(False) self.edgeButton.setFlat(True) def printButtonEvent(self): print self.scene.G.nodes() print self.scene.G.edges() def saveFile(self): if self.graphFile.path != "": self.graphFile.save(self.scene.G, self.scene.getPos()) else: self.saveAsFile() def saveAsFile(self): path = QFileDialog.getSaveFileName(self, "Open Graph", ".", "Text files (*.txt)") self.setFilePath(path) self.graphFile.save(self.scene.G, self.scene.getPos()) def loadFile(self): path = QFileDialog.getOpenFileName(self, "Open Graph", ".", "Text files (*.txt)") self.setFilePath(path) (G, pos, n, n) = self.graphFile.load() self.scene.clear() self.scene.drawGraph(G, pos) self.setInfo() def setFilePath(self, path): self.graphFile.path = path self.fileInput.setText(path)
class PasswordEnter(QDialog): def __init__(self, title = '', parent = None, mode = 1): QDialog.__init__(self, parent) self.prnt = parent self.mode = mode self.tr = self.prnt.tr self.Sound = self.prnt.Parent.sound self.Keyring = self.prnt.Keyring self.title = QLabel(self.tr._translate(title)) self.title.setAlignment(Qt.AlignHCenter) self.passwrd = QLineEdit() self.passwrd.setMaxLength(BLOCK_SIZE) self.passwrd.setPlaceholderText(self.tr._translate("Enter Password")) self.passwrd.setEchoMode(QLineEdit.Password) self.passwrd.setToolTip(self.tr._translate("Enter Password")) if self.mode : self.confirm = QLineEdit() self.confirm.setMaxLength(BLOCK_SIZE) self.confirm.setPlaceholderText(self.tr._translate("Confirm Password")) self.confirm.setEchoMode(QLineEdit.Password) self.confirm.setToolTip(self.tr._translate("Confirm it")) self._layout = QVBoxLayout() self._layout.addWidget(self.title) self._layout.addWidget(self.passwrd) if self.mode : self._layout.addWidget(self.confirm) self.ok = QPushButton(QIcon.fromTheme("dialog-ok"), "", self) self.cancel = QPushButton(QIcon.fromTheme("dialog-cancel"), "", self) self.buttonLayout = QHBoxLayout() self.buttonLayout.addWidget(self.ok) self.buttonLayout.addWidget(self.cancel) self._layout.addItem(self.buttonLayout) self.setLayout(self._layout) if self.mode : self.ok.clicked.connect(self.checkCorrectOfPassword) else : self.ok.clicked.connect(self.returnPassword) self.cancel.clicked.connect(self.clearEnterFields) QTimer.singleShot(100, self.moveToTrayIcon) def moveToTrayIcon(self): self.move(self.prnt.Parent.mapToGlobal(self.prnt.Parent.trayIconMenu.pos())) def checkCorrectOfPassword(self): if self.confirm.text() == self.passwrd.text() and \ not self.confirm.text().isEmpty() : self.Keyring.create_Keyring(self.passwrd.text()) self.Sound.Complete.play() QMessageBox.information(self, \ self.tr._translate("Create Keyring"), \ self.tr._translate("Keyring created."), \ 1) self.clearEnterFields() self.prnt.saveData() self.close() else : self.Sound.Attention.play() QMessageBox.information(self, \ self.tr._translate("Create Keyring"), \ self.tr._translate("Passwords mismatch or empty"), \ 1) self.clearEnterFields() def clearEnterFields(self): self.passwrd.clear() if self.mode : self.confirm.clear() def returnPassword(self): if not self.passwrd.text().isEmpty() : self.prnt.Keyring.password = to_unicode(self.passwrd.text()) self.clearEnterFields() self.close() else : self.Sound.Attention.play() QMessageBox.information(self, \ self.tr._translate("Enter Password"), \ self.tr._translate("Passwords empty"), \ 1) def closeEvent(self, ev): ev.ignore() if not self.prnt.Parent.isVisible() : self.prnt.Parent.show() self.prnt.Parent.autoHide(3) if self.prnt.Parent.isMinimized() : self.prnt.Parent.showNormal() self.done(0)
class MessageStackWidget(QWidget): checkEmpty = pyqtSignal(str) def __init__(self, obj, parent = None): QWidget.__init__(self, parent) self.prnt = obj self.setWindowTitle(self.prnt.tr._translate('M@il Checker : Stack')) self.mutex = QMutex() self.stack = QWidget() self.scroll = QScrollArea() self.scroll.setWidgetResizable(True) self.scroll.setWidget(self.stack) self.scrolledLayout = QVBoxLayout() self.buttonLayout = QHBoxLayout() self.stackLayout = QVBoxLayout() self.stackLayout.setSpacing(3) self.freezAllMSG = QPushButton(QIcon.fromTheme("layer-visible-on"), '') self.freezAllMSG.setToolTip(self.prnt.tr._translate('Freez all messages')) self.freezAllMSG.clicked.connect(self.freezAllMessages) self.clearAllMSG = QPushButton(QIcon.fromTheme("edit-clear"), '') self.clearAllMSG.setToolTip(self.prnt.tr._translate('Clear all messages')) self.clearAllMSG.clicked.connect(self.clearAllMessages) self.buttonLayout.addWidget(self.freezAllMSG) self.buttonLayout.addWidget(self.clearAllMSG) self.scrolledLayout.addItem(self.buttonLayout) self.scrolledLayout.addWidget(self.scroll) self.scrolledLayout.setSpacing(3) self.setLayout(self.scrolledLayout) self.setMinimumHeight(self.prnt.desktop.height()/5) self.setMinimumWidth(self.prnt.desktop.width()/3) self.stack.setStyleSheet("QWidget {background: rgba(235,240,255,0);}") self.MessageStack = {} self.checkEmpty.connect(self.checkStackContent) def newMessage(self, str_, jobID, lifetime = 0): self.MessageStack[jobID] = MessageDialog(str_, jobID, lifetime, self) self.stackLayout.insertWidget(0, self.MessageStack[jobID]) self.stack.setLayout(self.stackLayout) self.setLayout(self.scrolledLayout) if self.prnt.SoundEnabled : self.prnt.sound.NewMessage.play() def freezAllMessages(self): self.mutex.lock() to_Freez = [] for jobID in self.MessageStack.iterkeys() : if not self.MessageStack[jobID].isFrozen() : to_Freez.append(jobID) for jobID in to_Freez : self.MessageStack[jobID].freez(common = True) self.mutex.unlock() if self.prnt.SoundEnabled and len(to_Freez) : self.prnt.sound.Frozen.play() def clearAllMessages(self): self.clearAllMSG.setEnabled(False) self.mutex.lock() to_Delete = [] for jobID in self.MessageStack.iterkeys() : to_Delete.append(jobID) for jobID in to_Delete : self.MessageStack[jobID].rejected(common = True) self.mutex.unlock() self.clearAllMSG.setEnabled(True) if self.prnt.SoundEnabled and len(to_Delete) : self.prnt.sound.Cleared.play() def checkStackContent(self, key = ''): _key = str(key) self.stackLayout.removeWidget(self.MessageStack[_key]) if _key in self.MessageStack.iterkeys() : del self.MessageStack[_key] #print "MessageStack least:", [item for item in self.MessageStack.iterkeys()] count = self.stackLayout.count() if not count : self.close() def _show(self): self.show() def closeEvent(self, ev): ev.ignore() if not self.prnt.isVisible() : self.prnt.show() self.prnt.autoHide(3) if self.prnt.isMinimized() : self.prnt.showNormal() self.hide()
def __init__(self): super(GeneralSection, self).__init__() container = QVBoxLayout(self) # Inicio group_on_start = QGroupBox(self.tr("Al Iniciar:")) box = QVBoxLayout(group_on_start) box.setContentsMargins(20, 5, 20, 5) self.check_splash = QCheckBox(self.tr("Mostrar Splash")) self.check_splash.setChecked( settings.get_setting('general/show-splash')) box.addWidget(self.check_splash) self.check_on_start = QCheckBox(self.tr("Mostrar Página de Inicio")) show_start_page = settings.get_setting('general/show-start-page') self.check_on_start.setChecked(show_start_page) box.addWidget(self.check_on_start) self.check_load_files = QCheckBox(self.tr("Cargar archivos desde la " "última sesión")) load_files = settings.get_setting('general/load-files') self.check_load_files.setChecked(load_files) box.addWidget(self.check_load_files) container.addWidget(group_on_start) # Al salir group_on_exit = QGroupBox(self.tr("Al Salir:")) box = QVBoxLayout(group_on_exit) box.setContentsMargins(20, 5, 20, 5) self.check_on_exit = QCheckBox(self.tr("Confirmar Salida")) self.check_on_exit.setChecked( settings.get_setting('general/confirm-exit')) box.addWidget(self.check_on_exit) self.check_geometry = QCheckBox(self.tr( "Guardar posición y tamaño de la ventana")) self.check_geometry.setChecked( settings.get_setting('window/store-size')) box.addWidget(self.check_geometry) container.addWidget(group_on_exit) # Notificaciones group_notifications = QGroupBox(self.tr("Notificaciones:")) box = QVBoxLayout(group_notifications) box.setContentsMargins(20, 5, 20, 5) self.check_updates = QCheckBox(self.tr("Buscar Actualizaciones")) self.check_updates.setChecked( settings.get_setting('general/check-updates')) box.addWidget(self.check_updates) container.addWidget(group_notifications) # Sistema if settings.IS_LINUX: group_terminal = QGroupBox(self.tr("Sistema:")) box = QHBoxLayout(group_terminal) box.addWidget(QLabel(self.tr("Ejecutar programa con:"))) self.line_terminal = QLineEdit() self.line_terminal.setAlignment(Qt.AlignLeft) self.line_terminal.setFixedWidth(300) self.line_terminal.setText(settings.get_setting('terminal')) box.addWidget(self.line_terminal, 1, Qt.AlignLeft) container.addWidget(group_terminal) # User Interface group_ui = QGroupBox(self.tr("Interfáz de Usuario:")) box = QGridLayout(group_ui) box.setContentsMargins(20, 5, 20, 5) box.addWidget(QLabel(self.tr("Tema:")), 0, 0) self.combo_theme = QComboBox() self.combo_theme.setFixedWidth(200) self._update_combo() index = self.combo_theme.findText( settings.get_setting('window/style-sheet')) self.combo_theme.setCurrentIndex(index) box.addWidget(self.combo_theme, 0, 1) self.combo_lang = QComboBox() self.combo_lang.setFixedWidth(200) box.addWidget(QLabel(self.tr("Idioma:")), 1, 0) box.addWidget(self.combo_lang, 1, 1) langs = os.listdir(os.path.join(paths.PATH, "extras", "i18n")) self.combo_lang.addItems(["Spanish"] + [lang[:-3] for lang in langs]) lang = settings.get_setting('general/language') index = 0 if not lang else self.combo_lang.findText(lang) self.combo_lang.setCurrentIndex(index) container.addWidget(group_ui) box.setAlignment(Qt.AlignLeft) # Reestablecer group_restart = QGroupBox(self.tr("Reestablecer:")) box = QHBoxLayout(group_restart) box.setContentsMargins(20, 5, 20, 5) btn_restart = QPushButton(self.tr("Reiniciar configuraciones")) btn_restart.setObjectName("custom") box.addWidget(btn_restart) box.addStretch(1) container.addWidget(group_restart) container.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) # Conexiones btn_restart.clicked.connect(self._restart_configurations) self.combo_theme.currentIndexChanged[int].connect( self._change_style_sheet) # Install EnvironmentConfiguration.install_widget(self.tr("General"), self)
def __init__(self, parent): super(EditorConfiguration, self).__init__() self._preferences, vbox = parent, QVBoxLayout(self) # groups group1 = QGroupBox(translations.TR_PREFERENCES_EDITOR_CONFIG_INDENT) group2 = QGroupBox(translations.TR_PREFERENCES_EDITOR_CONFIG_MARGIN) group3 = QGroupBox(translations.TR_LINT_DIRTY_TEXT) group4 = QGroupBox(translations.TR_PEP8_DIRTY_TEXT) group5 = QGroupBox(translations.TR_HIGHLIGHTER_EXTRAS) group6 = QGroupBox(translations.TR_TYPING_ASSISTANCE) group7 = QGroupBox(translations.TR_DISPLAY) # groups container container_widget_with_all_preferences = QWidget() formFeatures = QGridLayout(container_widget_with_all_preferences) # Indentation hboxg1 = QHBoxLayout(group1) hboxg1.setContentsMargins(5, 15, 5, 5) self._spin, self._checkUseTabs = QSpinBox(), QComboBox() self._spin.setRange(1, 10) self._spin.setValue(settings.INDENT) hboxg1.addWidget(self._spin) self._checkUseTabs.addItems([ translations.TR_PREFERENCES_EDITOR_CONFIG_SPACES.capitalize(), translations.TR_PREFERENCES_EDITOR_CONFIG_TABS.capitalize() ]) self._checkUseTabs.setCurrentIndex(int(settings.USE_TABS)) hboxg1.addWidget(self._checkUseTabs) formFeatures.addWidget(group1, 0, 0) # Margin Line hboxg2 = QHBoxLayout(group2) hboxg2.setContentsMargins(5, 15, 5, 5) self._checkShowMargin = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MARGIN_LINE) self._checkShowMargin.setChecked(settings.SHOW_MARGIN_LINE) hboxg2.addWidget(self._checkShowMargin) self._spinMargin = QSpinBox() self._spinMargin.setRange(50, 100) self._spinMargin.setSingleStep(2) self._spinMargin.setValue(settings.MARGIN_LINE) hboxg2.addWidget(self._spinMargin) hboxg2.addWidget(QLabel(translations.TR_CHARACTERS)) formFeatures.addWidget(group2, 0, 1) # Display Errors vboxDisplay = QVBoxLayout(group7) vboxDisplay.setContentsMargins(5, 15, 5, 5) self._checkHighlightLine = QComboBox() self._checkHighlightLine.addItems([ translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_USE_BACKGROUND, translations.TR_PREFERENCES_EDITOR_CONFIG_ERROR_USE_UNDERLINE ]) self._checkHighlightLine.setCurrentIndex( int(settings.UNDERLINE_NOT_BACKGROUND)) hboxDisplay1 = QHBoxLayout() hboxDisplay1.addWidget(QLabel(translations.TR_DISPLAY_ERRORS)) hboxDisplay1.addWidget(self._checkHighlightLine) hboxDisplay2 = QHBoxLayout() self._checkDisplayLineNumbers = QCheckBox( translations.TR_DISPLAY_LINE_NUMBERS) self._checkDisplayLineNumbers.setChecked(settings.SHOW_LINE_NUMBERS) hboxDisplay2.addWidget(self._checkDisplayLineNumbers) vboxDisplay.addLayout(hboxDisplay1) vboxDisplay.addLayout(hboxDisplay2) formFeatures.addWidget(group7, 1, 0, 1, 0) # Find Lint Errors (highlighter) vboxg3 = QVBoxLayout(group3) self._checkErrors = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_FIND_ERRORS) self._checkErrors.setChecked(settings.FIND_ERRORS) self.connect(self._checkErrors, SIGNAL("stateChanged(int)"), self._disable_show_errors) self._showErrorsOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_ERRORS) self._showErrorsOnLine.setChecked(settings.ERRORS_HIGHLIGHT_LINE) self.connect(self._showErrorsOnLine, SIGNAL("stateChanged(int)"), self._enable_errors_inline) vboxg3.addWidget(self._checkErrors) vboxg3.addWidget(self._showErrorsOnLine) vboxg3.addItem(QSpacerItem(0, 0, QSizePolicy.Expanding)) formFeatures.addWidget(group3, 2, 0) # Find PEP8 Errors (highlighter) vboxg4 = QHBoxLayout(group4) vboxg4.setContentsMargins(5, 15, 5, 5) vvbox = QVBoxLayout() self._checkStyle = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_PEP8) self._checkStyle.setChecked(settings.CHECK_STYLE) self.connect(self._checkStyle, SIGNAL("stateChanged(int)"), self._disable_check_style) vvbox.addWidget(self._checkStyle) self._checkStyleOnLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TOOLTIP_PEP8) self._checkStyleOnLine.setChecked(settings.CHECK_HIGHLIGHT_LINE) self.connect(self._checkStyleOnLine, SIGNAL("stateChanged(int)"), self._enable_check_inline) vvbox.addWidget(self._checkStyleOnLine) vvbox.addItem( QSpacerItem(0, 0, QSizePolicy.Expanding, QSizePolicy.Expanding)) vboxg4.addLayout(vvbox) # Container for tree widget and buttons widget = QWidget() hhbox = QHBoxLayout(widget) hhbox.setContentsMargins(0, 0, 0, 0) # Tree Widget with custom item delegate # always adds uppercase text self._listIgnoreViolations = QTreeWidget() self._listIgnoreViolations.setObjectName("ignore_pep8") self._listIgnoreViolations.setItemDelegate(ui_tools.CustomDelegate()) self._listIgnoreViolations.setMaximumHeight(80) self._listIgnoreViolations.setHeaderLabel( translations.TR_PREFERENCES_EDITOR_CONFIG_IGNORE_PEP8) for ic in settings.IGNORE_PEP8_LIST: self._listIgnoreViolations.addTopLevelItem(QTreeWidgetItem([ic])) hhbox.addWidget(self._listIgnoreViolations) box = QVBoxLayout() box.setContentsMargins(0, 0, 0, 0) btn_add = QPushButton(QIcon(":img/add_small"), '') btn_add.setMaximumSize(26, 24) btn_add.clicked.connect(self._add_code_pep8) box.addWidget(btn_add) btn_remove = QPushButton(QIcon(":img/delete_small"), '') btn_remove.setMaximumSize(26, 24) btn_remove.clicked.connect(self._remove_code_pep8) box.addWidget(btn_remove) box.addItem(QSpacerItem(0, 0, QSizePolicy.Fixed, QSizePolicy.Expanding)) hhbox.addLayout(box) vboxg4.addWidget(widget) formFeatures.addWidget(group4) # Show Python3 Migration, DocStrings and Spaces (highlighter) vboxg5 = QVBoxLayout(group5) vboxg5.setContentsMargins(5, 15, 5, 5) self._showMigrationTips = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_MIGRATION) self._showMigrationTips.setChecked(settings.SHOW_MIGRATION_TIPS) vboxg5.addWidget(self._showMigrationTips) self._checkForDocstrings = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_CHECK_FOR_DOCSTRINGS) self._checkForDocstrings.setChecked(settings.CHECK_FOR_DOCSTRINGS) vboxg5.addWidget(self._checkForDocstrings) self._checkShowSpaces = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_SHOW_TABS_AND_SPACES) self._checkShowSpaces.setChecked(settings.SHOW_TABS_AND_SPACES) vboxg5.addWidget(self._checkShowSpaces) self._checkIndentationGuide = QCheckBox( translations.TR_SHOW_INDENTATION_GUIDE) self._checkIndentationGuide.setChecked(settings.SHOW_INDENTATION_GUIDE) vboxg5.addWidget(self._checkIndentationGuide) formFeatures.addWidget(group5, 3, 0) # End of line, Stop Scrolling At Last Line, Trailing space, Word wrap vboxg6 = QVBoxLayout(group6) vboxg6.setContentsMargins(5, 15, 5, 5) self._checkEndOfLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_END_OF_LINE) self._checkEndOfLine.setChecked(settings.USE_PLATFORM_END_OF_LINE) vboxg6.addWidget(self._checkEndOfLine) self._checkEndAtLastLine = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_END_AT_LAST_LINE) self._checkEndAtLastLine.setChecked(settings.END_AT_LAST_LINE) vboxg6.addWidget(self._checkEndAtLastLine) self._checkTrailing = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_REMOVE_TRAILING) self._checkTrailing.setChecked(settings.REMOVE_TRAILING_SPACES) vboxg6.addWidget(self._checkTrailing) self._allowWordWrap = QCheckBox( translations.TR_PREFERENCES_EDITOR_CONFIG_WORD_WRAP) self._allowWordWrap.setChecked(settings.ALLOW_WORD_WRAP) vboxg6.addWidget(self._allowWordWrap) formFeatures.addWidget(group6, 3, 1) # pack all the groups vbox.addWidget(container_widget_with_all_preferences) vbox.addItem( QSpacerItem(0, 10, QSizePolicy.Expanding, QSizePolicy.Expanding)) self.connect(self._preferences, SIGNAL("savePreferences()"), self.save)