def addSpinBox(self, name): sb = QSpinBox(self) sb.setEnabled(True) sb.setMinimumSize(QSize(60, 20)) sb.setMaximumSize(QSize(60, 20)) sb.setWrapping(False) sb.setFrame(True) sb.setButtonSymbols(QSpinBox.NoButtons) sb.setAccelerated(True) sb.setCorrectionMode(QSpinBox.CorrectToPreviousValue) sb.setKeyboardTracking(True) sb.setMinimum(0) sb.setMaximum(99999999) sb.setSingleStep(1000) sb.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter) sb.setProperty("value", 0) sb.setObjectName(name) return sb
def addSpinBox(self, name): sb = QSpinBox(self) sb.setEnabled(True) sb.setMinimumSize(QSize(60, 20)) sb.setMaximumSize(QSize(60, 20)) sb.setWrapping(False) sb.setFrame(True) sb.setButtonSymbols(QSpinBox.NoButtons) sb.setAccelerated(True) sb.setCorrectionMode(QSpinBox.CorrectToPreviousValue) sb.setKeyboardTracking(True) sb.setMinimum(0) sb.setMaximum(99999999) sb.setSingleStep(1000) sb.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) sb.setProperty("value", 0) sb.setObjectName(name) return sb
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()))
class Ui_TurnProtectionAndObstacleAssessment(object): def setupUi(self, Form): Form.setObjectName(_fromUtf8("Form")) Form.resize(435, 580) self.verticalLayout = QVBoxLayout(Form) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.gbGeneral = GroupBox(Form) self.gbGeneral.Caption = "General" self.verticalLayout.addWidget(self.gbGeneral) # self.cmbAerodrome = ComboBoxPanel(self.gbGeneral, True) # self.cmbAerodrome.Caption = "Aerodrome" # self.cmbAerodrome.LabelWidth = 120 # self.gbGeneral.Add = self.cmbAerodrome # # self.cmbRwyDir = ComboBoxPanel(self.gbGeneral, True) # self.cmbRwyDir.Caption = "Runway Direction" # self.cmbRwyDir.LabelWidth = 120 # self.cmbRwyDir.Width = 120 # self.gbGeneral.Add = self.cmbRwyDir self.cmbRnavSpecification = ComboBoxPanel(self.gbGeneral) self.cmbRnavSpecification.Caption = "Rnav Specification" self.cmbRnavSpecification.LabelWidth = 150 self.gbGeneral.Add = self.cmbRnavSpecification self.frameChbThree = Frame(self.gbGeneral, "HL") self.gbGeneral.Add = self.frameChbThree self.chbUseTwoWpt = CheckBox(self.frameChbThree) self.chbUseTwoWpt.Caption = "Use 2 Waypoints" self.frameChbThree.Add = self.chbUseTwoWpt self.chbInsertSymbol = CheckBox(self.frameChbThree) self.chbInsertSymbol.Caption = "Insert Symbol(s)" self.frameChbThree.Add = self.chbInsertSymbol self.chbCatH = CheckBox(self.frameChbThree) self.chbCatH.Caption = "Cat.H" self.frameChbThree.Add = self.chbCatH self.cmbPhaseOfFlight = ComboBoxPanel(self.gbGeneral) self.cmbPhaseOfFlight.Caption = "Phase Of Flight" self.cmbPhaseOfFlight.LabelWidth = 150 self.gbGeneral.Add = self.cmbPhaseOfFlight self.pnlArp = PositionPanel(self.gbGeneral) self.pnlArp.Caption = "Aerodrome Reference Point(ARP)" self.pnlArp.btnCalculater.hide() self.pnlArp.hideframe_Altitude() self.gbGeneral.Add = self.pnlArp self.gbWaypoint1 = GroupBox(self.gbGeneral) self.gbWaypoint1.Caption = "Waypoint1" self.gbGeneral.Add = self.gbWaypoint1 self.cmbType1 = ComboBoxPanel(self.gbWaypoint1) self.cmbType1.Caption = "Type" self.cmbType1.LabelWidth = 150 self.gbWaypoint1.Add = self.cmbType1 self.pnlTolerances = RnavTolerancesPanel(self.gbWaypoint1) self.pnlTolerances.set_Att(Distance(0.8, DistanceUnits.NM)) self.pnlTolerances.set_Xtt(Distance(1, DistanceUnits.NM)) self.pnlTolerances.set_Asw(Distance(2, DistanceUnits.NM)) self.gbWaypoint1.Add = self.pnlTolerances self.pnlWaypoint1 = PositionPanel(self.gbWaypoint1) self.pnlWaypoint1.btnCalculater.hide() self.pnlWaypoint1.hideframe_Altitude() self.gbWaypoint1.Add = self.pnlWaypoint1 self.gbWaypoint2 = GroupBox(self.gbGeneral) self.gbWaypoint2.Caption = "Waypoint2" self.gbGeneral.Add = self.gbWaypoint2 self.cmbType2 = ComboBoxPanel(self.gbWaypoint2) self.cmbType2.Caption = "Type" self.cmbType2.LabelWidth = 150 self.gbWaypoint2.Add = self.cmbType2 self.pnlTolerances2 = RnavTolerancesPanel(self.gbWaypoint2) self.pnlTolerances2.set_Att(Distance(0.8, DistanceUnits.NM)) self.pnlTolerances2.set_Xtt(Distance(1, DistanceUnits.NM)) self.pnlTolerances2.set_Asw(Distance(2, DistanceUnits.NM)) self.gbWaypoint2.Add = self.pnlTolerances2 self.pnlWaypoint2 = PositionPanel(self.gbWaypoint2) self.pnlWaypoint2.btnCalculater.hide() self.pnlWaypoint2.hideframe_Altitude() self.gbWaypoint2.Add = self.pnlWaypoint2 self.frmRadioBtns = Frame(self.gbGeneral, "HL") self.gbGeneral.Add = self.frmRadioBtns self.rdnTF = QRadioButton(self.frmRadioBtns) self.rdnTF.setObjectName("rdnTF") self.rdnTF.setText("TF") self.rdnTF.setChecked(True) self.frmRadioBtns.Add = self.rdnTF self.rdnDF = QRadioButton(self.frmRadioBtns) self.rdnDF.setObjectName("rdnDF") self.rdnDF.setText("DF") self.frmRadioBtns.Add = self.rdnDF self.rdnCF = QRadioButton(self.frmRadioBtns) self.rdnCF.setObjectName("rdnCF") self.rdnCF.setText("CF") self.frmRadioBtns.Add = self.rdnCF self.chbCircularArcs = CheckBox(self.gbGeneral) self.chbCircularArcs.Caption = "Use Circular Arcs Method for Turns <= 30" self.gbGeneral.Add = self.chbCircularArcs self.gbParameters = GroupBox(Form) self.gbParameters.Caption = "Parameters" self.verticalLayout.addWidget(self.gbParameters) self.cmbSelectionMode = ComboBoxPanel(self.gbParameters) self.cmbSelectionMode.Caption = "Selection Mode" self.cmbSelectionMode.LabelWidth = 150 self.gbParameters.Add = self.cmbSelectionMode self.pnlInbound = TrackRadialBoxPanel(self.gbParameters) self.pnlInbound.Caption = "In-bound Track" self.pnlInbound.LabelWidth = 150 self.gbParameters.Add = self.pnlInbound self.pnlOutbound = TrackRadialBoxPanel(self.gbParameters) self.pnlOutbound.Caption = "Out-bound Track" self.pnlOutbound.LabelWidth = 150 self.gbParameters.Add = self.pnlOutbound # icon = QIcon() # icon.addPixmap(QPixmap(_fromUtf8("Resource/coordinate_capture.png")), QIcon.Normal, QIcon.Off) self.pnlIas = SpeedBoxPanel(self.gbParameters) self.pnlIas.Caption = "IAS" self.pnlIas.LabelWidth = 150 self.pnlIas.Value = Speed(250) self.gbParameters.Add = self.pnlIas self.pnlTas = SpeedBoxPanel(self.gbParameters) self.pnlTas.Caption = "TAS" self.pnlTas.Enabled = False self.pnlTas.LabelWidth = 150 self.gbParameters.Add = self.pnlTas self.pnlAltitude = AltitudeBoxPanel(self.gbParameters) self.pnlAltitude.Caption = "Altitude" self.pnlAltitude.LabelWidth = 150 self.pnlAltitude.Value = Altitude(1000) self.gbParameters.Add = self.pnlAltitude self.pnlIsa = NumberBoxPanel(self.gbParameters, "0.0") self.pnlIsa.CaptionUnits = define._degreeStr + "C" self.pnlIsa.Caption = "ISA" self.pnlIsa.LabelWidth = 150 self.pnlIsa.Value = 15 self.gbParameters.Add = self.pnlIsa self.pnlBankAngle = NumberBoxPanel(self.gbParameters, "0.0") self.pnlBankAngle.CaptionUnits = define._degreeStr self.pnlBankAngle.Caption = "Bank Angle" self.pnlBankAngle.LabelWidth = 150 self.pnlBankAngle.Value = 25 self.gbParameters.Add = self.pnlBankAngle self.pnlBankEstTime = NumberBoxPanel(self.gbParameters, "0.0") self.pnlBankEstTime.Caption = "Bank Establishment Time" self.pnlBankEstTime.Value = 1 self.pnlBankEstTime.LabelWidth = 150 self.pnlBankEstTime.Value = 5 self.gbParameters.Add = self.pnlBankEstTime self.pnlPilotTime = NumberBoxPanel(self.gbParameters, "0.0") self.pnlPilotTime.Caption = "Pilot Reaction Time" self.pnlPilotTime.Value = 6 self.pnlPilotTime.LabelWidth = 150 self.gbParameters.Add = self.pnlPilotTime self.pnlWind = WindPanel(self.gbParameters) self.pnlWind.LabelWidth = 145 self.gbParameters.Add = self.pnlWind self.pnlPrimaryMoc = AltitudeBoxPanel(self.gbParameters) self.pnlPrimaryMoc.Caption = "Primary Moc" self.pnlPrimaryMoc.LabelWidth = 150 self.gbParameters.Add = self.pnlPrimaryMoc self.cmbConstructionType = ComboBoxPanel(self.gbParameters) self.cmbConstructionType.Caption = "Construction Type" self.cmbConstructionType.LabelWidth = 150 self.gbParameters.Add = self.cmbConstructionType self.frameMOCmultipiler = Frame(self.gbParameters, "HL") self.gbParameters.Add = self.frameMOCmultipiler self.labelMOCmultipiler = QLabel(self.frameMOCmultipiler) self.labelMOCmultipiler.setMinimumSize(QSize(145, 0)) self.labelMOCmultipiler.setMaximumSize(QSize(145, 16777215)) font = QFont() font.setBold(False) font.setWeight(50) self.labelMOCmultipiler.setFont(font) self.labelMOCmultipiler.setObjectName(_fromUtf8("labelMOCmultipiler")) self.labelMOCmultipiler.setText("MOCmultipiler") self.frameMOCmultipiler.Add = self.labelMOCmultipiler self.mocSpinBox = QSpinBox(self.frameMOCmultipiler) sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.mocSpinBox.sizePolicy().hasHeightForWidth()) self.mocSpinBox.setSizePolicy(sizePolicy) self.mocSpinBox.setMinimumSize(QSize(70, 0)) self.mocSpinBox.setMaximumSize(QSize(70, 16777215)) self.mocSpinBox.setMinimum(1) self.mocSpinBox.setObjectName(_fromUtf8("mocSpinBox")) self.frameMOCmultipiler.Add = self.mocSpinBox spacerItem = QSpacerItem(10,10,QSizePolicy.Expanding, QSizePolicy.Minimum) self.frameMOCmultipiler.layoutBoxPanel.addItem(spacerItem) self.chbDrawTolerance = CheckBox(self.gbParameters) self.chbDrawTolerance.Caption = "Draw Waypoint Tolerance" self.gbParameters.Add = self.chbDrawTolerance
class NumberBoxPanel(QWidget): def __init__(self, parent, resoution = "0.0000"): QWidget.__init__(self, parent) while not isinstance(parent, QDialog): parent = parent.parent() self.setObjectName("NumberBoxPanel" + str(len(parent.findChildren(NumberBoxPanel)))) self.hLayoutBoxPanel = QHBoxLayout(self) self.hLayoutBoxPanel.setSpacing(0) self.hLayoutBoxPanel.setContentsMargins(0,0,0,0) self.hLayoutBoxPanel.setObjectName(("hLayoutBoxPanel")) self.frameBoxPanel = QFrame(self) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.frameBoxPanel.sizePolicy().hasHeightForWidth()) self.frameBoxPanel.setSizePolicy(sizePolicy) self.frameBoxPanel.setFrameShape(QFrame.NoFrame) self.frameBoxPanel.setFrameShadow(QFrame.Raised) self.frameBoxPanel.setObjectName(("frameBoxPanel")) self.hLayoutframeBoxPanel = QHBoxLayout(self.frameBoxPanel) self.hLayoutframeBoxPanel.setSpacing(0) self.hLayoutframeBoxPanel.setMargin(0) self.hLayoutframeBoxPanel.setObjectName(("hLayoutframeBoxPanel")) self.captionLabel = QLabel(self.frameBoxPanel) sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.captionLabel.sizePolicy().hasHeightForWidth()) self.captionLabel.setSizePolicy(sizePolicy) self.captionLabel.setMinimumSize(QSize(200, 0)) self.captionLabel.setMaximumSize(QSize(200, 16777215)) font = QFont() font.setBold(False) font.setWeight(50) self.captionLabel.setFont(font) self.captionLabel.setObjectName(("captionLabel")) self.hLayoutframeBoxPanel.addWidget(self.captionLabel) if resoution != None: self.numberBox = QLineEdit(self.frameBoxPanel) self.numberBox.setEnabled(True) font = QFont() font.setBold(False) font.setWeight(50) self.numberBox.setFont(font) self.numberBox.setObjectName(self.objectName() + "_numberBox") self.numberBox.setText("0.0") self.numberBox.setMinimumWidth(70) self.numberBox.setMaximumWidth(70) self.hLayoutframeBoxPanel.addWidget(self.numberBox) self.numberBox.textChanged.connect(self.numberBoxChanged) self.numberBox.editingFinished.connect(self.numberBoxEditingFinished) else: self.numberBox = QSpinBox(self.frameBoxPanel) self.numberBox.setObjectName(self.objectName() + "_numberBox") self.numberBox.setMinimumWidth(70) self.numberBox.setMaximumWidth(70) self.numberBox.setMinimum(-100000000) self.numberBox.setMaximum(100000000) self.numberBox.setValue(1) self.hLayoutframeBoxPanel.addWidget(self.numberBox) self.imageButton = QPushButton(self.frameBoxPanel) self.imageButton.setText(("")) icon = QIcon() icon.addPixmap(QPixmap(("Resource/convex_hull.png")), QIcon.Normal, QIcon.Off) self.imageButton.setIcon(icon) self.imageButton.setObjectName(("imageButton")) self.imageButton.setVisible(False) self.hLayoutframeBoxPanel.addWidget(self.imageButton) self.hLayoutBoxPanel.addWidget(self.frameBoxPanel) spacerItem = QSpacerItem(10,10,QSizePolicy.Expanding, QSizePolicy.Minimum) self.hLayoutBoxPanel.addItem(spacerItem) self.imageButton.clicked.connect(self.imageButtonClicked) self.numberResolution = resoution str0 = String.Number2String(6.6788, "0.0000") self.Value = 0 self.captionUnits = "" def imageButtonClicked(self): self.emit(SIGNAL("Event_1"), self) def method_6(self, string_0): return "%s%s\t%f %s"%(string_0, self.Caption, self.Value, self.CaptionUnits); def numberBoxEditingFinished(self): self.emit(SIGNAL("editingFinished"), self) def numberBoxChanged(self): try: test = float(self.numberBox.text()) self.emit(SIGNAL("Event_0"), self) except: if self.numberBox.text() == "" or self.numberBox.text() == "-" or self.numberBox.text() == "+": return str0 = "You must input the float type in \"%s\"."%(self.Caption) QMessageBox.warning(self, "Warning" , str0) self.numberBox.setText("0.0") def get_CaptionUnits(self): return self.captionUnits def set_CaptionUnits(self, captionUnits): self.captionUnits = captionUnits CaptionUnits = property(get_CaptionUnits, set_CaptionUnits, None, None) def get_Caption(self): caption = self.captionLabel.text() findIndex = caption.indexOf("(") if findIndex > 0: val = caption.left(findIndex) return val return caption def set_Caption(self, captionStr): if self.CaptionUnits != "" and self.CaptionUnits != None: self.captionLabel.setText(QString(captionStr + "(") + self.CaptionUnits + QString("):")) else: self.captionLabel.setText(captionStr + ":") Caption = property(get_Caption, set_Caption, None, None) def get_Visible(self): return self.isVisible() def set_Visible(self, bool): self.setVisible(bool) Visible = property(get_Visible, set_Visible, None, None) def get_Value(self): try: if self.numberResolution != None: return float(self.numberBox.text()) else: return self.numberBox.value() except: return 0.0 def set_Value(self, valueFloat): if self.numberResolution != None: if valueFloat == None or valueFloat == "": rStr = String.Number2String(0, self.numberResolution) self.numberBox.setText(rStr) return try: test = float(valueFloat) rStr = String.Number2String(test, self.numberResolution) self.numberBox.setText(rStr) except: str0 = "You must put the float type in \"%s\"."%(self.Caption) QMessageBox.warning(self, "Warning" , str0) rStr = String.Number2String(0, self.numberResolution) self.numberBox.setText(rStr) else: try: test = int(valueFloat) self.numberBox.setValue(test) except: str0 = "You must put the float type in \"%s\"."%(self.Caption) QMessageBox.warning(self, "Warning" , str0) self.numberBox.setValue(0) Value = property(get_Value, set_Value, None, None) # def get_IsEmpty(self): # return self.numberBox.text() == "" or self.numberBox.text() == None # IsEmpty = property(get_IsEmpty, None, None, None) def get_ReadOnly(self): return self.numberBox.isReadOnly() def set_ReadOnly(self, bool): self.numberBox.setReadOnly(bool) ReadOnly = property(get_ReadOnly, set_ReadOnly, None, None) def set_LabelWidth(self, width): self.captionLabel.setMinimumSize(QSize(width, 0)) self.captionLabel.setMaximumSize(QSize(width, 16777215)) LabelWidth = property(None, set_LabelWidth, None, None) def set_Width(self, width): self.numberBox.setMinimumSize(QSize(width, 0)) self.numberBox.setMaximumSize(QSize(width, 16777215)) Width = property(None, set_Width, None, None) def get_Enabled(self): return self.isEnabled() def set_Enabled(self, bool): self.setEnabled(bool) Enabled = property(get_Enabled, set_Enabled, None, None) def set_Button(self, imageName): if imageName == None or imageName == "": self.imageButton.setVisible(False) return icon = QIcon() icon.addPixmap(QPixmap(("Resource/" + imageName)), QIcon.Normal, QIcon.Off) self.imageButton.setIcon(icon) self.imageButton.setVisible(True) Button = property(None, set_Button, None, None)