简体   繁体   English

[python][tkinter] 没有可见按钮,按钮在框架中

[英][python][tkinter] no visible button, button in frame in frame

can't see button in frame i make some like a matrix 3x3在框架中看不到按钮我做了一些像矩阵 3x3

3 frame top mid and bottom 3帧上中下

in earh frame descrive up i have 3 frame left mid and right in last frame's i have button but no see the button在earh frame 中描述我在最后一帧的中间和右侧有3帧我有按钮但没有看到按钮

from tkinter import *
root = Tk()


f_top = Frame(root) 
f_mid = Frame(root) 
f_down = Frame(root) 

frame1 = Frame(f_top, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')
frame2 = Frame(f_top, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')
frame3 = Frame(f_top, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')

frame4 = Frame(f_mid, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')
frame5 = Frame(f_mid, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')
frame6 = Frame(f_mid, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')

frame7 = Frame(f_down, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')
frame8 = Frame(f_down, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')
frame9 = Frame(f_down, width=50, height=50, background="bisque").pack(fill=None, expand=False,side = 'left')

f_top.pack()
f_mid.pack()
f_down.pack()

Button(frame2, text = 'top', command=a1)
Button(frame4,height=40, width=40, text = 'left', command=a3)
Button(frame6,height=40, width=40, text = 'right', command=a4)
Button(frame8,height=40, width=40, text = 'bottom', command=a2)
Button(frame5,height=40, width=40, text = 'start', command=a5)
Button(frame1,height=40, width=40, text = 'nostart', command=a6)

root.mainloop()
from tkinter import *
root = Tk()



idport = StringVar()

f_top = Frame(root) 
f_mid = Frame(root) 
f_down = Frame(root) 

frame1 = Frame(f_top, width=22, height=22, background="gainsboro")
frame1.pack(side = 'left')
frame2 = Frame(f_top, width=22, height=22, background="gainsboro")
frame2.pack(side = 'left')
frame3 = Frame(f_top, width=22, height=22, background="gainsboro")
frame3.pack(side = 'left')
frame4 = Frame(f_mid, width=22, height=22, background="gainsboro")
frame4.pack(side = 'left')
frame5 = Frame(f_mid, width=22, height=22, background="gainsboro")
frame5.pack(side = 'left')
frame6 = Frame(f_mid, width=22, height=22, background="gainsboro")
frame6.pack(side = 'left')
frame7 = Frame(f_down, width=22, height=22, background="gainsboro")
frame7.pack(side = 'left')
frame8 = Frame(f_down, width=22, height=22, background="gainsboro")
frame8.pack(side = 'left')
frame9 = Frame(f_down, width=22, height=22, background="gainsboro")
frame9.pack(side = 'left')

f_top.pack()
f_mid.pack()
f_down.pack()

Button(frame1,width=2, height=1, text = 'del', command=a6,background="gainsboro").pack(fill=None,side = 'left')
Button(frame2,width=2, height=1, text = '↑', command=a1,background="gainsboro").pack(fill=None,side = 'left')

Button(frame4,width=2, height=1, text = '←', command=a3,background="gainsboro").pack(fill=None,side = 'left')
Button(frame5,width=2, height=1, text = '↪', command=a5,background="gainsboro").pack(fill=None,side = 'left')
Button(frame6,width=2, height=1, text = '→', command=a4,background="gainsboro").pack(fill=None,side = 'left')
Button(frame7,width=2, height=1, text = 'com',command=setport,background="gainsboro").pack(fill=None,side = 'left')
Button(frame8,width=2, height=1, text = '↓', command=a2,background="gainsboro").pack(fill=None,side = 'left')
entrypoint = Entry(frame9,textvariable=idport,width=3).pack(fill=None,side = 'left')


root.mainloop()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM