Class menu in Tkinter Guiの後ろに続くTkinterアプリケーションを開始しようとしていますが、この機能を追加することもできます。ボタン・バー、ラジオボタンバーなどのような何か:メニュー、ボタンなどTkinter GUIのバー
from Tkinter import *
def clickTest():
print "Click!"
class App(Tk):
def __init__(self):
Tk.__init__(self)
menuBar = MenuBar(self)
buttonBar = ButtonBar(self)
self.config(menu=menuBar)
buttonBar.grid(row=0, column=0) ???
class MenuBar(Menu):
def __init__(self, parent):
Menu.__init__(self, parent)
fileMenu = Menu(self, tearoff=False)
self.add_cascade(label="File", menu=fileMenu)
fileMenu.add_command(label="Exit", command=clickTest)
class ButtonBar(Frame):
def __init__(self, parent):
Frame.__init__(self, parent)
firstButton = Button(parent, text="1st Button", command=clickTest)
secondButton = Button(parent, text="2nd Button", command=clickTest)
if __name__ == "__main__":
app = App()
app.mainloop()
しかし、私は同じウィンドウに表示するために、このすべてを取得するかどうかはわかりません。もちろん、そのままのコードは動作しません。どんな提案も感謝しています。ありがとう!
Cool。ありがとう。ええ、私もgrid()でそれを理解しました。ボタンの親のための最後の提案をありがとう - それは私のためにそれを修正した。 – Ryan