There is a main window. In this window there is a button that, when clicked, opens a new window. In this window, you can select parameters and set them when you press a certain button. But when I press this button, an error occurs.
Unbound method get () must be called with Settings_of_generation instance as the first argument (got nothing instead)
Here is a piece of code:
class Settings_of_generation(object): def __init__(self): self = Tk() self.title('Настройки генерации') self.maxsize(500, 500) self.minsize(500, 500) self.geometry('500x500+100+100') label_length_scale_of_password = Label(self, text = 'Длина пароля:', font = 'Arial') label_length_scale_of_password.place(x = 0, y = 0) length_scale_of_password = Scale(self, orient = HORIZONTAL, length = 30, from_ = 1, to = 30, tickinterval = 1, resolution = 1) length_scale_of_password.place(x = 0, y = 20, width = 500) but = Button(self, text = 'get', command = Settings_of_generation.get()) but.pack() def get(self): label_length_scale_of_password.configure(text = length_scale_of_password.get())
Full code:
# -*- coding: utf-8 -*- from Tkinter import * class Settings_of_generation(object): def __init__(self): self = Tk() self.title('Настройки генерации') self.maxsize(500, 500) self.minsize(500, 500) self.geometry('500x500+100+100') self.label_length_scale_of_password = Label(self, text = 'Длина пароля:', font = 'Arial') self.label_length_scale_of_password.place(x = 0, y = 0) self.length_scale_of_password = Scale(self, orient = HORIZONTAL, length = 30, from_ = 1, to = 30, tickinterval = 1, resolution = 1) self.length_scale_of_password.place(x = 0, y = 20, width = 500) but = Button(self, text = 'get', command = self.get()) print ('succes') but.pack() def get(self): self.label_length_scale_of_password.configure(text = self.length_scale_of_password.get()) root = Tk() root.title('Генератор пароля') root.maxsize(500, 300) root.minsize(500, 300) root.geometry('500x300+600+200') generation_settings_button = Button(root, text = 'Настройки генерации', command = Settings_of_generation) generation_settings_button.place(x = 0, y = 0) generation_button = Button(root, text = 'Сгенерировать') generation_button.place(x = 410, y = 0) root.mainloop()