0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

python tkinterのボタンを使う

Posted at

準備

まず初めにtkinter
をimportします

 import tkinter as tk

次にbuttonを表示するためのWindowを作成します

 import tkinter as tk
 root = tk.Tk()

これで準備は終了です

コードを書こう!

ではコードを書いていこうと思います
ボタンを作るには

ボタン名 = tk.Button(表示数Window名, text="表示するテキスト, command = ボタンが押されたとき実行する関数名).pack

とすればボタンを作成することができます

 import tkinter as tk
 
 def ok():
     print("OK!")
 
 root = tk.Tk()
 button = tk.Button(root, text ="OK", command =  ok).pack()

buttonの最後に”.pack“とありますが
pack以外にも gridや placeもあります

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?