Skip to content

Commit

Permalink
address Searching
Browse files Browse the repository at this point in the history
  • Loading branch information
miladbarooni committed Jan 23, 2020
1 parent d43fc48 commit 5c47d87
Show file tree
Hide file tree
Showing 4 changed files with 355 additions and 14 deletions.
55 changes: 41 additions & 14 deletions Main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from tkinter import Tk, Label, Button, Toplevel, StringVar, Entry, messagebox, Frame, END, Scrollbar, Y, RIGHT
from tkinter import Checkbutton, IntVar, BooleanVar

from functools import partial
import tkinter as tk
Expand Down Expand Up @@ -179,7 +180,7 @@ def showAddress():
# self.dashboard.destroy()
self.profile = Tk()
self.profile.title("User Profile")
self.profile.geometry("700x500")
self.profile.geometry("700x1000")


"""
Expand Down Expand Up @@ -227,28 +228,30 @@ def showAddress():
"""

"""
in this section we will show the user his/her information and he or she can change it
in this section we will show the user address
##########################################################3
"""
Label(self.profile, text="Your Address", bg="red", width="300", height="2", font=("Calibri", 13)).pack()
Label(self.profile, text="Address Management", bg="red", width="300", height="2", font=("Calibri", 13)).pack()
Label(text="").pack()
show_address_button = Button(self.profile, text="Show Current added address", command=showAddress)
show_address_button.pack()

add_address_button = Button(self.profile, text="Add Address", command=self.addAddress)
add_address_button.pack()
"""
##########################################################
"""


def addAddress(self):
def addNewAddress():
mydb.addAddress(x_entry.get(), y_entry.get(), self.user_id, city_combo.get(), mydb.addCity(city_combo.get())
mydb.addAddress(x_entry.get(), y_entry.get(), self.user_id, mydb.addCity(city_combo.get()), street_entry.get()
,alley_entry.get(), plaque_entry.get(), other_information_entry.get())
self.add_address_screen = Tk()
self.add_address_screen.title("Adding new address")
self.add_address_screen.geometry("700x500")
Label(self.add_address_screen, text="First select your city and then").pack()
city_combo = Combobox(self.add_address_screen)
cities = mydb.showCity()
cities = mydb.showAllCity()
cities_list = []
for i in cities:
cities_list.append(i[1])
Expand All @@ -274,7 +277,7 @@ def addNewAddress():
other_information_entry.pack()
add_address_button = Button(self.add_address_screen, text="Add This New Address", command=addNewAddress)
add_address_button.pack()



def updateUserInformation(self, user_id,firstname_entry, lastname_entry, phone_number_entry, email_address_entry, password_entry):
Expand All @@ -286,15 +289,39 @@ def updateUserInformation(self, user_id,firstname_entry, lastname_entry, phone_n


def restaurantsPage(self):
print ("resturantsPage")
def showRestaurants():
for variable in all_variables:
if (variable.get()):
index = all_variables.index(variable)
address_id = all_address[index][0]
mydb.searchShopByLocation()
self.address_selection_screen = Tk()
self.address_selection_screen.title("Your addresses")
self.address_selection_screen.geometry("700x500")
all_address = mydb.showAddress(self.user_id)
print (all_address)
all_variables = []

list_of_address_str = []
for address in all_address:
address_str = ""
for part in address[1:-2]:
address_str += str(part) + ", "
list_of_address_str.append(address_str)
vari = IntVar(self.address_selection_screen)
all_variables.append(vari)
Checkbutton(self.address_selection_screen, text=address_str, variable=vari).pack()
Button(self.address_selection_screen, text="Submit", command=showRestaurants).pack()




def orderPage(self):
print ("orderPage")





def showHistoryOfOrders():
print ("show history")
self.order_screen = Tk()
self.order_screen.title("Orders Page")
Button(self.order_screen,text="history of orders", height="2", width="30", command=showHistoryOfOrders).pack()

root = Tk()
my_gui = Application(root)
Expand Down
Binary file modified __pycache__/snapFood.cpython-37.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions snapFood.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ def showAllCity(self):
return self._mycursor.fetchall()

def addCity(self, city_name):
data = self.showAllCity()
for city in data :
if city_name == city[1]:
return city[0]
self._mycursor.execute("INSERT INTO CITY (name) VALUES (\'{}\');".format(city_name))
self._mydb.commit()
return self._mycursor.lastrowid
Expand Down
Loading

0 comments on commit 5c47d87

Please sign in to comment.