【发布时间】:2019-08-04 21:41:03
【问题描述】:
我正在制作一个游戏,屏幕上的第一件事是一个按钮,上面写着玩游戏。但是由于某种原因,该按钮没有显示在屏幕上?函数 play_sound_game 基本上是我的代码的其余部分。
我已经尝试删除turtle.mainloop() 但这也不起作用。
import turtle
import tkinter as tk
import time
import pygame
screen = turtle.Screen()
turtle.ht()
screen.bgcolor("blue")
turtle.color('deep pink')
style = ('Courier', 80, 'italic')
turtle.pu()
turtle.goto(-318,176)
turtle.pu
turtle.write('RHYMING WORDS', font=style)
turtle.hideturtle()
turtle.mainloop()
#Button for play game
button_playgame = tk.Button(canvas.master, text="Play Game", command=play_sound_game, font=('Arial', '65',"bold"), foreground = 'red')
button_playgame.config(height = -1, width = 4)
canvas.create_window(272, 88, window=button_playgame)
我没有收到任何错误消息。
【问题讨论】:
-
你还没有渲染按钮
(.pack, .grid, .place)also...height = -1? -
那我要改什么
-
你能告诉我我必须在我的代码中替换什么才能让它工作吗?这真的很有帮助,我知道 Tkinter 是如何工作的
-
如果你知道 Tkinter 是如何工作的,那么你就不会遇到这个问题了,哈哈。就像我的第一条评论建议的那样,你必须放置小部件......但既然你知道 tkinter 是如何工作的......
-
查看并运行stackoverflow.com/a/44654017/4180176 - 这可能会对您有所帮助
标签: python tkinter pygame turtle-graphics