1
1

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 5 years have passed since last update.

ビンゴカード

Posted at

ビンゴを作ったのでビンゴカードも作りました。

もっと見やすくしたかった。。。

import tkinter as tk
import numpy as np

bingo = list(range(1,76))
get = np.random.choice(bingo)
gets = np.random.choice(bingo,25,replace=False)
     
def pushed(self):    
    self["text"] = ""
    self["fg"]='#ff0000'    
    
win = tk.Tk()
win.title("ビンゴ表")
win.geometry("500x500")
Point=50

button1= tk.Button(win, text=gets[0], command= lambda : pushed(button1),font=("",Point))
button1.grid(column=0, row=0, sticky=(tk.N, tk.S, tk.E, tk.W))
button2 = tk.Button(win, text=gets[1], command= lambda : pushed(button2),font=("",Point))
button2.grid(column=0, row=1, sticky=(tk.N, tk.S, tk.E, tk.W))
button3 = tk.Button(win, text=gets[2], command= lambda : pushed(button3),font=("",Point))
button3.grid(column=0, row=2, sticky=(tk.N, tk.S, tk.E, tk.W))
button4 = tk.Button(win, text=gets[3], command= lambda : pushed(button4),font=("",Point))
button4.grid(column=0, row=3, sticky=(tk.N, tk.S, tk.E, tk.W))
button5 = tk.Button(win, text=gets[4], command= lambda : pushed(button5),font=("",Point))
button5.grid(column=0, row=4, sticky=(tk.N, tk.S, tk.E, tk.W))
button6 = tk.Button(win, text=gets[5], command= lambda : pushed(button6),font=("",Point))
button6.grid(column=1, row=0, sticky=(tk.N, tk.S, tk.E, tk.W))
button7 = tk.Button(win, text=gets[6], command= lambda : pushed(button7),font=("",Point))
button7.grid(column=1, row=1, sticky=(tk.N, tk.S, tk.E, tk.W))
button8 = tk.Button(win, text=gets[7], command= lambda : pushed(button8),font=("",Point))
button8.grid(column=1, row=2, sticky=(tk.N, tk.S, tk.E, tk.W))
button9 = tk.Button(win, text=gets[8], command= lambda : pushed(button9),font=("",Point))
button9.grid(column=1, row=3, sticky=(tk.N, tk.S, tk.E, tk.W))
button10 = tk.Button(win, text=gets[9], command= lambda : pushed(button10),font=("",Point))
button10.grid(column=1, row=4, sticky=(tk.N, tk.S, tk.E, tk.W))
button11 = tk.Button(win, text=gets[10], command= lambda : pushed(button11),font=("",Point))
button11.grid(column=2, row=0, sticky=(tk.N, tk.S, tk.E, tk.W))
button12 = tk.Button(win, text=gets[11], command= lambda : pushed(button12),font=("",Point))
button12.grid(column=2, row=1, sticky=(tk.N, tk.S, tk.E, tk.W))
button13 = tk.Button(win, text="start", command= lambda : pushed(button13),font=("",Point))
button13.grid(column=2, row=2, sticky=(tk.N, tk.S, tk.E, tk.W))
button14 = tk.Button(win, text=gets[13], command= lambda : pushed(button14),font=("",Point))
button14.grid(column=2, row=3, sticky=(tk.N, tk.S, tk.E, tk.W))
button15 = tk.Button(win, text=gets[14], command= lambda : pushed(button15),font=("",Point))
button15.grid(column=2, row=4, sticky=(tk.N, tk.S, tk.E, tk.W))
button16 = tk.Button(win, text=gets[15], command= lambda : pushed(button16),font=("",Point))
button16.grid(column=3, row=0, sticky=(tk.N, tk.S, tk.E, tk.W))
button17 = tk.Button(win, text=gets[16], command= lambda : pushed(button17),font=("",Point))
button17.grid(column=3, row=1, sticky=(tk.N, tk.S, tk.E, tk.W))
button18 = tk.Button(win, text=gets[17], command= lambda : pushed(button18),font=("",Point))
button18.grid(column=3, row=2, sticky=(tk.N, tk.S, tk.E, tk.W))
button19 = tk.Button(win, text=gets[18], command= lambda : pushed(button19),font=("",Point))
button19.grid(column=3, row=3, sticky=(tk.N, tk.S, tk.E, tk.W))
button20 = tk.Button(win, text=gets[19], command= lambda : pushed(button20),font=("",Point))
button20.grid(column=3, row=4, sticky=(tk.N, tk.S, tk.E, tk.W))
button21 = tk.Button(win, text=gets[20], command= lambda : pushed(button21),font=("",Point))
button21.grid(column=4, row=0, sticky=(tk.N, tk.S, tk.E, tk.W))
button22 = tk.Button(win, text=gets[21], command= lambda : pushed(button22),font=("",Point))
button22.grid(column=4, row=1, sticky=(tk.N, tk.S, tk.E, tk.W))
button23 = tk.Button(win, text=gets[22], command= lambda : pushed(button23),font=("",Point))
button23.grid(column=4, row=2, sticky=(tk.N, tk.S, tk.E, tk.W))
button24 = tk.Button(win, text=gets[23], command= lambda : pushed(button24),font=("",Point))
button24.grid(column=4, row=3, sticky=(tk.N, tk.S, tk.E, tk.W))
button25 = tk.Button(win, text=gets[24], command= lambda : pushed(button25),font=("",Point))
button25.grid(column=4, row=4, sticky=(tk.N, tk.S, tk.E, tk.W))


win.columnconfigure(0, weight=1)
win.columnconfigure(1, weight=1)
win.columnconfigure(2, weight=1)
win.columnconfigure(3, weight=1)
win.columnconfigure(4, weight=1)

win.rowconfigure(0, weight=1)
win.rowconfigure(1, weight=1)
win.rowconfigure(2, weight=1)
win.rowconfigure(3, weight=1)
win.rowconfigure(4, weight=1)


win.mainloop()
1
1
2

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?