python3.7 problem with validation - it doesnt work
alon.najman at gmail.com
alon.najman at gmail.com
Wed Sep 19 08:12:55 EDT 2018
python3.7 problem with validation - it doesn't work.
I added 2 variables to the IF of the validation:
global UserGmail
global PassGmail
here is the code:
import sys
import requests
from lxml import html
import requests
import urllib.request, urllib.error, urllib.parse
import _thread
from PyQt5 import QtCore, QtGui, QtWidgets
import time
import threading
import ctypes # An included library with Python install.
global flag
global loopexit
global UserSymbol
global RadioButtonBellow
global UserSymbol
global UserStockPrice
global RadioButtonAbove
global SMScheckBox
global UserGmail
global PassGmail
UserSymbol=0
RadioButtonBellow=0
RadioButtonAbove=0
UserSymbol=0
UserStockPrice=0
UserGmail=0
PassGmail=0
loopexit=0
def get_quote(str):
url="https://api.iextrading.com/1.0/stock/"+str+"/price"
resource = urllib.request.urlopen(url)
content = resource.read().decode(resource.headers.get_content_charset())
print (content)
content=float(content)
return content
def myfunction():
import paramiko
import sys
global RadioButtonBellow
global UserSymbol
global UserStockPrice
global RadioButtonAbove
global UserGmail
global PassGmail
print(UserGmail+" "+PassGmail)
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.resize(687, 571)
self.radioButton = QtWidgets.QRadioButton(Dialog)
self.radioButton.setGeometry(QtCore.QRect(80, 190, 191, 24))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButton.setFont(font)
self.radioButton.setObjectName("radioButton")
self.buttonGroup_2 = QtWidgets.QButtonGroup(Dialog)
self.buttonGroup_2.setObjectName("buttonGroup_2")
self.buttonGroup_2.addButton(self.radioButton)
self.checkBox = QtWidgets.QCheckBox(Dialog)
self.checkBox.setGeometry(QtCore.QRect(290, 450, 131, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.checkBox.setFont(font)
self.checkBox.setObjectName("checkBox")
self.checkBox_2 = QtWidgets.QCheckBox(Dialog)
self.checkBox_2.setGeometry(QtCore.QRect(290, 480, 141, 17))
font = QtGui.QFont()
font.setPointSize(14)
self.checkBox_2.setFont(font)
self.checkBox_2.setObjectName("checkBox_2")
self.radioButton_2 = QtWidgets.QRadioButton(Dialog)
self.radioButton_2.setGeometry(QtCore.QRect(300, 190, 186, 24))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButton_2.setFont(font)
self.radioButton_2.setObjectName("radioButton_2")
self.buttonGroup_2.addButton(self.radioButton_2)
self.pushButton = QtWidgets.QPushButton(Dialog)
self.pushButton.setEnabled(True)
self.pushButton.setGeometry(QtCore.QRect(60, 460, 72, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.pushButton.setFont(font)
self.pushButton.setObjectName("pushButton")
self.radioButton_3 = QtWidgets.QRadioButton(Dialog)
self.radioButton_3.setGeometry(QtCore.QRect(80, 250, 191, 24))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButton_3.setFont(font)
self.radioButton_3.setObjectName("radioButton_3")
self.buttonGroup = QtWidgets.QButtonGroup(Dialog)
self.buttonGroup.setObjectName("buttonGroup")
self.buttonGroup.addButton(self.radioButton_3)
self.radioButton_4 = QtWidgets.QRadioButton(Dialog)
self.radioButton_4.setGeometry(QtCore.QRect(300, 250, 186, 24))
font = QtGui.QFont()
font.setPointSize(14)
self.radioButton_4.setFont(font)
self.radioButton_4.setObjectName("radioButton_4")
self.buttonGroup.addButton(self.radioButton_4)
self.pushButton_2 = QtWidgets.QPushButton(Dialog)
self.pushButton_2.setGeometry(QtCore.QRect(30, 20, 75, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.pushButton_2.setFont(font)
self.pushButton_2.setObjectName("pushButton_2")
self.textEdit_4 = QtWidgets.QTextEdit(Dialog)
self.textEdit_4.setGeometry(QtCore.QRect(310, 383, 221, 38))
font = QtGui.QFont()
font.setPointSize(16)
self.textEdit_4.setFont(font)
self.textEdit_4.setObjectName("textEdit_4")
self.textEdit_5 = QtWidgets.QTextEdit(Dialog)
self.textEdit_5.setGeometry(QtCore.QRect(310, 340, 221, 38))
font = QtGui.QFont()
font.setPointSize(16)
self.textEdit_5.setFont(font)
self.textEdit_5.setObjectName("textEdit_5")
self.label = QtWidgets.QLabel(Dialog)
self.label.setGeometry(QtCore.QRect(150, 80, 111, 16))
font = QtGui.QFont()
font.setPointSize(14)
self.label.setFont(font)
self.label.setObjectName("label")
self.label_2 = QtWidgets.QLabel(Dialog)
self.label_2.setGeometry(QtCore.QRect(410, 80, 131, 16))
font = QtGui.QFont()
font.setPointSize(14)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.label_3 = QtWidgets.QLabel(Dialog)
self.label_3.setGeometry(QtCore.QRect(160, 350, 121, 20))
font = QtGui.QFont()
font.setPointSize(14)
self.label_3.setFont(font)
self.label_3.setObjectName("label_3")
self.label_4 = QtWidgets.QLabel(Dialog)
self.label_4.setGeometry(QtCore.QRect(140, 390, 171, 20))
font = QtGui.QFont()
font.setPointSize(14)
self.label_4.setFont(font)
self.label_4.setObjectName("label_4")
self.label_5 = QtWidgets.QLabel(Dialog)
self.label_5.setGeometry(QtCore.QRect(170, 30, 351, 31))
font = QtGui.QFont()
font.setFamily("Arial")
font.setPointSize(18)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.pushButton_3 = QtWidgets.QPushButton(Dialog)
self.pushButton_3.setGeometry(QtCore.QRect(150, 460, 72, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.pushButton_3.setFont(font)
self.pushButton_3.setObjectName("pushButton_3")
self.textEdit = QtWidgets.QTextEdit(Dialog)
self.textEdit.setGeometry(QtCore.QRect(80, 110, 221, 38))
font = QtGui.QFont()
font.setPointSize(16)
self.textEdit.setFont(font)
self.textEdit.setObjectName("textEdit")
self.textEdit_7 = QtWidgets.QTextEdit(Dialog)
self.textEdit_7.setGeometry(QtCore.QRect(330, 110, 221, 38))
font = QtGui.QFont()
font.setPointSize(16)
self.textEdit_7.setFont(font)
self.textEdit_7.setObjectName("textEdit_7")
self.minimize = QtWidgets.QPushButton(Dialog)
self.minimize.setGeometry(QtCore.QRect(564, 20, 91, 31))
font = QtGui.QFont()
font.setPointSize(14)
self.minimize.setFont(font)
self.minimize.setObjectName("minimize")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.pushButton.clicked.connect(self.printMessage)
self.radioButton.toggled.connect(self.myradioButton1_function)
self.radioButton_2.toggled.connect(self.myradioButton2_function)
self.pushButton_3.clicked.connect(self.stopButton)
self.checkBox.stateChanged.connect(self.SMScheckBox)
self.minimize.clicked.connect(self.Minimize)
def Minimize(self):
import win32gui, win32con
import os
import math
import time
time.sleep(2)
Minimize = win32gui.GetForegroundWindow()
win32gui.ShowWindow(Minimize, win32con.SW_MINIMIZE)
def SMScheckBox(self):
global SMScheckBox
if self.checkBox.isChecked()==True:
print("hi checkbox")
else:
print("no")
def myradioButton1_function(self):
global RadioButtonAbove
if self.radioButton.isChecked():
print ('Above is Checked')
RadioButtonAbove=self.radioButton.isChecked()
RadioButtonBellow=self.radioButton_2.isChecked()
self.pushButton.setDisabled(False)
def myradioButton2_function(self):
global RadioButtonBellow
if self.radioButton_2.isChecked():
print ('Bellow is Checked')
RadioButtonBellow=self.radioButton_2.isChecked()
RadioButtonAbove=self.radioButton.isChecked()
self.pushButton.setDisabled(False)
def printMessage(self):
global UserSymbol
global UserStockPrice
global RadioButtonBellow
global RadioButtonAbove
global UserGmail
global PassGmail
UserSymbol=self.textEdit.toPlainText()
UserSymbol=UserSymbol[0:4]
UserStockPrice=self.textEdit_7.toPlainText()
UserGmail=self.textEdit_5.toPlainText()
PassGmail=self.textEdit_4.toPlainText()
#here is the IF of the validation!
if PassGmail==0 or UserGmail==0 or UserSymbol==0 or UserStockPrice==0 or (RadioButtonAbove==0 and RadioButtonBellow==0):
def Mbox(title, text, style):
return ctypes.windll.user32.MessageBoxW(0, text, title, style)
Mbox('you need to enter all data first', 'you need to choose Stock value,price,bellow/above price', 1 )
else:
UserStockPrice=float(UserStockPrice)
UserSymbol=str(UserSymbol)
t = threading.Thread(target=myfunction)
t.start()
def stopButton(self):
global loopexit
loopexit=1
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
self.radioButton.setText(_translate("Dialog", "Above Price (x>)"))
self.checkBox.setText(_translate("Dialog", "SMS ALERT"))
self.checkBox_2.setText(_translate("Dialog", "GMAIL ALERT"))
self.radioButton_2.setText(_translate("Dialog", "Bellow Price (x<)"))
self.pushButton.setText(_translate("Dialog", "START"))
self.radioButton_3.setText(_translate("Dialog", "get alert once a day"))
self.radioButton_4.setText(_translate("Dialog", "get alert every time"))
self.pushButton_2.setText(_translate("Dialog", "EXIT"))
self.textEdit_4.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:16pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.textEdit_5.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:16pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.label.setText(_translate("Dialog", "SYMBOL:"))
self.label_2.setText(_translate("Dialog", "PRICE :"))
self.label_3.setText(_translate("Dialog", "User of Gmail:"))
self.label_4.setText(_translate("Dialog", "Password of Gmail:"))
self.label_5.setText(_translate("Dialog", "ALON STOCK MARKET APP"))
self.pushButton_3.setText(_translate("Dialog", "STOP"))
self.textEdit.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:16pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.textEdit_7.setHtml(_translate("Dialog", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:16pt; font-weight:400; font-style:normal;\">\n"
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
self.minimize.setText(_translate("Dialog", "Minimize"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
Dialog = QtWidgets.QDialog()
ui = Ui_Dialog()
ui.setupUi(Dialog)
Dialog.show()
sys.exit(app.exec_())
More information about the Python-list
mailing list