diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2021-12-13 12:33:14 +0000 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2021-12-13 12:33:14 +0000 |
commit | f95a8dbc5381f75be1e5e4eaad69fd3e70a65ff9 (patch) | |
tree | 6500bc336493ffe9cd41e6f45d140d914ac932ad /src | |
parent | 84812e0f7342a618fc8becd04e3de590359d9ca3 (diff) | |
download | esotericFORTRAN-f95a8dbc5381f75be1e5e4eaad69fd3e70a65ff9.tar.gz esotericFORTRAN-f95a8dbc5381f75be1e5e4eaad69fd3e70a65ff9.zip |
added IDE documentation
Diffstat (limited to 'src')
-rw-r--r-- | src/PythonIDE/src/esotericFORTRANIDE.py | 23 | ||||
-rw-r--r-- | src/PythonIDE/src/fortranText.py | 3 | ||||
-rw-r--r-- | src/PythonIDE/src/resultsPane.py | 5 |
3 files changed, 31 insertions, 0 deletions
diff --git a/src/PythonIDE/src/esotericFORTRANIDE.py b/src/PythonIDE/src/esotericFORTRANIDE.py index e132d9e..721e629 100644 --- a/src/PythonIDE/src/esotericFORTRANIDE.py +++ b/src/PythonIDE/src/esotericFORTRANIDE.py @@ -11,6 +11,13 @@ import sys import os class Application(tk.Tk): + """Class for implementing a simple IDE using Python tkinter. + Inherits from tk.Tk, all widgets are packed inside PanedWindows + for users to expand or shrink as nessicary. + + Args: + tk (Tk): A tk.Tk object to inherit from + """ def __init__(self, program_jar, current_file = "unsaved program", *args, **kwargs): super().__init__(*args, **kwargs) @@ -46,6 +53,9 @@ class Application(tk.Tk): self.save_file_as() def open_file(self): + """Called when the user selects the button to open a file or the + nessicary keyboard shortcuts. File is opened and inserted into the tk.Text + """ dia = filedialogue.askopenfilename( initialdir = self.__get_initial_dir(), filetypes = (("FORTRAN Files", ".ft"), ("Text Files", ".txt"), ("All files", "*.*")) @@ -79,10 +89,15 @@ class Application(tk.Tk): exit() def execute(self): + """Executes a file. A file needs to be saved to disk before it can be executed. + Check that we're operating on a saved file. Also check if we're working on the most + up-to date file by comparing the code in the tk.Text to the code on disk. + """ if self.current_file == "unsaved program": messagebox.showwarning("Error", "You need to make a file before it can be executed") return + # compare the files to check if we need to prompt the user to save with open(self.current_file, "r") as f: unsaved_version = "".join(f.readlines()) @@ -95,6 +110,7 @@ class Application(tk.Tk): if os.path.exists("build"): shutil.rmtree("build") + # execute the file with the jar in program args self.results_pane.clear_c_code() proc = subprocess.Popen(["java", "-jar", self.program_jar, self.current_file, "-c", "-e"], stdout=subprocess.PIPE) while True: @@ -103,6 +119,7 @@ class Application(tk.Tk): break self.results_pane.append_results_line(line.rstrip().decode()) + # if the build directory exists, the build was successful. if os.path.exists("build"): self.results_pane.append_results_line("Build Completed %s\n" % str(datetime.datetime.now())) for file_ in os.listdir("build"): @@ -124,6 +141,12 @@ class Application(tk.Tk): class ApplicationMenu(tk.Menu): + """Class that implements the menu bar in the application. It inherits from + tk.Menu() + + Args: + tk (Menu): The class inherits from tk.Menu + """ def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent diff --git a/src/PythonIDE/src/fortranText.py b/src/PythonIDE/src/fortranText.py index b88ff89..3b044c7 100644 --- a/src/PythonIDE/src/fortranText.py +++ b/src/PythonIDE/src/fortranText.py @@ -3,6 +3,9 @@ from tkinter import ttk from tkinter.scrolledtext import ScrolledText class FortranText(tk.Frame): + """This class is the left hand of the application, + basically just uses a tk.Text for FORTRAN code input + """ def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent diff --git a/src/PythonIDE/src/resultsPane.py b/src/PythonIDE/src/resultsPane.py index 7797916..c3ea110 100644 --- a/src/PythonIDE/src/resultsPane.py +++ b/src/PythonIDE/src/resultsPane.py @@ -3,6 +3,11 @@ from tkinter import ttk from tkinter.scrolledtext import ScrolledText class ResultsPane(tk.Frame): + """This class implements the right-hand side of the application. + It has two tk.Texts, one for the produced C code and one as the + output to stdout of running the .jar. They are inside paned windows + so the user can expand and shrink them as nessicary. + """ def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent |