def test_calc_selected_dont_overwrite_dont_skip_nulls( self, mock_selected_obsids, mock_messagebar, mock_skippopup): mock_selected_obsids.return_value = [u'rb1', u'rb2'] db_utils.sql_alter_db( u'''INSERT INTO obs_points (obsid, h_toc) VALUES ('rb1', 1)''') db_utils.sql_alter_db( u'''INSERT into w_levels (obsid, meas, date_time) VALUES ('rb1', 222, '2005-01-01 00:00:00')''' ) db_utils.sql_alter_db( u'''INSERT INTO obs_points (obsid, h_toc) VALUES ('rb2', NULL)''') db_utils.sql_alter_db( u'''INSERT into w_levels (obsid, meas, date_time) VALUES ('rb2', 444, '2005-01-01 00:00:00')''' ) db_utils.sql_alter_db( u'''INSERT into w_levels (obsid, meas, level_masl, date_time) VALUES ('rb2', 555, 667, '2005-01-02 00:00:00')''' ) self.calclvl.FromDateTime = QtGui.QDateTimeEdit() self.calclvl.FromDateTime.setDateTime( datestring_to_date(u'2000-01-01 00:00:00')) self.calclvl.ToDateTime = QtGui.QDateTimeEdit() self.calclvl.ToDateTime.setDateTime( datestring_to_date(u'2010-01-01 00:00:00')) self.calclvl.checkBox_overwrite_prev.setChecked(False) self.calclvl.calcselected() #self.checkBox_skipnulls test_string = utils_for_tests.create_test_string( db_utils.sql_load_fr_db( u'SELECT obsid, date_time, meas, h_toc, level_masl FROM w_levels ORDER BY obsid, date_time' )) reference_string = u'(True, [(rb1, 2005-01-01 00:00:00, 222.0, None, None), (rb2, 2005-01-01 00:00:00, 444.0, None, None), (rb2, 2005-01-02 00:00:00, 555.0, None, 667.0)])' print(str(mock_messagebar.mock_calls)) print(test_string) assert test_string == reference_string
def setupUi(self, calibrationClockDialog): calibrationClockDialog.setObjectName( _fromUtf8("calibrationClockDialog")) calibrationClockDialog.resize(400, 300) self.actualTime = QtGui.QDateTimeEdit(calibrationClockDialog) self.actualTime.setGeometry(QtCore.QRect(140, 110, 194, 22)) self.actualTime.setMaximumTime(QtCore.QTime(23, 59, 59)) self.actualTime.setCurrentSection(QtGui.QDateTimeEdit.YearSection) self.actualTime.setObjectName(_fromUtf8("actualTime")) self.setTimerButton = QtGui.QPushButton(calibrationClockDialog) self.setTimerButton.setGeometry(QtCore.QRect(150, 190, 75, 23)) self.setTimerButton.setObjectName(_fromUtf8("setTimerButton")) self.cancelTimerButton = QtGui.QPushButton(calibrationClockDialog) self.cancelTimerButton.setGeometry(QtCore.QRect(240, 190, 75, 23)) self.cancelTimerButton.setObjectName(_fromUtf8("cancelTimerButton")) self.label = QtGui.QLabel(calibrationClockDialog) self.label.setGeometry(QtCore.QRect(60, 110, 71, 20)) self.label.setObjectName(_fromUtf8("label")) self.downSiteTime = QtGui.QDateTimeEdit(calibrationClockDialog) self.downSiteTime.setGeometry(QtCore.QRect(140, 60, 194, 22)) self.downSiteTime.setObjectName(_fromUtf8("downSiteTime")) self.label_2 = QtGui.QLabel(calibrationClockDialog) self.label_2.setGeometry(QtCore.QRect(60, 60, 81, 16)) self.label_2.setObjectName(_fromUtf8("label_2")) self.retranslateUi(calibrationClockDialog) QtCore.QObject.connect(self.cancelTimerButton, QtCore.SIGNAL(_fromUtf8("clicked()")), calibrationClockDialog.close) QtCore.QMetaObject.connectSlotsByName(calibrationClockDialog)
def test_calc_selected(self, mock_selected_obsids): mock_selected_obsids.return_value = [u'rb1'] db_utils.sql_alter_db( u'''INSERT INTO obs_points (obsid, h_toc) VALUES ('rb1', 1)''') db_utils.sql_alter_db( u'''INSERT into w_levels (obsid, meas, date_time) VALUES ('rb1', 222, '2005-01-01 00:00:00')''' ) db_utils.sql_alter_db( u'''INSERT INTO obs_points (obsid, h_toc) VALUES ('rb2', 4)''') db_utils.sql_alter_db( u'''INSERT into w_levels (obsid, meas, date_time) VALUES ('rb2', 444, '2005-01-01 00:00:00')''' ) self.calclvl.FromDateTime = QtGui.QDateTimeEdit() self.calclvl.FromDateTime.setDateTime( datestring_to_date(u'2000-01-01 00:00:00')) self.calclvl.ToDateTime = QtGui.QDateTimeEdit() self.calclvl.ToDateTime.setDateTime( datestring_to_date(u'2010-01-01 00:00:00')) self.calclvl.calcselected() test_string = utils_for_tests.create_test_string( db_utils.sql_load_fr_db( u'SELECT obsid, date_time, meas, h_toc, level_masl FROM w_levels ORDER BY obsid' )) reference_string = u'(True, [(rb1, 2005-01-01 00:00:00, 222.0, 1.0, -221.0), (rb2, 2005-01-01 00:00:00, 444.0, None, None)])' assert test_string == reference_string
def initDownloaderParams(self): layoutDownloadParams = QtGui.QVBoxLayout(self) layoutAddNewSymbol = QtGui.QHBoxLayout(self) labelNewToDownload = QtGui.QLabel(self.tr('New symbol to download:')) self.editSymbolToAdd = QtGui.QLineEdit() addNewSymbol = QtGui.QPushButton(self.tr('Add')) layoutAddNewSymbol.addWidget(labelNewToDownload) layoutAddNewSymbol.addWidget(self.editSymbolToAdd) layoutAddNewSymbol.addWidget(addNewSymbol) self.connect(addNewSymbol,QtCore.SIGNAL("clicked()"),self.slotAddNewSymbol) layoutParameters = QtGui.QGridLayout(self) lablePeriod = QtGui.QLabel(self.tr("Period:")) periodComboBox=QtGui.QComboBox() self.periodComboBox = periodComboBox periodComboBox.insertItem(0,self.tr("D")) periodComboBox.insertItem(1,self.tr("min")) lableTimeStart = QtGui.QLabel(self.tr("Time start:")) timeStart = QtGui.QCalendarWidget() timeStart=QtGui.QDateTimeEdit() self.timeStartTimeEdit = timeStart timeStart.setDateTime(QtCore.QDateTime.fromString('2010-01-01 02:00:00','yyyy-MM-dd hh:mm:ss')) timeStart.setDisplayFormat("yyyy-MM-dd hh:mm:ss") timeStart.setCalendarPopup(True) lableTimeEnd = QtGui.QLabel(self.tr("Time end")) timeEnd=QtGui.QDateTimeEdit() self.timeEndTimeEdit = timeEnd timeEnd.setDateTime(QtCore.QDateTime.currentDateTime()) timeEnd.setDisplayFormat("yyyy-MM-dd hh:mm:ss") timeEnd.setCalendarPopup(True) layoutParameters.addWidget(lablePeriod,1,0) layoutParameters.addWidget(periodComboBox,1,1) layoutParameters.addWidget(lableTimeStart,2,0) layoutParameters.addWidget(timeStart,2,1) layoutParameters.addWidget(lableTimeEnd,3,0) layoutParameters.addWidget(timeEnd,3,1) DownloadOneButton=QtGui.QPushButton(self.tr("DownloadSelected")) DownloadAllButton=QtGui.QPushButton(self.tr("DownloadAll")) self.connect(DownloadOneButton,QtCore.SIGNAL("clicked()"),self.slotDownloadSelected) self.connect(DownloadAllButton,QtCore.SIGNAL("clicked()"),self.slotDownloadAll) layoutDownloadParams.addLayout(layoutParameters) layoutDownloadParams.addLayout(layoutAddNewSymbol) layoutDownloadParams.addWidget(DownloadOneButton) layoutDownloadParams.addWidget(DownloadAllButton) return layoutDownloadParams
def setupUi(self, PhoneRecipieDialog): PhoneRecipieDialog.setObjectName(_fromUtf8("PhoneRecipieDialog")) PhoneRecipieDialog.resize(361, 214) self.verticalLayout = QtGui.QVBoxLayout(PhoneRecipieDialog) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.searchLineEditLayout = QtGui.QHBoxLayout() self.searchLineEditLayout.setObjectName( _fromUtf8("searchLineEditLayout")) self.label = QtGui.QLabel(PhoneRecipieDialog) self.label.setObjectName(_fromUtf8("label")) self.searchLineEditLayout.addWidget(self.label) self.verticalLayout.addLayout(self.searchLineEditLayout) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout")) self.madetextLabel = QtGui.QLabel(PhoneRecipieDialog) self.madetextLabel.setMaximumSize(QtCore.QSize(80, 16777215)) self.madetextLabel.setObjectName(_fromUtf8("madetextLabel")) self.horizontalLayout.addWidget(self.madetextLabel) self.madeTimeEdit = QtGui.QDateTimeEdit(PhoneRecipieDialog) self.madeTimeEdit.setCalendarPopup(True) self.madeTimeEdit.setObjectName(_fromUtf8("madeTimeEdit")) self.horizontalLayout.addWidget(self.madeTimeEdit) self.verticalLayout.addLayout(self.horizontalLayout) self.horizontalLayout_2 = QtGui.QHBoxLayout() self.horizontalLayout_2.setObjectName(_fromUtf8("horizontalLayout_2")) self.label_3 = QtGui.QLabel(PhoneRecipieDialog) self.label_3.setMaximumSize(QtCore.QSize(80, 16777215)) self.label_3.setObjectName(_fromUtf8("label_3")) self.horizontalLayout_2.addWidget(self.label_3) self.dateTimeEdit = QtGui.QDateTimeEdit(PhoneRecipieDialog) self.dateTimeEdit.setCalendarPopup(True) self.dateTimeEdit.setObjectName(_fromUtf8("dateTimeEdit")) self.horizontalLayout_2.addWidget(self.dateTimeEdit) self.nowButton = QtGui.QPushButton(PhoneRecipieDialog) self.nowButton.setMaximumSize(QtCore.QSize(50, 16777215)) self.nowButton.setObjectName(_fromUtf8("nowButton")) self.horizontalLayout_2.addWidget(self.nowButton) self.verticalLayout.addLayout(self.horizontalLayout_2) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem) self.horizontalLayout_3 = QtGui.QHBoxLayout() self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3")) spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spacerItem1) self.canselButton = QtGui.QPushButton(PhoneRecipieDialog) self.canselButton.setObjectName(_fromUtf8("canselButton")) self.horizontalLayout_3.addWidget(self.canselButton) self.saveButton = QtGui.QPushButton(PhoneRecipieDialog) self.saveButton.setObjectName(_fromUtf8("saveButton")) self.horizontalLayout_3.addWidget(self.saveButton) self.verticalLayout.addLayout(self.horizontalLayout_3) self.retranslateUi(PhoneRecipieDialog) QtCore.QMetaObject.connectSlotsByName(PhoneRecipieDialog)
def createUI(self): # Line edit for entering repository self.repoEdit = QtGui.QLineEdit(self) self.repoStart = QtGui.QPushButton("Start", self) self.repoStart.clicked.connect(self.createRepo) self.repoStop = QtGui.QPushButton("Stop", self) self.repoStop.clicked.connect(self.stopRepo) self.repoLabel = QtGui.QLabel(self) self.repoLabel.setText("Enter Repository:") # Set date range self.startLabel = QtGui.QLabel(self) self.startLabel.setText("Start Date:") self.startDate = QtGui.QDateTimeEdit(self) self.startDate.setCalendarPopup(True) self.startDate.setDateTime(datetime.today()) self.startDate.setDateTimeRange(unixDt, datetime.today()) self.startDate.dateTimeChanged.connect(self.changeStartDate) self.endLabel = QtGui.QLabel(self) self.endLabel.setText("End Date:") self.endDate = QtGui.QDateTimeEdit(self) self.endDate.setCalendarPopup(True) self.endDate.setDateTime(datetime.today()) self.endDate.setDateTimeRange(unixDt, datetime.today()) self.endDate.dateTimeChanged.connect(self.changeEndDate) hbox = QtGui.QHBoxLayout() hbox.addWidget(self.repoEdit) hbox.addWidget(self.repoStart) hbox.addWidget(self.repoStop) dhbox1 = QtGui.QHBoxLayout() dhbox1.addWidget(self.startLabel) dhbox1.addWidget(self.endLabel) dhbox2 = QtGui.QHBoxLayout() dhbox2.addWidget(self.startDate) dhbox2.addWidget(self.endDate) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.repoLabel) vbox.addLayout(hbox) vbox.addLayout(dhbox1) vbox.addLayout(dhbox2) vbox.addWidget(self.layout) self.setLayout(vbox) self.setGeometry(0, 0, 1024, 720) self.setWindowTitle("GithubVis")
def __init__(self, parent=None): super(TaskEditorPane, self).__init__(parent) self.startEdit = QtGui.QDateTimeEdit( QtCore.QDateTime.currentDateTime(), parent) self.endEdit = QtGui.QDateTimeEdit(QtCore.QDateTime.currentDateTime(), parent) self.descriptionEdit = QtGui.QLineEdit(parent) self.fixedCheck = QtGui.QCheckBox(parent) self.addRow('Start', self.startEdit) self.addRow('End', self.endEdit) self.addRow('Description', self.descriptionEdit) self.addRow('Fixed', self.fixedCheck)
def create_widgets(self): """date_selector_widget""" self.start_date_label = QtGui.QLabel("<b>Select a start date:</b>") self.start_date_picker = QtGui.QDateTimeEdit() self.start_date_picker.setMinimumWidth(100) self.start_date_picker.setMaximumWidth(100) self.start_date_picker.setCalendarPopup(True) self.end_date_label = QtGui.QLabel("<b>Select an end date:</b>") self.end_date_picker = QtGui.QDateTimeEdit() self.end_date_picker.setMinimumWidth(100) self.end_date_picker.setMaximumWidth(100) self.end_date_picker.setCalendarPopup(True)
def __init__(self, parent=0, *args, **kwargs): QtGui.QDialog.__init__(self, parent, *args, **kwargs) self.setWindowTitle(_(u"Add statement")) self.title = PowerPageTitle(_(u"statement")) vbox = QtGui.QVBoxLayout() vbox.addWidget(self.title) titelebox = QtGui.QGridLayout() titelebox.addWidget(QtGui.QLabel((_(u" Date"))), 0, 1) titelebox.addWidget(QtGui.QLabel((_(u" Time"))), 0, 2) titelebox.addWidget(QtGui.QLabel((_(u"Type"))), 0, 3) titelebox.addWidget(QtGui.QLabel((_(u"Value"))), 0, 4) vbox.addLayout(titelebox) self.list_data = [] for n in range(0, 5): self.date_ = QtGui.QDateTimeEdit(QtCore.QDate.currentDate()) self.date_.setDisplayFormat("dd/MM/yyyy") self.time = QtGui.QDateTimeEdit(QtCore.QTime.currentTime()) self.time.setDisplayFormat("hh:mm") self.type_ = QtGui.QLineEdit() self.value_ = QtGui.QLineEdit() self.value_.setValidator(QtGui.QIntValidator()) liste_type = [_("balance"), _("added"), _("cut"), _("recovery")] #Combobox widget self.box_type = QtGui.QComboBox() for index in liste_type: self.box_type.addItem(u'%(type)s' % {'type': index}) self.list_data.append( (self.date_, self.time, self.box_type, self.value_)) editbox = QtGui.QHBoxLayout() editbox.addWidget(self.date_) editbox.addWidget(self.time) editbox.addWidget(self.box_type) editbox.addWidget(self.value_) vbox.addLayout(editbox) button_hbox = QtGui.QHBoxLayout() butt = QtGui.QPushButton(_(u"Add")) butt.clicked.connect(self.add_statement) cancel_but = QtGui.QPushButton(_(u"Cancel")) cancel_but.clicked.connect(self.cancel) button_hbox.addWidget(cancel_but) button_hbox.addWidget(butt) vbox.addLayout(button_hbox) self.setLayout(vbox)
def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(603, 553) self.centralWidget = QtGui.QWidget(MainWindow) self.gridlayout = QtGui.QGridLayout(self.centralWidget) self.vtkWidget = QVTKRenderWindowInteractor(self.centralWidget) self.gridlayout.addWidget(self.vtkWidget, 0, 1, 1, 12) MainWindow.setCentralWidget(self.centralWidget) self.date2 = QtGui.QDateTimeEdit() dateTime2 = QtCore.QDateTime(2012, 5, 1, 00, 00) self.date2.setDateTime(dateTime2) self.gridlayout.addWidget(self.date2, 1, 3, 2, 2) self.date1 = QtGui.QDateTimeEdit() dateTime1 = QtCore.QDateTime(2012, 5, 31, 00, 00) self.date1.setDateTime(dateTime1) self.gridlayout.addWidget(self.date1, 1, 5, 2, 2) # Magnitude upper limit filtering+submit magnitudeLabel = QtGui.QLabel("Magnitude:") magnitudeLabel.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(magnitudeLabel, 5, 3, 2, 2) self.magnitudeValue = QtGui.QLineEdit() # Use input mask for input validation, instead of setMaxLength # or other manual checks by using if to let input only numbers. self.magnitudeValue.setInputMask("0.0") self.magnitudeValue.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(self.magnitudeValue, 5, 5, 2, 2) # Controls the planes opacity planeOpacityLabel = QtGui.QLabel("Plane Opacity:") planeOpacityLabel.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(planeOpacityLabel, 7, 3, 2, 2) self.opacityValue = QtGui.QLineEdit() # Use input mask for input validation, instead of setMaxLength # or other manual checks by using if to let input only numbers. self.opacityValue.setInputMask("0.0") self.opacityValue.setAlignment(QtCore.Qt.AlignRight) self.gridlayout.addWidget(self.opacityValue, 7, 5, 2, 2) self.submit = QtGui.QPushButton("submit") self.gridlayout.addWidget(self.submit, 7, 7, 2, 2) self.sld = QtGui.QSlider(QtCore.Qt.Horizontal) self.sld.setTracking(False) self.sld.setDisabled(True) self.gridlayout.addWidget(self.sld, 9, 3, 1, 6)
def get_settings(self): sqlquery = QtSql.QSqlQuery( QtCore.QString(""" SELECT course.fullname, course.shortname, course.startdate, course.metacourse FROM course WHERE course.id='%1' """).arg(self.id), self.db) sqlquery.first() value = sqlquery.value(0).toString() self.settings["fullname"] = { "title": u"Повна назва", "value": value, "widget": QtGui.QLineEdit(value) } value = sqlquery.value(1).toString() self.settings["shortname"] = { "title": u"Коротка назва", "value": value, "widget": QtGui.QLineEdit(value) } value = sqlquery.value(2).toInt()[0] datetime = QtCore.QDateTime() datetime.setTime_t(value) datetimeedit = QtGui.QDateTimeEdit(datetime) datetimeedit.setCalendarPopup(True) self.settings["startdate"] = { "title": u"Дата початку", "value": value, "widget": datetimeedit } value = sqlquery.value(3).toInt()[0] checkbox = QtGui.QCheckBox() checkbox.setChecked(value) self.settings["metacourse"] = { "title": u"Мета курс", "value": value, "widget": checkbox } formlayout = QtGui.QFormLayout() for setting_key in self.settings.keys(): setting = self.settings[setting_key] formlayout.addRow(setting["title"], setting["widget"]) if self.ui.groupBoxSettings.layout(): layout = self.ui.groupBoxSettings.layout() print "try del" layout.deleteLater() self.ui.groupBoxSettings.setLayout(formlayout)
def setupUi(self, AddImage): AddImage.setObjectName(_fromUtf8("AddImage")) AddImage.resize(800, 600) self.pushButton_2 = QtGui.QPushButton(AddImage) self.pushButton_2.setGeometry(QtCore.QRect(330, 500, 160, 40)) self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) self.pushButton = QtGui.QPushButton(AddImage) self.pushButton.setGeometry(QtCore.QRect(80, 500, 160, 40)) self.pushButton.setObjectName(_fromUtf8("pushButton")) self.lineEdit = QtGui.QLineEdit(AddImage) self.lineEdit.setGeometry(QtCore.QRect(280, 150, 361, 31)) self.lineEdit.setObjectName(_fromUtf8("lineEdit")) self.label = QtGui.QLabel(AddImage) self.label.setGeometry(QtCore.QRect(90, 150, 191, 21)) self.label.setObjectName(_fromUtf8("label")) self.label_2 = QtGui.QLabel(AddImage) self.label_2.setGeometry(QtCore.QRect(160, 230, 121, 21)) self.label_2.setObjectName(_fromUtf8("label_2")) self.pushButton_3 = QtGui.QPushButton(AddImage) self.pushButton_3.setGeometry(QtCore.QRect(90, 310, 181, 29)) self.pushButton_3.setObjectName(_fromUtf8("pushButton_3")) self.lineEdit_3 = QtGui.QLineEdit(AddImage) self.lineEdit_3.setGeometry(QtCore.QRect(280, 310, 361, 31)) self.lineEdit_3.setObjectName(_fromUtf8("lineEdit_3")) self.dateTimeEdit = QtGui.QDateTimeEdit(AddImage) self.dateTimeEdit.setGeometry(QtCore.QRect(280, 230, 194, 29)) self.dateTimeEdit.setObjectName(_fromUtf8("dateTimeEdit")) self.retranslateUi(AddImage) QtCore.QMetaObject.connectSlotsByName(AddImage)
def createBottomRightGroupBox(self): self.bottomRightGroupBox = QtGui.QGroupBox("Group 3") self.bottomRightGroupBox.setCheckable(True) self.bottomRightGroupBox.setChecked(True) lineEdit = QtGui.QLineEdit('s3cRe7') lineEdit.setEchoMode(QtGui.QLineEdit.Password) spinBox = QtGui.QSpinBox(self.bottomRightGroupBox) spinBox.setValue(50) dateTimeEdit = QtGui.QDateTimeEdit(self.bottomRightGroupBox) dateTimeEdit.setDateTime(QtCore.QDateTime.currentDateTime()) slider = QtGui.QSlider(QtCore.Qt.Horizontal, self.bottomRightGroupBox) slider.setValue(40) scrollBar = QtGui.QScrollBar(QtCore.Qt.Horizontal, self.bottomRightGroupBox) scrollBar.setValue(60) dial = QtGui.QDial(self.bottomRightGroupBox) dial.setValue(30) dial.setNotchesVisible(True) layout = QtGui.QGridLayout() layout.addWidget(lineEdit, 0, 0, 1, 2) layout.addWidget(spinBox, 1, 0, 1, 2) layout.addWidget(dateTimeEdit, 2, 0, 1, 2) layout.addWidget(slider, 3, 0) layout.addWidget(scrollBar, 4, 0) layout.addWidget(dial, 3, 1, 2, 1) layout.setRowStretch(5, 1) self.bottomRightGroupBox.setLayout(layout)
def __init__(self, db, parent=None): qtgui.QDialog.__init__(self, parent=parent) self.db = db self.date = None lay_h = qtgui.QHBoxLayout() lay_v = qtgui.QVBoxLayout() self.datetime = qtgui.QDateTimeEdit() self.check_in = qtgui.QRadioButton('check in') self.check_out = qtgui.QRadioButton('check out') self.add = qtgui.QPushButton( self.style().standardIcon(qtgui.QStyle.SP_DialogOkButton), None) lay_v.addWidget(self.check_in) lay_v.addWidget(self.check_out) lay_h.addWidget(self.datetime) lay_h.addLayout(lay_v) lay_h.addWidget(self.add) self.setLayout(lay_h) self.add.clicked.connect(self.add_event)
def setupUi(self, Dialog): Dialog.setObjectName(_fromUtf8("Dialog")) Dialog.resize(512, 339) self.gridLayout = QtGui.QGridLayout(Dialog) self.gridLayout.setObjectName(_fromUtf8("gridLayout")) self.txtName = QtGui.QLineEdit(Dialog) self.txtName.setObjectName(_fromUtf8("txtName")) self.gridLayout.addWidget(self.txtName, 0, 1, 1, 1) self.label = QtGui.QLabel(Dialog) self.label.setObjectName(_fromUtf8("label")) self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.label_2 = QtGui.QLabel(Dialog) self.label_2.setObjectName(_fromUtf8("label_2")) self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) self.gridLayout.addItem(spacerItem, 3, 0, 1, 1) self.txtType = QtGui.QLineEdit(Dialog) self.txtType.setObjectName(_fromUtf8("txtType")) self.gridLayout.addWidget(self.txtType, 1, 1, 1, 1) self.btnSave = QtGui.QPushButton(Dialog) self.btnSave.setObjectName(_fromUtf8("btnSave")) self.gridLayout.addWidget(self.btnSave, 4, 2, 1, 1) self.label_3 = QtGui.QLabel(Dialog) self.label_3.setObjectName(_fromUtf8("label_3")) self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1) self.dateTurnering = QtGui.QDateTimeEdit(Dialog) self.dateTurnering.setObjectName(_fromUtf8("dateTurnering")) self.gridLayout.addWidget(self.dateTurnering, 2, 1, 1, 1) self.retranslateUi(Dialog) QtCore.QMetaObject.connectSlotsByName(Dialog)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.ui = uic.loadUi("superSpider.ui", self) #create a QDateTimeEdit object myDTE = QtGui.QDateTimeEdit() now = QtCore.QDateTime.currentDateTime() today = QtCore.QDate.currentDate() self.ui.resResultdate.setDate(today) self.ui.resResultdate2.setDate(today.addDays(14)) self.nowYear = str(today.year()) self.nowMonth = str(today.month()) self.nowDay = str(today.day()) if (len(self.nowMonth) == 1): self.nowMonth = "0" + self.nowMonth if (len(self.nowDay) == 1): self.nowDay = "0" + self.nowDay #print self.ui.resResultdate.date().year() #print self.ui.resResultdate.date().month() #print self.ui.resResultdate.date().day() self.superSpiderThread = self.SuperSpiderThread(self) self.connect(self.superSpiderThread, QtCore.SIGNAL("finishedWork"), self.done) self.connect(self.superSpiderThread, QtCore.SIGNAL("loggingWork"), self.traceLog) #This is about Signal and it is point https://nikolak.com/pyqt-threading-tutorial/ self.ui.show()
def setupUi(self, BuildingServicesClient): BuildingServicesClient.setObjectName( _fromUtf8("BuildingServicesClient")) BuildingServicesClient.resize(423, 130) font = QtGui.QFont() font.setFamily(_fromUtf8("Arial Narrow")) font.setPointSize(12) BuildingServicesClient.setFont(font) self.roomLabel = QtGui.QLabel(BuildingServicesClient) self.roomLabel.setGeometry(QtCore.QRect(8, 30, 36, 20)) self.roomLabel.setObjectName(_fromUtf8("roomLabel")) self.roomEdit = QtGui.QLineEdit(BuildingServicesClient) self.roomEdit.setGeometry(QtCore.QRect(50, 30, 150, 26)) self.roomEdit.setObjectName(_fromUtf8("roomEdit")) self.dateLabel = QtGui.QLabel(BuildingServicesClient) self.dateLabel.setGeometry(QtCore.QRect(210, 31, 27, 20)) self.dateLabel.setObjectName(_fromUtf8("dateLabel")) self.dateEdit = QtGui.QDateTimeEdit(BuildingServicesClient) self.dateEdit.setGeometry(QtCore.QRect(240, 30, 175, 26)) self.dateEdit.setObjectName(_fromUtf8("dateEdit")) self.responseLabel = QtGui.QLabel(BuildingServicesClient) self.responseLabel.setGeometry(QtCore.QRect(7, 63, 62, 20)) self.responseLabel.setObjectName(_fromUtf8("responseLabel")) self.bookButton = QtGui.QPushButton(BuildingServicesClient) self.bookButton.setGeometry(QtCore.QRect(58, 90, 75, 28)) self.bookButton.setObjectName(_fromUtf8("bookButton")) self.unBookButton = QtGui.QPushButton(BuildingServicesClient) self.unBookButton.setGeometry(QtCore.QRect(139, 90, 75, 28)) self.unBookButton.setObjectName(_fromUtf8("unBookButton")) self.quitButton = QtGui.QPushButton(BuildingServicesClient) self.quitButton.setGeometry(QtCore.QRect(220, 90, 75, 28)) self.quitButton.setObjectName(_fromUtf8("quitButton")) self.retranslateUi(BuildingServicesClient) QtCore.QMetaObject.connectSlotsByName(BuildingServicesClient)
def __init__(self, sysdate, user, parent=None): super(NewIB2EX, self).__init__(parent=parent) self.setWindowTitle(u'银证转账') self.sysdate = sysdate self.user = user layout = QtGui.QGridLayout() books = [] q = QtSql.QSqlQuery('SELECT NAME_CN FROM BOOKS ORDER BY ID') while q.next(): books.append(q.value(0).toString()) self.books = QtGui.QComboBox() self.books.addItems(books) layout.addWidget(QtGui.QLabel(u'转账日期'), 0, 0, 1, 1) self.settleDate = QtGui.QDateTimeEdit(datetime.datetime.now()) self.settleDate.setCalendarPopup(True) layout.addWidget(self.settleDate, 0, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'账簿'), 1, 0, 1, 1) layout.addWidget(self.books, 1, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'转账方向'), 2, 0, 1, 1) self.ib2ex = QtGui.QComboBox() self.ib2ex.addItems([u'银行间-->交易所', u'交易所-->银行间']) layout.addWidget(self.ib2ex, 2, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'金额(元)'), 3, 0, 1, 1) self.amount = QtGui.QLineEdit() self.amount.setValidator(QtGui.QDoubleValidator()) layout.addWidget(self.amount, 3, 1, 1, 1) layout.addWidget(QtGui.QLabel(u'备注'), 4, 0, 1, 1) self.comment = QtGui.QLineEdit() layout.addWidget(self.comment, 4, 1, 1, 1) btnLayout = QtGui.QHBoxLayout() btnLayout.addWidget(self.ok) btnLayout.addWidget(self.cancel) layout.addLayout(btnLayout, 5, 0, 1, 2) self.setLayout(layout)
def __init__(self, parent=None): super(MyTable, self).__init__(parent) self.setColumnCount(5) self.setRowCount(2) self.setItem(0, 0, QtGui.QTableWidgetItem(self.tr("性别"))) self.setItem(0, 1, QtGui.QTableWidgetItem(self.tr("姓名"))) self.setItem(0, 2, QtGui.QTableWidgetItem(self.tr("出生日期"))) self.setItem(0, 3, QtGui.QTableWidgetItem(self.tr("职业"))) self.setItem(0, 4, QtGui.QTableWidgetItem(self.tr("收入"))) lbp1 = QtGui.QLabel() lbp1.setPixmap(QtGui.QPixmap("image/4.gif")) self.setCellWidget(1, 0, lbp1) twi1 = QtGui.QTableWidgetItem("Tom") self.setItem(1, 1, twi1) dte1 = QtGui.QDateTimeEdit() dte1.setDateTime(QtCore.QDateTime.currentDateTime()) dte1.setDisplayFormat("yyyy/mm/dd") dte1.setCalendarPopup(True) self.setCellWidget(1, 2, dte1) cbw = QtGui.QComboBox() cbw.addItem("Worker") cbw.addItem("Famer") cbw.addItem("Doctor") cbw.addItem("Lawyer") cbw.addItem("Soldier") self.setCellWidget(1, 3, cbw) sb1 = QtGui.QSpinBox() sb1.setRange(1000, 10000) self.setCellWidget(1, 4, sb1)
def __init__(self, debt, parent=0, *args, **kwargs): super(OperationViewWidget, self).__init__(parent=parent,\ *args, **kwargs) self.setWindowTitle((u"Add operation")) self.debt = debt vbox = QtGui.QVBoxLayout() vbox.addWidget(DebtPageTitle(u"Operation")) hbox = QtGui.QHBoxLayout() tablebox = QtGui.QVBoxLayout() tablebox.addWidget(DebtBoxTitle(u"Table opertion")) self.table_op = OperationTableWidget(debt, parent=self) tablebox.addWidget(self.table_op) self.date_ = QtGui.QDateTimeEdit(QtCore.QDate.currentDate()) self.date_.setDisplayFormat("dd-MM-yyyy") self.time = QtGui.QDateTimeEdit(QtCore.QTime.currentTime()) self.time.setDisplayFormat("hh:mm") self.montant = QtGui.QLineEdit() self.montant.setValidator(QtGui.QIntValidator()) cretorbox = QtGui.QFormLayout() cretorbox.addWidget(DebtBoxTitle(u"Creditor info")) cretorbox.addRow("First name: ",\ QtGui.QLabel(self.debt.creditor.first_name)) cretorbox.addRow("Last name: ",\ QtGui.QLabel(self.debt.creditor.last_name)) cretorbox.addRow("Adress: ",\ QtGui.QLabel(self.debt.creditor.adress)) cretorbox.addRow("Phone: ", QtGui.QLabel(self.debt.creditor.phone)) formbox = QtGui.QFormLayout() formbox.setContentsMargins(200, 0, 200, 0) formbox.addWidget(DebtBoxTitle(u"Add opertion")) formbox.addRow("Date", self.date_) formbox.addRow("time", self.time) formbox.addRow("Montant", self.montant) butt = QtGui.QPushButton((u"Add")) butt.clicked.connect(self.add_operation) formbox.addWidget(butt) hbox.addLayout(cretorbox) hbox.addLayout(formbox) vbox.addLayout(hbox) vbox.addLayout(tablebox) self.setLayout(vbox)
def updateSymbolsToDownloadTable(self): """mid dfSymbolsToDownload.index = 'code' dfSymbolsToDownload.columns = ['code','name','c_name',...] """ self.tableSymbolsToDownload.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows) self.tableSymbolsToDownload.setEditTriggers(QtGui.QTableWidget.NoEditTriggers) self.tableSymbolsToDownload.setSelectionBehavior(QtGui.QTableWidget.SelectRows) self.tableSymbolsToDownload.setSelectionMode(QtGui.QTableWidget.SingleSelection) self.tableSymbolsToDownload.setAlternatingRowColors(True) self.tableSymbolsToDownload.clear() header = ["code","name","class"] self.tableSymbolsToDownload.setColumnCount(len(header)) self.tableSymbolsToDownload.setRowCount(len(self.dfSymbolsToDownload)) self.tableSymbolsToDownload.setHorizontalHeaderLabels(header) #mid should be after .setColumnCount() if (PY3 == True):#mid 这种填充方式虽然快,但是,当item有中文编码时,在py2下会出现问题 for row in range(len(self.dfSymbolsToDownload.index)): for column in range(len(self.dfSymbolsToDownload.columns)): self.tableSymbolsToDownload.setItem(row,column,QtGui.QTableWidgetItem(str(self.dfSymbolsToDownload.iget_value(row, column)))) else: #mid the above codes have better performance than the below. for row in np.arange(0,len(self.dfSymbolsToDownload)): symbol = self.dfSymbolsToDownload.index[row] name = self.dfSymbolsToDownload.loc[symbol,'name'] c_name = self.dfSymbolsToDownload.loc[symbol,'c_name'] timeStart = QtGui.QCalendarWidget() timeStart=QtGui.QDateTimeEdit() timeStart.setDateTime(QtCore.QDateTime.currentDateTime()) timeStart.setDisplayFormat("yyyy-MM-dd hh:mm:ss") timeStart.setCalendarPopup(True) timeEnd=QtGui.QDateTimeEdit() timeEnd.setDateTime(QtCore.QDateTime.currentDateTime()) timeEnd.setDisplayFormat("yyyy-MM-dd hh:mm:ss") timeEnd.setCalendarPopup(True) if(symbol is not None): self.tableSymbolsToDownload.setItem(row,0,QtGui.QTableWidgetItem(symbol)) if(name is not None): self.tableSymbolsToDownload.setItem(row,1,QtGui.QTableWidgetItem(name)) if(c_name is not None): self.tableSymbolsToDownload.setItem(row,2,QtGui.QTableWidgetItem(c_name)) self.tableSymbolsToDownload.setCellWidget(row,3,timeStart) self.tableSymbolsToDownload.setCellWidget(row,4,timeEnd)
def now(format="yyyy-MM-dd hh:mm:ss", mdate=QtCore.QDateTime.currentDateTime()): """ yyyy-MM-dd hh:mm:ss """ xx = QtGui.QDateTimeEdit(mdate) xx.setDisplayFormat(format) return xx.text()
def __init__(self, db, parent=None): qtgui.QDialog.__init__(self, parent=parent) self.db = db self.list = qtgui.QListWidget() self.list.itemSelectionChanged.connect(self.item_selected) self.date = qtgui.QDateTimeEdit() self.date.setDisplayFormat("dd.MM.yyyy") self.date.setCalendarPopup(True) self.dayboxes = {ds: [TimeSpinBox() for n in range(3)] for ds in WEEKDAYS_SHORT} self.daychecks = {ds: qtgui.QCheckBox(day) for day, ds in zip(WEEKDAYS, WEEKDAYS_SHORT)} self.vac = qtgui.QSpinBox() self.flex = TimeSpinBox() self.new = qtgui.QPushButton(self.style().standardIcon(qtgui.QStyle.SP_FileDialogNewFolder), None) self.save = qtgui.QPushButton(self.style().standardIcon(qtgui.QStyle.SP_DialogSaveButton), None) self.save.clicked.connect(lambda: self.save_enty()) lay_h = qtgui.QHBoxLayout() lay_h.addWidget(self.list) lay_f = qtgui.QGridLayout() lay_f.addWidget(qtgui.QLabel("Work"), 10, 1) lay_f.addWidget(qtgui.QLabel("Vacation"), 10, 2) lay_f.addWidget(qtgui.QLabel("Holiday"), 10, 3) for i, (day, ds) in enumerate(zip(WEEKDAYS, WEEKDAYS_SHORT)): lay_f.addWidget(self.daychecks[ds], 11 + i, 0) for j in range(3): lay_f.addWidget(self.dayboxes[ds][j], 11 + i, 1 + j) self.dayboxes[ds][j].valueChanged.connect(self.update_sums) lay_f.addWidget(qtgui.QLabel("Date"), 5, 0) lay_f.addWidget(self.date, 5, 1) lay_f.addWidget(qtgui.QLabel("Flexible"), 21, 0) lay_f.addWidget(self.flex, 21, 1) self.sums = [qtgui.QLabel("n/a"), qtgui.QLabel("n/a"), qtgui.QLabel("n/a")] lay_f.addWidget(self.sums[0], 25, 1) lay_f.addWidget(self.sums[1], 25, 2) lay_f.addWidget(self.sums[2], 25, 3) lay_f.addWidget(qtgui.QLabel("Vacation"), 31, 0) lay_f.addWidget(self.vac, 31, 1) lay_f.addWidget(self.save, 50, 1) lay_f.addWidget(self.new, 50, 2) lay_h.addLayout(lay_f) self.setLayout(lay_h) self.update()
def createDateTimeEdit(self, field, value): if value is not None: datetime = QtCore.QDateTime.fromString(value, QtCore.Qt.ISODate) else: datetime = QtCore.QDateTime.currentDateTime() ctrl = QtGui.QDateTimeEdit(datetime, self) ctrl.setCalendarPopup(True) ctrl.setDisplayFormat("yyyy.MM.dd hh:00") # Precise to +-1 hour return ctrl
def test_calcall(self, mock_messagebar): db_utils.sql_alter_db( u'''INSERT INTO obs_points (obsid, h_toc) VALUES ('rb1', 1)''') db_utils.sql_alter_db( u'''INSERT into w_levels (obsid, meas, date_time) VALUES ('rb1', 222, '2005-01-01 00:00:00')''' ) self.calclvl.FromDateTime = QtGui.QDateTimeEdit() self.calclvl.FromDateTime.setDateTime( datestring_to_date(u'2000-01-01 00:00:00')) self.calclvl.ToDateTime = QtGui.QDateTimeEdit() self.calclvl.ToDateTime.setDateTime( datestring_to_date(u'2010-01-01 00:00:00')) self.calclvl.calcall() test_string = utils_for_tests.create_test_string( db_utils.sql_load_fr_db( u'SELECT obsid, date_time, meas, h_toc, level_masl FROM w_levels' )) reference_string = u'(True, [(rb1, 2005-01-01 00:00:00, 222.0, 1.0, -221.0)])' assert test_string == reference_string
def __init__(self): #, filename = None): #initialize a viewer window with a grid layout. #---------------------------------------------- #---------------------------------------------- super(QtGui.QMainWindow, self).__init__() self.ax0 = None self.resize(500, 500) self.setWindowTitle('GOES') # Top GroupBox myQWidget = QtGui.QWidget() myBoxLayout = QtGui.QVBoxLayout() myQWidget.setLayout(myBoxLayout) self.setCentralWidget(myQWidget) self.tr = DEFAULT_TR self.lc = GOESLightCurve.create(self.tr) # date edit box self.dateSet = QtGui.QDateTimeEdit() self.dateSet.setDateTime( QtCore.QDateTime( QtCore.QDate(DEFAULT_TR.start.year, DEFAULT_TR.start.month, DEFAULT_TR.start.day), QtCore.QTime(00, 00, 00))) self.dateSet.setCalendarPopup(True) self.dateSet.setDisplayFormat("yyyy/MM/dd HH:mm:ss UT") myBoxLayout.addWidget(self.dateSet) # create the plot self.fig0 = plt.figure() self.canvas0 = FigureCanvas(self.fig0) self.update() myBoxLayout.addWidget(self.canvas0) # the next day button nextDayButton = QtGui.QPushButton('Next Day') myBoxLayout.addWidget(nextDayButton) QtCore.QObject.connect(nextDayButton, QtCore.SIGNAL('clicked()'), self.update_next_tr) # the previous day button previousDayButton = QtGui.QPushButton('Previous Day') myBoxLayout.addWidget(previousDayButton) QtCore.QObject.connect(previousDayButton, QtCore.SIGNAL('clicked()'), self.update_prev_tr) # refresh button refreshButton = QtGui.QPushButton('Refresh') myBoxLayout.addWidget(refreshButton) QtCore.QObject.connect(refreshButton, QtCore.SIGNAL('clicked()'), self.refresh) self.show()
def InitField(self, parent): if self.aVisualizzaData: if self.aVisualizzaOra: self.field = QtGui.QDateTimeEdit(parent) else: self.field = QtGui.QDateEdit(parent) else: self.field = QtGui.QTimeEdit(parent) self.field.setObjectName("field_%s" % self.aNomeCampo) # Forced rendering with default value self.setValue(self.aValore) return self.field
def fileWidget(self, parent): main_widget = QtGui.QWidget(parent) layout = QtGui.QFormLayout() file_label = QtGui.QLabel("Results file: ", main_widget) file_label.setFont(QtGui.QFont("Arial", 10, QtGui.QFont.Bold)) file_browse = QtGui.QPushButton('Browse...') file_browse.clicked.connect(self.browseFile) self.file_edit = QtGui.QLineEdit(main_widget) start_label = QtGui.QLabel("Start Date: ", main_widget) self.start_date = QtGui.QDateTimeEdit(main_widget) end_label = QtGui.QLabel("End Date: ", main_widget) self.end_date = QtGui.QDateTimeEdit(main_widget) layout.addRow(file_label) layout.addRow(file_browse, self.file_edit) layout.addRow(start_label, self.start_date) layout.addRow(end_label, self.end_date) main_widget.setLayout(layout) return main_widget
def updateSymbolsToDownloadTable(self): '''''' self.tableSymbolsToDownload.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.tableSymbolsToDownload.setEditTriggers( QtGui.QTableWidget.NoEditTriggers) self.tableSymbolsToDownload.setSelectionBehavior( QtGui.QTableWidget.SelectRows) self.tableSymbolsToDownload.setSelectionMode( QtGui.QTableWidget.SingleSelection) self.tableSymbolsToDownload.setAlternatingRowColors(True) self.tableSymbolsToDownload.clear() header = ["sybol", "name", "start", "end"] self.tableSymbolsToDownload.setColumnCount(len(header)) self.tableSymbolsToDownload.setRowCount(len(self.dfSymbolsToDownload)) self.tableSymbolsToDownload.setHorizontalHeaderLabels( header) #mid should be after .setColumnCount() for row in np.arange(0, len(self.dfSymbolsToDownload)): symbol = self.dfSymbolsToDownload.index[row] name = str(self.dfSymbolsToDownload.loc[symbol, 'name']) timeStart = QtGui.QCalendarWidget() timeStart = QtGui.QDateTimeEdit() timeStart.setDateTime(QtCore.QDateTime.currentDateTime()) timeStart.setDisplayFormat("yyyy-MM-dd hh:mm:ss") timeStart.setCalendarPopup(True) lableTimeEnd = QtGui.QLabel(self.tr("Time end")) timeEnd = QtGui.QDateTimeEdit() timeEnd.setDateTime(QtCore.QDateTime.currentDateTime()) timeEnd.setDisplayFormat("yyyy-MM-dd hh:mm:ss") timeEnd.setCalendarPopup(True) self.tableSymbolsToDownload.setItem(row, 0, QtGui.QTableWidgetItem(symbol)) self.tableSymbolsToDownload.setItem(row, 1, QtGui.QTableWidgetItem(name)) self.tableSymbolsToDownload.setCellWidget(row, 2, timeStart) self.tableSymbolsToDownload.setCellWidget(row, 3, timeEnd)
def get_height(self): height = [ QtGui.QLineEdit().sizeHint().height(), QtGui.QDateEdit().sizeHint().height(), QtGui.QDateTimeEdit().sizeHint().height(), QtGui.QSpinBox().sizeHint().height(), QtGui.QDateEdit().sizeHint().height(), QtGui.QComboBox().sizeHint().height() ] finalHeight = max(height) return finalHeight