Python と ttk に問題があります。正しく動作する UI を作成しましたが、少し雑然としています。フレームを追加して、パディングを追加したり、サイズ変更を有効にしたりしたかったのですが、ウィジェットが表示されません。私のコードは以下です。
以前は、ウィジェットの親として渡すだけでしたが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()