Ответ:
import tkinter as tk
class MyButton(tk.Button):
def __init__(self, master=None, **kwargs):
super().__init__(master, **kwargs)
self.bind("<Button-1>", self.on_click)
def on_click(self, event=None):
self.config(text="Місто: Київ", width=60, height=80)
root = tk.Tk()
root.geometry("200x100")
my_button = MyButton(root, text="Click me")
my_button.pack(pady=20)
root.mainloop()
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
import tkinter as tk
class MyButton(tk.Button):
def __init__(self, master=None, **kwargs):
super().__init__(master, **kwargs)
self.bind("<Button-1>", self.on_click)
def on_click(self, event=None):
self.config(text="Місто: Київ", width=60, height=80)
root = tk.Tk()
root.geometry("200x100")
my_button = MyButton(root, text="Click me")
my_button.pack(pady=20)
root.mainloop()