Ejemplo n.º 1
0
        def prompt_section():
            def back():
                nonlocal window
                self.browser.back()
                window.destroy()
                prompt_course()

            def exit_menu():
                self.browser.back()
                self.browser.back()
                window.destroy()

            subject = self.browser.find_element_by_xpath(
                '/html/body/div[3]/form/table/tbody/tr[3]/td[3]').text
            number = self.browser.find_element_by_xpath(
                '/html/body/div[3]/form/table/tbody/tr[3]/td[4]').text
            name = self.browser.find_element_by_xpath(
                '/html/body/div[3]/form/table/tbody/tr[3]/td[8]').text
            course = Course(subject, number, name)

            element_arr = self.browser.find_elements(
                By.XPATH, '/html/body/div[3]/form/table/tbody/tr')
            for i in range(3, len(element_arr) + 1):
                arr = []
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[1]/abbr'
                        % i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[2]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[5]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[6]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[9]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[10]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[11]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[13]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[17]' %
                        i).text)
                arr.append(
                    self.browser.find_element_by_xpath(
                        '/html/body/div[3]/form/table/tbody/tr[%i]/td[19]' %
                        i).text)
                course.add_section(arr)

            window = Tk()
            Label(window,
                  text="%s %s %s" %
                  (course.subject, course.number, course.name)).grid(
                      row=0, column=0, sticky='W')
            sections = []
            box_vars = []
            for key in course.sections:
                section = course.sections[key]
                sections.append(sections)
                box_var = IntVar()
                box_vars.append(box_var)
                Checkbutton(window, variable=box_var).grid(row=i,
                                                           column=0,
                                                           sticky='W')
                Label(window, text=section.status).grid(row=i,
                                                        column=1,
                                                        sticky='W')
                Label(window, text=section.course_number).grid(row=i,
                                                               column=2,
                                                               sticky='W')
                Label(window, text=section.section_number).grid(row=i,
                                                                column=3,
                                                                sticky='W')
                Label(window, text=section.campus).grid(row=i,
                                                        column=4,
                                                        sticky='W')
                Label(window, text=section.days).grid(row=i,
                                                      column=5,
                                                      sticky='W')
                Label(window, text=section.times).grid(row=i,
                                                       column=6,
                                                       sticky='W')
                Label(window, text=section.capacity).grid(row=i,
                                                          column=7,
                                                          sticky='W')
                Label(window, text=section.remaining).grid(row=i,
                                                           column=8,
                                                           sticky='W')
                Label(window, text=section.instructor).grid(row=i,
                                                            column=9,
                                                            sticky='W')
                Label(window, text=section.location).grid(row=i,
                                                          column=10,
                                                          sticky='W')
                i = i + 1
            Button(window, text=ADD_SECTIONS_BUTTON_TEXT, command=lambda: self.add_sections(sections, box_vars)).\
                grid(row=i, column=0, sticky='W')
            Button(window, text=BACK_BUTTON_TEXT,
                   command=back).grid(row=i, column=1, sticky='W')
            Button(window, text=EXIT_BUTTON_TEXT,
                   command=exit_menu).grid(row=i, column=2, sticky='W')
            window.mainloop()