-
Notifications
You must be signed in to change notification settings - Fork 3
/
gui.py
117 lines (87 loc) · 2.75 KB
/
gui.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import tkinter as tk
from tkinter import font
from backend import *
def test_function():
a = variable.get()
b = variable1.get()
# z = variable.get()
label['text'] = pre(a,b)
root = tk.Tk()
canvas = tk.Canvas(root,height='500',width='600')
canvas.pack()
background_image = tk.PhotoImage(file='landscape.png')
background_label = tk.Label(root,image=background_image)
background_label.place(relwidth=1,relheight=1)
label1 = tk.Label(root,text="Crop Recommendation System",bg = '#99ffcc', font=('Helvetica',15), fg='red',bd=5)
label1.place(relx=0.15,rely=0.02,relwidth=0.7,relheight=0.06)
frame = tk.Frame(root, bg = '#80c1ff',bd=5)
frame.place(relx=0.5, rely=0.1,relwidth=0.75,relheight=0.1, anchor='n')
#dropdown
OptionList = {
'Aandhra Pradesh': '0',
'Arunachal Pradesh' : '1',
'Assam' : '2',
'Bihar' : '3',
'Chattisgarh' : '4',
'Goa' : '5',
'Gujarat' : '6',
'Haryana' : '7',
'Himachal Pradesh' : '8',
'Jammu and Kashmir' : '9',
'Himachal Pradesh' : '10',
'Jharkhand' : '11',
'Karnataka' : '12',
'Kerala' : '13',
'Madhaya Pradesh' : '14',
'Maharashtra' : '15',
'Manipur' : '16',
'Mizoram' : '17',
'Meghalaya' : '18',
'Nagaland' : '19',
'Odisha' : '20',
'Punjab' : '21',
'Rajasthan' : '22',
'Sikkim' : '23',
'Tamil Nadu' : '24',
'Telangana' : '25',
'Tripura' : '26',
'Uttar Pradesh' : '27',
'Uttarakhand' : '28',
'West Bengal':'29'
}
variable = tk.StringVar(frame)
variable.set("Location")
opt = tk.OptionMenu(frame, variable, *OptionList)
opt.config(width=90, font=('Helvetica', 12))
opt.place(relx=0.1,rely=0.1,relwidth=0.8,relheight=0.8)
labelTest = tk.Label(text="", font=('Helvetica', 12), fg='red')
labelTest.pack(side="top")
# def callback(*args):
# labelTest.configure(text="The selected item is {}".format(variable.get()))
# # return variable.get()
# variable.trace("w", callback)
frame1 = tk.Frame(root, bg = '#80c1ff',bd=5)
frame1.place(relx=0.5, rely=0.25,relwidth=0.75,relheight=0.1, anchor='n')
OptionList1 = {
'Aluvial' : '0',
'Black': '1',
'Desert': '2',
'Laterite':'3',
'Mountain':'4',
'Red':'5'
}
variable1 = tk.StringVar(frame1)
variable1.set('Soil')
opt1 = tk.OptionMenu(frame1, variable1, *OptionList1)
opt1.config(width=90, font=('Helvetica', 12))
opt1.place(relx=0.1,rely=0.1,relwidth=0.8,relheight=0.8)
labelTest1 = tk.Label(text="", font=('Helvetica', 12), fg='red')
labelTest1.pack(side="top")
button = tk.Button(root,text="Submit",font=40,command=lambda: test_function())
button.place(relx=0.36,rely=0.4,relheight=0.07,relwidth=0.3)
lower_frame =tk.Frame(root,bg='#80c1ff',bd =10)
lower_frame.place(relx=0.5,rely=0.5,relwidth=0.75,relheight=0.4,anchor='n')
label = tk.Label(lower_frame,font=('Courier','14'),anchor = 'nw',justify = 'left',bd=4)
label.place(relwidth=1,relheight=1)
# start the GUI
root.mainloop()