<repo_name>DavidBartTobi/Algebra-Tools<file_sep>/inverse_Matrix.py
from tkinter import ttk
from tkinter import *
from tkinter import messagebox
from utilities import gui_utilities, coordinate_Entry, errors
import inverse_Entry
import numpy as np
from numpy.linalg import inv
from itertools import cycle

class InverseMatrix:

    def __init__(self, top, dimension):

        self.top = top
        self.dimension = dimension
        self.entries = [[],[],[],[],[],[]]
        self.colors = cycle(["#add8e6", '#ffcccb', '#90ee90'])

        gui_utilities.Window_Style(self.top, "מטריצה הפכית", "285x328")

        self.dimension_status6 = 'normal'
        self.dimension_status5 = 'normal'
        self.dimension_status4 = 'normal'
        self.dimension_status3 = 'normal'

        if dimension<6:
            self.dimension_status6 = 'disabled'
            if dimension<5:
                self.dimension_status5 = 'disabled'
                if dimension<4:
                    self.dimension_status4 = 'disabled'
                    if dimension<3:
                        self.dimension_status3 = 'disabled'

        self.background_label = Label(self.top, width=40, height=20, bg=gui_utilities.Main_Theme_Color())
        self.background_label.grid(row=1, column=0, rowspan=8, columnspan=6, sticky=W + N + E + S)

        coordinate_Entry.Coordinate_Entry(self.top, self.entries, self.dimension_status3, self.dimension_status4,
                                          self.dimension_status5, self.dimension_status6)

        self.confirm_button = ttk.Button(self.top, text="אישור", command=self.Get_Inverse, width=5,
                                         cursor='hand2')
        self.confirm_button.grid(row=7, column=0, pady=(20, 10), padx=(53, 0), columnspan=3)

        self.clear_button = ttk.Button(self.top, text="  נקה", command=self.Clear_Entries, width=5,
                                       cursor='hand2')
        self.clear_button.grid(row=7, column=3, pady=(20, 10), padx=(0, 53), columnspan=3)

        self.dimension_button = ttk.Button(self.top, text="     שנה גודל מטריצה", command=self.Change_Dimension,
                                           cursor='hand2', width=20)
        self.dimension_button.grid(row=8, column=0, pady=(10, 20), columnspan=6)

        self.top.bind('<Return>', lambda func: self.Get_Inverse())
        self.entries[0][0].focus_force()


    def Get_Inverse(self):

        vectors = []

        for i in range(self.dimension):
            vectors.append([])

            for j in range(self.dimension):

                if len(self.entries[i][j].get()) == 0:
                    errors.Empty_Error()
                    self.top.lift()
                    self.entries[i][j].focus_force()
                    return

                try:
                    vectors[i].append(float(self.entries[i][j].get()))

                except:
                    errors.Instance_Error("מספר")
                    self.top.lift()
                    self.entries[i][j].focus_force()
                    return

        self.Clear_Entries()

        np_vectors = np.array(vectors)

        try:
            inverse = inv(np_vectors)
            inverse = inverse.round(self.dimension)
            color = next(self.colors)
            for i in range(self.dimension):
                for j in range(self.dimension):
                    if float(inverse[i][j]).is_integer():
                        self.entries[i][j].insert(0, int(float(inverse[i][j])))
                    else:
                        self.entries[i][j].insert(0, float(inverse[i][j]))
                    self.entries[i][j].configure(bg=color)

            for i in range(len(vectors)):
                for j in range(len(vectors)):
                    if float(vectors[i][j]).is_integer():
                        vectors[i][j] = int(float(inverse[i][j]))
                    else:
                        vectors[i][j] = float(inverse[i][j])

        except:
            messagebox.showerror("Error", f"The matrix is NOT invertible.")
            self.top.destroy()


    def Clear_Entries(self):

        for row in self.entries:
            for entry in row:
                entry.delete(0, END)

        self.entries[0][0].focus_force()

    def Change_Dimension(self):

        top = Toplevel()
        inverse_Entry.InverseEntry(top)
        self.top.destroy()
<file_sep>/utilities/coordinate_Entry.py
from tkinter import *


def Coordinate_Entry(top, entries, dimension_status3, dimension_status4, dimension_status5, dimension_status6):

    entries[0].append(Entry(top, width=3, justify='center', state='normal'))
    entries[0][0].grid(row=1, column=0, pady=15, padx=(10, 0))

    entries[0].append(Entry(top, width=3, justify='center', state='normal'))
    entries[0][1].grid(row=1, column=1, pady=15)

    entries[0].append(Entry(top, width=3, justify='center', state=dimension_status3, disabledbackground='gray'))
    entries[0][2].grid(row=1, column=2, pady=15)

    entries[0].append(Entry(top, width=3, justify='center', state=dimension_status4, disabledbackground='gray'))
    entries[0][3].grid(row=1, column=3, pady=15)

    entries[0].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[0][4].grid(row=1, column=4, pady=15)

    entries[0].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[0][5].grid(row=1, column=5, pady=15, padx=(0, 10))


    entries[1].append(Entry(top, width=3, justify='center', state='normal'))
    entries[1][0].grid(row=2, column=0, padx=(10, 0))

    entries[1].append(Entry(top, width=3, justify='center', state='normal'))
    entries[1][1].grid(row=2, column=1)

    entries[1].append(Entry(top, width=3, justify='center', state=dimension_status3, disabledbackground='gray'))
    entries[1][2].grid(row=2, column=2)

    entries[1].append(Entry(top, width=3, justify='center', state=dimension_status4, disabledbackground='gray'))
    entries[1][3].grid(row=2, column=3)

    entries[1].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[1][4].grid(row=2, column=4)

    entries[1].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[1][5].grid(row=2, column=5, padx=(0 ,10))


    entries[2].append(Entry(top, width=3, justify='center', state=dimension_status3, disabledbackground='gray'))
    entries[2][0].grid(row=3, column=0, pady=(15,0), padx=(10, 0))

    entries[2].append(Entry(top, width=3, justify='center', state=dimension_status3, disabledbackground='gray'))
    entries[2][1].grid(row=3, column=1, pady=(15,0))

    entries[2].append(Entry(top, width=3, justify='center', state=dimension_status3, disabledbackground='gray'))
    entries[2][2].grid(row=3, column=2, pady=(15,0))

    entries[2].append(Entry(top, width=3, justify='center', state=dimension_status4, disabledbackground='gray'))
    entries[2][3].grid(row=3, column=3, pady=(15,0))

    entries[2].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[2][4].grid(row=3, column=4, pady=(15,0))

    entries[2].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[2][5].grid(row=3, column=5, pady=(15,0), padx=(0, 10))


    entries[3].append(Entry(top, width=3, justify='center', state=dimension_status4, disabledbackground='gray'))
    entries[3][0].grid(row=4, column=0, pady=(15,0), padx=(10, 0))

    entries[3].append(Entry(top, width=3, justify='center', state=dimension_status4, disabledbackground='gray'))
    entries[3][1].grid(row=4, column=1, pady=(15,0))

    entries[3].append(Entry(top, width=3, justify='center', state=dimension_status4, disabledbackground='gray'))
    entries[3][2].grid(row=4, column=2, pady=(15,0))

    entries[3].append(Entry(top, width=3, justify='center', state=dimension_status4, disabledbackground='gray'))
    entries[3][3].grid(row=4, column=3, pady=(15,0))

    entries[3].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[3][4].grid(row=4, column=4, pady=(15,0))

    entries[3].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[3][5].grid(row=4, column=5, pady=(15,0), padx=(0, 10))


    entries[4].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[4][0].grid(row=5, column=0, pady=(15,0), padx=(10, 0))

    entries[4].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[4][1].grid(row=5, column=1, pady=(15,0))

    entries[4].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[4][2].grid(row=5, column=2, pady=(15,0))

    entries[4].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[4][3].grid(row=5, column=3, pady=(15,0))

    entries[4].append(Entry(top, width=3, justify='center', state=dimension_status5, disabledbackground='gray'))
    entries[4][4].grid(row=5, column=4, pady=(15,0))

    entries[4].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[4][5].grid(row=5, column=5, pady=(15,0), padx=(0, 10))


    entries[5].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[5][0].grid(row=6, column=0, pady=(15,0), padx=(10, 0))

    entries[5].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[5][1].grid(row=6, column=1, pady=(15,0))

    entries[5].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[5][2].grid(row=6, column=2, pady=(15,0))

    entries[5].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[5][3].grid(row=6, column=3, pady=(15,0))

    entries[5].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[5][4].grid(row=6, column=4, pady=(15,0))

    entries[5].append(Entry(top, width=3, justify='center', state=dimension_status6, disabledbackground='gray'))
    entries[5][5].grid(row=6, column=5, pady=(15,0), padx=(0, 10))<file_sep>/axis_2d.py
import matplotlib.pyplot as plt
from itertools import cycle
import numpy as np

class Axis_2D:

    def __init__(self, x_vectors, y_vectors, max_vector):

        X = x_vectors
        Y = y_vectors

        # Creating the subplots and projecting the vectors

        fig, ax = plt.subplots()

        colors = cycle('grbcmy')
        for i in range(len(x_vectors)):
            current = next(colors)
            ax.quiver([0], [0], X[i], Y[i], units='xy', scale=1, color=current)
            if X[i].is_integer():
                X[i] = int(X[i])
            if Y[i].is_integer():
                Y[i] = int(Y[i])
            ax.text(X[i], Y[i], f'({X[i]},{Y[i]})', color=current)

        # Modifying the distance shown between the ticks\lines depending on the vector sizes

        major_ticks = np.arange(-10, 11, 1)
        minor_ticks = np.arange(-10, 11, 1)

        if max_vector>10 and max_vector <=100:
            major_ticks = np.arange(-100, 101, 10)
            minor_ticks = np.arange(-100, 101, 10)

        if max_vector>100 and max_vector <=1000:
            major_ticks = np.arange(-1000, 1001, 200)
            minor_ticks = np.arange(-1000, 1001, 200)

        ax.set_xticks(major_ticks)
        ax.set_xticks(minor_ticks, minor=True)
        ax.set_yticks(major_ticks)
        ax.set_yticks(minor_ticks, minor=True)

        ax.grid(which='both')
        ax.grid(which='minor', alpha=0.2)
        ax.grid(which='major', alpha=0.2)

        # UI details
        plt.grid()                      # grid lines
        ax.set_aspect('equal')          # Spaces of boxes
        ax.axhline(y=0, color='k')      # coloring origin Axis
        ax.axvline(x=0, color='k')
        fig.set_size_inches(6, 6)       # Setting figure size

        # Naming the Axis
        ax.set_xlabel('X')
        ax.set_ylabel('Y')

        plt.show()
<file_sep>/main.pyw
from tkinter import *
from utilities import gui_utilities
from PIL import ImageTk, Image
from tkinter import ttk
from vector_Entry_2d import Vector_Visualization_2D
from vector_Entry_3d import Vector_Visualization_3D
from inverse_Entry import InverseEntry
from determinant_Entry import DeterminantEntry


main_root = Tk()
gui_utilities.Window_Style(main_root, "  University Tools", "1003x589")

image = Image.open('images/main_img4.jpg')
resized_image = ImageTk.PhotoImage(image)
img_label = Label(main_root, image=resized_image, bg=gui_utilities.Main_Theme_Color())
img_label.grid(row=0, column=0, rowspan=5, columnspan=2)

main_root.iconbitmap('images/matrix.ico')


def Vector_Visualization_2D_Tab():
    vector_top = Toplevel()
    Vector_Visualization_2D(vector_top)


def Vector_Visualization_3D_Tab():
    vector_top = Toplevel()
    Vector_Visualization_3D(vector_top)


def Inverse_Matrix_Tab():
    inverse_top = Toplevel()
    InverseEntry(inverse_top)


def Determinant_Tab():
    det_top = Toplevel()
    DeterminantEntry(det_top)



vector_2d_button = ttk.Button(main_root, text="    הצגת וקטור דו-מימדי", command=Vector_Visualization_2D_Tab, width=21,
                              cursor='hand2')
vector_2d_button.grid(row=0, column=0, pady=100, padx=(150,0))

vector_3d_button = ttk.Button(main_root, text=" הצגת וקטור תלת-מימדי", command=Vector_Visualization_3D_Tab, width=21,
                              cursor='hand2')
vector_3d_button.grid(row=1, column=0, padx=(150,0))

Inverse_Matrix_button = ttk.Button(main_root, text="  חישוב מטריצה הפכית", command=Inverse_Matrix_Tab, width=21,
                                   cursor='hand2')
Inverse_Matrix_button.grid(row=0, column=1, pady=100, padx=(0,150))

determinant_button = ttk.Button(main_root, text="      חישוב דטרמיננטה", command=Determinant_Tab, width=21,
                                cursor='hand2')
determinant_button.grid(row=1, column=1, pady=25, padx=(0,150))


main_root.mainloop()<file_sep>/determinant.py
from tkinter import ttk
from tkinter import *
import numpy as np
from numpy.linalg import inv

from utilities import gui_utilities, coordinate_Entry, errors
import determinant_Entry


class Determinant:

    def __init__(self, top, dimension):

        self.top = top
        self.dimension = dimension
        self.entries = [[],[],[],[],[],[]]

        gui_utilities.Window_Style(self.top, "חישוב דטרמיננטה", "285x371")

        self.dimension_status6 = 'normal'
        self.dimension_status5 = 'normal'
        self.dimension_status4 = 'normal'
        self.dimension_status3 = 'normal'

        if dimension<6:
            self.dimension_status6 = 'disabled'
            if dimension<5:
                self.dimension_status5 = 'disabled'
                if dimension<4:
                    self.dimension_status4 = 'disabled'
                    if dimension<3:
                        self.dimension_status3 = 'disabled'

        self.background_label = Label(self.top, width=40, height=20, bg=gui_utilities.Main_Theme_Color())
        self.background_label.grid(row=1, column=0, rowspan=9, columnspan=6, sticky=W + N + E + S)

        coordinate_Entry.Coordinate_Entry(self.top, self.entries, self.dimension_status3, self.dimension_status4,
                                          self.dimension_status5, self.dimension_status6)

        self.confirm_button = ttk.Button(self.top, text="אישור", command=self.Get_Determinant, width=5,
                                         cursor='hand2')
        self.confirm_button.grid(row=7, column=0, pady=(20, 10), padx=(53, 0), columnspan=3)

        self.clear_button = ttk.Button(self.top, text="  נקה", command=self.Clear_Entries, width=5,
                                       cursor='hand2')
        self.clear_button.grid(row=7, column=3, pady=(20, 10), padx=(0, 53), columnspan=3)

        self.dimension_button = ttk.Button(self.top, text="     שנה גודל מטריצה", command=self.Change_Dimension,
                                           cursor='hand2', width=20)
        self.dimension_button.grid(row=8, column=0, pady=(10, 15), columnspan=6)

        self.det_frame = LabelFrame(self.top, bg=gui_utilities.Main_Theme_Color())
        self.det_frame.grid(row=9, column=0, columnspan=6, pady=(0,20))
        self.det_label = Label(self.det_frame, font='Helvetica', text="תוצאה", bg='#F9EFDA')
        self.det_label.grid(row=9, column=0, columnspan=6)

        self.top.bind('<Return>', lambda func: self.Get_Determinant())
        self.entries[0][0].focus_force()


    def Get_Determinant(self):

        vectors = []

        for i in range(self.dimension):
            vectors.append([])

            for j in range(self.dimension):
                if len(self.entries[i][j].get()) == 0:
                    errors.Empty_Error()
                    self.top.lift()
                    self.entries[i][j].focus_force()
                    return

                try:
                    vectors[i].append(int(self.entries[i][j].get()))

                except:
                    errors.Instance_Error("מספר")
                    self.top.lift()
                    self.entries[i][j].focus_force()
                    return


        # Getting the determinant
        np_vectors = np.array(vectors)
        det = np.linalg.det(np_vectors)

        # Checking if the determinant provided by numpy is a number that needs to be rounded
        # (for example, numpy returns -3.00000000000004 instead of -3 for the matrix [123, 132, 111])

        count_zeroes = 0
        count_nines = 0
        if '.' in str(det):
            index = str(det).index('.')
            for i in range(index+1, len(str(det))):
                if str(det)[i] == '0':
                    count_zeroes += 1
                elif str(det)[i] == '9':
                    count_nines += 1
                else:
                    break

            if count_zeroes >= 7 or count_nines >= 7:
                final_det = int(det)
                self.det_label.configure(text=str(final_det))
                self.entries[0][0].focus_force()

            else:
                self.det_label.configure(text=det)
                self.entries[0][0].focus_force()

        else:
            self.det_label.configure(text=det)
            self.entries[0][0].focus_force()

        self.Clear_Entries()


    def Clear_Entries(self):

        for row in self.entries:
            for entry in row:
                entry.delete(0, END)

        self.entries[0][0].focus_force()


    def Change_Dimension(self):

        top = Toplevel()
        determinant_Entry.DeterminantEntry(top)
        self.top.destroy()
<file_sep>/utilities/gui_utilities.py
from ttkthemes import ThemedStyle


def Center_Window(win):
    win.update_idletasks()

    screen_width = win.winfo_screenwidth()
    screen_height = win.winfo_screenheight()

    size = tuple(int(_) for _ in win.geometry().split('+')[0].split('x'))
    x = screen_width / 2 - size[0] / 2
    y = screen_height / 2 - size[1] / 2

    return x, y


def Window_Style(top, title, geometry):
    top.title(title)
    top.geometry(geometry)
    top.resizable(width=False, height=False)
    w, h = Center_Window(top)
    top.geometry("+%d+%d" % (w, h))
    # ttk theme:
    style = ThemedStyle(top)
    style.set_theme('blue')


def Main_Theme_Color():
    return '#aa5922'

<file_sep>/vector_Entry_3d.py
from tkinter import *
from tkinter import ttk
from axis_3d import Axis_3D
from utilities import gui_utilities, errors


class Vector_Visualization_3D():

    def __init__(self, top):

        self.x_vectors = []
        self.y_vectors = []
        self.z_vectors = []
        self.max_vector = 0

        self.top = top
        gui_utilities.Window_Style(self.top, "3D", "195x195")

        self.background_label = Label(self.top, bg=gui_utilities.Main_Theme_Color(), width=27)
        self.background_label.grid(row=0, column=0, rowspan=5, columnspan=2, sticky=W + N + E + S)

        self.x_label = Label(top, text="X", anchor='center', width=6, bg=gui_utilities.Main_Theme_Color())
        self.x_label.grid(row=1, column=0, pady=20)
        self.y_label = Label(top, text="Y", anchor='center', width=6, bg=gui_utilities.Main_Theme_Color())
        self.y_label.grid(row=2, column=0)
        self.z_label = Label(top, text="Z", anchor='center', width=6, bg=gui_utilities.Main_Theme_Color())
        self.z_label.grid(row=3, column=0, pady=20)

        self.x_entry = ttk.Entry(top, width=6, justify='center')
        self.x_entry.grid(row=1, column=1, pady=20)
        self.y_entry = ttk.Entry(top, width=6, justify='center')
        self.y_entry.grid(row=2, column=1)
        self.z_entry = ttk.Entry(top, width=6, justify='center')
        self.z_entry.grid(row=3, column=1, pady=20)

        self.add_button = ttk.Button(top, text="הוסף", command=self.Add_Vector, cursor='hand2')
        self.add_button.grid(row=4, column=0, pady=(0, 20))

        self.show_button = ttk.Button(top, text="הצג", command=self.Show_Vector, cursor='hand2')
        self.show_button.grid(row=4, column=1, pady=(0, 20))

        self.top.bind('<Return>', lambda func: self.Add_Vector())
        self.x_entry.focus_force()

    def Add_Vector(self):

        # Checking if the entries are empty

        if len(self.x_entry.get()) == 0:
            errors.Empty_Error()
            self.top.lift()
            self.x_entry.focus_force()
            return

        if len(self.y_entry.get()) == 0:
            errors.Empty_Error()
            self.top.lift()
            self.y_entry.focus_force()
            return

        if len(self.z_entry.get()) == 0:
            errors.Empty_Error()
            self.top.lift()
            self.z_entry.focus_force()
            return

        try:
            # Checking if the entries are numbers before we enter only 1 of them by mistake
            float(self.x_entry.get())
            float(self.y_entry.get())
            float(self.z_entry.get())

            # Checking the biggest vector

            if abs(float(self.x_entry.get())) > self.max_vector:
                self.max_vector = abs(float(self.x_entry.get()))
            if abs(float(self.y_entry.get())) > self.max_vector:
                self.max_vector = abs(float(self.y_entry.get()))
            if abs(float(self.z_entry.get())) > self.max_vector:
                self.max_vector = abs(float(self.z_entry.get()))

            # Entering the entries and deleting them from the fields
            self.x_vectors.append(float(self.x_entry.get()))
            self.y_vectors.append(float(self.y_entry.get()))
            self.z_vectors.append(float(self.z_entry.get()))
            self.x_entry.delete(0, END)
            self.y_entry.delete(0, END)
            self.z_entry.delete(0, END)
            self.x_entry.focus_force()

        except:
            errors.Instance_Error("מספר")
            self.top.lift()
            self.x_entry.focus_force()
            return

    def Show_Vector(self):
        self.top.destroy()
        Axis_3D(self.x_vectors, self.y_vectors, self.z_vectors, self.max_vector)<file_sep>/vector_Entry_2d.py
from tkinter import *
from tkinter import ttk
from utilities import gui_utilities, errors
from axis_2d import Axis_2D


class Vector_Visualization_2D:

    def __init__(self, top):

        self.x_vectors = []
        self.y_vectors = []
        self.max_vector = 0

        self.top = top
        gui_utilities.Window_Style(self.top, "2D", "195x150")

        self.background_label = Label(self.top, bg=gui_utilities.Main_Theme_Color(), width=27)
        self.background_label.grid(row=0, column=0, rowspan=4, columnspan=2, sticky=W + N + E + S)

        self.x_label = Label(top, text="X", anchor='center', width=6, bg=gui_utilities.Main_Theme_Color())
        self.x_label.grid(row=1, column=0, pady=20)
        self.y_label = Label(top, text="Y", anchor='center', width=6, bg=gui_utilities.Main_Theme_Color())
        self.y_label.grid(row=2, column=0, pady=(0, 20))

        self.x_entry = ttk.Entry(top, width=6, justify='center')
        self.x_entry.grid(row=1, column=1, pady=20)
        self.y_entry = ttk.Entry(top, width=6, justify='center')
        self.y_entry.grid(row=2, column=1, pady=(0, 20))

        self.add_button = ttk.Button(top, text="הוסף", command=self.Add_Vector, cursor='hand2')
        self.add_button.grid(row=3, column=0, pady=(0, 20))

        self.show_button = ttk.Button(top, text="הצג", command=self.Show_Vector, cursor='hand2')
        self.show_button.grid(row=3, column=1, pady=(0, 20))

        self.top.bind('<Return>', lambda func: self.Add_Vector()) # Binding the 'Enter' key to a button
        self.x_entry.focus_force()


    def Add_Vector(self):

        # Checking if the entries are empty

        if len(self.x_entry.get()) == 0:
            errors.Empty_Error()
            self.top.lift()
            self.x_entry.focus_force()
            return

        if len(self.y_entry.get()) == 0:
            errors.Empty_Error()
            self.top.lift()
            self.y_entry.focus_force()
            return

        try:
            # Checking if the entries are numbers before we enter only 1 of them by mistake
            float(self.x_entry.get())
            float(self.y_entry.get())

            # Checking the biggest vector

            if abs(float(self.x_entry.get())) > self.max_vector:
                self.max_vector = abs(float(self.x_entry.get()))
            if abs(float(self.y_entry.get())) > self.max_vector:
                self.max_vector = abs(float(self.y_entry.get()))

            # Entering the entries and deleting them from the fields
            self.x_vectors.append(float(self.x_entry.get()))
            self.y_vectors.append(float(self.y_entry.get()))
            self.x_entry.delete(0, END)
            self.y_entry.delete(0, END)
            self.x_entry.focus_force()

        except:
            errors.Instance_Error("מספר")
            self.top.lift()
            self.x_entry.focus_force()
            return


    def Show_Vector(self):
        self.top.destroy()
        Axis_2D(self.x_vectors, self.y_vectors, self.max_vector)<file_sep>/inverse_Entry.py
from tkinter import ttk
from tkinter import *

from utilities import gui_utilities, errors
from inverse_Matrix import InverseMatrix


class InverseEntry:

    def __init__(self, top):

        self.top = top
        gui_utilities.Window_Style(self.top, "מטריצה הפכית", "332x150")

        self.background_label = Label(self.top, width=47, bg=gui_utilities.Main_Theme_Color())
        self.background_label.grid(row=1, column=0, rowspan=4, sticky=W + N + E + S)

        self.label = Label(self.top, text='הזינו את גודל המטריצה הריבועית (2 - 6):', width=20, height=3,
                           bg=gui_utilities.Main_Theme_Color())
        self.label.grid(row=0, column=0, sticky=W + N + E + S)

        self.entry = ttk.Entry(self.top, width=10, justify='center')
        self.entry.grid(row=2, column=0, pady=5, padx=50)

        self.button = ttk.Button(self.top, text="אישור", command=self.Coordinate_Entry, cursor='hand2')
        self.button.grid(row=3, column=0, pady=(15, 25))

        self.top.bind('<Return>', lambda func: self.Coordinate_Entry())
        self.entry.focus_force()


    def Coordinate_Entry(self):

        if len(self.entry.get()) == 0:
            errors.Empty_Error()
            self.top.lift()
            self.entry.focus_force()
            return

        try:
            if int(self.entry.get()) < 2 or int(self.entry.get()) > 6:
                errors.Range_Error('2', '6')
                self.top.lift()
                self.entry.focus_force()
                return

        except:
            errors.Instance_Error("מספר")
            self.top.lift()
            self.entry.focus_force()
            return

        dimension = int(self.entry.get())
        coordinate_top = Toplevel()
        self.top.destroy()
        InverseMatrix(coordinate_top, dimension)
<file_sep>/utilities/errors.py
from tkinter import messagebox


def Instance_Error(instance):
    messagebox.showerror("שגיאה", f"אנא הזינו {instance}")


def Range_Error(min, max):
    messagebox.showerror("שגיאה", f"הטווח המותר הוא: {max} - {min}")

def Empty_Error():

    messagebox.showerror("שגיאה", f"אנא מלאו את כל השדות")
<file_sep>/axis_3d.py
from itertools import cycle

import matplotlib.pyplot as plt
import numpy as np

class Axis_3D:

    def __init__(self, x_vectors, y_vectors, z_vectors, max_vector):

        X = x_vectors
        Y = y_vectors
        Z = z_vectors

        # Creating the subplots and the axis

        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')

        # Modifying the distance shown between the ticks\lines depending on the vector sizes

        major_ticks = np.arange(-10, 11, 2)
        minor_ticks = np.arange(-10, 11, 2)

        axis_tick_modifier = 10

        if max_vector>10 and max_vector <=100:
            axis_tick_modifier*=10
            major_ticks = np.arange(-100, 101, 20)
            minor_ticks = np.arange(-100, 101, 20)

        if max_vector>100 and max_vector <=1000:
            axis_tick_modifier*=100
            major_ticks = np.arange(-1000, 1001, 200)
            minor_ticks = np.arange(-1000, 1001, 200)

        x, y, z = np.array([[-axis_tick_modifier, 0, 0], [0, -axis_tick_modifier, 0], [0, 0, -axis_tick_modifier]])
        u, v, w = np.array([[2*axis_tick_modifier, 0, 0], [0, 2*axis_tick_modifier, 0], [0, 0, 2*axis_tick_modifier]])

        ax.set_xticks(major_ticks)
        ax.set_xticks(minor_ticks, minor=True)
        ax.set_yticks(major_ticks)
        ax.set_yticks(minor_ticks, minor=True)
        ax.set_zticks(major_ticks)
        ax.set_zticks(minor_ticks, minor=True)

        ax.grid(which='both')
        ax.grid(which='minor', alpha=0.5)
        ax.grid(which='major', alpha=0.5)

        # Setting the origin axis vectors and the size of the figure
        ax.set_xlim(-10, 10)
        ax.set_ylim(-10, 10)
        ax.set_zlim(-10, 10)
        fig.set_size_inches(7, 6)

        # Make a 3D quiver plot
        ax.quiver(x, y, z, u, v, w, arrow_length_ratio=0.1, color="black")

        # Naming the axis
        ax.set_xlabel('X')
        ax.set_ylabel('Y')
        ax.set_zlabel('Z')

        # Projecting the vectors while rotating their colors
        colors = cycle('grbcmy')
        for i in range(len(x_vectors)):
            current = next(colors)
            ax.quiver([0], [0], [0], X[i], Y[i], Z[i], color=current)
            if X[i].is_integer():
                X[i] = int(X[i])
            if Y[i].is_integer():
                Y[i] = int(Y[i])
            if Z[i].is_integer():
                Z[i] = int(Z[i])
            ax.text(X[i], Y[i], Z[i], f'({X[i]},{Y[i]},{Z[i]})', color=current)

        plt.show()
