Event Handler tkinter

Viewed 24

After entering data on the second window in the Entry field, the Main class should work. The result is written to the created table in the main window (there is no table in the code) The table is created only after all fields are filled and the button is pressed. The size of the table is equal to the result that is obtained in the Main class. How can this be implemented?

import tkinter as tk
import random
from tkinter import ttk


class Main():
    def Main_1(self):
        rez = int(input())

        hmin = int(input())
        hmax = int(input())

        m = []
        itr = iter(m)

        while rez > 0:
            rand = random.randint(hmin, hmax)
            rez = rez - rand
            if rez > 0:
                m.append(rand)
            else:

                m.append(rez + rand)

        arr2d = [m[i:i + 6] for i in range(0, len(m), 6)]



class Window(tk.Toplevel):
    def __init__(self, parent):
        super().__init__(parent)

        self.geometry('300x100')
        self.title('Toplevel Window')


        e1 = ttk.Entry(self,
                  text='Goal').pack()
        e2 = ttk.Entry(self,
                  text='Goal').pack()
        e3 = ttk.Entry(self,
                  text='Goal').pack()


        ttk.Button(self,
                text='Close',
                command=self.destroy).pack(expand=True)


class App(tk.Tk):
    def __init__(self):
        super().__init__()

        self.geometry('300x200')
        self.title('Main Window')


        ttk.Button(self,
                text='Open a window',
                command=self.open_window).pack(expand=True)

    def open_window(self):
        window = Window(self)
        window.grab_set()


if __name__ == "__main__":
    app = App()
    app.mainloop()
0 Answers
Related