我正在用 python 做一个小图形用户界面,我想添加一个带有图像的按钮。所以我遵循这里所说的:https : //www.geeksforgeeks.org/python-add-image-on-a-tkinter-button/
它给 :
downimage = PhotoImage(file = "Downloadimage.png")
Dowloadbutton = Button(window, image=downimage, font=("Source Code Pro Light", 20), bg='black', fg='lime', command=start)
Dowloadbutton.pack()
Run Code Online (Sandbox Code Playgroud)
正如链接中所说。但是神奇的事情发生了:
Traceback (most recent call last):
File "Keylogger.pyw", line 28, in <module>
downimage = PhotoImage(file = "Downloadimage.png")
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 3545, in __init__
Image.__init__(self, 'photo', name, cnf, master, **kw)
File "C:\Users\Elève\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 3501, in __init__
self.tk.call(('image', 'create', imgtype, name,) + options)
_tkinter.TclError: CRC check failed
Run Code Online (Sandbox Code Playgroud)
第 28 行对应于downimage = PhotoImage(file = "Downloadimage.png")。其他所有东西都打包并出现,但我的按钮没有并给我那个错误。我不知道这是什么意思,当我尝试在互联网上搜索它时,出现了很多与 …
我正在使用 Ursina 引擎创建 3D 游戏。然而,当我尝试加载 FirstPersonCharacter 时,我得到的只是一个灰色背景(正常)和一个位于中心的非常小的洋红色正方形,倾斜角度为 45\xc2\xb0。那是什么 ?
\n我首先尝试为第一人称角色制作自己的机制,根据鼠标位置移动相机(我有这个),我正在玩数学和运动的东西......我正在看这个视频(https ://www.youtube.com/watch?v=DHSRaVeQxIk)完全是别的东西,我发现了 FirstPersonController。
\n但是,使用与他(几乎)相同的代码,它不起作用!这是什么问题,有人遇到过吗?FirstPersonController 坏了吗?还是我脑子坏了?
\n编辑:在 ursina 备忘单中发现,洋红色的小倾斜方块是光标。但我还是动不了,没有重力什么的?我看不到我的地板。
\n第二次编辑:使用 ursina 备忘单提供的一些代码进行安排,我现在可以看到我的楼层。但我只能在 1 个轴上移动相机(上下),我无法移动,没有重力,什么都没有......
\n这是我的代码:
\nfrom ursina import *\nfrom ursina.prefabs.first_person_controller import FirstPersonController\n\napp = Ursina()\n\nwindow.title = \'The lab\'\nwindow.borderless = False\nwindow.fullscreen = True\nwindow.exit_button.visible = False\nwindow.fps_counter.enabled = True\n\nfloorcubes = []\nfor i in range(-20, 20, 2):\n for j in range(-20, 20, 2):\n floorcubes.append(Entity(model=\'cube\', color=color.white, scale=(2,2,2), position = (i, 0, j)))\nplayer = FirstPersonController()\napp.run()\nRun Code Online (Sandbox Code Playgroud)\n这是 ursina 备忘单中提供的代码,稍作安排:
\nfrom …Run Code Online (Sandbox Code Playgroud)