Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #import library
- from appJar import gui
- #create gui variable called app
- app = gui("Login Form")
- #add widgets
- app.addLabel("title", "Welcome to RapidWear")
- app.setLabelBg("title", "teal")
- app.setLabelFg("title", "pink")
- app.setFont(20)
- #add username and password
- app.addLabelEntry("Username:")
- app.addLabelSecretEntry("Password:")
- #login function
- def press(button):
- if button == "Cancel":
- app.stop()
- if app.getEntry("Username:") == "middy":
- if app.getEntry("Password:") == "hello":
- app.infoBox("Success", "Congratulations, you are logged in!")
- else:
- app.errorBox("Failed login.", "Invalid password.")
- else:
- app.errorBox("Failed login.", "Invalid username.")
- app.addSecretEntry("Password:")
- #add buttons
- app.addButtons(["Submit", "Cancel"],press)
- #start cursor off at username
- app.setFocus("Username:")
- #start gui
- app.go()
- Success = True
- open
- import pandas
- import requests, json
- import random
- def sort(btn):
- topsdf = pandas.read_csv("Tops.csv")
- bottomsdf = pandas.read_csv("Bottoms.csv")
- shoesdf= pandas.read_csv("Shoes.csv")
- if btn== "Sort Weather":
- findweather= app.stringBox("Sort,", "Would you like to sort by warm or cold weather?")
- sorttopweather = topsdf[(topsdf.Weather== findweather)].TOPS
- sorttopweather1 = sorttopweather.tolist()
- sortbottomweather= bottomsdf[(bottomsdf.Weather == findweather)].BOTTOMS
- sortbottomweather1= sortbottomweather.tolist()
- sortshoesweather= shoesdf[(shoesdf.Weather == findweather)].SHOES
- sortshoesweather1= sortshoesweather.tolist()
- app.startSubWindow("Weather", modal=True)
- app.showSubWindow("Weather")
- app.addLabel("l1", "Weather")
- app.addListBox("Sort Weather",[sorttopweather1, sortbottomweather1, sortshoesweather1])
- app.stopLabelFrame()
- app.stopSubWindow()
- elif btn == "Sort Color":
- findcolor= app.stringBox("Sort,", "Would you like to sort by bright or muted colors?")
- sorttopcolor = topsdf[(topsdf.Color== findcolor)].TOPS
- sorttopcolor1 = sorttopcolor.tolist()
- sortbottomcolor= bottomsdf[(bottomsdf.Color == findcolor)].BOTTOMS
- sortbottomcolor1= sortbottomcolor.tolist()
- sortshoescolor= shoesdf[(shoesdf.Color == findcolor)].SHOES
- sortshoescolor1= sortshoescolor.tolist()
- app.startSubWindow("Color", modal=True)
- app.showSubWindow("Color")
- app.addLabel("l2", "Color")
- app.addListBox("Sort Color",[sorttopcolor1, sortbottomcolor1, sortshoescolor1])
- app.stopLabelFrame()
- app.stopSubWindow()
- elif btn == "Sort Occasion":
- findoca= app.stringBox("Sort,", "Would you like to sort by formal or informal?")
- sorttopoca = topsdf[(topsdf.Occasion== findoca)].TOPS
- sorttopoca1 = sorttopoca.tolist()
- sortbottomoca= bottomsdf[(bottomsdf.Occasion == findoca)].BOTTOMS
- sortbottomoca1= sortbottomoca.tolist()
- sortshoesoca= shoesdf[(shoesdf.Occasion == findoca)].SHOES
- sortshoesoca1= sortshoesoca.tolist()
- app.startSubWindow("Occasion", modal=True)
- app.showSubWindow("Occasion")
- app.addLabel("l3", "Occasion")
- app.addListBox("Sort Occasion",[sorttopoca1, sortbottomoca1, sortshoesoca1])
- app.stopSubWindow()
- elif btn == "Sort Tops":
- app.startSubWindow("Tops", modal=True)
- app.showSubWindow("Tops")
- app.addLabel("l4", "Tops")
- topsdf = pandas.read_csv("Tops.csv")
- sort_tops = topsdf.TOPS
- sort_tops1= sort_tops.tolist()
- app.addListBox("Tops",sort_tops1)
- app.stopSubWindow()
- elif btn == "Sort Bottoms":
- app.startSubWindow("Bottoms", modal=True)
- app.showSubWindow("Bottoms")
- app.addLabel("l5", "Bottoms")
- bottomsdf = pandas.read_csv("Bottoms.csv")
- sort_bottoms = bottomsdf.BOTTOMS
- sort_bottoms1= sort_bottoms.tolist()
- app.addListBox("Bottoms",sort_bottoms1)
- app.stopSubWindow()
- elif btn == "Sort Shoes":
- app.startSubWindow("Shoes", modal=True)
- app.showSubWindow("Shoes")
- app.addLabel("l6", "Shoes")
- shoesdf = pandas.read_csv("Shoes.csv")
- sort_shoes = shoesdf.SHOES
- sort_shoes1= sort_shoes.tolist()
- app.addListBox("Shoes",sort_shoes1)
- app.stopSubWindow()
- def press(btn):
- if btn == "Exit":
- app.stop()
- elif btn == "Today":
- app.startSubWindow("Condition", modal=True)
- app.addLabel("l1", "Conditions")
- app.startLabelFrame("Today", 0, 0)
- api_key = "eba1bb6ae19da64736fd227b51d5e9dd"
- base_url = "http://api.openweathermap.org/data/2.5/weather?"
- city_name = app.stringBox("City", "What city do you need the weather for?")
- complete_url = base_url + "appid=" + api_key + "&q=" + city_name
- response = requests.get(complete_url)
- x = response.json()
- y = x["main"]
- current_temperature = y["temp"]
- current_pressure = y["pressure"]
- current_humidity = y["humidity"]
- z = x["weather"]
- weather_description = z[0]["description"]
- K = float(current_temperature)
- ftemp= (9/5)*(K - 273) + 32
- app.infoBox("l4",( ftemp, "pressure is ", current_pressure,"percent humidity = ", \
- current_humidity,"weather conditions are ",weather_description))
- app.stopLabelFrame()
- app.stopSubWindow()
- elif btn == "Inventory":
- app.addButtons(["Sort Tops", "Sort Bottoms","Sort Shoes"], sort)
- app.addButtons(["Sort Weather","Sort Color","Sort Occasion"], sort)
- elif btn == "Random Outfit":
- findweather = app.stringBox("Weather","Is it cold or warm?")
- findcolor= app.stringBox("Color", "Do you want bright colors or muted colors?")
- findoccasion= app.stringBox("Occasion", "Should the clothing be formal or informal?")
- findprice= app.stringBox("Price","Do you want to wear your expensive clothes or your cheaper clothes?")
- findcomfort= app.stringBox("Comfort","Comfortable or uncomfortable?")
- topsdf = pandas.read_csv("Tops.csv")
- bottomsdf = pandas.read_csv("Bottoms.csv")
- shoesdf= pandas.read_csv("Shoes.csv")
- pot_tops = topsdf[(topsdf.Weather== findweather) & (topsdf.Color== findcolor) & (topsdf.Occasion== findoccasion) &(topsdf.Price== findprice) & (topsdf.Comfort== findcomfort)].TOPS
- pot_bottoms = bottomsdf[(bottomsdf.Weather== findweather) & (bottomsdf.Color== findcolor) & (bottomsdf.Occasion== findoccasion) & (bottomsdf.Price== findprice) & (bottomsdf.Comfort== findcomfort)].BOTTOMS
- pot_shoes = shoesdf[(shoesdf.Weather== findweather) & (shoesdf.Color== findcolor) & (shoesdf.Occasion== findoccasion) & (shoesdf.Price== findprice) & (shoesdf.Comfort== findcomfort)].SHOES
- pot_tops1 = pot_tops.tolist()
- pot_bottoms1= pot_bottoms.tolist()
- pot_shoes1=pot_shoes.tolist()
- answertop= (random.choice(pot_tops1))
- answerbottom= (random.choice(pot_bottoms1))
- answershoes= (random.choice(pot_shoes1))
- app.infoBox("Your top is ",answertop)
- app.infoBox("Your bottom is ",answerbottom)
- app.infoBox("Your shoes are ",answershoes)
- elif btn == "Upload":
- topsdf = pandas.read_csv("Tops.csv")
- bottomsdf = pandas.read_csv("Bottoms.csv")
- shoesdf= pandas.read_csv("Shoes.csv")
- clothingchoice = app.stringBox("Clothing Type", "Is the item a top, bottom, or shoes?")
- name= app.stringBox("Item Name", "What is the name of the item?")
- weather = app.stringBox("Weather","Is it cold or warm?")
- color= app.stringBox("Color", "Do you want bright colors or muted colors?")
- occasion= app.stringBox("Occasion", "Should the clothing be formal or informal?")
- price= app.stringBox("Price","Do you want to wear your expensive clothes or your cheaper clothes?")
- comfort= app.stringBox("Comfort","Comfortable or uncomfortable?")
- if clothingchoice == "top":
- uploadedtop = topsdf.append({'TOPS': name,'Weather': weather, 'Color': color, 'Occasion':occasion, 'Price':price, 'Comfort':comfort}, ignore_index=True)
- uploadedtop.to_csv("Tops.csv", index=False)
- app.infoBox("Complete", "Your item has been added!")
- elif clothingchoice =="bottom":
- uploadedbottom = bottomsdf.append({'Weather': weather, 'Color': color, 'Occasion':occasion, 'Price':price, 'Comfort':comfort}, ignore_index=True)
- uploadedbottom.to_csv("Bottoms.csv", index=False)
- app.infoBox("Complete", "Your item has been added!")
- elif clothingchoice == "shoes":
- uploadedshoes = shoesdf.append({'TOPS': name, 'Weather': weather, 'Color': color, 'Occasion':occasion, 'Price':price, 'Comfort':comfort}, ignore_index=True)
- uploadedshoes.to_csv("Shoes.csv", index=False)
- app.infoBox("Complete", "Your item has been added!")
- else:
- app.infoBox("Error","Please pick either top, bottom, or shoes.")
- else:
- print('Pick a valid option')
- app=gui("Main Menu","1200x620")
- app.showSplash("RapidWear", fill='grey', stripe='black', fg='white', font=44)
- app.addLabel("title", "Welcome to the csv Main Menu")
- app.setLabelBg("title", "orange")
- app.setFont(18)
- # 3 buttons, each calling the same function
- app.addButton("Inventory", press)
- app.addButton("Upload", press)
- app.addButton("Random Outfit", press)
- app.addButton("Today", press)
- app.addButton("Exit",press)
- app.go()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement