If you click the button with the TKINTER GUI, the current time is printed, but the button is not printed in the 23rd and 3rd positions.
There are no errors.
What's the problem?
from datetime import datetime
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
import webbrowser
class MyInformation:
def __init__(self):
self.root = Tk()
def Button_Clicked(self): # Current visual output function
now = datetime.now()
print("now date and time : "+str(now))
button = Button (self.root, text="current visual output", command=self.Button_Closed, width=10, height=2)
self.button.grid(row=23, column=3)
self.root.mainloop()
from tkinter import *
from datetime import datetime
# import matplotlib.pyplot as plt
# from matplotlib.figure import Figure
# from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
# import webbrowser
class MyInformation:
def __init__(self):
self.root = Tk()
Self button = button (self text, root button clicked,. = = "It's now output" ; command self width 2 = 10, height).
self.button.grid(row=23, column=3)
self.label = Label(self.root, text="", width=40, height=2)
self.label.grid(row=1, column=1)
def button_clicked(self): # Current visual output function
now = datetime.now()
print("now date and time : " + str(now))
self.label["text"] = "now date and time : " + str(now)
def run(self):
self.root.mainloop()
main = MyInformation()
main.run()
You must create a class object. Variable = class.
© 2024 OneMinuteCode. All rights reserved.