Guest User

Untitled

a guest
Nov 5th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.15 KB | None | 0 0
  1. import os
  2. import json
  3. import sys
  4. from PySide import QtCore, QtGui
  5. from home import Ui_Home #imports template of splash screen
  6. from logIn import Ui_LogIn #imports template of login screen
  7. from secondWindow import Ui_Dialog #imports template of orderscreen
  8. from settings import Ui_Settings
  9.  
  10.  
  11.  
  12.  
  13. class home(QtGui.QMainWindow, Ui_Home):
  14. def __init__(self, parent = None): #handles all functions and properties that occur at startup, and object events
  15. super(home, self).__init__(parent)
  16. self.setupUi(self)
  17. global admin
  18. if admin == True:
  19. self.actionSettings.setEnabled(True)
  20. self.btnEnter.clicked.connect(self.openSecondWindow)
  21. self.actionSettings.triggered.connect(self.settingsWindow)
  22. self.btnLogOut.clicked.connect(self.returnLogin)
  23.  
  24. def openSecondWindow(self):
  25. self.sWindow = secondWindow()
  26. self.sWindow.show()
  27. self.hide()
  28.  
  29. def settingsWindow(self):
  30. self.setWindow = settings()
  31. self.setWindow.show()
  32.  
  33.  
  34. def returnLogin(self):
  35. self.logIn= logIn()
  36. self.log.show()
  37. self.close()
  38.  
  39. class logIn(QtGui.QMainWindow, Ui_LogIn):
  40. def __init__(self):
  41. super(logIn, self).__init__()
  42. self.setupUi(self)
  43.  
  44. self.btnLogin.clicked.connect(self.openHome)
  45.  
  46. def userPass(self):
  47. users = {"admin":"root", "Josh123":"password"}
  48. ## counter = 3
  49. if self.userEntry.text() in users and self.passEntry.text() == users[self.userEntry.text()]:
  50. if self.userEntry.text() == "admin":
  51. global admin
  52. admin = True
  53. return True
  54. else:
  55. global admin
  56. admin = False
  57. return True
  58. else:
  59. self.textEdit.setPlainText("Incorrect username or password.")
  60. ## counter -= 1
  61.  
  62. def openHome(self):
  63. userPass = self.userPass()
  64. if userPass == True:
  65. print(admin)
  66. self.home = home(self)
  67. self.home.show()
  68. self.hide()
  69.  
  70. else:
  71. print("Login Failed")
  72.  
  73.  
  74. class secondWindow(QtGui.QDialog, Ui_Dialog):
  75. def __init__(self):
  76. super(secondWindow, self).__init__()
  77. self.setupUi(self)
  78. self.btnBack.clicked.connect(self.returnHome)
  79. self.btnCheckPrice.clicked.connect(self.calculate)
  80.  
  81.  
  82. def returnHome(self):
  83. self.home = home()
  84. self.home.show()
  85. self.close()
  86.  
  87. def calculate(self):
  88.  
  89. try:
  90. width = float(self.widEntry.text())
  91. height = float(self.heiEntry.text())
  92. area = width * height
  93. fee = float(self.feeEntered.text())
  94. sinSel = 0.01
  95. douSel = 0.02
  96. tinSel = 0.005
  97. if self.sinSel.isChecked() == True:
  98. cost = fee + (area * sinSel)
  99. self.totCost.setPlainText('$' + str(round(cost ,2)))
  100. elif self.douSel.isChecked() == True:
  101. cost = fee + (area * douSel)
  102. self.totCost.setPlainText('$' + str(round(cost ,2)))
  103. elif self.tinSel.isChecked() == True:
  104. cost = fee + (area * tinSel)
  105. self.totCost.setPlainText('$' + str(round(cost,2)))
  106. elif self.tinSel.isChecked() == False and self.douSel.isChecked() == False and self.sinSel.isChecked() == False:
  107. print("Please select a window type.")
  108. except ValueError:
  109. if len(self.widEntry.text()) == 0 or len(self.heiEntry.text()) == 0:
  110. print("No entry in width or height.")
  111. else:
  112. print("Characters and symbols not accepted. Please enter valid numbers.")
  113.  
  114. def order(self):
  115. perOrder = self.userEntry.text()
  116. sing = {}
  117. dou = {}
  118. tin = {}
  119. order = {}
  120. try:
  121. width = float(self.widEntry.text())
  122. height = float(self.heiEntry.text())
  123. area = width * height
  124. fee = float(self.feeEntered.text())
  125. sinSel = 0.01
  126. douSel = 0.02
  127. tinSel = 0.005
  128. if self.sinSel.isChecked() == True:
  129. cost = fee + (area * sinSel)
  130. self.totCost.setPlainText('$' + str(round(cost ,2)))
  131.  
  132. elif self.douSel.isChecked() == True:
  133. cost = fee + (area * douSel)
  134. self.totCost.setPlainText('$' + str(round(cost ,2)))
  135. elif self.tinSel.isChecked() == True:
  136. cost = fee + (area * tinSel)
  137. self.totCost.setPlainText('$' + str(round(cost,2)))
  138. elif self.tinSel.isChecked() == False and self.douSel.isChecked() == False and self.sinSel.isChecked() == False:
  139. print("Please select a window type.")
  140. except ValueError:
  141. if len(self.widEntry.text()) == 0 or len(self.heiEntry.text()) == 0:
  142. print("No entry in width or height.")
  143. else:
  144. print("Characters and symbols not accepted. Please enter valid numbers.")
  145.  
  146.  
  147.  
  148. class settings(QtGui.QMainWindow, Ui_Settings):
  149. def __init__(self, parent = None):
  150. super(settings, self).__init__(parent)
  151. self.setupUi(self)
  152. self.btnApply.clicked.connect(self.applyChanges)
  153.  
  154. def applyChanges(self):
  155. with open('settings.txt', 'r') as f:
  156. data = json.load(f)
  157.  
  158. serValue = str(self.change_ServiceText.text())
  159. data['serviceFee'] = serValue
  160. with open('settings.txt', 'w') as f:
  161. json.dump(data, f)
  162.  
  163.  
  164.  
  165. if __name__ == "__main__":
  166. app = QtGui.QApplication(sys.argv)
  167. logIn = logIn()
  168. logIn.show()
  169. sys.exit(app.exec_())
  170.  
  171. from PySide import QtCore, QtGui
  172.  
  173. class Ui_LogIn(object):
  174. def setupUi(self, LogIn):
  175. LogIn.setObjectName("LogIn")
  176. LogIn.resize(400, 300)
  177. LogIn.setMinimumSize(QtCore.QSize(400, 300))
  178. LogIn.setMaximumSize(QtCore.QSize(400, 300))
  179. self.formLayoutWidget = QtGui.QWidget(LogIn)
  180. self.formLayoutWidget.setGeometry(QtCore.QRect(10, 100, 371, 71))
  181. self.formLayoutWidget.setObjectName("formLayoutWidget")
  182. self.container = QtGui.QFormLayout(self.formLayoutWidget)
  183. self.container.setContentsMargins(0, 0, 0, 0)
  184. self.container.setObjectName("container")
  185. self.userLbl = QtGui.QLabel(self.formLayoutWidget)
  186. font = QtGui.QFont()
  187. font.setPointSize(10)
  188. font.setWeight(75)
  189. font.setBold(True)
  190. self.userLbl.setFont(font)
  191. self.userLbl.setObjectName("userLbl")
  192. self.container.setWidget(0, QtGui.QFormLayout.LabelRole, self.userLbl)
  193. self.userEntry = QtGui.QLineEdit(self.formLayoutWidget)
  194. self.userEntry.setObjectName("userEntry")
  195. self.container.setWidget(0, QtGui.QFormLayout.FieldRole, self.userEntry)
  196. spacerItem = QtGui.QSpacerItem(20, 10, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
  197. self.container.setItem(1, QtGui.QFormLayout.FieldRole, spacerItem)
  198. self.lblPass = QtGui.QLabel(self.formLayoutWidget)
  199. font = QtGui.QFont()
  200. font.setPointSize(10)
  201. font.setWeight(75)
  202. font.setBold(True)
  203. self.lblPass.setFont(font)
  204. self.lblPass.setObjectName("lblPass")
  205. self.container.setWidget(2, QtGui.QFormLayout.LabelRole, self.lblPass)
  206. self.passEntry = QtGui.QLineEdit(self.formLayoutWidget)
  207. self.passEntry.setObjectName("passEntry")
  208. self.passEntry.setEchoMode(QtGui.QLineEdit.EchoMode.Password)
  209. self.container.setWidget(2, QtGui.QFormLayout.FieldRole, self.passEntry)
  210. self.textEdit = QtGui.QTextEdit(LogIn)
  211. self.textEdit.setGeometry(QtCore.QRect(10, 200, 371, 31))
  212. self.textEdit.setObjectName("textEdit")
  213. self.textEdit.setReadOnly(True)
  214. self.btnLogin = QtGui.QPushButton(LogIn)
  215. self.btnLogin.setGeometry(QtCore.QRect(310, 240, 75, 23))
  216. self.btnLogin.setObjectName("btnLogin")
  217. self.label = QtGui.QLabel(LogIn)
  218. self.label.setGeometry(QtCore.QRect(110, 10, 161, 81))
  219. font = QtGui.QFont()
  220. font.setPointSize(18)
  221. font.setWeight(75)
  222. font.setUnderline(True)
  223. font.setStrikeOut(False)
  224. font.setBold(True)
  225. self.label.setFont(font)
  226. self.label.setObjectName("label")
  227.  
  228. self.retranslateUi(LogIn)
  229. QtCore.QMetaObject.connectSlotsByName(LogIn)
  230.  
  231. def retranslateUi(self, LogIn):
  232. LogIn.setWindowTitle(QtGui.QApplication.translate("LogIn", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
  233. self.userLbl.setText(QtGui.QApplication.translate("LogIn", "Username:", None, QtGui.QApplication.UnicodeUTF8))
  234. self.lblPass.setText(QtGui.QApplication.translate("LogIn", "Password:", None, QtGui.QApplication.UnicodeUTF8))
  235. self.btnLogin.setText(QtGui.QApplication.translate("LogIn", "Login", None, QtGui.QApplication.UnicodeUTF8))
  236. self.label.setText(QtGui.QApplication.translate("LogIn", "System Login", None, QtGui.QApplication.UnicodeUTF8))
  237.  
  238.  
  239. if __name__ == "__main__":
  240. import sys
  241. app = QtGui.QApplication(sys.argv)
  242. LogIn = QtGui.QDialog()
  243. ui = Ui_LogIn()
  244. ui.setupUi(LogIn)
  245. LogIn.show()
  246. sys.exit(app.exec_())
  247.  
  248. from PySide import QtCore, QtGui
  249.  
  250. class Ui_Home(object):
  251. def setupUi(self, Home):
  252. Home.setObjectName("Home")
  253. Home.resize(700, 300)
  254. Home.setMinimumSize(QtCore.QSize(700, 300))
  255. Home.setMaximumSize(QtCore.QSize(700, 300))
  256. self.centralwidget = QtGui.QWidget(Home)
  257. self.centralwidget.setObjectName("centralwidget")
  258. self.lblTitle = QtGui.QLabel(self.centralwidget)
  259. self.lblTitle.setGeometry(QtCore.QRect(60, 10, 591, 71))
  260. font = QtGui.QFont()
  261. font.setPointSize(48)
  262. font.setWeight(75)
  263. font.setUnderline(True)
  264. font.setBold(True)
  265. self.lblTitle.setFont(font)
  266. self.lblTitle.setObjectName("lblTitle")
  267. self.introMessage = QtGui.QTextBrowser(self.centralwidget)
  268. self.introMessage.setGeometry(QtCore.QRect(60, 90, 591, 71))
  269. self.introMessage.setObjectName("introMessage")
  270. self.horizontalLayoutWidget = QtGui.QWidget(self.centralwidget)
  271. self.horizontalLayoutWidget.setGeometry(QtCore.QRect(60, 160, 591, 80))
  272. self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
  273. self.horizontalLayout = QtGui.QHBoxLayout(self.horizontalLayoutWidget)
  274. self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
  275. self.horizontalLayout.setObjectName("horizontalLayout")
  276. self.btnEnter = QtGui.QPushButton(self.horizontalLayoutWidget)
  277. self.btnEnter.setObjectName("btnEnter")
  278. self.horizontalLayout.addWidget(self.btnEnter)
  279.  
  280. self.btnCheck = QtGui.QPushButton(self.horizontalLayoutWidget)
  281. self.btnCheck.setObjectName("btnCheck")
  282. self.horizontalLayout.addWidget(self.btnCheck)
  283.  
  284.  
  285.  
  286. self.btnAbout = QtGui.QPushButton(self.horizontalLayoutWidget)
  287. self.btnAbout.setObjectName("btnAbout")
  288. self.horizontalLayout.addWidget(self.btnAbout)
  289. Home.setCentralWidget(self.centralwidget)
  290.  
  291. self.btnLogOut = QtGui.QPushButton(self.horizontalLayoutWidget)
  292. self.btnLogOut.setObjectName("btnLogOut")
  293. self.horizontalLayout.addWidget(self.btnLogOut)
  294.  
  295. self.menubar = QtGui.QMenuBar(Home)
  296. self.menubar.setGeometry(QtCore.QRect(0, 0, 700, 21))
  297. self.menubar.setObjectName("menubar")
  298. self.menuFile = QtGui.QMenu(self.menubar)
  299. self.menuFile.setObjectName("menuFile")
  300. Home.setMenuBar(self.menubar)
  301. self.statusbar = QtGui.QStatusBar(Home)
  302. self.statusbar.setObjectName("statusbar")
  303. Home.setStatusBar(self.statusbar)
  304. self.actionSettings = QtGui.QAction(Home)
  305. self.actionSettings.setObjectName("actionSettings")
  306. self.actionSettings.setEnabled(False)
  307. self.menuFile.addAction(self.actionSettings)
  308. self.menubar.addAction(self.menuFile.menuAction())
  309.  
  310. self.retranslateUi(Home)
  311. QtCore.QMetaObject.connectSlotsByName(Home)
  312.  
  313. def retranslateUi(self, Home):
  314. Home.setWindowTitle(QtGui.QApplication.translate("Home", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
  315. self.lblTitle.setText(QtGui.QApplication.translate("Home", "Wendy's Windows", None, QtGui.QApplication.UnicodeUTF8))
  316. self.introMessage.setHtml(QtGui.QApplication.translate("Home", "<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">n"
  317. "<html><head><meta name="qrichtext" content="1" /><style type="text/css">n"
  318. "p, li { white-space: pre-wrap; }n"
  319. "</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">n"
  320. "<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Welcome to Wendy's Windows home to all your window needs, to start a new order click 'New Order' , to check your existing order please click 'Check Order', or to learn more about Wendy's and current prices please click 'About'. </p>n"
  321. "<p align="center" 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>n"
  322. "<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Thank you for shopping with Wendy's!</p></body></html>", None, QtGui.QApplication.UnicodeUTF8))
  323. self.btnEnter.setText(QtGui.QApplication.translate("Home", "New Order", None, QtGui.QApplication.UnicodeUTF8))
  324. self.btnCheck.setText(QtGui.QApplication.translate("Home", "Check Order", None, QtGui.QApplication.UnicodeUTF8))
  325. self.btnAbout.setText(QtGui.QApplication.translate("Home", "About", None, QtGui.QApplication.UnicodeUTF8))
  326. self.btnLogOut.setText(QtGui.QApplication.translate("Home", "Log Out", None, QtGui.QApplication.UnicodeUTF8))
  327. self.menuFile.setTitle(QtGui.QApplication.translate("Home", "File", None, QtGui.QApplication.UnicodeUTF8))
  328. self.actionSettings.setText(QtGui.QApplication.translate("Home", "Settings", None, QtGui.QApplication.UnicodeUTF8))
  329.  
  330.  
  331. if __name__ == "__main__":
  332. import sys
  333. app = QtGui.QApplication(sys.argv)
  334. Home = QtGui.QMainWindow()
  335. ui = Ui_Home()
  336. ui.setupUi(Home)
  337. Home.show()
  338. sys.exit(app.exec_())
Add Comment
Please, Sign In to add comment