def Fdisplaypanel_widgets(self):
     self.display_canvas = W.Canvas(self.Fdisplaypanel, 880, 650)
     self.display_canvas.pack()
     self.idle_image = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                   "MemePic.png")
     self.idle_image_canvas = self.display_canvas.create_image(
         0, 0, anchor=tk.NW, image=self.idle_image)
 def refresh_display_panel_to_show_meme(self):
     self.Fdisplaypanel.destroy()
     self.Fdisplaypanel = W.Frame(self.PageFrame, 880, 650)
     self.Fdisplaypanel.grid(column=1, row=1, rowspan=2)
     self.display_canvas = W.Canvas(self.Fdisplaypanel, 880, 650)
     self.display_canvas.pack()
     self.idle_image = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                   "MemePic.png")
     self.idle_image_canvas = self.display_canvas.create_image(
         0, 0, anchor=tk.NW, image=self.idle_image)
    def Setup_Button_Frame(self):
        self.search_submit_img = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                             "search_submit_button.png")
        self.search_submit_button = tk.Button(self.searchcourse_button_frame,
                                              image=self.search_submit_img,
                                              bd=0,
                                              highlightthickness=0,
                                              cursor='hand2')
        self.search_submit_button.pack(pady=15)

        def search_button_func(event):
            try:
                self.CD = self.scrape_course_data(self.term_curr.get(),
                                                  self.dept_curr.get(),
                                                  self.code_curr.get())
                self.refresh_display_panel_to_show_courses()
            except self.SearchFailure:
                self.refresh_display_panel_to_show_meme()
                popmsg.showerror(
                    "Fatal Error occurred during Search",
                    "There are several reasons that might lead to this error:\n \
1. One of your search fields might contain invalid input (CourseCode has to be valid).\n \
2. We can NOT find ANY courses that fulfils your search filter/parameter \n \
3. Your Internet Connection might be down \n \
4. There is a bug in our codes/system")

        self.search_submit_button.bind('<Button-1>', func=search_button_func)
    def create_frame(self):
        w, h = self.page_size()

        self.Fheader = W.Frame(self.PageFrame, w, 70, bg='#000000')
        self.Fcurrentcourse = W.Frame(self.PageFrame,
                                      400,
                                      325,
                                      hlt=1,
                                      hlb='#888888',
                                      hlc='#888888')
        self.Fsearchcourse = W.Frame(self.PageFrame,
                                     400,
                                     325,
                                     hlt=1,
                                     hlb='#888888',
                                     hlc='#888888')
        self.Fdisplaypanel = W.Frame(self.PageFrame, 880, 650)
    def Fsearchcourse_widgets(self):
        self.searchcourse_label = tk.Label(self.Fsearchcourse,
                                           text="SEARCH COURSES",
                                           font=font.Font(family="Arial",
                                                          size=-20,
                                                          weight="bold"),
                                           bg='#ffffff',
                                           bd=0,
                                           pady=10)
        self.searchcourse_label.grid(row=0,
                                     column=0,
                                     pady=(20, 0),
                                     sticky=self.ALL_STICK)

        self.searchcourse_term_frame = W.Frame(self.Fsearchcourse, 400, 70)
        self.searchcourse_term_frame.grid(row=1,
                                          column=0,
                                          sticky=self.ALL_STICK)
        self.Setup_Term_Frame()

        self.searchcourse_dept_frame = W.Frame(self.Fsearchcourse, 400, 70)
        self.searchcourse_dept_frame.grid(row=2,
                                          column=0,
                                          pady=7,
                                          sticky=self.ALL_STICK)
        self.Setup_Dept_Frame()

        self.searchcourse_code_frame = W.Frame(self.Fsearchcourse, 400, 70)
        self.searchcourse_code_frame.grid(row=3,
                                          column=0,
                                          sticky=self.ALL_STICK)
        self.Setup_Code_Frame()

        self.searchcourse_button_frame = W.Frame(self.Fsearchcourse, 400, 90)
        self.searchcourse_button_frame.grid(row=4,
                                            column=0,
                                            sticky=self.ALL_STICK)
        self.Setup_Button_Frame()

        self.Fsearchcourse.columnconfigure(0, weight=1)
        self.Fsearchcourse.rowconfigure(0, weight=1)
        self.Fsearchcourse.rowconfigure(1, weight=1)
        self.Fsearchcourse.rowconfigure(2, weight=1)
        self.Fsearchcourse.rowconfigure(3, weight=1)
        self.Fsearchcourse.rowconfigure(4, weight=1)
    def __init__(self, MainFrame, account_name, account_password):
        self.MainFrame = MainFrame;
        w,h = self.page_size();
        self.PageFrame = W.Frame(self.MainFrame, w, h);
        self.PageFrame.pack();

        self.account_name = account_name;
        self.account_password = account_password;

        self._switch_page = False;
    def Fheader_widgets(self):

        self.home_image = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                      "UCI_black_logo.png")

        self.home_canvas = W.Canvas(self.Fheader, 300, 70, bg='#000000')
        self.home_canvas.pack(anchor=tk.NW)

        self.home_canvas_img1 = self.home_canvas.create_image(
            16, 3, image=self.home_image, anchor=tk.NW)

        def temp_func(event):
            popmsg.askyesno(
                "Flow_Incomplete_Exception: failed to invoke JUMP to another page",
                "Jump to the Home Page?")

        self.home_canvas.tag_bind(self.home_canvas_img1,
                                  '<Button-1>',
                                  func=temp_func)
 def Faccount_image_widgets(self):
     self.account_image = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                      "account_image.png")
     self.account_image_label = tk.Label(self.Faccount_image,
                                         image=self.account_image,
                                         bd=0,
                                         relief=tk.FLAT,
                                         bg='#ffffff',
                                         activebackground='#ffffff')
     self.account_image_label.pack()
    def Fsubmit_widgets(self):
        self.submit_button_image = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                               "home_submit_button.png")
        self.submit_button = tk.Button(self.Fsubmit,
                                       image=self.submit_button_image,
                                       bd=0,
                                       highlightthickness=0,
                                       cursor='hand2')
        self.submit_button.pack(anchor=tk.W, padx=(577, 0))

        def jump_to_FunctionPage(event, self=self):
            #print("jump to FunctionPage");
            try:
                with open(CURR_WORKING_DIR /
                          "initialization_email_msg.txt") as f:
                    acc_name = self.account_name.get()
                    acc_pw = self.account_password.get()
                    msg = MIMEMultipart()
                    msg['From'] = acc_name
                    msg['To'] = acc_name
                    msg['Subject'] = "Welcome to the UCI Schedule Assistant"
                    msg.attach(MIMEText(f.read(), 'html'))
                    self.send_email(acc_name, acc_pw, msg.as_string())
            except smtp_engine.SETUP_SMTP_CONNECTION_ERROR:
                popmsg.showerror(
                    "Connection to Server Failed", "\
1. Please Make Sure your Internet Connection is in good condition.\n \
2. Please Make Sure you have enabled the permission called <Let Less Secure App access your account> in your gmail account"
                )
            except smtp_engine.LOGIN_FAILURE:
                popmsg.showerror(
                    "Login Failure", "\
1. Please Re-Check your account name and password are correct \n \
3. ONLY GMAIL ACCOUNT is currently supported \n \
2. Please Make Sure you have enabled the permission called <Let Less Secure App access your account> in your gmail account"
                )
            except smtp_engine.FAILED_TO_SENDMAIL:
                popmsg.showerror(
                    "Unable to Send Mail", "\
1. Please Make Sure your Internet Connection is in good condition.\n \
2. Please Make Sure you have enabled the permission called <Let Less Secure App access your account> in your gmail account"
                )
            else:
                self.next_page_id = "FP"
                self._switch_page = True

        self.submit_button.bind('<Button-1>', func=jump_to_FunctionPage)
        self.MainFrame.bind_all('<Return>', func=jump_to_FunctionPage)
    def Ffooter_widgets(self):
        self.moreinfo_button_image = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                                 "LearnMore_icon.png")
        self.moreinfo_button = tk.Button(self.Ffooter,
                                         image=self.moreinfo_button_image,
                                         bg='#ffffff',
                                         pady=9,
                                         bd=0,
                                         highlightthickness=0,
                                         cursor='hand2')
        self.moreinfo_button.pack(anchor=tk.E, padx=(0, 6))

        def temp_func(event):
            popmsg.askyesno(
                "Flow_Incomplete_Exception: failed to invoke JUMP to another page",
                "Jump to the AboutUs Page?")

        self.moreinfo_button.bind('<Button-1>', func=temp_func)
Example #11
0
    def __init__(self,
                 win_size=default_win_size,
                 start_coord=default_start_coord):

        self._running = False

        w, h = win_size
        x, y = start_coord

        #self.app_icon = Image.open("app_icon.ico", mode = 'r');

        # ------ DEFINING THE ROOT APP WINDOW ------ #
        self.Root = tk.Tk()
        self.Root.iconbitmap(CURR_WORKING_DIR / "pics" / "app_icon.ico")
        self.Root.title("UCI Schedule Assistant - {} Operating System".format(
            CURR_OPERATING_SYSTEM))
        self.Root.geometry(f"{w}x{h}+{x}+{y}")
        self.Root.resizable(width=False, height=False)
        self.Root.grid_propagate(False)
        # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #

        # --------- DEFINING THE MAIN FRAME --------- #
        self.MainFrame = W.Frame(self.Root, w, h)
        self.MainFrame.pack()
        # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #

        # ------ Instantiate TK VAR ------ #
        self.account_name = tk.StringVar()
        self.account_password = tk.StringVar()
        # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #

        # --------- Initialize the First Page --------- #
        page_id = ("HP", "FP", "AB")
        self.curr_page_id = "HP"
        self.CurrentPage = FunctionPage.FunctionPage(self.MainFrame,
                                                     self.account_name,
                                                     self.account_password)
    def Fcurrentcourse_widgets(self):
        self.currentcourse_label = tk.Label(self.Fcurrentcourse,
                                            text="TRACKED COURSES",
                                            height=3,
                                            font=font.Font(family="Arial",
                                                           size=-20,
                                                           weight="bold"),
                                            bg='#ffffff',
                                            bd=0,
                                            pady=10)
        self.currentcourse_label.grid(row=0,
                                      column=0,
                                      columnspan=3,
                                      pady=(10, 0),
                                      sticky=self.ALL_STICK)

        self.trackedcourse_vertical_scrollbar = tk.Scrollbar(
            self.Fcurrentcourse, width=15, orient=tk.VERTICAL)
        self.trackedcourse_horizontal_scrollbar = tk.Scrollbar(
            self.Fcurrentcourse, width=15, orient=tk.HORIZONTAL)
        self.trackedcourse_panel = tk.Listbox(
            self.Fcurrentcourse,
            selectmode=tk.MULTIPLE,
            relief=tk.GROOVE,
            width=28,
            bd=2,
            bg='#ffffff',
            highlightthickness=0,
            font=font.Font(family="Segoe UI", size=14),
            yscrollcommand=self.trackedcourse_vertical_scrollbar.set,
            xscrollcommand=self.trackedcourse_horizontal_scrollbar.set,
            listvariable=self.display_tracked_course)
        self.trackedcourse_vertical_scrollbar.grid(row=1,
                                                   column=1,
                                                   sticky=self.ALL_STICK)
        self.trackedcourse_horizontal_scrollbar.grid(row=2,
                                                     column=0,
                                                     sticky=self.ALL_STICK)
        self.trackedcourse_panel.grid(row=1, column=0, sticky=self.ALL_STICK)
        self.trackedcourse_vertical_scrollbar.config(
            command=self.trackedcourse_panel.yview)
        self.trackedcourse_horizontal_scrollbar.config(
            command=self.trackedcourse_panel.xview)

        self.trackedcourse_control_frame = W.Frame(self.Fcurrentcourse,
                                                   90,
                                                   0,
                                                   bg='#B6B6B6')
        self.trackedcourse_control_frame.grid(row=1,
                                              column=2,
                                              sticky=self.ALL_STICK)
        self.reset_button_icon = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                             "reset_button.png")
        self.reset_button = tk.Button(self.trackedcourse_control_frame,
                                      image=self.reset_button_icon,
                                      bd=0,
                                      highlightthickness=0,
                                      cursor='hand2',
                                      command=self.reset_tracked_courses)
        self.reset_button.pack(anchor=tk.CENTER, pady=40)
        self.delete_button_icon = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                              "delete_button.png")
        self.delete_button = tk.Button(
            self.trackedcourse_control_frame,
            image=self.delete_button_icon,
            bd=0,
            highlightthickness=0,
            cursor='hand2',
            command=self.delete_selected_tracked_courses)
        self.delete_button.pack(anchor=tk.CENTER, pady=30)

        self.starttrack_button_frame = W.Frame(self.Fcurrentcourse, 400, 60)
        self.starttrack_button_frame.grid(row=3,
                                          column=0,
                                          columnspan=3,
                                          sticky=self.ALL_STICK)
        self.starttrack_button_icon = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                                  "start_tracking_button.png")
        self.stoptrack_button_icon = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                                 "stop_tracking_button.png")
        self.starttrack_button = tk.Button(self.starttrack_button_frame,
                                           image=self.starttrack_button_icon,
                                           bd=0,
                                           highlightthickness=0,
                                           cursor='hand2')

        def start_tracking(event):
            if not self.tracking:
                self.starttrack_button.configure(
                    image=self.stoptrack_button_icon)
                self.trackedcourse_panel.configure(state=tk.DISABLED)
                self.reset_button.configure(state=tk.DISABLED)
                self.delete_button.configure(state=tk.DISABLED)
                self.tracking = True
                self.start_threads_to_track()

            else:
                self.starttrack_button.configure(
                    image=self.starttrack_button_icon)
                self.trackedcourse_panel.configure(state=tk.NORMAL)
                self.reset_button.configure(state=tk.NORMAL)
                self.delete_button.configure(state=tk.NORMAL)
                self.tracking = False
                self.stop_tracking_threads()

        self.starttrack_button.bind('<Button-1>', func=start_tracking)
        self.starttrack_button.pack(pady=15)

        self.Fcurrentcourse.columnconfigure(0, weight=1)
        self.Fcurrentcourse.columnconfigure(1, weight=1)
        self.Fcurrentcourse.columnconfigure(2, weight=1)
        self.Fcurrentcourse.rowconfigure(0, weight=1)
        self.Fcurrentcourse.rowconfigure(1, weight=1)
    def refresh_display_panel_to_show_courses(self):
        self.Fdisplaypanel.destroy()
        self.Fdisplaypanel = W.Frame(self.PageFrame, 880, 650)
        self.Fdisplaypanel.grid(column=1, row=1, rowspan=2)
        self.display_canvas = W.Canvas(self.Fdisplaypanel,
                                       860,
                                       650,
                                       bg='#ffffff')
        self.display_scroll = tk.Scrollbar(self.Fdisplaypanel,
                                           width=20,
                                           orient=tk.VERTICAL)
        self.display_scroll.config(command=self.display_canvas.yview)
        self.display_scroll.grid(row=0, column=1, sticky=self.ALL_STICK)
        self.display_canvas.config(yscrollcommand=self.display_scroll.set)
        self.display_canvas.grid(row=0, column=0, sticky=self.ALL_STICK)
        self.Fdisplaypanel.bind_all("<MouseWheel>", self._scroll_canvas)

        curr_x, curr_y, w_rect, h_rect = (0, 0, 860, 50)
        bright_color = True

        self.clickable_rect = []

        for course in self.CD:
            coursename, formalname = course.name()
            curr_rect = self.display_canvas.create_rectangle(
                curr_x,
                curr_y,
                curr_x + w_rect,
                curr_y + h_rect,
                fill=("#C9C9C9" if bright_color else "#FFFFFF"))
            self.clickable_rect.append(curr_rect)
            self.display_canvas.tag_bind(
                curr_rect,
                '<Button-1>',
                func=self.return_display_one_course_function(course))

            curr_coursename = self.display_canvas.create_text(
                curr_x + 20,
                curr_y + h_rect / 2,
                font=font.Font(family="Arial", size=14),
                anchor=tk.W,
                text=coursename)
            curr_formalname = self.display_canvas.create_text(
                curr_x + 175,
                curr_y + h_rect / 2,
                font=font.Font(family="Arial", size=14, weight="bold"),
                anchor=tk.W,
                text=formalname)
            curr_y += h_rect
            bright_color = not bright_color

        self.display_canvas.config(
            scrollregion=(0, 0, 860, (curr_y if curr_y >= 650 else 650)))

        def detect_clickable_in_canvas(event, self=self):
            clickable_bbox_list = [
                self.display_canvas.bbox(clickable)
                for clickable in self.clickable_rect
            ]
            for x1, y1, x2, y2 in clickable_bbox_list:
                if (x1 <= event.x <= x2) and (y1 <= event.y <= y2):
                    self.display_canvas.config(cursor='hand2')
                    #print('hand2')
                    return
            self.display_canvas.config(cursor='arrow')

        self.display_canvas.bind("<Motion>", detect_clickable_in_canvas)
        def refresh_display_panel_to_show_one_course(event):
            self.Fdisplaypanel.destroy()
            self.Fdisplaypanel = W.Frame(self.PageFrame, 880, 650)
            self.Fdisplaypanel.grid(column=1, row=1, rowspan=2)
            self.display_canvas = W.Canvas(self.Fdisplaypanel,
                                           860,
                                           650,
                                           bg='#ffffff')
            self.display_scroll = tk.Scrollbar(self.Fdisplaypanel,
                                               width=20,
                                               orient=tk.VERTICAL)
            self.display_scroll.config(command=self.display_canvas.yview)
            self.display_scroll.grid(row=0, column=1, sticky=self.ALL_STICK)
            self.display_canvas.config(yscrollcommand=self.display_scroll.set)
            self.display_canvas.grid(row=0, column=0, sticky=self.ALL_STICK)
            self.Fdisplaypanel.bind_all("<MouseWheel>", self._scroll_canvas)

            cn, fn = course.name()
            curr_x, curr_y = (80, 30)
            self.display_canvas.create_text(curr_x,
                                            curr_y,
                                            text=cn,
                                            font=font.Font(family="Arial",
                                                           size=17),
                                            anchor=tk.W)
            self.display_canvas.create_text(curr_x + 170,
                                            curr_y,
                                            text=fn,
                                            font=font.Font(family="Arial",
                                                           size=17,
                                                           weight="bold"),
                                            anchor=tk.W)

            self.add_button_img = W.OpenImage(CURR_WORKING_DIR / "pics" /
                                              "add_button.png")

            curr_x, curr_y = (50, 80)
            indented_width = 50
            next_increment_height = 50
            course_info_indent = (40, 110, 160, 210, 270, 500, 620)

            for primary_course in course:
                if primary_course.description() not in self.tracked_courses:
                    curr_add_button = self.display_canvas.create_image(
                        curr_x, curr_y, image=self.add_button_img)
                    self.display_canvas.tag_bind(
                        curr_add_button,
                        '<Button-1>',
                        func=self.return_add_tracked_course_function(
                            primary_course))
                display_class_info_on_canvas(primary_course, curr_x,
                                             curr_y - 1, course_info_indent)
                curr_y += next_increment_height
                for secondary_course in primary_course:
                    if secondary_course.description(
                    ) not in self.tracked_courses:
                        curr_add_button = self.display_canvas.create_image(
                            curr_x + indented_width,
                            curr_y,
                            image=self.add_button_img)
                        self.display_canvas.tag_bind(
                            curr_add_button,
                            '<Button-1>',
                            func=self.return_add_tracked_course_function(
                                secondary_course))
                    display_class_info_on_canvas(secondary_course,
                                                 curr_x + indented_width,
                                                 curr_y - 1,
                                                 course_info_indent)
                    curr_y += next_increment_height

            #print(curr_y)

            self.display_canvas.config(
                scrollregion=(0, 0, 860, (curr_y if curr_y >= 650 else 650)))
    def create_frame(self):

        ht = (70, 70, 70, 40, 100, 35, 56, 30, 56, 50, 32, 65, 46)
        # height tuple for each frame below sequentially

        w, h = self.page_size()

        if (sum(ht) != h):
            raise self.PageHasInvalidSize(
                "Total Frame Height(:={}) is not equal to the Root Window Height(:={})"
                .format(sum(ht), h))

        self.Fheader = W.Frame(self.PageFrame, w, ht[0], bg='#000000')
        self.Fblank1 = W.Frame(self.PageFrame, w, ht[1])
        self.Fwelcome_banner = W.Frame(self.PageFrame, w, ht[2])
        self.Fblank2 = W.Frame(self.PageFrame, w, ht[3])
        self.Faccount_image = W.Frame(self.PageFrame, w, ht[4])
        self.Fblank3 = W.Frame(self.PageFrame, w, ht[5])
        self.Faccount_name = W.Frame(self.PageFrame, w, ht[6])
        self.Fblank4 = W.Frame(self.PageFrame, w, ht[7])
        self.Faccount_password = W.Frame(self.PageFrame, w, ht[8])
        self.Fblank5 = W.Frame(self.PageFrame, w, ht[9])
        self.Fsubmit = W.Frame(self.PageFrame, w, ht[10])
        self.Fblank6 = W.Frame(self.PageFrame, w, ht[11])
        self.Ffooter = W.Frame(self.PageFrame, w, ht[12], bg='#ffffff')