1
저는 Python 및 ttk에 어려움을 겪고 있습니다. 올바르게 작동하는 UI를 만들었지 만 조금 어색해 보입니다. 패딩을 추가하고 크기 조정 등을 할 수 있도록 프레임을 추가하고 싶었지만 지금은 위젯이 전혀 표시되지 않습니다. 내 코드는 아래와 같습니다.프레임의 ttk 위젯이 표시되지 않습니다.
이전에는 parent
을 위젯의 부모로 전달했는데, 이는 작동했습니다. 나는 몇 가지 튜토리얼을 통해 작업 해왔고 분명히 잘못된 것을 볼 수는 없다.
class Application:
def __init__(self, parent):
self.parent = parent
self.content = ttk.Frame(parent, padding=(3,3,12,12))
self.content.columnconfigure(1, weight=1)
self.content.rowconfigure(1, weight=1)
self.row1()
def row1(self):
self.enButton = ttk.Button(self.content, text="Enable", command=self.enableCmd)
self.disButton = ttk.Button(self.content, text="Disable", command=self.disableCmd)
self.enButton.grid(column=1, row=1)
self.disButton.grid(column=2, row=1)
self.disButton.state(['disabled'])
def enableCmd(self):
self.disButton.state(['!disabled'])
self.enButton.state(['disabled'])
self.ser.write("pe001\n")
if __name__ == '__main__':
root = Tk()
root.title("PC Control Interface")
img = Image("photo", file="appicon.gif")
root.tk.call('wm','iconphoto',root._w,img)
app = Application(root)
root.mainloop()