[python][tkinter]无可见按钮,在帧中的帧中的按钮

2024-05-19 03:03:09 发布

您现在位置:Python中文网/ 问答频道 /正文

在框架中看不到按钮 我做了一些像矩阵3x3

3框架顶部、中部和底部

在earh frame descripve up中,我有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()

Tags: textnonefalsetopbuttonwidthleftfill
1条回答
网友
1楼 · 发布于 2024-05-19 03:03:09
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()

相关问题 更多 >

    热门问题