如何解决尽管对所有行都赋予了权重,但是grid_propagate0无法正常工作
我遇到dealer_score_no.grid_propagate(0)
和player_score_no.grid_propagate(0)
的问题,这两个分别是发牌人和玩家的分数。我尝试过调整字体大小,或者在游戏过程中删除分数标签,然后得到的结果是使周围的行跳动。我尝试配置行的权重,问题是我真的不知道我需要哪些权重。我猜我做错了什么。我发现了一种解决方法,只需放弃调整大小,然后简单地删除分配给它们的textvariables(我知道这个名字很不好),然后将文本重置为一个空字符串,就可以了。没有更多的反弹行。但是我仍然想知道如何使用权重和grid_propagate(0)
选项。
felt = tkinter.Frame(mainWindow,bg=FELT_COLOR) #,relief='groove',borderwidth='3')
felt.grid(row=1,column=0,sticky='wens',columnspan=3)
# Dealer cards and score area
dealer_score_label = tkinter.Intvar()
dealer_card_frame = tkinter.Frame(felt,height=card_frame_height,width=800,background=FELT_COLOR,bd=0,relief="groove")
dealer_card_frame.grid(row=0,column=1,columnspan=3,padx=400,sticky='w')
dealer_score_obj = tkinter.Label(felt,text='',fg=themes[theme]['card_frame_lbl_fg'])
dealer_score_obj.grid(row=1,sticky='n',pady=4)
dealer_score_obj.place()
dealer_score_no = tkinter.Label(felt,font=font.Font(size=18),fg=themes[theme]['card_frame_lbl_fg'])
dealer_score_no.grid(row=2,pady=8)
dealer_score_no.grid_propagate(0)
# Player's score area
player_score_label = tkinter.Intvar()
player_score_obj = tkinter.Label(felt,fg=themes[theme]['card_frame_lbl_fg'])
player_score_obj.grid(row=3,sticky='sew',pady=(200,0))
player_score_no = tkinter.Label(felt,fg=themes[theme]['card_frame_lbl_fg'])
player_score_no.grid(row=4,pady=8)
player_score_no.grid_propagate(0)
player_card_frame = tkinter.Frame(felt,relief="groove")
player_card_frame.grid(row=5,sticky='sw')
betting_frame = tkinter.Frame(felt,height=100,bg=FELT_COLOR,width=int(mainWindow.winfo_screenwidth() * 0.66))
betting_frame.grid(row=6,sticky='ew')
felt.config(height=felt.winfo_reqheight())```
[![This is how it looks like.][1]][1]
[1]: https://i.stack.imgur.com/Ae4pt.png
解决方法
grid_propagate
仅在您调用的小部件有子级时才重要。如果您在没有子代的小部件上调用它,则将无效。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。