- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的 reset()
函数应该清除所有内容并重绘新的内容,但它不起作用。有人可以给我一些建议吗?
import pygame
import string
import random
import time
import sys
pygame.init ()
size = (1600, 900)
win = pygame.display.set_mode(size)
pygame.display.set_caption('Gerador de encontros para Tomb of Annihilation')
win.fill((255,255,255))
pygame.display.update()
red = (200,0,0)
green = (0,200,0)
blue = (0,0,200)
black = (0,0,0)
white = (255,255,255)
encontro1 = "Aguardando"
encontro = 0
MONSTRO_T = "Arakrocra.jpg"
texto = "Monstro Puto"
item = "NONE"
image = pygame.image.load(MONSTRO_T)
imagePos = (1100,190)
win.blit(image, imagePos)
def text_objects(text, font, color):
textSurface = font.render(text, True, color)
return textSurface, textSurface.get_rect()
def button(msg,x,y,w,h,ic,ac,it,at,action=None):
mouse = pygame.mouse.get_pos()
click = pygame.mouse.get_pressed()
if x+w > mouse[0] > x and y+h > mouse[1] > y:
pygame.draw.rect(win, ac,(x,y,w,h))
smallText = pygame.font.Font("freesansbold.ttf",18)
textSurf, textRect = text_objects(msg, smallText,at)
textRect.center = ( (x+(w/2)), (y+(h/2)) )
win.blit(textSurf, textRect)
if click[0] == 1 and action != None:
action()
else:
pygame.draw.rect(win, ic,(x,y,w,h))
smallText = pygame.font.Font("freesansbold.ttf",20)
textSurf, textRect = text_objects(msg, smallText,it)
textRect.center = ( (x+(w/2)), (y+(h/2)) )
win.blit(textSurf, textRect)
## x = eixoX, y = eixoY, w = Altura, h = Largura, ic = Cor inativa ( do botão ), ac = cor ativa, it = Inative text color, at = active text color
def M_generator():
return (random.randint(1,100))
def ef():
global encontro
global encontro1
encontro = 1
encontro1 = "Characters Level 1 to 4"
def en():
global encontro
global encontro1
encontro = 2
encontro1 = "Characters Level 4 to 8"
def em():
global encontro
global encontro1
encontro = 3
encontro1 = "Characters Level 8 or above"
def warning():
largeText = pygame.font.Font('freesansbold.ttf',50)
TextSurf, TextRect = text_objects('Selecione a dificuldade primeiro', largeText, red)
TextRect.center = ((700),(300))
win.blit(TextSurf, TextRect)
pygame.display.update()
def lore(tf,color,ta,tl,texto):
largeText = pygame.font.Font('freesansbold.ttf',tf)
TextSurf, TextRect = text_objects(texto, largeText, color)
TextRect.center = ((tl),(ta))
win.blit(TextSurf, TextRect)
pygame.display.update()
def quitgame():
pygame.quit()
exit()
def CACHES():
global texto
global item
roll = (random.randint(1,20))
if roll == 1:
texto = "Rain catcher (see chapter l) and mess kit "
item1 = (random.randint(1,100))
item = "1"
elif roll == 2:
texto = "10-day supply of preserved rations"
item1 = (random.randint(1,10))
item = str(item1)
elif roll == 3:
texto = "20-day supply of preserved rations"
item1 = (random.randint(1,20))
item = str(item1)
elif roll == 4:
texto = "50-day supply of preserved rations"
item1 = (random.randint(1,50))
item = str(item1)
elif roll == 5:
texto = "ld4 casks of water holding 5 gallons each"
item1 = (random.randint(1,4))
item = str(item1)
elif roll == 6:
texto = "ld4 casks oftej (see chapter l)"
item1 = (random.randint(1,4))
item = str(item1)
elif roll == 7:
texto = "ld4 climber's kits"
item1 = (random.randint(1,4))
item = str(item1)
elif roll == 8:
texto = "20-day supply of insect repellent salve (see chapter l) in a leather tube"
item1 = (random.randint(1,20))
item = str(item1)
elif roll == 9:
texto = "ld4 quivers, each containing ld20 arrows"
item1 = (random.randint(1,4))
item = str(item1)
elif roll == 10:
texto = "Canoe with six paddles"
item1 = (random.randint(1,100))
item = "1"
elif roll == 11:
texto = "2 hooded lanterns and 10 flasks of lamp oil"
item1 = (random.randint(1,10))
item = str(item1)
elif roll == 12:
texto = "Two-person tent and ld4 explorer's packs"
item1 = (random.randint(1,4))
item = str(item1)
elif roll == 13:
texto = "Wooden box containing 2dl0 daggers (low quality,of the type used as trade goods)"
item1 = (random.randint(2,20))
item = str(item1)
elif roll == 14:
texto = "20-day supply of insect repellent salve (see chapter l) in a leather tube"
item1 = (random.randint(1,20))
item = str(item1)
elif roll == 15:
texto = "Set of navigator's tools"
item1 = (random.randint(1,100))
item = "1"
elif roll == 16:
texto = "ldlO changes of woolen clothing"
item1 = (random.randint(1,10))
item = str(item1)
elif roll == 17:
texto = "Set of cartographer's tools"
item1 = (random.randint(1,100))
item = "1"
elif roll == 18:
texto = "Two-person tent and 1d4 healer's kits"
item1 = (random.randint(1,4))
item = str(item1)
elif roll == 19:
texto = "2 two-person tents, folding camp table, and four folding stools"
item1 = (random.randint(1,100))
item = "1"
else :
texto = "Wooden box containing 2d4 po lions of healing"
item1 = (random.randint(2,8))
item = str(item1)
def beach():
global MONSTRO_T
MONSTRO_N = (M_generator())
if (MONSTRO_N < 7):
if encontro == 1:
MONSTRO_T = "Arakocra.jpg"
imagePos = (900,190)
win.blit(image, imagePos)
lore(30,black,250,500,"Any character with a passive Wisdom (Perception) score ")
lore(30,black,300,500,"of 15 or higher spots ld4 + 1 aarakocra flying overhead. ")
lore(30,black,350,500,"These creatures are scouts from Kir Sabal or another ")
lore(30,black,400,500,"aerie. They observe the party from a safe distance")
lore(30,black,450,500,"but don't approach unless the characters demonstrate")
lore(30,black,500,500,"peaceful intentions. The bird folk are friendly and can")
lore(30,black,550,500,"point characters in the direction of nearby landmarks.")
grupo1 = (random.randint(1,4)+1)
print(grupo1)
grupo = str(grupo1)
lore(35,black,600,500,"Grupo de ")
lore(35,black,600,650,grupo)
if encontro == 2:
MONSTRO_T = "Arakocra.jpg"
imagePos = (900,190)
win.blit(image, imagePos)
lore(30,black,250,500,"Any character with a passive Wisdom (Perception) score ")
lore(30,black,300,500,"of 15 or higher spots 2d4 + 2 aarakocra flying overhead. ")
lore(30,black,350,500,"These creatures are scouts from Kir Sabal or another ")
lore(30,black,400,500,"aerie. They observe the party from a safe distance")
lore(30,black,450,500,"but don't approach unless the characters demonstrate")
lore(30,black,500,500,"peaceful intentions. The bird folk are friendly and can")
lore(30,black,550,500,"point characters in the direction of nearby landmarks.")
grupo1 = (random.randint(2,8)+2)
print(grupo1)
grupo = str(grupo1)
lore(35,black,600,500,"Grupo de ")
lore(35,black,600,650,grupo)
if encontro == 3:
MONSTRO_T = "Arakocra.jpg"
imagePos = (900,190)
win.blit(image, imagePos)
lore(30,black,250,500,"Any character with a passive Wisdom (Perception) score ")
lore(30,black,300,500,"of 15 or higher spots 3d4 + 3 aarakocra flying overhead. ")
lore(30,black,350,500,"These creatures are scouts from Kir Sabal or another ")
lore(30,black,400,500,"aerie. They observe the party from a safe distance")
lore(30,black,450,500,"but don't approach unless the characters demonstrate")
lore(30,black,500,500,"peaceful intentions. The bird folk are friendly and can")
lore(30,black,550,500,"point characters in the direction of nearby landmarks.")
grupo1 = (random.randint(3,12)+3)
print(grupo1)
grupo = str(grupo1)
lore(35,black,600,500,"Grupo de ")
lore(35,black,600,650,grupo)
elif ((MONSTRO_N > 7) and (MONSTRO_N < 10)):
MONSTRO_T = "Cache.jpg"
imagePos = (900,190)
win.blit(image, imagePos)
lore(30,black,250,500,"The party finds a cache of supplies left behind by other")
lore(30,black,300,500,"explorers. There's no way to ten from the cache whether")
lore(30,black,350,500,"those who left it are still alive and coming back for it, or")
lore(30,black,400,500,"dead. Roll a d20 and consult the Caches table to determine what")
lore(30,black,450,500,"the characters find. ")
lore(30,black,500,500,texto)
lore(30,black,500,700,item)
elif ((MONSTRO_N > 10) and (MONSTRO_N < 12)):
MONSTRO_T = "Chwinga.jpg"
elif ((MONSTRO_N > 12) and (MONSTRO_N < 14)):
MONSTRO_T = "Dinossauro, Allosaurus.jpg"
elif ((MONSTRO_N > 14) and (MONSTRO_N < 16)):
MONSTRO_T = "Dinossauro, Dimetrodon.jpg"
elif ((MONSTRO_N > 16) and (MONSTRO_N < 21)):
MONSTRO_T = "Dinossauro, Plesiosaurus.jpg"
elif ((MONSTRO_N > 21) and (MONSTRO_N < 28)):
MONSTRO_T = "Dinossauro, Pteranodon.jpg"
elif ((MONSTRO_N > 28) and (MONSTRO_N < 31)):
MONSTRO_T = "Dinossauro, Quetzalcoatlus.jpg"
elif ((MONSTRO_N > 31) and (MONSTRO_N < 37)):
MONSTRO_T = "Dinossauro, Velociraptor.jpg"
elif ((MONSTRO_N > 37) and (MONSTRO_N < 40)):
MONSTRO_T = "Dragon, Red.jpg"
elif ((MONSTRO_N > 40) and (MONSTRO_N < 42)):
MONSTRO_T = "Emerald Enclave.jpg"
elif ((MONSTRO_N > 42) and (MONSTRO_N < 46)):
MONSTRO_T = "Explorers.jpg"
elif ((MONSTRO_N > 46) and (MONSTRO_N < 49)):
MONSTRO_T = "Flaming Fist.jpg"
elif ((MONSTRO_N > 49) and (MONSTRO_N < 52)):
MONSTRO_T = "Flying Monkeys"
elif ((MONSTRO_N > 52) and (MONSTRO_N < 55)):
MONSTRO_T = "Flying Snakes.jpg"
elif ((MONSTRO_N > 55) and (MONSTRO_N < 57)):
MONSTRO_T = "Frost Giants"
elif ((MONSTRO_N > 57) and (MONSTRO_N < 63)):
MONSTRO_T = "Giant Lizard"
elif ((MONSTRO_N > 63) and (MONSTRO_N < 67)):
MONSTRO_T = "Giant Snapping Turtle"
elif ((MONSTRO_N > 67) and (MONSTRO_N < 71)):
MONSTRO_T = "LizardFolk"
elif ((MONSTRO_N > 71) and (MONSTRO_N < 74)):
MONSTRO_T = "Red Wizard"
elif ((MONSTRO_N > 74) and (MONSTRO_N < 84)):
MONSTRO_T = "Sea Hags"
elif ((MONSTRO_N > 84) and (MONSTRO_N < 87)):
MONSTRO_T = "Stirges"
elif ((MONSTRO_N > 87) and (MONSTRO_N < 89)):
MONSTRO_T = "Swarm of bats"
elif ((MONSTRO_N > 89) and (MONSTRO_N < 94)):
MONSTRO_T = "Tabaxy Hunter"
elif ((MONSTRO_N > 94) and (MONSTRO_N < 100)):
MONSTRO_T = "Tri-Flower Frond"
def noundead():
print("oioioi")
def Lundead():
print("oioioi")
def Gundead():
print("oioioi")
def mountains():
print("oioioi")
def rivers():
print("oioioi")
def ruins():
print("oioioi")
def swamp():
print("oioioi")
def wasteland():
print("oioioi")
def reset():
win.fill(white)
button("Facil",20,10,110,50,green,blue,black,white,ef)
button("Normal",150,10,110,50,green,blue,black,white,en)
button("Mortal",280,10,110,50,green,blue,black,white,em)
button("resete",410,10,110,50,green,blue,black,white,reset)
main()
def main():
while True:
for ev in pygame.event.get():
if ev.type == pygame.QUIT:
pygame.quit()
exit()
button("Facil",20,10,110,50,green,blue,black,white,ef)
button("Normal",150,10,110,50,green,blue,black,white,en)
button("Mortal",280,10,110,50,green,blue,black,white,em)
button("reset",410,10,110,50,green,blue,black,white,reset)
if encontro == 0:
button("Aguardando",930,10,300,50,green,blue,black,white)
elif encontro == 1:
button("Characters Level 1 to 4",930,10,300,50,green,blue,black,white)
elif encontro == 2:
button("Characters Level 4 to 8",930,10,300,50,green,blue,black,white)
elif encontro == 3:
button("Characters Level 8 or above",930,10,300,50,green,blue,black,white)
if encontro == 0:
button("Beach",20,100,110,50,green,blue,black,white,warning)
button("NoUndead",150,100,110,50,green,blue,black,white,warning)
button("- Undead",280,100,110,50,green,blue,black,white,warning)
button("+ undead",410,100,110,50,green,blue,black,white,warning)
button("Mountains",540,100,110,50,green,blue,black,white,warning)
button("Rivers",670,100,110,50,green,blue,black,white,warning)
button("Ruins",800,100,110,50,green,blue,black,white,warning)
button("Swamp",930,100,110,50,green,blue,black,white,warning)
button("Wasteland",1060,100,110,50,green,blue,black,white,warning)
button("Sair",1060,100,110,50,green,blue,black,white,quitgame)
elif encontro > 0:
win.fill(white)
if encontro == 1:
button("Characters Level 1 to 4",930,10,300,50,green,blue,black,white)
elif encontro == 2:
button("Characters Level 4 to 8",930,10,300,50,green,blue,black,white)
elif encontro == 3:
button("Characters Level 8 or above",930,10,300,50,green,blue,black,white)
button("Facil",20,10,110,50,green,blue,black,white,ef)
button("Normal",150,10,110,50,green,blue,black,white,en)
button("Mortal",280,10,110,50,green,blue,black,white,em)
button("Beach",20,100,110,50,green,blue,black,white,beach)
button("NoUndead",150,100,110,50,green,blue,black,white,noundead)
button("- Undead",280,100,110,50,green,blue,black,white,Lundead)
button("+ undead",410,100,110,50,green,blue,black,white,Gundead)
button("Mountains",540,100,110,50,green,blue,black,white,mountains)
button("Rivers",670,100,110,50,green,blue,black,white,rivers)
button("Ruins",800,100,110,50,green,blue,black,white,ruins)
button("Swamp",930,100,110,50,green,blue,black,white,swamp)
button("Wasteland",1060,100,110,50,green,blue,black,white,wasteland)
button("Sair",1060,100,110,50,green,blue,black,white,quitgame)
pygame.display.update()
main()
但是当我使用 reset()
函数时,一个循环使应用程序崩溃。我的功能有什么问题?我尝试使用很多东西,但我认为我的逻辑是错误的。我如何创建一个 reset()
函数来清除应用程序并重绘所有内容?或者,如何重新从头开始运行?
最佳答案
一般来说,一个好的 Stack Overflow 问题应该包含以下所有内容:
在这种情况下,我想我已经能够重现您的问题。我添加了几个打印语句来帮助我查看流程,并运行了您的代码。在打印了无数次“reset”之后,我收到了这条错误信息:
Traceback (most recent call last):
File "SO_63564495.py", line 382, in <module>
main()
File "SO_63564495.py", line 334, in main
button("reset",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
File "SO_63564495.py", line 319, in reset
button("resete",410,10,110,50,green,blue,black,white,reset)
File "SO_63564495.py", line 42, in button
action()
[ELIDED because it is too damn long!]
File "/usr/lib/python3.8/posixpath.py", line 153, in dirname
sep = _get_sep(p)
File "/usr/lib/python3.8/posixpath.py", line 42, in _get_sep
if isinstance(path, bytes):
RecursionError: maximum recursion depth exceeded while calling a Python object
这就告诉我们问题所在:reset()
是调用button()
,后者又调用了reset()
,没有限制直到程序崩溃。可能需要在 reset
内部发生一些事情,这样 pygame.mouse.get_pressed()[0]
将不再是 1
>按钮
;我不确定。
也就是说,看起来您有点不知所措。如果您重新开始使用一个或另一个编程抽象来构建您的工作,那么您的代码中有很多可以改进的地方(变得更短、更容易阅读、更容易推理并说服我们自己相信其正确性) . Object Oriented Programming是一个很好的起点。
你承担了一个大项目;不要失去希望!
关于python - 如何正确实现复位功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63564495/
我正在处理一组标记为 160 个组的 173k 点。我想通过合并最接近的(到 9 或 10 个组)来减少组/集群的数量。我搜索过 sklearn 或类似的库,但没有成功。 我猜它只是通过 knn 聚类
我有一个扁平数字列表,这些数字逻辑上以 3 为一组,其中每个三元组是 (number, __ignored, flag[0 or 1]),例如: [7,56,1, 8,0,0, 2,0,0, 6,1,
我正在使用 pipenv 来管理我的包。我想编写一个 python 脚本来调用另一个使用不同虚拟环境(VE)的 python 脚本。 如何运行使用 VE1 的 python 脚本 1 并调用另一个 p
假设我有一个文件 script.py 位于 path = "foo/bar/script.py"。我正在寻找一种在 Python 中通过函数 execute_script() 从我的主要 Python
这听起来像是谜语或笑话,但实际上我还没有找到这个问题的答案。 问题到底是什么? 我想运行 2 个脚本。在第一个脚本中,我调用另一个脚本,但我希望它们继续并行,而不是在两个单独的线程中。主要是我不希望第
我有一个带有 python 2.5.5 的软件。我想发送一个命令,该命令将在 python 2.7.5 中启动一个脚本,然后继续执行该脚本。 我试过用 #!python2.7.5 和http://re
我在 python 命令行(使用 python 2.7)中,并尝试运行 Python 脚本。我的操作系统是 Windows 7。我已将我的目录设置为包含我所有脚本的文件夹,使用: os.chdir("
剧透:部分解决(见最后)。 以下是使用 Python 嵌入的代码示例: #include int main(int argc, char** argv) { Py_SetPythonHome
假设我有以下列表,对应于及时的股票价格: prices = [1, 3, 7, 10, 9, 8, 5, 3, 6, 8, 12, 9, 6, 10, 13, 8, 4, 11] 我想确定以下总体上最
所以我试图在选择某个单选按钮时更改此框架的背景。 我的框架位于一个类中,并且单选按钮的功能位于该类之外。 (这样我就可以在所有其他框架上调用它们。) 问题是每当我选择单选按钮时都会出现以下错误: co
我正在尝试将字符串与 python 中的正则表达式进行比较,如下所示, #!/usr/bin/env python3 import re str1 = "Expecting property name
考虑以下原型(prototype) Boost.Python 模块,该模块从单独的 C++ 头文件中引入类“D”。 /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c)
如何编写一个程序来“识别函数调用的行号?” python 检查模块提供了定位行号的选项,但是, def di(): return inspect.currentframe().f_back.f_l
我已经使用 macports 安装了 Python 2.7,并且由于我的 $PATH 变量,这就是我输入 $ python 时得到的变量。然而,virtualenv 默认使用 Python 2.6,除
我只想问如何加快 python 上的 re.search 速度。 我有一个很长的字符串行,长度为 176861(即带有一些符号的字母数字字符),我使用此函数测试了该行以进行研究: def getExe
list1= [u'%app%%General%%Council%', u'%people%', u'%people%%Regional%%Council%%Mandate%', u'%ppp%%Ge
这个问题在这里已经有了答案: Is it Pythonic to use list comprehensions for just side effects? (7 个答案) 关闭 4 个月前。 告
我想用 Python 将两个列表组合成一个列表,方法如下: a = [1,1,1,2,2,2,3,3,3,3] b= ["Sun", "is", "bright", "June","and" ,"Ju
我正在运行带有最新 Boost 发行版 (1.55.0) 的 Mac OS X 10.8.4 (Darwin 12.4.0)。我正在按照说明 here构建包含在我的发行版中的教程 Boost-Pyth
学习 Python,我正在尝试制作一个没有任何第 3 方库的网络抓取工具,这样过程对我来说并没有简化,而且我知道我在做什么。我浏览了一些在线资源,但所有这些都让我对某些事情感到困惑。 html 看起来
我是一名优秀的程序员,十分优秀!