def _add_category(self, name='', percent=0, is_gen=False) -> None: """adds a catatory to the screen, also updating the canvas""" category_frame = tk.Frame(self._category_frame) category_frame.grid(row=len(self._categories) + 1, column=0, columnspan=2, sticky=tk.NSEW) utils.configure_frame(category_frame, rowspan=4, colspan=2) if not is_gen: utils.create_separator(category_frame, 0, 0, colspan=2, pady=10) name = utils.create_labeled_entry(category_frame, 'Name:', 1, insert=name) percent = utils.create_labeled_entry(category_frame, 'Percent of Grade:', 2, insert=percent) cat = Category(category_frame, name, percent) if not is_gen: utils.create_button(category_frame, 'Remove', lambda: self._remove_category(id(cat)), 3, 0, sticky=tk.NS) self._categories.update({id(cat): cat}) self._scroll.update_canvas() return name
def __init__(self, tkschedule): self._tkschedule = tkschedule self._root = tk.Tk() self._root.protocol('WM_DELETE_WINDOW', self._destroy) self._root.minsize(300, 300) utils.init_root_options(self._root) utils.init_theme() self._tkschedule._root_tracker.add_root(self._root) self._frame = tk.Frame(self._root) utils.configure_frame(self._root, colspan = 1) self._root.rowconfigure(0, weight = 1) self._frame.grid(row = 0, column = 0, sticky = tk.NSEW) utils.configure_frame(self._frame, colspan = 2) for i in range(3): self._frame.rowconfigure(i + 2, weight = 1) utils.create_title(self._frame, 'Edit Schedule', colspan = 2) name = utils.create_labeled_entry(self._frame, 'Name: ', 2, insert = tkschedule._schedule.name) units = utils.create_labeled_entry(self._frame, 'Units: ', 3, insert = tkschedule._schedule.units) gpa = utils.create_labeled_entry(self._frame, 'GPA: ', 4, insert = tkschedule._schedule.gpa) buttons_frame = tk.Frame(self._frame) buttons_frame.grid(row = 5, column = 0, columnspan = 2, sticky = tk.NSEW) for i in range(2): buttons_frame.columnconfigure(i, weight = 1, uniform = 'button') utils.create_button(buttons_frame, 'Update Schedule', self._update, 5, 0) utils.create_button(buttons_frame, 'Cancel', self._cancel, 5, 1) self._root.mainloop()
def __init__(self, root, root_frame, start_page): self._root = root self._start_page = start_page self._root_frame = root_frame self._frame = tk.Frame(self._root_frame) self._frame.grid(row=0, column=0, sticky=tk.NSEW) # can't use rowspan in the configure_frame for some reason??? for i in range(self.ROWSPAN - 2): self._frame.rowconfigure(i + 2, weight=1) utils.configure_frame(self._frame, colspan=self.COLSPAN) utils.create_title(self._frame, 'Create a new schedule', self.ROWSPAN) self._name = utils.create_labeled_entry(self._frame, 'Name:', 2, 0, 10, 10) self._units = utils.create_labeled_entry(self._frame, 'Current Units Completed:', 3, 0, 10, 10, '0') self._gpa = utils.create_labeled_entry(self._frame, 'Current GPA:', 4, 0, 10, 10, '0.00') utils.create_button(self._frame, 'Create', self._create, self.ROWSPAN, 0) utils.create_button(self._frame, 'Cancel', self._cancel, self.ROWSPAN, 1) utils.set_menu(self._root, utils.START_MENU) self.load_schedule()
def show_user_name_field(self, message): self.destroy_widgets() Label(self.form_panel, text=message, bg="#B00020", foreground="#ffffff").pack() self.user_name_field = Entry(self.form_panel) self.user_name_field.pack() create_button(self.form_panel, "Send", self.user_name_field_handler).pack()
def __init__(self, schedule, root_tracker: root_tracker.Root_Tracker, c: Course = None): self._schedule = schedule self._root_tracker = root_tracker self._c = c self._root = tk.Tk() utils.init_root_options(self._root) utils.init_theme() self._root.minsize(300, 300) self._root.protocol('WM_DELETE_WINDOW', self.destroy) self._root_tracker.add_root(self._root) self._root.columnconfigure(0, weight=1) self._root.rowconfigure(2, weight=1) self._scroll = ScrollingFrame(self._root, 2, 0, height_border=105) self._scroll_frame = self._scroll.frame utils.configure_frame(self._scroll_frame, rowspan=100, colspan=2) self._grade_cutoffs_frame = utils.create_labelframe( self._scroll_frame, 'Grade Cutoff Percentages', row=2, column=0, colspan=2) utils.configure_frame(self._grade_cutoffs_frame, rowspan=11, colspan=2) self._category_frame = utils.create_labelframe(self._scroll_frame, 'Categories', row=3, column=0, colspan=2) utils.configure_frame(self._category_frame, rowspan=1, colspan=1) self._grades = ['A', 'A-', 'B+', 'B', 'B-', 'C+', 'C', 'C-', 'D+'] self._categories = dict() utils.create_button(self._category_frame, 'Add Category', command=self._add_category, row=0, column=0, colspan=2) self._buttons_frame = tk.Frame(self._root) self._buttons_frame.grid(row=4, column=0, sticky=tk.NSEW) utils.configure_frame(self._buttons_frame, colspan=2) utils.create_button(self._buttons_frame, 'Cancel', command=self._cancel, column=1)
def __init__(self, parent, **kwargs): Frame.__init__(self, parent) self.__parent = parent self.buttons = [] try: for button in kwargs['buttons']: self.buttons.append(create_button(self.get_parent(), button)) except BaseException: pass self.place_buttons()
def __init__(self, c: 'Course', course_widget: 'Course Widget', root_tracker: root_tracker.Root_Tracker): TkAssignment.__init__(self, c, course_widget, root_tracker) self._root.title('Add An Assignment') utils.create_title(self._root, 'Add An Assignment', self.COLSPAN) self._name = utils.create_labeled_entry(self._root, 'Name:', 2, 0) self._points = utils.create_labeled_entry(self._root, 'Points Received:', 3, 0) self._points_total = utils.create_labeled_entry( self._root, 'Total Points:', 5, 0) utils.create_button(self._root, 'Add Assignment', self._create, 7, 0, sticky=tk.EW + tk.S, colspan=2) self._root.mainloop()
def __init__(self, c: 'Course', course_widget: 'Course Widget', root_tracker: root_tracker.Root_Tracker, a: Assignemnt): TkAssignment.__init__(self, c, course_widget, root_tracker) self._a = a self._root.title('Edit Assignment') self._points = a.points utils.create_title(self._root, f'Edit Assignment', self.COLSPAN) self._name = utils.create_labeled_entry(self._root, 'Name:', 2, 0, insert=a.name) p = '' if a.points is None else a.points self._points = utils.create_labeled_entry(self._root, 'Points Received:', 3, 0, insert=p) self._points_total = utils.create_labeled_entry(self._root, 'Total Points:', 5, 0, insert=a.points_total) self._cat.set(a.category) utils.create_button(self._root, 'Update Assignment', self._update_assignment, 7, 0, sticky=tk.EW + tk.S, colspan=2) if self._a.points is None: self._disable_points_entry() self._root.mainloop()
def __init__(self, schedule, root_tracker: root_tracker.Root_Tracker, c: Course, course_widget, tkschedule): TkCourse.__init__(self, schedule, root_tracker) self._c = c self._root.title('Edit Course') self._course_widget = course_widget self._tkschedule = tkschedule utils.create_title(self._root, f'Edit Course', 1, pady=1) self._name = utils.create_labeled_entry(self._scroll_frame, 'Name:', 0, 0, insert=self._c.name) self._units = utils.create_labeled_entry(self._scroll_frame, 'Units:', 1, 0, insert=self._c.units) self._a = utils.create_labeled_entry(self._grade_cutoffs_frame, 'A :', 3, insert=self._c._a) self._a_minus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'A- :', 4, insert=self._c._a_minus) self._b_plus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'B+ :', 5, insert=self._c._b_plus) self._b = utils.create_labeled_entry(self._grade_cutoffs_frame, 'B :', 6, insert=self._c._b) self._b_minus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'B- :', 7, insert=self._c._b_minus) self._c_plus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'C+ :', 8, insert=self._c._c_plus) self._c_grade = utils.create_labeled_entry(self._grade_cutoffs_frame, 'C :', 9, insert=self._c._c) self._c_minus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'C- :', 10, insert=self._c._c_minus) self._d_plus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'D+ :', 11, insert=self._c._d_plus) self._d = utils.create_labeled_entry(self._grade_cutoffs_frame, 'D :', 12, insert=self._c._d) self._grades_values = [ self._a, self._a_minus, self._b_plus, self._b, self._b_minus, self._c_plus, self._c_grade, self._c_minus, self._d_plus, self._d ] utils.create_button(self._buttons_frame, 'Update Course', command=self._update_course, column=0) for cat, percent in self._c.categories.items(): if cat == 'General': self._add_category(cat, percent, True) else: self._add_category(cat, percent) self._root.mainloop()
def __init__(self, schedule, tkschedule, root_tracker: root_tracker.Root_Tracker): TkCourse.__init__(self, schedule, root_tracker) self._tkschedule = tkschedule self._root.title('Add A Course') utils.create_title(self._root, 'Add A Course', 1, pady=1) self._name = utils.create_labeled_entry(self._scroll_frame, 'Name:', 0, 0) self._units = utils.create_labeled_entry(self._scroll_frame, 'Units:', 1, 0) self._a = utils.create_labeled_entry(self._grade_cutoffs_frame, 'A :', 0, insert='93.5') self._a_minus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'A- :', 1, insert='90.0') self._b_plus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'B+ :', 2, insert='86.5') self._b = utils.create_labeled_entry(self._grade_cutoffs_frame, 'B :', 3, insert='83.5') self._b_minus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'B- :', 4, insert='80.0') self._c_plus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'C+ :', 5, insert='76.5') self._c = utils.create_labeled_entry(self._grade_cutoffs_frame, 'C :', 6, insert='73.5') self._c_minus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'C- :', 7, insert='70.0') self._d_plus = utils.create_labeled_entry(self._grade_cutoffs_frame, 'D+ :', 8, insert='66.5') self._d = utils.create_labeled_entry(self._grade_cutoffs_frame, 'D :', 9, insert='63.5') self._grades_values = [ self._a, self._a_minus, self._b_plus, self._b, self._b_minus, self._c_plus, self._c, self._c_minus, self._d_plus, self._d ] utils.create_button(self._buttons_frame, 'Add Course', command=self._create, column=0) self._add_category('General', 100, True).config(state='disabled') self._root.mainloop()
def print_on_gui(message): Label(root.left_panel, text=message, anchor="w", width=300).pack() # Function to print the file list on the left side of the panel def print_to_file_list_panel(message): Label(file_list_panel, text=message, anchor="w", width=300).pack() root.print_on_gui = print_on_gui root.print_files = print_to_file_list_panel root.file_list_panel = file_list_panel # Connect Disconnect buttons used for client GUI greet_button = create_button( root.right_top_panel, "Connect", connect_client ) # Call connect_client function when connect button is clicked greet_button.pack(padx=10, pady=30) close_button = create_button( root.right_top_panel, "Disconnect", disconnect_client ) # Call disconnect_client function when Disconnect button is clicked close_button.pack() root.right_top_panel.pack(side="top", expand=True, fill="x") root.right_panel.pack_propagate(0) root.right_panel.pack(side="right", expand=True, fill="both") root.mainloop()
Label(file_list_panel, text=message, anchor="w", width=300).pack() def print_to_client_list_panel(message): Label(client_list_panel, text=message, anchor="w", width=300).pack() root.print_left = print_to_left_panel root.print_files = print_to_file_list_panel root.print_clients = print_to_client_list_panel # printing the client list root.file_list_panel = file_list_panel root.client_list_panel = client_list_panel # Start/ stop buttons used for client GUI greet_button = create_button(right_panel, "Start Server", run_server) # Call start_server function when start button is clicked greet_button.pack(padx=10, pady=10) close_button = create_button(right_panel, "Stop Server", stop_server) # Call stop_server function when stop button is clicked close_button.pack() clear_messages_button = create_button(right_panel, "Clear Messages", clear_messages) # Clear all the messages function clear_messages is called clear_messages_button.pack() right_panel.pack(side="right", expand=True, fill="both") root.mainloop()
def show_file_dialog(self): self.destroy_widgets() create_button(self.form_panel, "Upload file", self.file_upload_handler).pack()
def __init__(self, c: course.Course, schedule_frame: tk.Frame, scroll: tk.Canvas, schedule, root_tracker, tkschedule): self._c = c self._scroll = scroll self._schedule_frame = schedule_frame self._schedule = schedule self._root_tracker = root_tracker self._tkschedule = tkschedule self._frame = tk.Frame(self._schedule_frame) for i in range(self.COLSPAN): self._frame.columnconfigure(i, weight=1, uniform='course') self._assignments_widgets = dict() # initializes the name frame and label name_frame = tk.Frame(self._frame) name_frame.grid(row=0, column=0, sticky=tk.EW) for i in range(2): name_frame.columnconfigure(i, weight=1, uniform='name') self._name = utils.create_label(name_frame, self._c.name, 0, 1, sticky=tk.W) # initializes the course info self._units = utils.create_label(self._frame, self._c.units, 0, 1, padx=0) self._amt = utils.create_label(self._frame, len(self._c.assignments), 0, 2, padx=0) self._grade = utils.create_label(self._frame, self._c.grade, 0, 3, padx=0) # initializes the course drop down self._course_frame = tk.Frame(self._frame) self._course_frame.grid(row=1, column=0, columnspan=self.COLSPAN, sticky=tk.NSEW) utils.configure_frame(self._course_frame, rowspan=2, colspan=1) self._course_frame.grid_remove() # initializes the options frame options_frame = utils.create_labelframe(self._course_frame, 'Options', 0, 0) utils.configure_frame(options_frame, colspan=4) utils.create_button(options_frame, 'Add Assignment', self._create_assignment, 0, 0) utils.create_button(options_frame, 'Edit Course', self._edit_course, 0, 1) utils.create_button(options_frame, 'Submit Course', self._submit_course, 0, 2) utils.create_button(options_frame, 'Remove Course', self._remove_tkcourse, 0, 3) # initializes the assignments frame self._assignments_frame = utils.create_labelframe( self._course_frame, 'Assignments', 1, 0) for i in range(self.A_COLSPAN): self._assignments_frame.columnconfigure(i, weight=1, uniform='assignment') # initializes the drop down button icon = tk.Button(name_frame, command=lambda: self._course_menu(icon), width=16, height=16) utils.set_widget_image(icon, 'res/arrow.png', 2, 2) icon['border'] = '0' icon.state = 'hidden' icon.grid(row=0, column=0) if len(self._c.assignments) < 1: self._clear_assignments_info() else: self._init_assignments_info() for i in range(len(self._c.assignments)): self._update_tkassignment(self._c.assignments[i], i + 1) utils.create_separator(self._frame, 2, 0, self.COLSPAN, 0, 5)