Python 不显示正确的帧大小

发布于 2025-01-09 12:31:53 字数 1555 浏览 1 评论 0原文

我尝试找出一些框架来获得类似的东西: 在此处输入图像描述

问题是不显示帧尺寸。好像没有考虑尺寸。 我错过了什么吗? 这是代码:

from tkinter import *
from PIL import ImageTk, Image
import os
img_dir=os.getcwd()
#Main window
root=Tk()
root.title('L-GEST')
#root.attributes('-fullscreen', True)
root.rowconfigure(0,weight=1)
root.rowconfigure(1,weight=5)
#Screen dimensions
w,h=root.winfo_screenwidth(),root.winfo_screenheight()
w2, h2=int(0.8*w),int(0.8*h)
dimensions=str(w2)+"x"+str(h2)
largeur, hauteur=str(w),str(h)
#Resizing to 80%
root.geometry(dimensions)
#Top Frame
bandeau=Frame(root, borderwidth=1,relief=RIDGE)
bandeau.config(width=w2, height=100, bg='white')
bandeau.pack(side=TOP)
#Left side
Logo_path=img_dir+'/'+'logo.jpg'
Logo=Image.open(Logo_path)
Logo=Logo.resize((200,100),Image.ANTIALIAS)
Logo_load=ImageTk.PhotoImage(Logo)
Logo_label=Label(bandeau,image=Logo_load)
Logo_label.pack(side=LEFT)
#Middle
bandeau2_width=int(w2)-300
Button(bandeau, text="w2 ="+str(w2)+"w2-300 = "+str(bandeau2_width)).pack(fill='both', expand=True)
# Right side
Logo2_path=img_dir+'/'+'power.png'
Logo2=Image.open(Logo2_path)
Logo2=Logo2.resize((100,100),Image.ANTIALIAS)
Logo2_load=ImageTk.PhotoImage(Logo2)
Logo2_label=Label(bandeau,image=Logo2_load)
Logo2_label.pack(side=RIGHT)


#Bottom Frame
main=Frame(root, borderwidth=1,relief=RIDGE)
main.pack(fill='both', expand='YES')
Label(main, text='main').pack()
Label(main, text="main row 1").pack()
root.mainloop()
Could someone help ?

I try to figure out some frames to obtain something like that:
enter image description here

Problem is that the frame sizes are not displayed. Seems like sizes are not taken into account.
I missed something ?
Here is the code:

from tkinter import *
from PIL import ImageTk, Image
import os
img_dir=os.getcwd()
#Main window
root=Tk()
root.title('L-GEST')
#root.attributes('-fullscreen', True)
root.rowconfigure(0,weight=1)
root.rowconfigure(1,weight=5)
#Screen dimensions
w,h=root.winfo_screenwidth(),root.winfo_screenheight()
w2, h2=int(0.8*w),int(0.8*h)
dimensions=str(w2)+"x"+str(h2)
largeur, hauteur=str(w),str(h)
#Resizing to 80%
root.geometry(dimensions)
#Top Frame
bandeau=Frame(root, borderwidth=1,relief=RIDGE)
bandeau.config(width=w2, height=100, bg='white')
bandeau.pack(side=TOP)
#Left side
Logo_path=img_dir+'/'+'logo.jpg'
Logo=Image.open(Logo_path)
Logo=Logo.resize((200,100),Image.ANTIALIAS)
Logo_load=ImageTk.PhotoImage(Logo)
Logo_label=Label(bandeau,image=Logo_load)
Logo_label.pack(side=LEFT)
#Middle
bandeau2_width=int(w2)-300
Button(bandeau, text="w2 ="+str(w2)+"w2-300 = "+str(bandeau2_width)).pack(fill='both', expand=True)
# Right side
Logo2_path=img_dir+'/'+'power.png'
Logo2=Image.open(Logo2_path)
Logo2=Logo2.resize((100,100),Image.ANTIALIAS)
Logo2_load=ImageTk.PhotoImage(Logo2)
Logo2_label=Label(bandeau,image=Logo2_load)
Logo2_label.pack(side=RIGHT)


#Bottom Frame
main=Frame(root, borderwidth=1,relief=RIDGE)
main.pack(fill='both', expand='YES')
Label(main, text='main').pack()
Label(main, text="main row 1").pack()
root.mainloop()
Could someone help ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文