Advertisement
matisarnowski

main.py

Feb 19th, 2023
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.34 KB | None | 0 0
  1. from my_tkinter import *
  2. from compute import *
  3. import matplotlib.pyplot as plt
  4. import numpy as np
  5.  
  6. if __name__ == "__main__":
  7.     root = tk.Tk()
  8.     my_gui = Window(root, False)
  9.     root.mainloop()
  10.  
  11.     if my_gui.parametr:
  12.         compute = LinearEquations(float(my_gui.text_variable_a1.get()),
  13.                                   float(my_gui.text_variable_b1.get()),
  14.                                   float(my_gui.text_variable_c1.get()),
  15.                                   float(my_gui.text_variable_a2.get()),
  16.                                   float(my_gui.text_variable_b2.get()),
  17.                                   float(my_gui.text_variable_c2.get()))
  18.  
  19.         bool_var = compute.is_compute()
  20.  
  21.         if bool_var:
  22.             co_ordinates = compute.equal_equations_linear()
  23.         else:
  24.             string_var = compute.equal_equations_linear()
  25.  
  26.         fig = plt.figure()
  27.         ax = fig.add_subplot(1, 1, 1)
  28.         x = np.linspace(-5, 5, 100)
  29.         ax.spines['left'].set_position('center')
  30.         ax.spines['bottom'].set_position('center')
  31.         ax.spines['right'].set_color('none')
  32.         ax.spines['top'].set_color('none')
  33.         ax.xaxis.set_ticks_position('bottom')
  34.         ax.yaxis.set_ticks_position('left')
  35.         num_1 = -1 * float(my_gui.text_variable_a1.get()) / float(
  36.             my_gui.text_variable_b1.get())
  37.         free_word_1 = float(my_gui.text_variable_c1.get()) / float(
  38.             my_gui.text_variable_b1.get())
  39.         num_2 = -1 * float(my_gui.text_variable_a2.get()) / float(
  40.             my_gui.text_variable_b2.get())
  41.         free_word_2 = float(my_gui.text_variable_c2.get()) / float(
  42.             my_gui.text_variable_b2.get())
  43.         plt.plot(x,
  44.                  num_1 * x + free_word_1,
  45.                  '-r',
  46.                  label='{a1}x + {b1}y = {c1}'.format(
  47.                      a1=my_gui.text_variable_a1.get(),
  48.                      b1=my_gui.text_variable_b1.get(),
  49.                      c1=my_gui.text_variable_c1.get()))
  50.         plt.plot(x,
  51.                  num_2 * x + free_word_2,
  52.                  '-g',
  53.                  label='{a2}x + {b2}y = {c2}'.format(
  54.                      a2=my_gui.text_variable_a2.get(),
  55.                      b2=my_gui.text_variable_b2.get(),
  56.                      c2=my_gui.text_variable_c2.get()))
  57.         plt.legend(loc='upper left')
  58.         plt.show()
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement