0

基本的に以下は私が今持っているものです。問題は、これらのボタンのそれぞれが新しいウィンドウを開き、右上にコースの追加などの現在の機能が表示されていることを望み、「時間の追加」をクリックするとコースの追加が削除され、追加が追加されることです。時間が表示されます。「編集」辞書操作ごとにこれを実行し、このウィンドウの右下に「最新」の表を印刷する方法はありますか? ありがとう。

   class menu():
        def __init__(self, master):
            self.master = master
            self.table = {}
            self.createButtons()
#   creates buttons with alignment and their functions
    def createButtons(self):
        load = Button(self.master, text = "Load Table",
                      command = self.loadTable)
        load.grid(row =0, column =0, pady = 30)

        course = Button(self.master, text = "Add Course",
                        command = self.addCourse)
        course.grid(row =1, column =0, pady = 30)

        time = Button(self.master, text = "Add Time",
                      command = self.addTime)
        time.grid(row =2, column =0, pady = 30)

        reset = Button(self.master, text = "Reset Time",
                       command = self.resetTime)
        reset.grid(row =3, column =0, pady = 30)

        comment = Button(self.master, text = "Change Comment",
                         command = self.changeComment)
        comment.grid(row =4, column =0, pady = 30)

        view = Button(self.master, text = "View Table",
                      command = self.viewTable)
        view.grid(row =5, column =0, pady = 30)

def addCourse(self):
        #creates addCourse window and text boxes for input
        toplevel = Toplevel()
        toplevel.title('Add Course')
        Label (toplevel, text='Enter the course name').grid()
        courseBox = Entry(toplevel, width=10)
        courseBox.grid()
        label =Label (toplevel, text='Enter the hours per week spent on course')
        label.grid(padx=10,pady=10)
        weekHoursBox = Entry(toplevel, width=10)
        weekHoursBox.grid()

        #function to accept input from boxes into dict
        def callback():
            course = courseBox.get()
            weekHours = weekHoursBox.get()
            string = "0 "+ str(weekHours) + " "
            self.table[course] = string

        enterB = Button(toplevel, text='Enter Information', command = callback)
        enterB.grid(pady=10)
4

1 に答える 1