def request1(self, appkey, date): ''' 获得具体的黄历信息 ''' url = "http://v.juhe.cn/laohuangli/d" params = { "key": appkey, # 应用APPKEY(应用详细页查询) "date": date # 日期,格式2014-09-09 } f = requests.get(url, params=params) content = f.text res = json.loads(content) # 转换成json格式 if res: error_code = res["error_code"] data = res["result"] if error_code == 0: # 成功请求 self.label.setText("阳历:" + date) self.label_2.setText("阴历:" + data["yinli"]) self.label_3.setText("忌:" + data["ji"]) self.label_4.setText("宜:" + data["yi"]) else: # 请求失败 QMessageBox.Warning( self, "警告", "错误代码:" + res["error_code"] + "错误原因:" + res["reason"]) else: # 哦嚯,失败了 QMessageBox.Warning(self, "警告", "API请求失败")
def Started(self): #开始进程 global quitc while True: time.sleep(times) if webAddress == "": QMessageBox.Warning(self, '警告', '请输入完整的网站地址', QMessageBox.Ok) break elif times == 0: QMessageBox.Warning(self, '警告', '请输入间隔时间', QMessageBox.Ok) break elif phoneNum == "": QMessageBox.Warning(self, '警告', '请输入正确的手机号码', QMessageBox.Ok) break elif quitc == True: break else: self.lists = self.robotMain(webAddress) if self.lists == "": self.view_console.append("信息:暂无更新") continue else: text1 = '\n抓取到新消息:' text2 = '' timed = '\n发送日期:' + time.strftime( '%Y-%m-%d %H:%M:%S', time.localtime(time.time())) if keyword == "": for i in range(len(self.lists)): self.view_console.append(str(self.lists[i])) temp = str() text1 = text1 + '\n' + self.lists[i][ 0] + ":" + self.lists[i][1] text2 = text2 + "\n" + self.lists[i][2] try: print(text1 + timed) sender.SendMessage(phoneNum, text1 + timed) sender.SendMessage(phoneNum, text2) self.view_console.append("已向(" + phoneNum + ")发送信息") except: self.view_console.append("信息:发送失败") else: for i in range(len(self.lists)): t = re.findall(keyword, str(self.lists[i])) if t: text1 = text1 + "\n" + self.lists[i][ 0] + self.lists[i][1] text2 = text2 + "\n" + self.lists[i][2] else: continue try: print(text1 + timed) sender.SendMessage(phoneNum, text1 + timed) sender.SendMessage(phoneNum, text2) self.view_console.append("已向(" + phoneNum + ")发送关键词信息") except: self.view_console.append("信息:发送失败") self.view_console.append("信息:进程关闭") quitc = False
def create_transform(self, vc): fs = vc.fsamp if fs is None: return # Design the filter selected_filter = self.filter_selector.currentText() low_fc_str = self.low_cutoff_le.text() high_fc_str = self.high_cutoff_le.text() poles_str = self.poles_le.text() if poles_str == '': QMessageBox.Warning('Number of poles must by specified') return else: poles = int(poles_str) if low_fc_str == '': low_fc = None else: low_fc = float(low_fc_str) if high_fc_str == '': high_fc = None else: high_fc = float(high_fc_str) if low_fc is not None and high_fc is not None and low_fc >= high_fc: QMessageBox.Warning('Low cut-off frequency cannot be higher', 'than high cut-off frequency') return if selected_filter == 'Butterworth': if low_fc and high_fc: b, a = butter(poles, [low_fc / (fs / 2), high_fc / (fs / 2)], 'bandpass') elif low_fc and not high_fc: b, a = butter(poles, low_fc / (fs / 2), 'highpass') elif not low_fc and high_fc: b, a = butter(poles, high_fc / (fs / 2), 'lowpass') else: return # Greate the transform object transform = FilterTransform() transform.a = a transform.b = b transform.name = (' / ' + selected_filter + '; ' + '-'.join([low_fc_str, high_fc_str]) + 'Hz') return transform
def __init__(self): super(MainWindowClass, self).__init__() self.setupUi(self) self.tws = None self.status_message = QLabel() self.statusbar.addPermanentWidget(self.status_message) self.db = Database(self.tws) self.tab2 = None self.tab3 = None self.tab4 = None # Connect to TWS connection_established = self.connect() if not connection_established: QMessageBox.Warning('Couldn\'t connect to TWS API') # ############################################################################################################# # Signals # ############################################################################################################# # QAction # self.connect(self.connectPB, SIGNAL("triggered()"), self.connect) # QButton # self.connect(self.connectPB, SIGNAL("clicked()"), self.connect) self.init_gui() self.guisave(self.ui, QtCore.QSettings('saved.ini', QtCore.QSettings.IniFormat)) self.guirestore(self.ui, QtCore.QSettings('saved.ini', QtCore.QSettings.IniFormat))
def x_change_data(self): self.model6.database().transaction() if (self.model6.submitAll()): self.model6.database().commit() else: self.model6.database().rollback() QMessageBox.Warning(self, "警告", "数据库错误")
def createDatabase(self): try: self.connection = sqlite3.connect('database/tc.db') self.cursor = self.connection.cursor() self.createTableInDatabase() except Exception as e: print(e) a = QMessageBox.Warning( self, 'Database Error', 'Failed to create database.' 'Try running application as administrator')
def openCamera(self): flag = self.cap.open(self.CAM_NUM) if flag == False: msg = QMessageBox.Warning(self, u'Warning', u'请检测相机与电脑是否连接正确', buttons=QMessageBox.Ok, defaultButton=QMessageBox.Ok) else: self.timer_camera.start(30) # 30ms调用一次show_camera self.enable_camera_button.setText('关闭摄像头')
def phoneTest(self): #进行手机短信号码的测试 timeText = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) text1 = '如果你收到这条短信则证明你的手机可以正常接收到通知的消息!\n来自开学日期提醒程序。\n日期:' try: sender.SendMessage(self.lineEdit_phoneNum.text(), text1 + timeText) QMessageBox.information(self, "发送成功", '已向你的手机发送消息。', QMessageBox.Ok) except: QMessageBox.Warning(self, '发送错误', '发送失败,请检查你输入的号码。', QMessageBox.Ok)
def saveAsFile(self, fileName=None): if fileName == None: fileName = self.m_currentFile if fileName == '': QMessageBox.Warning(self, "Save failed!", "Warning: the file name can't be empty") text = self.m_systemMark + self.saveText() f = open(fileName, '+w') f.write(text) f.close() self.m_currentFile = fileName self.m_changed = False self.updateState()
def RunProgram(self): dataBase=warehouseDB() answer=QMessageBox.question(self,"LOCATION TRANSFER",'Do you want to tranfer for this record ?',QMessageBox.Yes | QMessageBox.No) if(answer==QMessageBox.Yes): gelen=self.window.tblList.currentItem().text().split("/") processId='8' mId=gelen[4] quan=gelen[7] mUId=gelen[8] partyNo=gelen[10] expDate=gelen[11] id=gelen[0] quanNew=self.window.txtQuantity.text() locName=self.window.cmbLocNo.currentText() locId=str(dataBase.ListingLocation_V2 (locName)[0][0]) isOk=0 quanUpdate=int(quan)-int(quanNew) if(quanNew>quan): QMessageBox.Warning(self,"LOCATION TRANSFER","Quantity updated is bigger than quantity",QMessageBox.Ok,QMessageBox.Ok) else: dataBase.InsertingProcess(processId,mId,quan,mUId,partyNo) dataBase.InsertingWarehouseQuantity(locId,mId,quanNew,mUId,partyNo,expDate) if(quanUpdate==0): dataBase.UpdatingWarehouseQuantityWithQuantityIsOk(id,quanUpdate,isOk) else: dataBase.UpdatingWarehouseQuantityWithQuantity(id,quanUpdate) QMessageBox.information(self,"LOCATION TRANSFER","This transfer is successful",QMessageBox.Ok,QMessageBox.Ok) self.window.tblList.clear() self.FillingTable() elif (answer==QMessageBox.No): QMessageBox.information(self,"LOCATION TRANSFER","This transfer is unsuccessful",QMessageBox.Ok,QMessageBox.Ok)
def main(): app = QApplication(sys.argv) window = MainWindow() app.setApplicationDisplayName('ES Time') window.setWindowTitle('Estimator') global Stayontop global darkmode global resetfields global viewResMsgBox global ScaleFact global configpath try: configFile = pickle.load(open(configpath, "rb")) darkmode = configFile[0] ScaleFact = configFile[1] Stayontop = configFile[2] viewResMsgBox = configFile[3] resetfields = configFile[4] except: pass #black shadow effect shadow_black = QGraphicsDropShadowEffect() shadow_black.setBlurRadius(20) shadow_black.setYOffset(5) shadow_black.setXOffset(0) if darkmode == 1: shadow_black.setColor(PyQt5.QtGui.QColor("#A1A1A1")) else: shadow_black.setColor(PyQt5.QtGui.QColor("#c1c1c1")) window.tabWidget.setGraphicsEffect(shadow_black) #setup for Dark mode wrapping if darkmode == 1: #Tabs window.tabWidget.setStyleSheet( "QTabBar::tab:selected {border-bottom: 2px solid #00BFF3;} QTabBar::tab:hover {border-bottom: 2px solid #00BFF3;}" ) #TimeES labels window.label_AvSp.setStyleSheet("color:white;") window.label_Si.setStyleSheet("color:white;") window.label_Comp.setStyleSheet("color:white;") window.label_Perc.setStyleSheet("color:white;") window.label_Result.setStyleSheet("color:#27C499;") window.label_Er.setStyleSheet("color:#F1304D;") #TimeES inputs window.input_AvSp.setStyleSheet("color:white;") window.input_Si.setStyleSheet("color:white;") window.input_Comp.setStyleSheet("color:white;") #TimeES buttons window.SpeedTest_PB.setStyleSheet( "#SpeedTest_PB { font: 87 8pt 'Arca Majora 3 Heavy'; background: #656565; border-radius: 5.3px; border: 1px solid #FFFFFF; color:white; } #SpeedTest_PB:hover { border: 1.25px solid #FFFFFF; background: #00bff3; } #SpeedTest_PB:pressed { background: #007392; color:lightgray; }" ) window.Start_PB.setStyleSheet( "#Start_PB { background: #656565; border-radius: 8px; border: 2px solid #FFFFFF; color:white; } #Start_PB:hover { border: 3px solid #FFFFFF; background: #00bff3; } #Start_PB:pressed {background: #007392; color:lightgray;}" ) #TimeES radios window.RB_KBs.setStyleSheet("color:white;") window.RB_MBs.setStyleSheet("color:white;") window.RB_Mbs.setStyleSheet("color:white;") window.RB_MB.setStyleSheet("color:white;") window.RB_GB.setStyleSheet("color:white;") window.RB_TB.setStyleSheet("color:white;") #DataES labels window.label_AvSpD.setStyleSheet("color: white;") window.label_Time_head.setStyleSheet("color: white;") window.label_seconds.setStyleSheet("color:white;") window.label_minutes.setStyleSheet("color:white;") window.label_hours.setStyleSheet("color:white;") window.label_days.setStyleSheet("color:white;") window.label_months.setStyleSheet("color:white;") window.label_years.setStyleSheet("color:white;") window.label_decades.setStyleSheet("color:white;") window.label_centuries.setStyleSheet("color:white;") window.label_ResultD.setStyleSheet("color:#27C499;") #DataES inputs window.input_AvSpD.setStyleSheet("color:white;") window.SPcomboBox.setStyleSheet("color:white;") #DataES spinners window.spinSeconds.setStyleSheet("color:white;") window.spinMinutes.setStyleSheet("color:white;") window.spinHours.setStyleSheet("color:white;") window.spinDays.setStyleSheet("color:white;") window.spinMonths.setStyleSheet("color:white;") window.spinYears.setStyleSheet("color:white;") window.spinDecades.setStyleSheet("color:white;") window.spinCenturies.setStyleSheet("color:white;") #DataES PB window.StartD_PB.setStyleSheet( "#StartD_PB { background: #656565; border-radius: 8px; border: 2px solid #FFFFFF; color:white; } #StartD_PB:hover { border: 3px solid #FFFFFF; /*color:#00bff3;*/ background: #00bff3; } #StartD_PB:pressed { /*border: 3px solid lightgray;*/ background: #007392; color:lightgray; }" ) window.ResetD_PB.setStyleSheet( "#ResetD_PB { font: 87 8pt 'Arca Majora 3 Heavy'; background: #656565; border-radius: 5.3px; border: 1px solid #FFFFFF; color:white; } #ResetD_PB:hover { border: 1.25px solid #FFFFFF; background: #00bff3; } #ResetD_PB:pressed { background: #007392; color:lightgray; }" ) window.SpeedTest_PB_2.setStyleSheet( "#SpeedTest_PB_2 { font: 87 8pt 'Arca Majora 3 Heavy'; background: #656565; border-radius: 5.3px; border: 1px solid #FFFFFF; color:white; } #SpeedTest_PB_2:hover { border: 1.25px solid #FFFFFF; background: #00bff3; } #SpeedTest_PB_2:pressed { background: #007392; color:lightgray; }" ) #savePB window.Save_PB.setStyleSheet( "#Save_PB { font: 87 8pt 'Arca Majora 3 Heavy'; background: #656565; border-radius: 5.3px; border: 1px solid #FFFFFF; color:white; } #Save_PB:hover { border: 1.25px solid #FFFFFF; background: #00bff3; } #Save_PB:pressed { background: #007392; color:lightgray; }" ) #UpdatePB #window.Update_PB.setStyleSheet("#Update_PB { font: 87 8pt 'Arca Majora 3 Heavy'; background: #656565; border-radius: 5.3px; border: 1px solid #FFFFFF; color:white; } #Update_PB:hover { border: 1.25px solid #FFFFFF; background: #00bff3; } #Update_PB:pressed { background: #007392; color:lightgray; }") #scalesettingSpinner window.scaleSpin.setStyleSheet("color:white;") #Restart_label window.Restart_label.setStyleSheet("color:#F1304D;") #set size window.setFixedHeight(190) window.border_bottom.move(0, 187) #load fonts font_status = PyQt5.QtGui.QFontDatabase.addApplicationFont( ':/Font/Files/Fonts/ArcaMajora3-Bold.otf' ) #set font (returns -1 if failed) font_status_2 = PyQt5.QtGui.QFontDatabase.addApplicationFont( ':/Font/Files/Fonts/ArcaMajora3-Heavy.otf') window.label_Er.hide() #Hide Error label window.DMW_label.hide() window.SizeBrowse_PB.hide() #Hide Browse Button (still in dev) #Get App location path for no reason (yet) #print(application_path) #initiate loading animation window.movie = QMovie(":/Animation/Files/Animation/loader.gif") window.loading.setMovie(window.movie) window.loading_2.setMovie(window.movie) window.loading.hide() window.loading_2.hide() window.show() #load theme #fd = QtCore.QFile(":/Themes/Files/Theme/light-blue.qss") #if fd.open(QtCore.QIODevice.ReadOnly | QtCore.QFile.Text): #qss = QtCore.QTextStream(fd).readAll() #fd.close() #app.setStyleSheet(qss) if darkmode == 1: qtmodern.styles.dark(app) mw = qtmodern.windows.ModernWindow(window.DMW_label) #mw.show() #Warning for failed font loading: if font_status == -1 or font_status_2 == -1: QMessageBox.Warning(window, "Font failed to load", "Font failed to load, using default system font") ############ app.exec_()
def LOG_Warning(self, Content): QMessageBox.Warning(self, "Warning", str(Content), QMessageBox.Ok)
def not_connect_dialog(self): QMessageBox.Warning(self, 'Error', 'Please connect first!', QMessageBox.Yes)