雑多な技術系メモ

自分用のメモ。内容は保証しません。よろしくお願いします。

tkinterについてのメモ

tkinter

pythonで簡単にguiアプリが作れるライブラリ

とりあえず動かす

ボタンが1つついているアプリが起動する

import tkinter

root = tkinter.Tk()
root.geometry("300x200")    # サイズの指定
root.title("test")          # タイトルの設定

label = tkinter.Label(text="not clicked")
label.place(x=30, y=70)

# ボタンがクリックされた処理
def button_clicked():
    label["text"] = "clicked!"

# ボタンの作成(add)
button = tkinter.Button(root, text="btn", command=button_clicked)
button.place(x=100, y=170)

root.mainloop()