本文实例为大家分享了python3实现弹弹球小游戏的具体代码,供大家参考,具体内容如下
from tkinter import *
from tkinter import messagebox
import random
import time
from PIL import Image, ImageTk
import sys
class Game:
def __init__(self):
self.tk = Tk()
self.times = 0
sw = self.tk.winfo_screenwidth()
sh = self.tk.winfo_screenheight()
image = Image.open(r'02.jpg')
background_image = ImageTk.PhotoImage(image)
ww = background_image.width()
wh = background_image.height()
x = (sw-ww)/2
y = (sh-wh)/2
self.tk.geometry("%dx%d+%d+%d" % (ww, wh, x, y))
self.tk.title('欢迎进入弹弹弹')
background_label = Label(self.tk, image=background_image)
background_label.place(x=0, y=0, relwidth=1, relheight=1)
self.tk.resizable(False, False)
self.tk.wm_attr