投稿
6月, 2024の投稿を表示しています
Here's a basic example of how to use Python Tkinter
- リンクを取得
- ×
- メール
- 他のアプリ
Here's a basic example of how to use Python Tkinter to create a simple GUI application with a label and a button: Python import tkinter as tk # Create the main window window = tk.Tk() # Set the title of the window window.title( "Sample Tkinter App" ) # Create a label widget label = tk.Label(window, text= "Hello, Tkinter!" ) label.pack() # Pack the label widget into the window # Define a function to handle button click def click_me (): label.config(text= "Button clicked!" ) # Change the label text # Create a button widget button = tk.Button(window, text= "Click Me" , command=click_me) button.pack() # Pack the button widget into the window # Run the main loop to keep the window open window.mainloop() Explanation: We import tkinter as tk for easier use. We create the main application window using tk.Tk() . We set the title of the window using the title() method. We create a label widget using tk.Label() with some te...