나는 Tkinter
을 사용하여 새롭고 정말 쉬운 GUI를 만들고 있습니다. JavaFX 배경에서 오는 것은 좌표에 내 버튼 위치를 지정할 수 없기 때문에 다소 혼란 스럽습니다.레이아웃 - Tkinter - 함께 버튼 그룹화
이 내 실제 코드 :
class MoveRobot(Frame):
grid_counter = 0
def __init__(self):
Frame.__init__(self)
self.master.title("Control Robot")
self.master.geometry("400x400")
self.master.rowconfigure(0, weight=1)
self.master.columnconfigure(0, weight=1)
self.grid(sticky=W + E + N + S)
self.list_box = Listbox(self)
self.list_box.grid(rowspan=4, sticky=W + E + N + S)
self.button1 = Button(self, text="UP", command=self.button_up)
self.button1.grid(row=0, column=1, columnspan=2, sticky=W + E + N + S)
self.button2 = Button(self, text="DOWN", command=self.button_down)
self.button2.grid(row=1, column=1, columnspan=2, sticky=W + E + N + S)
self.button3 = Button(self, text="LEFT", command=self.button_left)
self.button3.grid(row=2, column=1, columnspan=2, sticky=W + E + N + S)
self.button4 = Button(self, text="RIGHT", command=self.button_right)
self.button4.grid(row=3, column=1, columnspan=2, sticky=W + E + N + S)
self.button_cancel = Button(self, text="Remove Last", command=self.button_remove_last)
self.button_cancel.grid(row=4, columnspan=2, sticky=W + E + N + S)
self.button_cancel = Button(self, text="Clear", command=self.button_clear)
self.button_cancel.grid(row=5, columnspan=2, sticky=W + E + N + S)
self.button_compile = Button(self, text="Compile", command=self.button_compile)
self.button_compile.grid(row=6, columnspan=2, sticky=W + E + N + S)
self.rowconfigure(1, weight=1)
self.columnconfigure(1, weight=1)
#controller code is removed because unnecessary
def main():
MoveRobot().mainloop()
if __name__ == "__main__":
main()
그리고 아래에있는 내 GUI를 만든 사람.
그러나, 나는 함께 'UP'버튼, 'DOWN', 'LEFT'과 '오른쪽'을 충실 관리 할 수 없습니다. 포럼과 웹 사이트를 살펴 보았지만 해결책을 찾지 못했습니다. 그것은 단지 레이아웃 문제이기 때문에 꽤 직설적이어야합니다.
나는 이런 식으로 뭔가를해야 원하는 출력 ..
사람은 도움을 줄 수있다? 나는이 질문이 다른 사람들에게도 도움이되기를 바랍니다. 왜냐하면 나는 Tkinter를 사용하는 방법을 모르며 웹을 통해 해결책을 찾을 수 없기 때문입니다.
미리 감사드립니다.
첫 번째 문장은 의미가 없습니다. 목록 상자에 명시적인 높이를 지정하면이 경우 아무 것도 수행하지 않습니다 (실제로 작은 숫자로 설정하지 않은 경우). 또한, 가중치는 "tkinter가 한 단위 씩 확장되도록 알려줍니다"하지 않습니다. "단위"가이 컨텍스트에서 무엇이라고 생각하는지 모르지만, 가중치는 tkinter에게 위젯에 여분의 공간을 배포하는 방법을 알려줍니다. –
네가 맞아 @ 브라이언 오클리, 어떤 특정 유닛에 의해 확장되지 않는다. 나는 명확하지 않다. – EriktheRed
@BryanOakley 그러나 나는 명시적인 높이에 관해 말한대로 서있다. 목록 상자가 레이아웃 (내 ascii 참조)에 있어야하는 것보다 큼을 감안할 때, tkinter는 크기가 얼마나 커야 하는지를 제외하고는 축소 할 것입니다.이 문제를 해결하는 다른 방법이있을 수 있지만, 가장 간단한 방법 인 것처럼 보입니다. 나, 그리고 내가 한 일부 테스트에서 작동합니까 – EriktheRed