Відповідь:
import tkinter as tk
# Define planet information
planet_info = {
"Mars": "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System, after Mercury. It is often referred to as the Red Planet because of its reddish appearance.",
}
# Define function to show planet information
def show_info(planet):
info_label.configure(text=planet_info[planet])
# Create main window
root = tk.Tk()
root.title("Information about planets")
root.geometry("300x200")
# Create button for Mars
mars_button = tk.Button(root, text="Mars", command=lambda: show_info("Mars"))
mars_button.pack(pady=10)
# Create label for displaying information
info_label = tk.Label(root, text="", font=("Helvetica", 12))
info_label.pack(pady=20)
# Run main loop
root.mainloop()
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Відповідь:
import tkinter as tk
# Define planet information
planet_info = {
"Mars": "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System, after Mercury. It is often referred to as the Red Planet because of its reddish appearance.",
}
# Define function to show planet information
def show_info(planet):
info_label.configure(text=planet_info[planet])
# Create main window
root = tk.Tk()
root.title("Information about planets")
root.geometry("300x200")
# Create button for Mars
mars_button = tk.Button(root, text="Mars", command=lambda: show_info("Mars"))
mars_button.pack(pady=10)
# Create label for displaying information
info_label = tk.Label(root, text="", font=("Helvetica", 12))
info_label.pack(pady=20)
# Run main loop
root.mainloop()