Skip to content

Commit

Permalink
release v-0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BuczynskiRafal committed Sep 18, 2024
1 parent 7907f72 commit ec32e57
Show file tree
Hide file tree
Showing 15 changed files with 1,252 additions and 868 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RCG.exe filter=lfs diff=lfs merge=lfs -text
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,13 @@ dmypy.json

# Pyre type checker
.pyre/
.idea/dbnavigator.xml
.gitignore
.gitignore
.gitignore
.idea/inspectionProfiles/Project_Default.xml
.idea/inspectionProfiles/profiles_settings.xml
.idea/rapid-catchment-generator.iml
.idea/modules.xml
.idea/misc.xml
.idea/vcs.xml
516 changes: 277 additions & 239 deletions README.md

Large diffs are not rendered by default.

46 changes: 33 additions & 13 deletions gui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,26 @@
from rcg.runner import generate_subcatchment


def get_help_file_path():
if getattr(sys, 'frozen', False):
base_path = sys._MEIPASS
else:
base_path = os.path.abspath(".")
return os.path.join(base_path, "gui", "help_content.txt")


class RcgApp:
def __init__(self, root):
self.root = root
self.file_path = None
self.root.title("Rapid Catchment Generator")
self.set_window_size(width=340, height=270)
self.set_window_size(width=340, height=300)
self.create_widgets()

def set_window_size(self, width, height):
self.root.geometry(f"{width}x{height}")

def create_widgets(self):
# Tworzenie rozwijanej listy LandCover
land_cover_label = tk.Label(self.root, text="Select land cover type:")
land_cover_label.grid(row=0, column=0, padx=10, pady=10, sticky="w")

Expand All @@ -46,10 +53,9 @@ def create_widgets(self):
"marshes",
],
width=25
)
)
land_cover_combobox.grid(row=0, column=1, padx=10, pady=10)

# Tworzenie rozwijanej listy LandType
land_form_label = tk.Label(self.root, text="Select land form type:")
land_form_label.grid(row=1, column=0, padx=10, pady=10, sticky="w")

Expand All @@ -69,48 +75,62 @@ def create_widgets(self):
"highest mountains",
],
width=25
)
)
land_form_combobox.grid(row=1, column=1, padx=10, pady=10)

# Tworzenie pola do wprowadzenia parametru Area
area_label = tk.Label(self.root, text="Area [ha]:")
area_label.grid(row=2, column=0, padx=10, pady=10, sticky="w")

self.area_var = tk.StringVar()
area_entry = tk.Entry(self.root, textvariable=self.area_var, width=28)
area_entry.grid(row=2, column=1, padx=10, pady=10)

# Selecting file
file_label = tk.Label(self.root, text="Select file:")
file_label.grid(row=3, column=0, padx=10, pady=10, sticky="w")

choose_file_button = tk.Button(self.root, text="Select file", command=self.choose_file, width=23)
choose_file_button.grid(row=3, column=1, padx=10, pady=10)

# Selected file
selected_label = tk.Label(self.root, text="Selected file:")
selected_label.grid(row=4, column=0, padx=10, pady=10, sticky="w")

self.selected_file_label = tk.Entry(self.root, width=28, state='readonly')
self.selected_file_label.grid(row=4, column=1, padx=10, pady=10, sticky="w")

# Tworzenie przycisku Run
run_label = tk.Label(self.root, text="Run simulation:")
run_label.grid(row=5, column=0, padx=10, pady=10, sticky="w")

run_button = tk.Button(self.root, text="Run", command=self.run_simulation, width=23, bg="#36D7B7")
run_button.grid(row=5, column=1, padx=10, pady=10, sticky="w")

help_button = tk.Button(self.root, text="Help", command=self.show_help, width=23, bg="#a5d8ff")
help_button.grid(row=6, column=1, padx=10, pady=10, sticky="w")

def show_help(self):
help_window = tk.Toplevel(self.root)
help_window.title("Help - Categories and Instructions")
help_window.geometry("400x400")

try:
with open(get_help_file_path(), "r") as file:
text = file.read()
except FileNotFoundError:
messagebox.showerror("Error", "Help file not found.")
return

help_text = tk.Text(help_window, wrap='word', width=50, height=20)
help_text.insert(tk.END, text)
help_text.config(state="disabled")
help_text.pack(padx=10, pady=10, expand=True, fill=tk.BOTH)

def choose_file(self):
file_path = filedialog.askopenfilename(title="Wybierz plik", filetypes=(("Pliki tekstowe", "*.txt"), ("Wszystkie pliki", "*.*")))
file_path = filedialog.askopenfilename(title="Select file", filetypes=(("Text files", "*.txt"), ("All files", "*.*")))
if file_path:
# Sprawdź, czy plik ma rozszerzenie ".inp"
file_extension = os.path.splitext(file_path)[1]
if file_extension.lower() != ".inp":
messagebox.showerror("Error", "Please select a file with the '.inp' extension.")
return

# Aktualizowanie pola tekstowego z nazwą pliku
self.selected_file_label.config(state='normal')
self.selected_file_label.delete(0, tk.END)
self.selected_file_label.insert(0, file_path)
Expand Down Expand Up @@ -150,8 +170,8 @@ def run_simulation(self):

messagebox.showinfo("Information", f"Simulation has been executed successfully for values: \n\nArea: {area}\nLand cover type: {land_cover}\nLand form type: {land_form}\nFile: {self.file_path}")


if __name__ == "__main__":
root = tk.Tk()
root.iconbitmap("gui\icon.png")
app = RcgApp(root)
root.mainloop()
Loading

0 comments on commit ec32e57

Please sign in to comment.