-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathview_listed_properties.py
66 lines (49 loc) · 1.9 KB
/
view_listed_properties.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from tkinter import *
import tkinter as tk
from tkinter import ttk
import os
import mysql.connector
mydb = mysql.connector.Connect(
host='localhost',
user='root',
password='asusrog',
database='home_rental'
)
def back():
root.destroy()
os.system("python main.py")
def populate_table():
myc = mydb.cursor()
branch_no = branch_no_entry.get()
sql = "SELECT p_no, Type, Rooms, Rent,Address, Name FROM prop_registration WHERE branch_no = %s"
val = (branch_no,)
myc.execute(sql, val)
result = myc.fetchall()
for row in result:
table.insert('', 'end', values=row)
mydb.commit()
root = Tk()
root.title("View Listed Properties")
root.geometry('1290x520')
root.configure(bg="#DAF5FF")
view_head_label = Label(root, text="View Listed Properties", font=("Arial", 20, "bold"), bg="#DAF5FF", fg="#576CBC")
view_head_label.place(x=500, y=20)
branch_no_label = Label(root, text="Branch No",bg="#DAF5FF", fg="#394867",font=("Arial", 13))
branch_no_label.place(x=45, y=80)
branch_no_entry = Entry(root, width=30)
branch_no_entry.place(x=145, y=82)
table = ttk.Treeview(root, columns=('Property Number', 'Type', 'Rooms', 'Rent','Address', 'Name'), show='headings')
table.heading('Property Number', text='Property Number')
table.heading('Type', text='Type')
table.heading('Rooms', text='Rooms')
table.heading('Rent', text='Rent')
table.heading('Address', text='Address')
table.heading('Name', text='Name')
table.place(x=45, y=200)
xscrollbar = tk.Scrollbar(root, orient='horizontal', command=table.xview)
xscrollbar.grid(row=1, column=0, sticky='ew')
table.config(xscrollcommand=xscrollbar.set)
submit_but = Button(root, text="Submit", width=10, bg="#3E54AC", fg="white",font=("Arial", 12), command=populate_table)
submit_but.place(x=47, y=130)
back=Button(root, text="Back", width=10, bg="#595260", fg="white",font=("Arial", 12), command=back).place(x=500, y=450)
root.mainloop()