1
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

はじめに

Pythonは未だ初心者ですが、Tkinterを使ってコメントを投稿してみました。

Tkinterをインポートする

まず初めにTkinterをインポートします。

>>>import tkinter

コードを実行する

下記はコードの実行結果です。

import tkinter
""" 投稿ボタンの生成 """
def click_btn():
    x = text_x.get('1.0', 'end -1c')
    text_y.insert(tkinter.END, x)
""" 消去ボタンの生成 """
def delete_btn():
    text_y.delete('1.0', tkinter.END)


root = tkinter.Tk()
root.title('コメント出力')
root.geometry('600x600')
"""コメント書き込み欄の生成 """
text_x = tkinter.Text(width = 50, height = 6, font = ('Times New Roman', 16))
text_x.place(x = 20, y = 350)
""" コメント投稿欄の生成 """
text_y = tkinter.Text(width = 50, height = 6, font = ('Times New Roman', 16), bg = 'lightyellow')
text_y.place(x = 20, y = 50)
btn = tkinter.Button(text = '投稿', font = ('Times New Roman', 16), command = click_btn, bg = 'lightblue')
btn.place(x = 190, y = 550)
btn = tkinter.Button(text = '消去', font = ('Times New Roman', 16), command = delete_btn, bg = 'lightgreen')
btn.place(x = 290, y = 550)

root.mainloop()

tkinterコメント投稿.png

以上になります。

1
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
1
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?