def buildPostProcessorForm(self, theParams): """Build Post Processor Tab Args: * theParams - dictionary containing element of form Returns: not applicable """ # create postprocessors tab myTab = QWidget() myFormLayout = QFormLayout(myTab) myFormLayout.setLabelAlignment(Qt.AlignLeft) self.tabWidget.addTab(myTab, self.tr('Postprocessors')) self.tabWidget.tabBar().setVisible(True) # create element for the tab myValues = {} for myLabel, myOptions in theParams.items(): myInputValues = {} # NOTE (gigih) : 'params' is assumed as dictionary if 'params' in myOptions: myGroupBox = QGroupBox() myGroupBox.setCheckable(True) myGroupBox.setTitle(get_postprocessor_human_name(myLabel)) # NOTE (gigih): is 'on' always exist?? myGroupBox.setChecked(myOptions.get('on')) myInputValues['on'] = self.bind(myGroupBox, 'checked', bool) myLayout = QFormLayout(myGroupBox) myGroupBox.setLayout(myLayout) # create widget element from 'params' myInputValues['params'] = {} for myKey, myValue in myOptions['params'].items(): myHumanName = get_postprocessor_human_name(myKey) myInputValues['params'][myKey] = self.buildWidget( myLayout, myHumanName, myValue) myFormLayout.addRow(myGroupBox, None) elif 'on' in myOptions: myCheckBox = QCheckBox() myCheckBox.setText(get_postprocessor_human_name(myLabel)) myCheckBox.setChecked(myOptions['on']) myInputValues['on'] = self.bind(myCheckBox, 'checked', bool) myFormLayout.addRow(myCheckBox, None) else: raise NotImplementedError('This case is not handled for now') myValues[myLabel] = myInputValues self.values['postprocessors'] = myValues
def build_post_processor_form(self, parameters): """Build Post Processor Tab. :param parameters: A Dictionary containing element of form :type parameters: dict """ # create postprocessors tab tab = QWidget() form_layout = QFormLayout(tab) form_layout.setLabelAlignment(Qt.AlignLeft) self.tabWidget.addTab(tab, self.tr('Postprocessors')) self.tabWidget.tabBar().setVisible(True) # create element for the tab values = OrderedDict() for label, options in parameters.items(): input_values = OrderedDict() # NOTE (gigih) : 'params' is assumed as dictionary if 'params' in options: group_box = QGroupBox() group_box.setCheckable(True) group_box.setTitle(get_postprocessor_human_name(label)) # NOTE (gigih): is 'on' always exist?? # (MB) should always be there group_box.setChecked(options.get('on')) input_values['on'] = self.bind(group_box, 'checked', bool) layout = QFormLayout(group_box) group_box.setLayout(layout) # create widget element from 'params' input_values['params'] = OrderedDict() for key, value in options['params'].items(): input_values['params'][key] = self.build_widget( layout, key, value) form_layout.addRow(group_box, None) elif 'on' in options: checkbox = QCheckBox() checkbox.setText(get_postprocessor_human_name(label)) checkbox.setChecked(options['on']) input_values['on'] = self.bind(checkbox, 'checked', bool) form_layout.addRow(checkbox, None) else: raise NotImplementedError('This case is not handled for now') values[label] = input_values self.values['postprocessors'] = values
def buildPostProcessorForm(self, theParams): """Build Post Processor Tab :param theParams: A Dictionary containing element of form """ # create postprocessors tab myTab = QWidget() myFormLayout = QFormLayout(myTab) myFormLayout.setLabelAlignment(Qt.AlignLeft) self.tabWidget.addTab(myTab, self.tr('Postprocessors')) self.tabWidget.tabBar().setVisible(True) # create element for the tab myValues = OrderedDict() for myLabel, myOptions in theParams.items(): myInputValues = OrderedDict() # NOTE (gigih) : 'params' is assumed as dictionary if 'params' in myOptions: myGroupBox = QGroupBox() myGroupBox.setCheckable(True) myGroupBox.setTitle(get_postprocessor_human_name(myLabel)) # NOTE (gigih): is 'on' always exist?? myGroupBox.setChecked(myOptions.get('on')) myInputValues['on'] = self.bind(myGroupBox, 'checked', bool) myLayout = QFormLayout(myGroupBox) myGroupBox.setLayout(myLayout) # create widget element from 'params' myInputValues['params'] = OrderedDict() for myKey, myValue in myOptions['params'].items(): myInputValues['params'][myKey] = self.buildWidget( myLayout, myKey, myValue) myFormLayout.addRow(myGroupBox, None) elif 'on' in myOptions: myCheckBox = QCheckBox() myCheckBox.setText(get_postprocessor_human_name(myLabel)) myCheckBox.setChecked(myOptions['on']) myInputValues['on'] = self.bind(myCheckBox, 'checked', bool) myFormLayout.addRow(myCheckBox, None) else: raise NotImplementedError('This case is not handled for now') myValues[myLabel] = myInputValues self.values['postprocessors'] = myValues
def create_layout(self): # select directory containing images # configure the skip-frames # cancel or create project self.project_name_ = QLineEdit() self.filefield_ = QFileField(msg="Select Image Directory...", select_dir=True) self.skip_ = QSpinBox() self.skip_.setRange(0,50) self.skip_.setValue(5) layout = QFormLayout(self) layout.setLabelAlignment(Qt.AlignVCenter) layout.addRow("Project Name:", self.project_name_) layout.addRow("Image Directory:", self.filefield_) layout.addRow("Skip images:", self.skip_) dbb = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) dbb.accepted.connect(self.on_accept) dbb.rejected.connect(self.on_reject) layout.addRow(dbb) self.setLayout(layout)
def buildMinimumNeedsForm(self, theParams): """Build minimum needs tab :param theParams: A Dictionary containing element of form """ # create minimum needs tab myTab = QWidget() myFormLayout = QFormLayout(myTab) myFormLayout.setLabelAlignment(Qt.AlignLeft) self.tabWidget.addTab(myTab, self.tr('Minimum Needs')) self.tabWidget.tabBar().setVisible(True) myWidget = QWidget() myLayout = QFormLayout(myWidget) myWidget.setLayout(myLayout) myValues = OrderedDict() for myLabel, myValue in theParams.items(): myValues[myLabel] = self.buildWidget(myLayout, myLabel, myValue) myFormLayout.addRow(myWidget, None) self.values['minimum needs'] = myValues
def buildMinimumNeedsForm(self, theParams): """Build minimum needs tab :param theParams: A Dictionary containing element of form """ # create minimum needs tab myTab = QWidget() myFormLayout = QFormLayout(myTab) myFormLayout.setLabelAlignment(Qt.AlignLeft) self.tabWidget.addTab(myTab, self.tr('Minimum Needs')) self.tabWidget.tabBar().setVisible(True) myWidget = QWidget() myLayout = QFormLayout(myWidget) myWidget.setLayout(myLayout) myValues = OrderedDict() for myLabel, myValue in theParams.items(): myValues[myLabel] = self.buildWidget( myLayout, myLabel, myValue) myFormLayout.addRow(myWidget, None) self.values['minimum needs'] = myValues
def build_minimum_needs_form(self, parameters): """Build minimum needs tab. :param parameters: A Dictionary containing element of form """ # create minimum needs tab tab = QWidget() form_layout = QFormLayout(tab) form_layout.setLabelAlignment(Qt.AlignLeft) self.tabWidget.addTab(tab, self.tr('Minimum Needs')) self.tabWidget.tabBar().setVisible(True) widget = QWidget() layout = QFormLayout(widget) widget.setLayout(layout) values = OrderedDict() for myLabel, value in parameters.items(): values[myLabel] = self.build_widget( layout, myLabel, value) form_layout.addRow(widget, None) self.values['minimum needs'] = values
def mkHostBox(self): box = QGroupBox(tr("Hostname and domain configuration")) form = QFormLayout(box) form.setLabelAlignment(Qt.AlignLeft) self.hostname = QLabel() self.edit_hostname = EditButton(flat=False) self.connect(self.edit_hostname, SIGNAL('clicked()'), self._edit_hostname) form.addRow(self.hostname, self.edit_hostname) self.domain = QLabel() self.edit_domain = EditButton(flat=False) self.connect(self.edit_domain, SIGNAL('clicked()'), self._edit_domain) form.addRow(self.domain, self.edit_domain) self.qhostnamecfg.registerCallbacks( lambda: True, self.updateHostname) self.qresolvcfg.registerCallbacks( lambda: True, self.updateDomain) return box
class RegSubmitDialog(QDialog): def __init__(self, parent, reg): flags = Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowSystemMenuHint QDialog.__init__(self, parent, flags) self._setupUi() self.reg = reg self.submitButton.clicked.connect(self.submitClicked) self.contributeButton.clicked.connect(self.contributeClicked) self.cancelButton.clicked.connect(self.reject) def _setupUi(self): self.setWindowTitle(tr("Enter your registration key")) self.resize(365, 126) self.verticalLayout = QVBoxLayout(self) self.promptLabel = QLabel(self) appname = str(QCoreApplication.instance().applicationName()) prompt = tr("Type the key you received when you contributed to $appname, as well as the " "e-mail used as a reference for the purchase.").replace('$appname', appname) self.promptLabel.setText(prompt) self.promptLabel.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) self.promptLabel.setWordWrap(True) self.verticalLayout.addWidget(self.promptLabel) self.formLayout = QFormLayout() self.formLayout.setSizeConstraint(QLayout.SetNoConstraint) self.formLayout.setFieldGrowthPolicy(QFormLayout.ExpandingFieldsGrow) self.formLayout.setLabelAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter) self.formLayout.setFormAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignTop) self.label2 = QLabel(self) self.label2.setText(tr("Registration key:")) self.formLayout.setWidget(0, QFormLayout.LabelRole, self.label2) self.label3 = QLabel(self) self.label3.setText(tr("Registered e-mail:")) self.formLayout.setWidget(1, QFormLayout.LabelRole, self.label3) self.codeEdit = QLineEdit(self) self.formLayout.setWidget(0, QFormLayout.FieldRole, self.codeEdit) self.emailEdit = QLineEdit(self) self.formLayout.setWidget(1, QFormLayout.FieldRole, self.emailEdit) self.verticalLayout.addLayout(self.formLayout) self.horizontalLayout = QHBoxLayout() self.contributeButton = QPushButton(self) self.contributeButton.setText(tr("Contribute")) self.contributeButton.setAutoDefault(False) self.horizontalLayout.addWidget(self.contributeButton) spacerItem = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) self.horizontalLayout.addItem(spacerItem) self.cancelButton = QPushButton(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.cancelButton.sizePolicy().hasHeightForWidth()) self.cancelButton.setSizePolicy(sizePolicy) self.cancelButton.setText(tr("Cancel")) self.cancelButton.setAutoDefault(False) self.horizontalLayout.addWidget(self.cancelButton) self.submitButton = QPushButton(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.submitButton.sizePolicy().hasHeightForWidth()) self.submitButton.setSizePolicy(sizePolicy) self.submitButton.setText(tr("Submit")) self.submitButton.setAutoDefault(False) self.submitButton.setDefault(True) self.horizontalLayout.addWidget(self.submitButton) self.verticalLayout.addLayout(self.horizontalLayout) #--- Events def contributeClicked(self): self.reg.app.contribute() def submitClicked(self): code = self.codeEdit.text() email = self.emailEdit.text() if self.reg.app.set_registration(code, email, False): self.accept()