• <bdo id='4npfx'></bdo><ul id='4npfx'></ul>

    <legend id='4npfx'><style id='4npfx'><dir id='4npfx'><q id='4npfx'></q></dir></style></legend>

    1. <small id='4npfx'></small><noframes id='4npfx'>

    2. <i id='4npfx'><tr id='4npfx'><dt id='4npfx'><q id='4npfx'><span id='4npfx'><b id='4npfx'><form id='4npfx'><ins id='4npfx'></ins><ul id='4npfx'></ul><sub id='4npfx'></sub></form><legend id='4npfx'></legend><bdo id='4npfx'><pre id='4npfx'><center id='4npfx'></center></pre></bdo></b><th id='4npfx'></th></span></q></dt></tr></i><div id='4npfx'><tfoot id='4npfx'></tfoot><dl id='4npfx'><fieldset id='4npfx'></fieldset></dl></div>
        <tfoot id='4npfx'></tfoot>

        框架内的网格?

        Grid within a frame?(框架内的网格?)

        <legend id='v30s9'><style id='v30s9'><dir id='v30s9'><q id='v30s9'></q></dir></style></legend>

          • <small id='v30s9'></small><noframes id='v30s9'>

                <tbody id='v30s9'></tbody>

                <i id='v30s9'><tr id='v30s9'><dt id='v30s9'><q id='v30s9'><span id='v30s9'><b id='v30s9'><form id='v30s9'><ins id='v30s9'></ins><ul id='v30s9'></ul><sub id='v30s9'></sub></form><legend id='v30s9'></legend><bdo id='v30s9'><pre id='v30s9'><center id='v30s9'></center></pre></bdo></b><th id='v30s9'></th></span></q></dt></tr></i><div id='v30s9'><tfoot id='v30s9'></tfoot><dl id='v30s9'><fieldset id='v30s9'></fieldset></dl></div>
                <tfoot id='v30s9'></tfoot>
                  <bdo id='v30s9'></bdo><ul id='v30s9'></ul>
                • 本文介绍了框架内的网格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  是否可以将 Tkinter 中的按钮网格放置在另一个框架内?

                  Is it possible to place a grid of buttons in Tkinter inside another frame?

                  我想创建一个类似于井字游戏的游戏,并希望使用网格功能来放置游戏方块(即按钮).但是,我想在 GUI 中添加除游戏板之外的其他内容,因此将所有内容都放在一个网格中并不理想.

                  I'm wanting to create a tic-tac-toe like game and want to use the grid feature to put gamesquares (that will be buttons). However, I'd like to have other stuff in the GUI other than just the game board so it's not ideal to just have everything in the one grid.

                  举例说明:

                  O | X | X   |
                  ----------  |
                  O | O | X   | Player 2 wins!
                  ----------  | 
                  X | O | X   |
                  

                  井字棋盘位于由所有按钮组成的网格中,玩家 2 获胜"是框架内的标签.

                  The tic tac toe board is in a grid that is made up of all buttons and the 'player 2 wins' is a label inside a frame.

                  这是对我试图做的事情的过度简化,请耐心等待,因为到目前为止我设计程序的方式(板是动态创建的)网格最有意义.

                  This is an oversimplification of what I'm trying to do so bear with me, for the way I've designed the program so far (the board is dynamically created) a grid makes the most sense.

                  有一个想法,但是当我运行它时,什么也没发生?如果我取出框架位,它会.有什么想法吗?

                  Had a thought but when I run it, nothing happens? If I take out the frame bit it does. Any ideas?

                  from Tkinter import * 
                  
                  root = Tk()
                  
                  b = Button(root, text = "1")
                  b.grid(row=1, column=3)
                  b2 = Button(root, text = "2")
                  b2.grid(row=1, column=4)
                  
                  f = Frame(root, bg = "red")
                  f.pack(side=RIGHT)
                  
                  root.mainloop()
                  

                  推荐答案

                  终于想出了一个办法:

                  from Tkinter import * 
                  
                  root = Tk()
                  
                  f = Frame(root, bg = "orange", width = 500, height = 500)
                  f.pack(side=LEFT, expand = 1)
                  
                  f3 = Frame(f, bg = "red", width = 500)
                  f3.pack(side=LEFT, expand = 1, pady = 50, padx = 50)
                  
                  f2 = Frame(root, bg = "black", height=100, width = 100)
                  f2.pack(side=LEFT, fill = Y)
                  
                  b = Button(f2, text = "test")
                  b.pack()
                  
                  b = Button(f3, text = "1", bg = "red")
                  b.grid(row=1, column=3)
                  b2 = Button(f3, text = "2")
                  b2.grid(row=1, column=4)
                  b3 = Button(f3, text = "2")
                  b3.grid(row=2, column=0)
                  
                  root.mainloop()
                  

                  将网格放在框架内的框架内是一种让网格周围的填充工作的技巧,但它可以工作,所以我很高兴.

                  Having the grid inside a frame inside a frame is a bit of a hack to get the padding around the grid working but it works so I'm happy.

                  这篇关于框架内的网格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                  <tfoot id='18Kbe'></tfoot>

                      <bdo id='18Kbe'></bdo><ul id='18Kbe'></ul>
                      • <legend id='18Kbe'><style id='18Kbe'><dir id='18Kbe'><q id='18Kbe'></q></dir></style></legend>
                          <i id='18Kbe'><tr id='18Kbe'><dt id='18Kbe'><q id='18Kbe'><span id='18Kbe'><b id='18Kbe'><form id='18Kbe'><ins id='18Kbe'></ins><ul id='18Kbe'></ul><sub id='18Kbe'></sub></form><legend id='18Kbe'></legend><bdo id='18Kbe'><pre id='18Kbe'><center id='18Kbe'></center></pre></bdo></b><th id='18Kbe'></th></span></q></dt></tr></i><div id='18Kbe'><tfoot id='18Kbe'></tfoot><dl id='18Kbe'><fieldset id='18Kbe'></fieldset></dl></div>
                        • <small id='18Kbe'></small><noframes id='18Kbe'>

                              <tbody id='18Kbe'></tbody>