2019年5月18日土曜日

じゃんけんゲームのゲーム画面のプログラム その3

じゃんけんゲームのゲーム画面のプログラム その3です。




#coding:utf-8

import tkinter as tk

def click1():
    rirekibox.insert(tk.END,editbox1.get() + 'は、グーを出しました' + '\n')
def click2():
    rirekibox.insert(tk.END,editbox1.get() + 'は、チョキを出しました'+'\n')
def click3():
    rirekibox.insert(tk.END,editbox1.get() + 'は、パーを出しました'+'\n')


root = tk.Tk()
root.geometry('800x380')
root.title('じゃんけんゲーム')

label1 = tk.Label(root,text = 'じゃんけんをはじめます。', font = ('Courier',14))
label2 = tk.Label(root,text = '名前を入力して下さい。', font = ('Courier',14))
editbox1 = tk.Entry(width = 15, font = ('Courier',14))
label3 =tk.Label(root,text = '何を出しますか?', font = ('Courier',14))
button1 = tk.Button(root,text = ' グー  ', font = ('Courier',14),command = click1)
button2 = tk.Button(root,text = ' チョキ ', font = ('Courier',14),command = click2)
button3 = tk.Button(root,text = ' パー  ', font = ('Courier',14),command = click3)
button4 = tk.Button(root,text = 'ゲーム終了', font = ('Courier',14))
rirekibox = tk.Text(root, font = ('Courier',14))

label1.place(x = 20, y = 20)
label2.place(x = 20, y = 50)
editbox1.place(x = 40, y = 90)
label3.place(x = 20, y = 150)
button1.place(x = 20, y = 190)
button2.place(x = 150, y = 190)
button3.place(x = 280, y = 190)
button4.place(x = 320, y = 300)
rirekibox.place(x = 500, y =0, width = 300, height = 380)




root.mainloop()
  

メモ

・まだゲームは出来ません。
・画面表示をこんな感じにしたいなと思っています。
・「いちばんやさしいPython入門教室」という本を参考にしています。
・プレイヤーの名前を入力してそれが表示されるようにしました。

0 件のコメント:

コメントを投稿