Это мой код (предположительно работоспособный)
Код: Выделить всё
from tkinter import *
from tkinter import ttk
class OPButton(Button):
""" """
def ___init___(self, parent, string, message, *args, **kwargs):
ttk.Button.__init__(self, parent, *args, **kwargs)
self.bind("", command=lambda e: string.set(message))
self.bind("", command=lambda e: string.set(""))
if __name__ == '__main__':
root = Tk()
root.str= StringVar()
OPButton(root, root.str, "hovering the button", text="click here").pack()
ttk.Label(root, textvariable=root.str).pack()
root.mainloop()
Код: Выделить всё
Traceback (most recent call last):
File "C:\Users\planchoo\oPButton.py", line 19, in
OPButton(root, "Hello World", "Bouton", text="Hello").pack()
TypeError: __init__() takes from 1 to 3 positional arguments but 4 were given
Подробнее здесь: https://stackoverflow.com/questions/466 ... -arguments
Мобильная версия