Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.90 KB | None | 0 0
  1.  
  2.  
  3. #import library
  4. from appJar import gui
  5.  
  6. #create gui variable called app
  7. app = gui("Login Form")
  8.  
  9. #add widgets
  10. app.addLabel("title", "Welcome to RapidWear")
  11. app.setLabelBg("title", "teal")
  12. app.setLabelFg("title", "pink")
  13. app.setFont(20)
  14.  
  15. #add username and password
  16. app.addLabelEntry("Username:")
  17. app.addLabelSecretEntry("Password:")
  18.  
  19. #login function
  20. def press(button):
  21. if button == "Cancel":
  22. app.stop()
  23.  
  24. if app.getEntry("Username:") == "middy":
  25. if app.getEntry("Password:") == "hello":
  26. app.infoBox("Success", "Congratulations, you are logged in!")
  27. else:
  28. app.errorBox("Failed login.", "Invalid password.")
  29. else:
  30. app.errorBox("Failed login.", "Invalid username.")
  31. app.addSecretEntry("Password:")
  32.  
  33. #add buttons
  34. app.addButtons(["Submit", "Cancel"],press)
  35.  
  36. #start cursor off at username
  37. app.setFocus("Username:")
  38.  
  39. #start gui
  40. app.go()
  41.  
  42. Success = True
  43. open
  44.  
  45. import pandas
  46. import requests, json
  47. import random
  48.  
  49.  
  50. def sort(btn):
  51. topsdf = pandas.read_csv("Tops.csv")
  52. bottomsdf = pandas.read_csv("Bottoms.csv")
  53. shoesdf= pandas.read_csv("Shoes.csv")
  54. if btn== "Sort Weather":
  55. findweather= app.stringBox("Sort,", "Would you like to sort by warm or cold weather?")
  56. sorttopweather = topsdf[(topsdf.Weather== findweather)].TOPS
  57. sorttopweather1 = sorttopweather.tolist()
  58. sortbottomweather= bottomsdf[(bottomsdf.Weather == findweather)].BOTTOMS
  59. sortbottomweather1= sortbottomweather.tolist()
  60. sortshoesweather= shoesdf[(shoesdf.Weather == findweather)].SHOES
  61. sortshoesweather1= sortshoesweather.tolist()
  62.  
  63. app.startSubWindow("Weather", modal=True)
  64. app.showSubWindow("Weather")
  65. app.addLabel("l1", "Weather")
  66. app.addListBox("Sort Weather",[sorttopweather1, sortbottomweather1, sortshoesweather1])
  67. app.stopLabelFrame()
  68.  
  69. app.stopSubWindow()
  70.  
  71. elif btn == "Sort Color":
  72.  
  73. findcolor= app.stringBox("Sort,", "Would you like to sort by bright or muted colors?")
  74. sorttopcolor = topsdf[(topsdf.Color== findcolor)].TOPS
  75. sorttopcolor1 = sorttopcolor.tolist()
  76. sortbottomcolor= bottomsdf[(bottomsdf.Color == findcolor)].BOTTOMS
  77. sortbottomcolor1= sortbottomcolor.tolist()
  78. sortshoescolor= shoesdf[(shoesdf.Color == findcolor)].SHOES
  79. sortshoescolor1= sortshoescolor.tolist()
  80. app.startSubWindow("Color", modal=True)
  81. app.showSubWindow("Color")
  82. app.addLabel("l2", "Color")
  83.  
  84. app.addListBox("Sort Color",[sorttopcolor1, sortbottomcolor1, sortshoescolor1])
  85. app.stopLabelFrame()
  86.  
  87. app.stopSubWindow()
  88.  
  89. elif btn == "Sort Occasion":
  90.  
  91. findoca= app.stringBox("Sort,", "Would you like to sort by formal or informal?")
  92. sorttopoca = topsdf[(topsdf.Occasion== findoca)].TOPS
  93. sorttopoca1 = sorttopoca.tolist()
  94. sortbottomoca= bottomsdf[(bottomsdf.Occasion == findoca)].BOTTOMS
  95. sortbottomoca1= sortbottomoca.tolist()
  96. sortshoesoca= shoesdf[(shoesdf.Occasion == findoca)].SHOES
  97. sortshoesoca1= sortshoesoca.tolist()
  98. app.startSubWindow("Occasion", modal=True)
  99. app.showSubWindow("Occasion")
  100. app.addLabel("l3", "Occasion")
  101. app.addListBox("Sort Occasion",[sorttopoca1, sortbottomoca1, sortshoesoca1])
  102. app.stopSubWindow()
  103.  
  104. elif btn == "Sort Tops":
  105. app.startSubWindow("Tops", modal=True)
  106. app.showSubWindow("Tops")
  107. app.addLabel("l4", "Tops")
  108. topsdf = pandas.read_csv("Tops.csv")
  109. sort_tops = topsdf.TOPS
  110. sort_tops1= sort_tops.tolist()
  111. app.addListBox("Tops",sort_tops1)
  112. app.stopSubWindow()
  113.  
  114. elif btn == "Sort Bottoms":
  115. app.startSubWindow("Bottoms", modal=True)
  116. app.showSubWindow("Bottoms")
  117. app.addLabel("l5", "Bottoms")
  118. bottomsdf = pandas.read_csv("Bottoms.csv")
  119. sort_bottoms = bottomsdf.BOTTOMS
  120. sort_bottoms1= sort_bottoms.tolist()
  121. app.addListBox("Bottoms",sort_bottoms1)
  122. app.stopSubWindow()
  123.  
  124. elif btn == "Sort Shoes":
  125. app.startSubWindow("Shoes", modal=True)
  126. app.showSubWindow("Shoes")
  127. app.addLabel("l6", "Shoes")
  128. shoesdf = pandas.read_csv("Shoes.csv")
  129. sort_shoes = shoesdf.SHOES
  130. sort_shoes1= sort_shoes.tolist()
  131. app.addListBox("Shoes",sort_shoes1)
  132. app.stopSubWindow()
  133. def press(btn):
  134. if btn == "Exit":
  135. app.stop()
  136.  
  137. elif btn == "Today":
  138.  
  139. app.startSubWindow("Condition", modal=True)
  140. app.addLabel("l1", "Conditions")
  141. app.startLabelFrame("Today", 0, 0)
  142. api_key = "eba1bb6ae19da64736fd227b51d5e9dd"
  143. base_url = "http://api.openweathermap.org/data/2.5/weather?"
  144. city_name = app.stringBox("City", "What city do you need the weather for?")
  145. complete_url = base_url + "appid=" + api_key + "&q=" + city_name
  146. response = requests.get(complete_url)
  147. x = response.json()
  148. y = x["main"]
  149. current_temperature = y["temp"]
  150. current_pressure = y["pressure"]
  151. current_humidity = y["humidity"]
  152. z = x["weather"]
  153. weather_description = z[0]["description"]
  154. K = float(current_temperature)
  155. ftemp= (9/5)*(K - 273) + 32
  156. app.infoBox("l4",( ftemp, "pressure is ", current_pressure,"percent humidity = ", \
  157. current_humidity,"weather conditions are ",weather_description))
  158.  
  159. app.stopLabelFrame()
  160. app.stopSubWindow()
  161.  
  162. elif btn == "Inventory":
  163.  
  164. app.addButtons(["Sort Tops", "Sort Bottoms","Sort Shoes"], sort)
  165. app.addButtons(["Sort Weather","Sort Color","Sort Occasion"], sort)
  166.  
  167.  
  168. elif btn == "Random Outfit":
  169.  
  170. findweather = app.stringBox("Weather","Is it cold or warm?")
  171. findcolor= app.stringBox("Color", "Do you want bright colors or muted colors?")
  172. findoccasion= app.stringBox("Occasion", "Should the clothing be formal or informal?")
  173. findprice= app.stringBox("Price","Do you want to wear your expensive clothes or your cheaper clothes?")
  174. findcomfort= app.stringBox("Comfort","Comfortable or uncomfortable?")
  175.  
  176.  
  177.  
  178. topsdf = pandas.read_csv("Tops.csv")
  179. bottomsdf = pandas.read_csv("Bottoms.csv")
  180. shoesdf= pandas.read_csv("Shoes.csv")
  181.  
  182. pot_tops = topsdf[(topsdf.Weather== findweather) & (topsdf.Color== findcolor) & (topsdf.Occasion== findoccasion) &(topsdf.Price== findprice) & (topsdf.Comfort== findcomfort)].TOPS
  183. pot_bottoms = bottomsdf[(bottomsdf.Weather== findweather) & (bottomsdf.Color== findcolor) & (bottomsdf.Occasion== findoccasion) & (bottomsdf.Price== findprice) & (bottomsdf.Comfort== findcomfort)].BOTTOMS
  184. pot_shoes = shoesdf[(shoesdf.Weather== findweather) & (shoesdf.Color== findcolor) & (shoesdf.Occasion== findoccasion) & (shoesdf.Price== findprice) & (shoesdf.Comfort== findcomfort)].SHOES
  185.  
  186. pot_tops1 = pot_tops.tolist()
  187. pot_bottoms1= pot_bottoms.tolist()
  188. pot_shoes1=pot_shoes.tolist()
  189.  
  190. answertop= (random.choice(pot_tops1))
  191. answerbottom= (random.choice(pot_bottoms1))
  192. answershoes= (random.choice(pot_shoes1))
  193.  
  194. app.infoBox("Your top is ",answertop)
  195. app.infoBox("Your bottom is ",answerbottom)
  196. app.infoBox("Your shoes are ",answershoes)
  197.  
  198. elif btn == "Upload":
  199.  
  200. topsdf = pandas.read_csv("Tops.csv")
  201. bottomsdf = pandas.read_csv("Bottoms.csv")
  202. shoesdf= pandas.read_csv("Shoes.csv")
  203. clothingchoice = app.stringBox("Clothing Type", "Is the item a top, bottom, or shoes?")
  204. name= app.stringBox("Item Name", "What is the name of the item?")
  205. weather = app.stringBox("Weather","Is it cold or warm?")
  206. color= app.stringBox("Color", "Do you want bright colors or muted colors?")
  207. occasion= app.stringBox("Occasion", "Should the clothing be formal or informal?")
  208. price= app.stringBox("Price","Do you want to wear your expensive clothes or your cheaper clothes?")
  209. comfort= app.stringBox("Comfort","Comfortable or uncomfortable?")
  210. if clothingchoice == "top":
  211. uploadedtop = topsdf.append({'TOPS': name,'Weather': weather, 'Color': color, 'Occasion':occasion, 'Price':price, 'Comfort':comfort}, ignore_index=True)
  212. uploadedtop.to_csv("Tops.csv", index=False)
  213. app.infoBox("Complete", "Your item has been added!")
  214. elif clothingchoice =="bottom":
  215. uploadedbottom = bottomsdf.append({'Weather': weather, 'Color': color, 'Occasion':occasion, 'Price':price, 'Comfort':comfort}, ignore_index=True)
  216. uploadedbottom.to_csv("Bottoms.csv", index=False)
  217. app.infoBox("Complete", "Your item has been added!")
  218. elif clothingchoice == "shoes":
  219. uploadedshoes = shoesdf.append({'TOPS': name, 'Weather': weather, 'Color': color, 'Occasion':occasion, 'Price':price, 'Comfort':comfort}, ignore_index=True)
  220. uploadedshoes.to_csv("Shoes.csv", index=False)
  221. app.infoBox("Complete", "Your item has been added!")
  222. else:
  223. app.infoBox("Error","Please pick either top, bottom, or shoes.")
  224.  
  225.  
  226. else:
  227. print('Pick a valid option')
  228.  
  229.  
  230. app=gui("Main Menu","1200x620")
  231. app.showSplash("RapidWear", fill='grey', stripe='black', fg='white', font=44)
  232. app.addLabel("title", "Welcome to the csv Main Menu")
  233. app.setLabelBg("title", "orange")
  234. app.setFont(18)
  235. # 3 buttons, each calling the same function
  236. app.addButton("Inventory", press)
  237. app.addButton("Upload", press)
  238. app.addButton("Random Outfit", press)
  239. app.addButton("Today", press)
  240. app.addButton("Exit",press)
  241.  
  242. app.go()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement