我一直很难弄清楚如何将我的输入框放在同一行(entry,entry2,entry3)上,我曾尝试在互联网上进行检查,但没有一个能解决我的问题。 这是基本代码(我正在使用我的raspbian atm):
import curses, time
import Tkinter as Alarm
class test(Alarm.Frame):
def __init__(self, parent):
Alarm.Frame.__init__(self, parent)
self.prompt = Alarm.Label(self, text="Enter hours (Max: 24 hours) , minutes, seconds:", anchor="w")
self.entry = Alarm.Entry(self, width=1)
self.entry2 = Alarm.Entry(self, width=1)
self.entry3 = Alarm.Entry(self, width=1)
self.prompt2 = Alarm.Label(self, text="Alarm Message:", anchor="w")
self.entry4 = Alarm.Entry(self)
self.output = Alarm.Label(self, text="00:00:00",font=(24))
self.submit = Alarm.Button(self, text="Start", command = self.startTimer)
self.prompt.pack(side="top", fill="x")
self.entry.pack(side="top", fill="x", padx=10)
self.entry2.pack(side="top", fill="x", padx=10)
self.entry3.pack(side="top", fill="x", padx=10)
self.prompt2.pack(side="top", fill="x")
self.entry4.pack(side="top", fill="x", padx=20)
self.output.pack(side="top", fill="x", expand=True)
self.submit.pack(side="bottom")
我从实际文件中复制并粘贴了大多数代码,因此在这里和那里可能有一些不相关的代码。
答案 0 :(得分:1)
如果您真的坚持使用pack,我建议您在中间为输入添加一个框架。
class test(Alarm.Frame):
def __init__(self, parent):
Alarm.Frame.__init__(self, parent)
self.prompt = Alarm.Label(self, text="Enter hours (Max: 24 hours) , minutes, seconds:", anchor="w")
self.prompt2 = Alarm.Label(self, text="Alarm Message:", anchor="w")
self.entry4 = Alarm.Entry(self)
self.output = Alarm.Label(self, text="00:00:00",font=(24))
self.submit = Alarm.Button(self, text="Start", command = self.startTimer)
self.prompt.pack(side="top", fill="x")
mid_frame = Alarm.Frame(self)
mid_frame.pack()
self.entry = Alarm.Entry(mid_frame, width=1)
self.entry2 = Alarm.Entry(mid_frame, width=1)
self.entry3 = Alarm.Entry(mid_frame, width=1)
self.entry.pack(side="left", fill="x",padx=10)
self.entry2.pack(side="left",fill="x", padx=10)
self.entry3.pack(side="left",fill="x", padx=10)
self.prompt2.pack(side="top", fill="x")
self.entry4.pack(side="top", fill="x", padx=20)
self.output.pack(side="top", fill="x", expand=True)
self.submit.pack(side="bottom")
self.pack()