import tkinter as tk
from tkinter import *
import tkintermapview
import customtkinter
from tkcalendar import DateEntry
import pandas as pd
from customtkinter import CTkComboBox
[docs]
root = customtkinter.CTk()
root.geometry(f"{1400}x{800}")
root.title("calcey")
customtkinter.set_appearance_mode("Dark")
#lists---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[docs]
label_list = ["Crop name", "Date sowing", "Date harvest", "Fertilizer #1 used", "Fertilizer #2 used", "Fertilizer #3 used", "yield drymass", "yield freshmass", "irrigation", "diesel consumed" ]
[docs]
df_crops = pd.read_excel('data/Mapping_data_Calcey.xlsx', sheet_name='Mapping_Fertilizer', usecols='A')
[docs]
frame2 =customtkinter.CTkFrame(root, width=100, height=100)
[docs]
frame3 = customtkinter.CTkFrame(root, width=100, height=100)
frame2.grid(row=1, column=0, padx=10, pady=10, sticky=tk.W)
frame3.grid(column=0, row=0, sticky=tk.W, padx=5, pady=5)
[docs]
label = customtkinter.CTkLabel(frame3, text="Welcome to calcey!", width=300, height=50, fg_color='transparent',font=customtkinter.CTkFont(family="Circular Std Black",size=30, weight="bold"))
label.pack()
#getting coordinates
map_widget.grid(row=0, column=4,rowspan = 12, padx=10, pady=10, sticky=tk.E)
[docs]
def get_coordinates(coordinates_tuple):
longitude = coordinates_tuple[1]
latitude = coordinates_tuple[0]
Longitude.delete(0,"end")
Latitude.delete(0,"end")
Longitude.insert(0, longitude)
Latitude.insert(0, latitude)
marker = map_widget.set_marker(latitude, longitude)
map_widget.add_left_click_map_command(get_coordinates)
#dropdowns---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#dropdown_unit
[docs]
Fertilizer1_unit = CTkComboBox(frame2, width = 200, values=[' ','kg/ha'] )
#Fertilizer1_unit.set('Please select (optional)')
[docs]
Fertilizer2_unit = CTkComboBox(frame2, width = 200, values=[' ','kg/ha'])
#Fertilizer2_unit.set('Please select (optional)')
[docs]
Fertilizer3_unit = CTkComboBox(frame2, width = 200, values=[' ','kg/ha'])
#Fertilizer3_unit.set('Please select (optional)')
[docs]
yield_drymass_unit = CTkComboBox(frame2, width = 200, values=[' ','kg/ha'])
#yield_drymass_unit.set('Please select (optional)')
[docs]
irrigation_unit = CTkComboBox(frame2, width = 200, values =[' ','m^3/ha'] )
#irrigation_unit.set('Please select (optional)')
[docs]
diesel_consumed_unit = CTkComboBox(frame2, width = 200, values = [' ','l/ha'])
#diesel_consumed_unit.set('Please select (optional)')
#dropdown_fertilizer
[docs]
Fert=(' ','Ammonium Sulphate', 'Ammoniumchloride', 'Calcium Ammonium Nitrate', 'Calcium Nitrate', 'Urea', 'Single superphosphate', 'Rock Phosphate', 'Potassium chloride', 'Potassium Sulphate', '15-15-15', '10-26-26')
[docs]
Fert1 = CTkComboBox(frame2, width = 200, values=Fert,)
#Fert1.set('Please select (optional)')
[docs]
Fert2 = CTkComboBox(frame2, width = 200, values=Fert)
#Fert2.set('Please select (optional)')
[docs]
Fert3 = CTkComboBox(frame2, width = 200, values=Fert)
#Fert3.set('Please select (optional)')
#dropdown yield
[docs]
yiel=(' ','drymass', 'freshmass')
[docs]
yield1 = CTkComboBox(frame2, width = 200, values = yiel)
#yield1.set('Please select (optional)')
#dropdown crop
#df_crops.insert(0, ["Please select"])
[docs]
crop1 = CTkComboBox(frame2, width = 200, values = list(df_crops['List_UI']))
crop1.set('Please select (mandatory)')
# Create a dictionary to store the widgets
# Create a function to create and place the widgets
# Create the labels
[docs]
labels = ["Longitude", "Latitude", "Crop name", "Date sowing", "Date harvest"," " , " ", "Fertilizer #1 used", "Fertilizer #2 used", "Fertilizer #3 used", "Yield", "Water consumed", "Diesel consumed"]
for row, label in enumerate(labels):
create_widget(row+1,0 , customtkinter.CTkLabel, text=label, font=customtkinter.CTkFont(family="Circular Std Black",size=15, weight="bold"),justify="left", anchor="w")
[docs]
option = customtkinter.CTkLabel(frame2, text="option",font=customtkinter.CTkFont(family="Circular Std Black",size=15, weight="bold"))
option.grid(row = 7, column = 1, padx=10, pady=10)
[docs]
unit = customtkinter.CTkLabel(frame2, text="unit",font=customtkinter.CTkFont(family="Circular Std Black",size=15, weight="bold"))
unit.grid(row = 7, column = 3, padx=10, pady=10)
[docs]
mass = customtkinter.CTkLabel(frame2, text="amount", font=customtkinter.CTkFont(family="Circular Std Black",size=15, weight="bold"))
mass.grid(row = 7, column = 2, padx=10, pady=10)
#first column
[docs]
Crop = customtkinter.CTkEntry(frame2, width = 200,placeholder_text=" ")
[docs]
Sowing_date = customtkinter.CTkEntry(frame2, width = 200)
[docs]
cal=DateEntry(frame2, width = 27)
cal.grid(row=4,column=1, padx=10, pady=10)
[docs]
Harvest_date = customtkinter.CTkEntry(frame2, width = 200)
[docs]
cal2=DateEntry(frame2, width = 27,selectmode='day')
cal2.grid(row=5,column=1, padx=10, pady=10)
[docs]
Fertilizer1 = customtkinter.CTkEntry(frame2, width = 200)
[docs]
Fertilizer2 = customtkinter.CTkEntry(frame2, width = 200)
[docs]
Fertilizer3 = customtkinter.CTkEntry(frame2, width = 200)
#third column - mass
[docs]
Fert1_mass = customtkinter.CTkEntry(frame2, width = 200)
[docs]
Fert2_mass = customtkinter.CTkEntry(frame2, width = 200)
[docs]
Fert3_mass = customtkinter.CTkEntry(frame2, width = 200)
[docs]
yield_drymass_mass = customtkinter.CTkEntry(frame2, width = 200)
[docs]
irrigation_mass = customtkinter.CTkEntry(frame2, width = 200)
[docs]
diesel_consumed_mass= customtkinter.CTkEntry(frame2, width = 200)
[docs]
Longitude = customtkinter.CTkEntry(frame2, width = 200,placeholder_text="Please place marker on the map")
[docs]
Latitude= customtkinter.CTkEntry(frame2, width = 200,placeholder_text="Please place marker on the map")
#grid---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
#entry
Longitude.grid(row = 1, column = 1, padx=10, pady=10)
Latitude.grid(row = 2, column = 1, padx=10, pady=10)
crop1.grid(row = 3, column = 1, padx=10, pady=10)
Fert1.grid(row = 8, column = 1, padx=10, pady=10)
Fert2.grid(row = 9, column = 1, padx=10, pady=10)
Fert3.grid(row = 10, column = 1, padx=10, pady=10)
yield1.grid(row = 11, column = 1, padx=10, pady=10)
#amount
Fert1_mass.grid(row = 8, column = 2, padx=10, pady=10)
Fert2_mass.grid(row = 9, column = 2, padx=10, pady=10)
Fert3_mass.grid(row = 10, column = 2, padx=10, pady=10)
yield_drymass_mass.grid(row = 11, column = 2, padx=10, pady=10)
irrigation_mass.grid(row = 12, column = 2, padx=10, pady=10)
diesel_consumed_mass.grid(row = 13, column = 2, padx=10, pady=10)
#unit
Fertilizer1_unit.grid(row = 8, column = 3, padx=10, pady=10)
Fertilizer2_unit.grid(row = 9, column = 3, padx=10, pady=10)
Fertilizer3_unit.grid(row = 10, column = 3, padx=10, pady=10)
yield_drymass_unit.grid(row = 11, column = 3, padx=10, pady=10)
irrigation_unit.grid(row = 12, column = 3, padx=10, pady=10)
diesel_consumed_unit.grid(row = 13, column = 3, padx=10, pady=10)
#getting input---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
customtkinter.CTkButton(frame2,height = 90, width=110, text = "submit",font=customtkinter.CTkFont(family="Circular Std Black",size=20, weight="bold"),
command = getInput).grid(column = 0,row = 13,columnspan= 5, sticky = E)
root.mainloop()