Windows 10
Python (3.8)
Библиотека pillow 8.1.2
Добрый вечер,
Пишу код создания тестирования с регистрацией. При нажатии на кнопку Save чтобы сохранить данные с полей ввода выдает ошибку 'NoneType' object has no attribute 'get', И так же хотел бы спросить как можно из разных классов в tkinter принимать переменные (К примеру в моем случае в класс MainWindow получить переменные self.a, self.b, self.c из класса Register).
Python (3.8)
Библиотека pillow 8.1.2
Добрый вечер,
Пишу код создания тестирования с регистрацией. При нажатии на кнопку Save чтобы сохранить данные с полей ввода выдает ошибку 'NoneType' object has no attribute 'get', И так же хотел бы спросить как можно из разных классов в tkinter принимать переменные (К примеру в моем случае в класс MainWindow получить переменные self.a, self.b, self.c из класса Register).
Python:
from tkinter import *
import tkinter as tk
from TestingProgramm import NewWindow
from Register import Register
from PIL import Image as PilImage
from PIL import ImageTk
class MainWindow:
def __init__(self, width, height, title="Math", resizable=(True, True), icon="res/12079.ico"):
self.root = Tk()
self.root.title(title)
self.root.geometry(f'{width}x{height}+200+200')
self.root.resizable(resizable[0], resizable[1])
if icon:
self.root.iconbitmap(icon)
img = PilImage.open(r"res\math.jpg")
img = img.resize((560, 750), PilImage.ANTIALIAS)
self.login = Entry
self.photo_image = ImageTk.PhotoImage(img)
def run(self):
self.objects_on_the_screen()
self.root.mainloop()
def objects_on_the_screen(self):
Button(self.root, width=30, height=5, text="Регистрация",
command=lambda: self.create_window1(400, 500, "Registration"),
relief=GROOVE, bd=7, font=("Times New Roman", 15, "bold")).place(x=100, y=240)
Button(self.root, width=30, height=5, text="Начать тестирование",
relief=GROOVE, bd=7, font=("Times New Roman", 15, "bold")).place(x=100, y=410)
Button(self.root, image=self.photo_image).place(x=700, y=200)
Button(self.root, width=30, height=5, text="Выход", command=quit,
relief=GROOVE, bd=7, font=("Times New Roman", 15, "bold")).place(x=100, y=580)
def create_window(self, width, height, title="Test", resizable=(True, True), icon=None):
e = Register(self.root, width, height, title, resizable, icon)
def create_window1(self, width, height, title="Test2", resizable=(True, True), icon=None):
a = Register(self.root, width, height, title, resizable, icon)
if __name__ == "__main__":
window = MainWindow(1920, 1080)
window.run()
# __name__ == __main__
Python:
from tkinter import *
class Register:
def __init__(self, parent, width, height, title="Registration", resizable=(False, False), icon=None):
self.root = Toplevel(parent)
self.root.title(title)
self.root.geometry(f"{width}x{height}+200+200")
self.root.resizable(resizable[0], resizable[1])
if icon:
self.root.iconbitmap(icon)
self.login1 = Label(self.root, text="").pack()
self.login2 = Label(self.root, text="").pack()
self.login3 = Label(self.root, text="").pack()
self.login = Label(self.root, text="Login:").pack()
self.login_entry = Entry(self.root).pack()
self.age = Label(self.root, text="Password:").pack()
self.password_entry = Entry(self.root, show="*").pack()
self.password = Label(self.root, text="Age:").pack()
self.age_entry = Entry(self.root).pack()
self.bUtton = Button(self.root, width=30, height=5, text="Save", command=lambda: self.save(),
relief=GROOVE, bd=7, font=("Times New Roman", 15, "bold")).pack()
def save(self):
self.a = self.login_entry.get()
self.b = self.age_entry.get()
self.c = self.password_entry.get()
self.login11 = Label(self.root, text=self.a).pack()
# __name__ == __Register__
Код:
from tkinter import *
class NewWindow:
def __init__(self, parent, width, height, title="Test", resizable=(False ,False), icon=None):
self.root = Toplevel(parent)
self.root.title(title)
self.root.geometry(f"{width}x{height}+200+200")
self.root.resizable(resizable[0], resizable[1])
if icon:
self.root.iconbitmap(icon)
# __name__ == __TestingProgramm__