Reputation: 47
can someone tell me, what's wrong with my script ._. it's run but nothing happend. my purpose is create a new window if i click my "input button" on "mainWindow". and my mainWindow did't show anything :( can someone tell me the clue for fix this problem ? thank you for your time :)
from tkinter import*
master = Tk()
# create frame menu
def mainWindow(self, master):
menuFrame = Frame(master)
inputButton = Button(menuFrame, text="Input Data", command=windowInput)
showButton = Button(menuFrame, text="Show Data")
deleteButton = Button(menuFrame, text="Delete Data")
menuFrame.pack(fill=BOTH)
inputButton.grid(row=0, column=0)
showButton.grid(row=1, column=0)
deleteButton.grid(row=0, column=1)
# create new window
def windowInput():
window_input = Toplevel(master)
window_input.wm_title("Input")
inputFrame = Frame(master)
kodeLabel = Label(inputFrame, text="Book Kode")
nameLabel = Label(inputFrame, text="Book Name")
priceLabel = Label(inputFrame, text="Book Price")
kodeEntry = Entry(inputFrame)
nameEntry = Entry(inputFrame)
priceEntry = Entry(inputFrame)
submitButton = Button(inputFrame, text="Submit", command=NONE)
backButton = Button(inputFrame, text="Back", command=NONE)
inputFrame.pack()
kodeLabel.grid(row=0, column=0)
nameLabel.grid(row=1, column=0)
priceLabel.grid(row=2, column=0)
kodeEntry.grid(row=0, column=1)
nameEntry.grid(row=1, column=1)
priceEntry.grid(row=2, column=1)
submitButton.grid(row=3, column=0, columnspan=2)
backButton.grid(row=3, column=2)
if __name__ == "__main__":
master.mainloop()
Upvotes: 1
Views: 57
Reputation: 162
If you don't pass anything in def mainWindow(self, master):
like def mainWindow():
and if you change the if statement from
if __name__ == "__main__":
master.mainloop()
to:
if __name__ == "__main__":
mainWindow()
windowInput()
master.mainloop()
it should work
Upvotes: 2