You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Python Tkinter中Ratings List按钮不显示问题求助

问题分析与解决方法

你的Ratings List按钮不显示的原因很明确:你设置的窗口高度为500像素(screen.geometry("925x500+300+200")),但将rating_button的y坐标设为了500,这会让按钮完全处于窗口可视区域的下方,自然无法被看到。

只需调整rating_button的place方法中y的取值,让它落在窗口范围内即可,比如将y改为300:

#Creating a new screen
screen = Toplevel(root)
screen.title("App")
screen.geometry("925x500+300+200")
screen.config(bg="white")

myFont = font.Font(size=15)

Label (screen, text="Please choose the Rankings or the Ratings", bg='#fff', font=('Calibri(Body)',25,'bold')).pack(expand=False)

ranking_button = Button(screen,width=15,text='Rankings List', border=2, bg='white',cursor='hand2',fg='#57a1f8')
ranking_button['font'] = myFont
ranking_button.place(x=100,y=200)

rating_button = Button(screen,width=15,text='Ratings List', border=2, bg='white',cursor='hand2',fg='#57a1f8')
rating_button['font'] = myFont
rating_button.place(x=100,y=300)  # 修改y坐标至窗口可视范围内

screen.mainloop()

另外,也可以考虑使用pack或grid布局管理器,它们会自动处理组件位置,避免手动设置坐标出现超出窗口的问题。比如用pack布局的写法:

# 替换两个按钮的place代码为以下内容
ranking_button.pack(pady=20)
rating_button.pack(pady=20)

这样两个按钮会垂直排列,自动适配窗口大小。

内容的提问来源于stack exchange,提问作者Kirsty Maull

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 12:21:03