Dodanie funkcji liczacej

This commit is contained in:
kat 2023-10-17 18:34:16 +02:00
parent cea9e3f640
commit 76d77f58ea

View File

@ -1,7 +1,31 @@
import tkinter.filedialog as filedialog import tkinter.filedialog as filedialog
import tkinter as tk import tkinter as tk
from tkinter import ttk
from tkinter import filedialog
from price_evaluation import predict
def predict_price():
try:
stan = input_entry5.get()
czynsz = float(input_entry3.get())
liczba_pokoi = int(input_entry2.get())
metraz = float(input_entry.get())
rynek = input_entry4.get()
price = predict(stan, czynsz, liczba_pokoi, metraz, rynek)
output_entry.configure(state='normal')
output_entry.delete(0, 'end')
output_entry.insert(0, str(price))
output_entry.configure(state='readonly')
except ValueError:
output_entry.configure(state='normal')
output_entry.delete(0, 'end')
output_entry.insert(0, "Invalid input")
output_entry.configure(state='readonly')
master = tk.Tk() master = tk.Tk()
header_text = "Ceny mieszkań" header_text = "Ceny mieszkań"
header_label = tk.Label(master, text=header_text, font=("Arial", 25), anchor = "center", justify="center") header_label = tk.Label(master, text=header_text, font=("Arial", 25), anchor = "center", justify="center")
header_label.pack(fill="both", expand=True, padx=20, pady=20) header_label.pack(fill="both", expand=True, padx=20, pady=20)
@ -43,15 +67,20 @@ input_path3 = tk.Label(middle_frame, text="Czynsz:")
input_entry3 = tk.Entry(middle_frame, text="", width=40) input_entry3 = tk.Entry(middle_frame, text="", width=40)
input_path4 = tk.Label(middle_frame, text="Rynek:") input_path4 = tk.Label(middle_frame, text="Rynek:")
input_entry4= tk.Entry(middle_frame, text="", width=40) input_entry4 = ttk.Combobox(middle_frame, values=["Pierwotny", "Wtórny", "Pierwotny i wtórny"], state="readonly", width=37)
input_entry4.set("Wybierz")
input_path5 = tk.Label(middle_frame, text="Stan:") input_path5 = tk.Label(middle_frame, text="Stan:")
input_entry5= tk.Entry(middle_frame, text="", width=40) input_entry5= ttk.Combobox(middle_frame, values=["Pod klucz", "Deweloperski", "Do wykończenia", "Do remontu"], state="readonly", width=37)
input_entry5.set("Wybierz")
begin_button = tk.Button(bottom_frame, text='Oblicz') begin_button = tk.Button(bottom_frame, text='Oblicz')
begin_button.configure(command=predict_price)
output_path = tk.Label(bottom_frame, text="Prognozowana cena:") output_path = tk.Label(bottom_frame, text="Prognozowana cena:")
output_entry = tk.Entry(bottom_frame, text="", width=40) output_entry = tk.Entry(bottom_frame, text="", width=40, state="readonly")
output_entry.insert(0, "Your result goes here")
line.pack(pady=4) line.pack(pady=4)
top_frame.pack(side=tk.TOP) top_frame.pack(side=tk.TOP)