[每次我必须使用Python设计GUI时,我的首选始终是PyQt5(Qt Designer 5),因为在我看来,它比Tkinter容易,但是现在我有一个分配,并且必须使用Tkinter。] >
我想在Tkinter中实现的GUI是:
Qt Designer 5中的GUI
这是我为Tkinter GUI设计编写的一部分代码:
from tkinter import Tk,Text from tkinter import ttk class MiApp(ttk.Frame): def __init__(self,main_window): super().__init__(main_window) self.promDaily = [] self.datos = {} self.csv = " " self.botonCSV = ttk.Button(main_window,text="Escoger CSV",width=91,command=self.ChooseCSVFile) self.botonCSV.place(x=9,y=16) self.pathCSV = ttk.Entry(main_window,width=351,state="disable") self.pathCSV.place(x=120,y=17) self.labelAbsc = ttk.Label(main_window,text="Abscisa:",width=47) self.labelAbsc.place(x=9,y=52) self.labelOrden = ttk.Label(main_window,text="Ordenada:",width=55) self.labelOrden.place(x=120,y=52) self.labelPromD = ttk.Label(main_window,text="Promedio diario:",width=79) self.labelPromD.place(x=245,y=52) self.comboBAbsc = ttk.Combobox(main_window,width=91) self.comboBAbsc.place(x=9,y=78) self.comboBOrden = ttk.Combobox(main_window, width=91) self.comboBOrden.place(x=120, y=78) self.botonCalc = ttk.Button(main_window,text="Calcular",width=75) self.botonCalc.place(x=245,y=78) self.posibilidadCalc = ttk.Entry(main_window,width=211) self.posibilidadCalc.place(x=245,y=114) self.botonGraph = ttk.Button(main_window,width=75) self.botonGraph.place(x=62,y=201) self.textMaxMin = Text(main_window,width=211,height=131) self.textMaxMin.place(x=245,y=147) (...) root = Tk() root.config(width=480,height=337) mainW = ttk.Frame(root,width=480,height=337) mainW.pack() root.resizable(0,0) app = MiApp(mainW) app.mainloop()
现在,我的Tkinter GUI看起来像这样:
Tkinter中的GUI
如何将这些宽度值设置为像素?
感谢您的关注。
[每次我必须使用Python设计GUI时,我的首选始终是PyQt5(Qt Designer 5),因为我认为它比Tkinter容易,但是现在我有一个分配,并且必须使用Tkinter。 ...
我不知道,在创建Frame之后在place()内定义宽度和高度允许按像素放置: