返回

我正在尝试在 python 中加载图像,但它不起作用(我正在使用 Pillow)

发布时间:2022-07-04 11:43:37 186
# node.js

当在VS代码上使用枕头时,我似乎无法加载图像。我在网上到处搜索,试图找出我做错了什么,但什么也找不到。我希望有人能给出答案。知道我做错了什么吗?这是我的代码:

         #Imports
         import tkinter
         import numpy #numpy is a useful list library, for example, numpy.random.rand()
         import keyboard #keyboard so we can take keyboard presses, for example,        
         keyboard.is_pressed()from tkinter import * #for creating a window
         import PIL


        #Creating variables
        playing = False #playing to see if game is running, can be used to stop game
        height = 300 #height for the height of the game window, needed for creating the game window
        width = 500 #width for the width of the game window, needed for creating the game window
        fps = 60 #frames per second, useful for when start running things


        # declare the window
        window = Tk()
        # set window title
        window.title("Fighting Game")
        # set window width and height
        window.configure(width=500, height=300)
        # set window background color
        window.configure(bg='white')
        window.mainloop()   
 
        #Creating game loop
        playing = True #Make playing true
        while playing == True: #The game loop
        img = Image.open('Untitled.png') #creating image
        img.show() #showing image
特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像