def config_navigation(self, button_container, label_container): self._back_img = IMAGES.create(IMAGES.BACK) self._next_img = IMAGES.create(IMAGES.NEXT) next_command = partial(self.switch_page, PageSystem.NEXT) prev_command = partial(self.switch_page, PageSystem.PREVIOUS) # Button: Go to previous page self._prev_button = CButton(parent=button_container, image=self._back_img, command=prev_command, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=0) self._prev_button._disable() # Button: Go to next page self._next_button = CButton(parent=button_container, image=self._next_img, command=next_command, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=1) self._next_button._disable() parent_bg = label_container.cget('background') self._current_page_label = Label(master=label_container, text='<current page index>', font=Fonts.small(bold=True), foreground='black', background=parent_bg) self._current_page_label.pack(side=LEFT, padx=10, fill='x', expand=1)
def __init__(self, parent, background, shown: bool = False, order = None): super().__init__( master=parent, cnf={}, background='#696969' ) self.parent = parent self.table = None self.scrolllist = None # Assure that the frame won't resize with the contained widgets self.pack_propagate(0) self.grid_propagate(0) # Private members self._is_hidden = shown self._background = background self._right_container = Frame( master=self, background='#696969' ) self._right_container.pack(side=RIGHT, fill='y') self._export_img = IMAGES.create(IMAGES.EXPORT) self._export_button = Button( master=self._right_container, image=self._export_img, command=self._export_receipt, background=REFS.LIGHT_GRAY ) self._export_button.pack(side=TOP, padx=5, pady=5) # Initialize visibility-state if not shown: self.hide_view() else: self.show_view(order)
def __init__(self, parent, toolbar_container: Frame, background="white", shown: bool = False): super().__init__(parent=parent, title=REFS.ADDORDERVIEW_TITLE, toolbar_container=toolbar_container, background=background, shown=shown) if REFS.MOBILE: AddOrderView.COLUMNS = 3 self._checkmark_img = IMAGES.create(IMAGES.CHECK_MARK) self._close_light_img = IMAGES.create(IMAGES.CLOSE_LIGHT) self._add_img = IMAGES.create(IMAGES.ADD) self._back_img = IMAGES.create(IMAGES.BACK) self._trashcan_img = IMAGES.create(IMAGES.TRASH_CAN) self._order_img = IMAGES.create(IMAGES.ORDER) self._background = background self._root_category = None self._current_category = None self._views = [] self._meal_details_view = MealDetailsView(self, background, False) self._views.append(self._meal_details_view) self._current_order_view = CurrentOrderView(self, background, False) self._views.append(self._current_order_view) self._receipt_view = ReceiptView(parent=self, background=background, shown=False) self._views.append(self._receipt_view) self._current_order_view.meal_number_changed_event.add( self._added_meal_number_changed) ######## Setting toolbar content ######## # Right Button Container self._button_container_right = Frame(self.toolbar, background="#EFEFEF") self._button_container_right.grid(row=0, column=2, sticky='nsew') self._label_meal_counter = Label(master=self._button_container_right, text='0', foreground='red', font=Fonts.small(bold=True), background="#EFEFEF") self._label_meal_counter.grid(row=0, column=0, padx=15) # Button: Finish current order self._finish_order_button = CButton( parent=self._button_container_right, image=self._checkmark_img, command=self.finish_current_order, fg=CButton.WHITE, bg=CButton.GREEN, row=0, column=1) self._finish_order_button._hide() self._finish_order_button._disable() # Button: Finish current order self._close_receipt_button = CButton( parent=self._button_container_right, image=self._close_light_img, command=self.close_receipt, fg=CButton.WHITE, bg=REFS.LIGHT_RED, row=0, column=1) self._close_receipt_button._hide() # Button: Show current order self._current_order_button = CButton( parent=self._button_container_right, image=self._order_img, command=self.show_current_order, fg=CButton.WHITE, bg=CButton.LIGHT, row=0, column=2) # Middle Breadcrumb Container self._breadcrumb_container_middle = Frame(self.toolbar, background="#EFEFEF") self._breadcrumb_container_middle.grid(row=0, column=1, sticky='nsew') self._breadcrumb = Label(master=self._breadcrumb_container_middle, text='<breadcrumb>', font=Fonts.small(), foreground='black', background='#EFEFEF') self._breadcrumb.pack(side=LEFT, padx=10, fill='x', expand=1) # Left Button Container self._button_container_left = Frame(self.toolbar, background="#EFEFEF") self._button_container_left.grid(row=0, column=0, sticky='nsew') self.toolbar.grid_rowconfigure(0, weight=1) self.toolbar.grid_columnconfigure( 0, weight=0) # Left Container -> fit self.toolbar.grid_columnconfigure( 1, weight=1) # Middle Container -> expand self.toolbar.grid_columnconfigure( 2, weight=0) # Right Container -> fit # Button: Add meal to order self._add_meal_to_order_button = CButton( parent=self._button_container_left, image=self._add_img, command=self.add_meal_to_order, fg=CButton.WHITE, bg=CButton.GREEN, spaceX=(0.0, 1.0), row=0, column=0) # Button: Go up one category self._back_button = CButton(parent=self._button_container_left, image=self._back_img, command=self.go_back, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=1) # Button: Reset the category and content self._clear_button = CButton( parent=self._button_container_left, image=self._trashcan_img, command=self.clear_addorderview, fg=CButton.DARK, bg=CButton.LIGHT, # spaceX=(0.0,1.0), row=0, column=2)
def __init__(self, mobile_view: bool = False, main_station: bool = True, debug: bool = False, suppress_logs: bool = False): CashDeskGUI.DEBUG = debug if suppress_logs: sys.stdout = open(os.devnull, 'w') REFS.MOBILE = mobile_view REFS.MAIN_STATION = main_station # Initializing the main window root = Tk() ## root.resizable(False, False) root.resizable(True, True) root.attributes('-fullscreen', True) root.config(background='#696969') #if not CashDeskGUI.DEBUG: # root.attributes('-fullscreen', True) # Window Size: approx. 7 in root_bg = "#696969" # root.config(width=866, height=487, background=root_bg) #root.config(width=800, height=480, background=root_bg) station = 'Küche' #if main_station: # station = 'Kasse' title_size = 'Mobile Ansicht (7")' #if not mobile_view: # title_size = 'Vollbild' # if CashDeskGUI.DEBUG: # root.attributes('-fullscreen', True) root.wm_title(f"Bestellsystem - {station} - {title_size}") root.update() root.pack_propagate(0) self._root = root # The default font for the labels def_font = Fonts.medium() paddings = (5, 5) if mobile_view: # The default font for the labels def_font = Fonts.xxsmall() paddings = (0, 0) # Declaring the cash desk's model object self.model = CashDeskModel(root) ## -------- HEADER STUFF -------- ## self._headercontainer = Frame(root, background="#EFEFEF") self._headercontainer.pack(side=TOP, fill='x', padx=paddings, pady=paddings) self._toolbar_container = Frame(self._headercontainer, background="#EFEFEF") self._toolbar_container.pack(side=LEFT, fill='both', expand=1) if REFS.MOBILE: self._nav_img = IMAGES.create(IMAGES.NAVIGATION) self._more_button_container = Frame(master=self._headercontainer, background="#EFEFEF") self._more_button_container.pack(side=RIGHT, fill='both') self._more_button = CButton(parent=self._more_button_container, image=self._nav_img, width=1, command=self.open_side_bar, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=0) # The frame at the top of the window # header = Frame(self._headercontainer, background="#EFEFEF") # header.pack(side=TOP, fill='x', padx=5, pady=5) # header.grid(row=0, column=0, sticky='nsew') ## -------- BODY STUFF -------- ## self.body_container = Frame(root, background=root_bg) self.body_container.pack(side=TOP, expand=1, fill='both', padx=paddings) # The content panel (container) in the middle of the window self.body = ContentPanel( self.body_container, self._toolbar_container) #self.model.body_content_changed_event) self.body.pack(side=LEFT, expand=1, fill='both') # Lowered to the minimum z-Layer, so that the notification toasts are visible self.body.lower() ## -------- FOOTER STUFF -------- ## # The frame at the bottom of the window that acts as a container for all the elements footerContainer = Frame(root, background="#EFEFEF") if REFS.MOBILE: self.side_bar_visible = False self.side_bar = Frame(self.body_container, background="#EFEFEF") footerContainer = self.side_bar else: footerContainer.pack(side=BOTTOM, fill='x', padx=paddings, pady=paddings) # The frame within the container holding all the buttons footer = Frame(footerContainer, background="#EFEFEF") # The label within the container with the current timestamp self._footer_clock = Label(master=footerContainer, text="<CURRENT_TIME>", background="#EFEFEF", font=def_font, padx=10) self.connection_image = IMAGES.create(IMAGES.CONNECTION) self.connection_lost_image = IMAGES.create(IMAGES.CONNECTION_LOST) self.connection_ready_image = IMAGES.create(IMAGES.CONNECTION_READY) self._connection_symbol = Label(master=footerContainer, background="#EFEFEF", image=self.connection_image, padx=5, pady=5) if mobile_view: footer.pack(side=BOTTOM) self._footer_clock.pack(side=TOP) self._connection_symbol.pack(side=TOP) else: footer.pack(side=LEFT) # The label within the container with the title of the currently active view self._footer_title = Label(master=footerContainer, text="<Current Content View>", background="#EFEFEF", font=def_font, padx=10) self._footer_title.pack(side=LEFT) self._footer_clock.pack(side=RIGHT) self._connection_symbol.pack(side=RIGHT) spaceX = (0.0, 1.0) spaceY = (0.0, 0.0) if mobile_view: spaceX = (0.0, 0.0) spaceY = (0.0, 0.5) self._exit_img = IMAGES.create(IMAGES.EXIT) # The button to exit the program self._exit_button = CButton(parent=footer, image=self._exit_img, width=1 - 2 * mobile_view, vertical=mobile_view, spaceX=spaceX, spaceY=(spaceY[1], spaceY[0]), command=self.terminate, fg=CButton.WHITE, bg=CButton.DARK_RED, row=0, column=0 + 5 * mobile_view, flip_row_and_col=mobile_view) if REFS.MAIN_STATION: self.add_order_view_img = IMAGES.create(IMAGES.BURGER_DARK) # The button to bring up the add order view self._add_order_view_button = CButton( parent=footer, image=self.add_order_view_img, vertical=mobile_view, command=self.show_add_order, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=1, flip_row_and_col=mobile_view) self.in_progress_img = IMAGES.create(IMAGES.IN_PROGRESS) # The button to bring up the active orders view self._active_orders_button = CButton(parent=footer, image=self.in_progress_img, vertical=mobile_view, command=self.show_active_orders, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=2, flip_row_and_col=mobile_view) self.history_img = IMAGES.create(IMAGES.HISTORY) # The button to bring up the history view self._history_button = CButton(parent=footer, image=self.history_img, vertical=mobile_view, spaceX=spaceX, command=self.show_history, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=3, flip_row_and_col=mobile_view) if REFS.MAIN_STATION: self.settings_img = IMAGES.create(IMAGES.SETTINGS) # The button to bring up the settings view self._settings_button = CButton(parent=footer, image=self.settings_img, vertical=mobile_view, spaceX=spaceX, command=self.show_settings, fg=CButton.DARK, bg=CButton.LIGHT, row=0, column=4, flip_row_and_col=mobile_view) ## -------- ADDITIONAL STUFF -------- ## # Add callback functions that are called as soon as the database connection is established if REFS.MAIN_STATION: self.model.db_connection_ready_event.add( self.body.add_order_view.initialize) else: self.model.db_connection_ready_event.add( self.body.active_orders_view.update_view_and_database_content) # self.body.add_order_view.initialize() # Initializing the model after the GUI has finished the init process self.model.initialize(debug=CashDeskGUI.DEBUG) # Adding the GUI's callback function to the main periodic thread event of the model self.model.on_cycle_event.add(self.on_cycle) self.model.body_content_changed_event.add(self.body_changed) # Start main loop to wait for actions mainloop()
def __init__( self, title, summary, id, remove_cb, remove_all_cb, origin = (0,0), margin = (15,15), keep_alive = False # If True, the toast won't fade out ): self._timer_id = -1 self._fade_timer_id = -1 self._id = id self._keep_alive = keep_alive self._visible = True self._stop_checking = False self._title = title self._summary = summary self._dest_x = origin[0] self._dest_y = origin[1] self._margin = margin window = Toplevel() window.overrideredirect(1) window.attributes('-topmost', 1) window.config(background=self.BACKGROUND) window.attributes("-alpha", self.INITIAL_ALPHA) if keep_alive: window.config(highlightbackground=REFS.LIGHT_YELLOW) window.config(highlightthickness=4) window.update() self._window = window self.update_window_geometry() self._header_frame = Frame( master=window, bg=self.BACKGROUND ) self._header_frame.pack(side=TOP, fill='x', padx=5, pady=(5,0)) self._title_label = Label( master=self._header_frame, text=self._title, font=Fonts.xlarge(bold=True), anchor="nw", justify="left", bg=self.BACKGROUND ) self._title_label.pack(side=LEFT) self._button_frame = Frame( master=self._header_frame, bg=self.BACKGROUND ) self._button_frame.pack(side=RIGHT) self.close_img = IMAGES.create(IMAGES.CLOSE) self.close_all_img = IMAGES.create(IMAGES.CLOSE_ALL) std_button_width = 20 + 20 * (not REFS.MOBILE) self.remove_self = partial(remove_cb, self) self._close_button = Button( master=self._button_frame, image=self.close_img, command=self.remove_self, width=std_button_width, height=std_button_width, bg=self.BACKGROUND ) self._close_button.pack(side=RIGHT, padx=(5,0)) self._close_all_button = Button( master=self._button_frame, image=self.close_all_img, command=remove_all_cb, width=std_button_width, height=std_button_width, bg=self.BACKGROUND ) self._close_all_button.pack(side=RIGHT, padx=5) self._summary_label = Label( master=window, text=self._summary, font=Fonts.medium(), anchor="nw", justify="left", bg=self.BACKGROUND ) self._summary_label.pack(side=TOP, fill='both', padx=5, pady=5)
def __init__(self, parent, toolbar_container: Frame, background='white', shown: bool = False): super().__init__(parent=parent, title=REFS.HISTORYVIEW_TITLE, toolbar_container=toolbar_container, background='#696969', shown=shown) if REFS.MOBILE: HistoryView.SPACING = 2 HistoryView.PADX_COL = 15 HistoryItem.HEIGHT = 80 - 40 * REFS.MOBILE HistoryItem.EXPAND_HEIGHT = 600 - 300 * REFS.MOBILE OrderMessagingService.on_database_changed_event.add( self.update_view_and_database_content) OrdersService.on_orders_changed.add( self.update_view_and_database_content) self.order_items = [] self.page_system = PageSystem( on_page_changed=self.update_view_and_database_content, items_per_page=HistoryView.ITEMS_PER_PAGE, numbering_mode=PageSystem.ITEM_NUMBERING) self._back_img = IMAGES.create(IMAGES.BACK) self._next_img = IMAGES.create(IMAGES.NEXT) self._reset_i_img = IMAGES.create(IMAGES.RESET_I) self._trashcan_img = IMAGES.create(IMAGES.TRASH_CAN) ######## Setting toolbar content ######## #### Right Button Container self._button_container_right = Frame(self.toolbar, background="#EFEFEF") self._button_container_right.grid(row=0, column=2, sticky='nsew') # Button: Reset history self._reset_i_button = CButton(parent=self._button_container_right, image=self._reset_i_img, command=self.reset_order_counter, fg=CButton.DARK, bg=CButton.LIGHT, width=1.0, row=0, column=0) # Button: Clear history self._clear_button = CButton(parent=self._button_container_right, image=self._trashcan_img, command=self.clear_history, fg=CButton.DARK, bg=CButton.LIGHT, width=1.0, row=0, column=1) #### Page System # Middle Breadcrumb Container self._container_middle = Frame(self.toolbar, background="#EFEFEF") self._container_middle.grid(row=0, column=1, sticky='nsew') ## Left Button Container self._button_container_left = Frame(self.toolbar, background="#EFEFEF") self._button_container_left.grid(row=0, column=0, sticky='nsew') self.page_system.config_navigation( button_container=self._button_container_left, label_container=self._container_middle) self.toolbar.grid_rowconfigure(0, weight=1) self.toolbar.grid_columnconfigure( 0, weight=0) # Left Container -> fit self.toolbar.grid_columnconfigure( 1, weight=1) # Middle Container -> expand self.toolbar.grid_columnconfigure( 2, weight=0) # Right Container -> fit ######## END setting toolbar content ######## header_bg = '#F4F4F4' ########## HEADER ########## self.header = Frame(master=self, background=header_bg, height=HistoryItem.HEIGHT) self.header.pack(side=TOP, fill='x', pady=(0, HistoryView.SPACING)) self.header.pack_propagate(0) self.timestamp_head = Label( master=self.header, background=header_bg, text=REFS.ORDERS_TABLE_TIMESTAMP_GER.capitalize(), font=Fonts.xsmall(), width=18) self.timestamp_head.pack(side=LEFT, padx=HistoryView.PADX_COL) self.number_head = Label(master=self.header, background=header_bg, text=REFS.ORDERS_TABLE_ID_GER.capitalize(), font=Fonts.xsmall(bold=True), width=8) self.number_head.pack(side=LEFT, padx=HistoryView.PADX_COL) self.form_head = Label(master=self.header, background=header_bg, text=REFS.ORDERS_TABLE_FORM_GER.capitalize(), font=Fonts.xsmall(), width=10) self.form_head.pack(side=LEFT, padx=HistoryView.PADX_COL) self.price_head = Label(master=self.header, background=header_bg, text=REFS.ORDERS_TABLE_PRICE_GER.capitalize(), font=Fonts.xsmall(), width=6) self.price_head.pack(side=LEFT, padx=HistoryView.PADX_COL) self.edit_head = Label( master=self.header, background=header_bg, # text=REFS.HISTORY_TABLE_EDIT, font=Fonts.xsmall(), width=5) self.edit_head.pack(side=RIGHT, padx=HistoryView.PADX_COL) self.edit_head.update() HistoryView.EDIT_HEADER_WIDTH = self.edit_head.winfo_reqwidth() self.expand_head = Label( master=self.header, background=header_bg, # text=REFS.HISTORY_TABLE_EXPAND, font=Fonts.xsmall(), width=5) self.expand_head.pack(side=RIGHT, padx=(HistoryView.PADX_COL, 0)) self.expand_head.update() HistoryView.EXPAND_HEADER_WIDTH = self.expand_head.winfo_reqwidth() self.active_head = Label( master=self.header, background=header_bg, text=REFS.ORDERS_TABLE_ACTIVE_GER.capitalize(), font=Fonts.xsmall(), width=8) self.active_head.pack(side=RIGHT, padx=HistoryView.PADX_COL) self.state_head = Label(master=self.header, background=header_bg, text=REFS.ORDERS_TABLE_STATE_GER.capitalize(), font=Fonts.xsmall(), width=10) self.state_head.pack(side=RIGHT, padx=HistoryView.PADX_COL) ########## TABLE ########## self.table = Frame(master=self, background='#F4F4F4') self.table.pack(side=TOP, fill='both', expand=1) self.scrolllist = ScrollList(parent=self.table, spacing=HistoryView.SPACING, background='#696969')
def __init__(self, parent, order, background='white'): super().__init__(parent=parent, height=HistoryItem.HEIGHT, background='#F4F4F4') self._background = '#F4F4F4' self._order = OrdersService.convert_to_order_object(order) self.expanded = False self._changed_order = self._order.copy() self.edit_view_shown = False self.meals_view_shown = False column_names: [] = OrdersService.get_column_names() self._edit_img = IMAGES.create(IMAGES.EDIT) self._check_img = IMAGES.create(IMAGES.CHECK_MARK) self._down_img = IMAGES.create(IMAGES.DOWN) self._up_img = IMAGES.create(IMAGES.UP) self._empty_img = IMAGES.create(IMAGES.EMPTY) ########## COLUMNS ########## self.row_frame = Frame(master=self, background=background, height=HistoryItem.HEIGHT) self.row_frame.pack(side=TOP, fill='x') self.row_frame.pack_propagate(0) self.meals_frame = Frame(master=self, background='#F4F4F4') self.set_meals_content() self.edit_frame = Frame(master=self, background='#F4F4F4') self.set_edit_view() ##### TIMESTAMP ##### self.timestamp = Label(master=self.row_frame, text=OrdersService.convert_timestamp( self._order.timestamp, extended=True), font=Fonts.xsmall(), background=background, width=18) self.timestamp.pack(side=LEFT, padx=HistoryView.PADX_COL) ##### NUMBER ##### self.number = Label(master=self.row_frame, text=f"#{self._order.id}", font=Fonts.xsmall(bold=True), background=background, width=8) self.number.pack(side=LEFT, padx=HistoryView.PADX_COL) ##### FORM ##### self.form = Label(master=self.row_frame, text=OrdersService.convert_form(self._order.form), font=Fonts.xsmall(), background=background, width=10) self.form.pack(side=LEFT, padx=HistoryView.PADX_COL) ##### PRICE ##### self.price = Label(master=self.row_frame, text=f"{self._order.price_str}{REFS.CURRENCY}", font=Fonts.xsmall(), background=background, width=6) self.price.pack(side=LEFT, padx=HistoryView.PADX_COL) ##### EDIT BUTTON ##### self.edit_container = Frame(master=self.row_frame, width=HistoryView.EDIT_HEADER_WIDTH, height=60, bg=background) self.edit_container.pack(side=RIGHT, padx=HistoryView.PADX_COL) self.edit = Button(master=self.edit_container, image=self._edit_img, command=self.edit_order_command) self.edit.place(relx=0.5, rely=0.5, anchor="center") self.initial_button_background = self.edit.cget('background') if self._order.state != REFS.OPEN and self._order.state != REFS.CHANGED: self.edit.config(state="disabled") ##### EXPAND BUTTON ##### self.expand_container = Frame(master=self.row_frame, width=HistoryView.EXPAND_HEADER_WIDTH, height=60, bg=background) self.expand_container.pack(side=RIGHT, padx=(HistoryView.PADX_COL, 0)) expand_button_cmd = partial(self.expand_button_command, HistoryItem.MEALS_CONTENT_MODE) self.expand = Button(master=self.expand_container, image=self._down_img, command=expand_button_cmd) self.expand.place(relx=0.5, rely=0.5, anchor="center") ##### ACTIVE ##### active_i = column_names.index(REFS.ORDERS_TABLE_ACTIVE) self.active = Label(master=self.row_frame, text=OrdersService.convert_active(order[active_i]), font=Fonts.xsmall(), background=background, width=8) self.active.pack(side=RIGHT, padx=HistoryView.PADX_COL) ##### STATUS ##### state_i = column_names.index(REFS.ORDERS_TABLE_STATE) self.state = Label(master=self.row_frame, text=OrdersService.convert_status(order[state_i]), font=Fonts.xsmall(), background=REFS.ORDER_STATE_COLORS[int( order[state_i])], width=10) self.state.pack(side=RIGHT, padx=HistoryView.PADX_COL)
def __init__(self, parent, toolbar_container: Frame, background="white", shown: bool = False): super().__init__(parent=parent, title=REFS.ACTIVEORDERSVIEW_TITLE, toolbar_container=toolbar_container, background=background, shown=False) if REFS.MOBILE: ActiveOrdersView.NUM_COLUMNS = 3 ActiveOrdersView.NUM_ROWS = 1 self._background = background # OrdersService.on_order_created_event.add(self._order_created_event) #OrdersService.on_orders_changed.add( # self.update_view_and_database_content #) self.auto_refresh_enabled = False OrderMessagingService.on_database_changed_event.add( self.update_view_and_database_content) self._mark_mode = ActiveOrdersView.MARK_OFF self.page_system = PageSystem( on_page_changed=self.update_view_and_database_content, items_per_page=ActiveOrdersView.NUM_COLUMNS * ActiveOrdersView.NUM_ROWS, numbering_mode=PageSystem.PAGE_NUMBERING) ######## Setting main content ######## self.body_container = Frame(master=self, background=background) self.body_container.pack(side=TOP, fill='both', expand=1) self.body_container.grid_propagate(0) self._order_tiles = [] self._insert_order_tiles() ######## Setting toolbar content ######## self._checkmark_img = IMAGES.create(IMAGES.CHECK_MARK) self._checkmark_dark_img = IMAGES.create(IMAGES.CHECK_MARK_DARK) self._close_img = IMAGES.create(IMAGES.CLOSE_LIGHT) self._close_dark_img = IMAGES.create(IMAGES.CLOSE_DARK) self._undo_img = IMAGES.create(IMAGES.UNDO_LIGHT) self._undo_dark_img = IMAGES.create(IMAGES.UNDO) self._automatic_refresh_img = IMAGES.create(IMAGES.AUTO_REFRESH) self._refresh_img = IMAGES.create(IMAGES.UNDO) #### Right Button Container self._button_container_right = Frame(self.toolbar, background="#EFEFEF") self._button_container_right.grid(row=0, column=3, sticky='nsew') self._toggle_button_group = ToggleButtonGroup() # Button: Mark orders as done self._mark_done_button = ToggleButton( parent=self._button_container_right, image=self._checkmark_dark_img, highlight_image=self._checkmark_img, command=self._update_mark_mode, initial_state=True, group=self._toggle_button_group, # bg=REFS.LIGHT_GREEN, bg=REFS.LIGHT_GRAY, # highlight=CButton.GREEN, highlight=REFS.LIGHT_GREEN, row=0, column=0) # Button: Mark orders as open self._mark_open_button = ToggleButton( parent=self._button_container_right, image=self._undo_dark_img, highlight_image=self._undo_img, command=self._update_mark_mode, initial_state=False, group=self._toggle_button_group, bg=REFS.LIGHT_GRAY, highlight=CButton.DARK, # spaceX=(0.0,1.0), row=0, column=1) # Button: Mark orders as canceled self._mark_canceled_button = ToggleButton( parent=self._button_container_right, image=self._close_dark_img, highlight_image=self._close_img, command=self._update_mark_mode, initial_state=False, group=self._toggle_button_group, # bg=REFS.LIGHT_RED, bg=REFS.LIGHT_GRAY, # highlight=CButton.DARK_RED, highlight=REFS.LIGHT_RED, row=0, column=2) self._update_mark_mode() ### Middle Breadcrumb Container self._container_middle = Frame(self.toolbar, background="#EFEFEF") self._container_middle.grid(row=0, column=2, sticky='nsew') #### Left Middle Button Container self._button_container_left_middle = Frame(self.toolbar, background="#EFEFEF") self._button_container_left_middle.grid(row=0, column=1, sticky='nsew') self._toggle_button_group_2 = ToggleButtonGroup() # Button: Toggle auto refresh self.auto_refresh_button = ToggleButton( parent=self._button_container_left_middle, image=self._automatic_refresh_img, highlight_image=self._automatic_refresh_img, command=self._toggle_automatic_refresh, initial_state=self.auto_refresh_enabled, group=self._toggle_button_group_2, # bg=REFS.LIGHT_GREEN, bg=REFS.LIGHT_GRAY, # highlight=CButton.GREEN, highlight=REFS.LIGHT_YELLOW, row=0, column=0, width=1.0, spaceX=(1.0, 0.0)) # Button: Refresh page self.refresh_button = CButton( parent=self._button_container_left_middle, image=self._refresh_img, command=self.update_view_and_database_content, bg=REFS.LIGHT_GRAY, row=0, column=1, width=1.0) #### Left Button Container self._button_container_left = Frame(self.toolbar, background="#EFEFEF") self._button_container_left.grid(row=0, column=0, sticky='nsew') self.page_system.config_navigation( button_container=self._button_container_left, label_container=self._container_middle) self.toolbar.grid_rowconfigure(0, weight=1) self.toolbar.grid_columnconfigure( 0, weight=0) # Left Container -> fit self.toolbar.grid_columnconfigure( 1, weight=0) # Left Middle Container -> fit self.toolbar.grid_columnconfigure( 2, weight=1) # Middle Container -> expand self.toolbar.grid_columnconfigure( 3, weight=0) # Right Container -> fit ######## END setting toolbar content ######## if shown: super().show_view()
def __init__(self, parent, meal, index, remove_meal_cb, on_amount_changed_cb=None, background='white'): super().__init__(master=parent, cnf={}, background=background, highlightbackground='#606060', highlightthickness=2) self.padding = 15 if REFS.MOBILE: self.padding = 5 if AddedMealTile.PADDING != self.padding: AddedMealTile.PADDING = self.padding self.on_amount_changed_event: Event = Event() if on_amount_changed_cb != None and callable(on_amount_changed_cb): self.on_amount_changed_event.add(on_amount_changed_cb) self._meal = meal self.close_img = IMAGES.create(IMAGES.CLOSE) self.up_img = IMAGES.create(IMAGES.UP) self.down_img = IMAGES.create(IMAGES.DOWN) # TODO: Maybe as subheading to the name title we can add the last category of the meal #### Setup header std_button_width = 20 + 20 * (not REFS.MOBILE) self._header = Frame(master=self, background=background) self._header.pack(side=TOP, padx=self.padding, pady=self.padding, fill='x') self._l_name = Label(master=self._header, text=meal.name, background=background, foreground='black', font=Fonts.large(bold=True)) self._l_name.pack(side=LEFT, fill='x', expand=1) self._b_delete = Button(master=self._header, image=self.close_img, command=partial(remove_meal_cb, self), width=std_button_width, height=std_button_width) self._b_delete.pack(side=RIGHT, padx=(5, 0)) self.body_frame = Frame(master=self, background=background) self.body_frame.pack(side=TOP, padx=self.padding, pady=(0, self.padding), fill='both', expand=1) self.left_frame = Frame(master=self.body_frame, background=background) self.left_frame.pack(side=LEFT, fill='both', expand=1) #### Counter buttons self.right_frame = Frame(master=self.body_frame, background=background) self.right_frame.pack(side=RIGHT, fill='y') self._b_count_up = Button(master=self.right_frame, image=self.up_img, command=partial(self.change_amount, +1), width=std_button_width, height=std_button_width * 2) self._b_count_up.pack(side=TOP, pady=(0, 5)) self._b_count_down = Button(master=self.right_frame, image=self.down_img, command=partial(self.change_amount, -1), width=std_button_width, height=std_button_width * 2) self._b_count_down.pack(side=TOP) self._b_count_down.config(state="disabled") #### Setup size if len(meal.size_objects) > 0: size_text = f"{meal.size_objects[0].name}" if not REFS.MOBILE: size_text = f"{REFS.SIZE_LABEL}: " + size_text self._l_size = Label(master=self.left_frame, text=size_text, background=background, foreground='black', font=Fonts.xxsmall(), justify='left') self._l_size.pack(side=TOP, padx=self.padding, pady=(0, self.padding), anchor='nw') (meal_title, meal_text) = MealsService.meal_content_to_text(meal, indent="") self._l_content = Label(master=self.left_frame, text=meal_text, background=background, foreground='black', font=Fonts.xsmall(), justify='left') self._l_content.pack(side=TOP, padx=self.padding, pady=(0, self.padding), anchor='nw') # #### Setup ingredients list # # Only add ingredients, if there are any # if len(meal.ingredient_objects) > 0: # self._l_ingredients = Label( # master=self.left_frame, # text='', # background=background, # foreground='black', # font=Fonts.xxsmall(), # justify='left' # ) # self._l_ingredients.pack(side=TOP, padx=15, pady=(0, 15), anchor='nw') # for idx,ingr in enumerate(meal.ingredients): # curr_text = self._l_ingredients.cget('text') # nl = '\n' # if idx == len(meal.ingredients) - 1: # nl = '' # self._l_ingredients.config(text=f"{curr_text}- OHNE {ingr}{nl}") # #### Setup extras list # # Only add extras, if there are any # if len(meal.addons) > 0: # self._l_addons = Label( # master=self.left_frame, # text='', # background=background, # foreground='black', # font=Fonts.xxsmall(), # justify='left' # ) # self._l_addons.pack(side=TOP, padx=15, pady=(0, 15), anchor='nw') # for idx,addon in enumerate(meal.addons): # curr_text = self._l_addons.cget('text') # nl = '\n' # if idx == len(meal.addons) - 1: # nl = '' # self._l_addons.config(text=f"{curr_text}+ MIT {addon}{nl}") self.set_position(0, index) self.grid_propagate(0) self.pack_propagate(0)
def __init__(self, parent, background='white'): super().__init__( parent=parent, height=HistoryItem.HEIGHT, background=background #'#F4F4F4' ) self.meal_added_event: Event = Event() self.expanded = False self.edit_view_shown = False self.details_view_shown = False self.row_frame = Frame(master=self, background=background, height=HistoryItem.HEIGHT) self.row_frame.pack(side=TOP, fill='x') self.row_frame.pack_propagate(0) self.details_frame = Frame(master=self, background='#F4F4F4') self.set_details_content() self._undo_img = IMAGES.create(IMAGES.UNDO) self._add_img = IMAGES.create(IMAGES.ADD) self._down_img = IMAGES.create(IMAGES.DOWN) self._up_img = IMAGES.create(IMAGES.UP) self.index = Label(master=self.row_frame, font=Fonts.xsmall(), text="", background=background, width=MealsSettingsView.INDEX_WIDTH) self.index.pack(side=LEFT, padx=MealsSettingsView.PADDING) self.category = Text(master=self.row_frame, font=Fonts.xsmall(), background=background, width=MealsSettingsView.CATEGORY_WIDTH, height=1) self.category.pack(side=LEFT, padx=MealsSettingsView.PADDING) self.name = Text(master=self.row_frame, font=Fonts.xsmall(bold=True), background=background, width=MealsSettingsView.NAME_WIDTH + 3, height=1) self.name.pack(side=LEFT, padx=MealsSettingsView.PADDING) self.name_bg = self.name.cget('background') ##### ADD BUTTON ##### self.add_container = Frame(master=self.row_frame, width=MealsSettingsView.DELETE_HEADER_WIDTH, height=60, bg=background) self.add_container.pack(side=RIGHT, padx=MealsSettingsView.PADDING) self.add = Button(master=self.add_container, image=self._add_img, command=self.add_meal_command, background=CButton.GREEN) self.add.place(relx=0.5, rely=0.5, anchor="center") ##### UNDO BUTTON ##### self.undo_container = Frame(master=self.row_frame, width=MealsSettingsView.EDIT_HEADER_WIDTH, height=60, bg=background) self.undo_container.pack(side=RIGHT, padx=(MealsSettingsView.PADDING, 0)) self.undo = Button(master=self.undo_container, image=self._undo_img, command=self.undo_command) self.undo.place(relx=0.5, rely=0.5, anchor="center") # self.initial_button_background = self.edit.cget('background') # if self._order.state != REFS.OPEN and self._order.state != REFS.CHANGED: # self.edit.config(state="disabled") ##### EXPAND BUTTON ##### self.expand_container = Frame( master=self.row_frame, width=MealsSettingsView.EXPAND_HEADER_WIDTH, height=60, bg=background) self.expand_container.pack(side=RIGHT, padx=(MealsSettingsView.PADDING, 0)) # self.expand = Button( # master=self.expand_container, # image=self._down_img, # command=self.expand_button_command # ) # self.expand.place(relx=0.5, rely=0.5, anchor="center") ##### BASE PRICE ##### self.base_price = Text(master=self.row_frame, font=Fonts.xsmall(), background=background, width=MealsSettingsView.PRICE_WIDTH, height=1) self.base_price.pack(side=RIGHT, padx=MealsSettingsView.PADDING) self.base_price_bg = self.base_price.cget('background')
def __init__(self, parent, meal, index, background='white'): super().__init__( parent=parent, height=HistoryItem.HEIGHT, background=background #'#F4F4F4' ) self.meal = meal self.meal_deleted_event: Event = Event() self.expanded = False self.edit_view_shown = False self.details_view_shown = False self.row_frame = Frame(master=self, background=background, height=HistoryItem.HEIGHT) self.row_frame.pack(side=TOP, fill='x') self.row_frame.pack_propagate(0) self.details_frame = Frame(master=self, background='#F4F4F4') self.set_details_content() self._edit_img = IMAGES.create(IMAGES.EDIT) self._check_img = IMAGES.create(IMAGES.CHECK_MARK) self._trashcan_img = IMAGES.create(IMAGES.TRASH_CAN_LIGHT) self._down_img = IMAGES.create(IMAGES.DOWN) self._up_img = IMAGES.create(IMAGES.UP) self.index = Label(master=self.row_frame, text=f"{index}", font=Fonts.xsmall(), background=background, width=MealsSettingsView.INDEX_WIDTH) self.index.pack(side=LEFT, padx=MealsSettingsView.PADDING) self.category = Label(master=self.row_frame, text=meal.category_raw, font=Fonts.xsmall(), background=background, width=MealsSettingsView.CATEGORY_WIDTH) self.category.pack(side=LEFT, padx=MealsSettingsView.PADDING) self.name = Label(master=self.row_frame, text=meal.name, font=Fonts.xsmall(bold=True), background=background, width=MealsSettingsView.NAME_WIDTH) self.name.pack(side=LEFT, padx=MealsSettingsView.PADDING) ##### DELETE BUTTON ##### self.delete_container = Frame( master=self.row_frame, width=MealsSettingsView.DELETE_HEADER_WIDTH, height=60, bg=background) self.delete_container.pack(side=RIGHT, padx=MealsSettingsView.PADDING) self.delete = Button(master=self.delete_container, image=self._trashcan_img, command=self.delete_meal_command, background=CButton.DARK_RED) self.delete.place(relx=0.5, rely=0.5, anchor="center") ##### EDIT BUTTON ##### self.edit_container = Frame(master=self.row_frame, width=MealsSettingsView.EDIT_HEADER_WIDTH, height=60, bg=background) self.edit_container.pack(side=RIGHT, padx=(MealsSettingsView.PADDING, 0)) self.edit = Button( master=self.edit_container, image=self._edit_img, command=None #self.edit_order_command ) self.edit.place(relx=0.5, rely=0.5, anchor="center") self.edit.config(state="disabled") # self.initial_button_background = self.edit.cget('background') # if self._order.state != REFS.OPEN and self._order.state != REFS.CHANGED: # self.edit.config(state="disabled") ##### EXPAND BUTTON ##### self.expand_container = Frame( master=self.row_frame, width=MealsSettingsView.EXPAND_HEADER_WIDTH, height=60, bg=background) self.expand_container.pack(side=RIGHT, padx=(MealsSettingsView.PADDING, 0)) self.expand = Button(master=self.expand_container, image=self._down_img, command=self.expand_button_command) self.expand.place(relx=0.5, rely=0.5, anchor="center") self.expand.config(state="disabled") ##### BASE PRICE ##### self.base_price_head = Label(master=self.row_frame, text=f"{meal.price_str}{REFS.CURRENCY}", font=Fonts.xsmall(), background=background, width=MealsSettingsView.PRICE_WIDTH) self.base_price_head.pack(side=RIGHT, padx=MealsSettingsView.PADDING)
def __init__(self, parent, toolbar_container: Frame, background="white", shown: bool = False): super().__init__(parent=parent, title=REFS.ADDORDERVIEW_TITLE, toolbar_container=toolbar_container, background=background, shown=shown) self._root_category = None self._order_type = REFS.EAT_IN self._checkmark_img = IMAGES.create(IMAGES.CHECK_MARK) self._close_light_img = IMAGES.create(IMAGES.CLOSE_LIGHT) self._add_img = IMAGES.create(IMAGES.ADD) self._back_img = IMAGES.create(IMAGES.BACK) self._trashcan_img = IMAGES.create(IMAGES.TRASH_CAN) self._order_img = IMAGES.create(IMAGES.ORDER) self._empty_img = IMAGES.create(IMAGES.EMPTY) self._background = background ######## Setting toolbar content ######## # #### Right Button Container self._button_container_right = Frame(self.toolbar, background="#EFEFEF") self._button_container_right.grid(row=0, column=2, sticky='nsew') self._radio_button_group = RadioButtonGroup() self._eat_in_button = RadioButton(parent=self._button_container_right, text=REFS.ORDER_FORMS[REFS.EAT_IN], image=self._empty_img, highlight_image=self._empty_img, command=self._update_order_type, initial_state=True, group=self._radio_button_group, fg="#000000", bg=REFS.LIGHT_GRAY, highlight=REFS.LIGHT_CYAN, row=0, column=0 # width=1.5, height=0.6 ) # Button: Change order type to "eat in" # self._eat_in_button = ToggleButton( # parent=self._button_container_right, # text=REFS.ORDER_FORMS[REFS.EAT_IN], # image=self._empty_img, # highlight_image=self._empty_img, # command=self._update_order_type, # initial_state=True, # group=self._toggle_button_group, # bg=REFS.LIGHT_GRAY, # highlight=REFS.LIGHT_CYAN, # row=0, column=0 # ) self._takeaway_button = RadioButton( parent=self._button_container_right, text=REFS.ORDER_FORMS[REFS.TAKEAWAY], image=self._empty_img, highlight_image=self._empty_img, command=self._update_order_type, initial_state=False, group=self._radio_button_group, fg="#000000", bg=REFS.LIGHT_GRAY, highlight=REFS.LIGHT_CYAN, row=0, column=1 # width=1.5, height=0.6 ) # Button: Change order type to "takeaway" # self._takeaway_button = ToggleButton( # parent=self._button_container_right, # text=REFS.ORDER_FORMS[REFS.TAKEAWAY], # image=self._empty_img, # highlight_image=self._empty_img, # command=self._update_order_type, # initial_state=False, # group=self._toggle_button_group, # bg=REFS.LIGHT_GRAY, # highlight=REFS.LIGHT_CYAN, # row=0, column=1 # ) self._update_order_type() # Middle Breadcrumb Container self._breadcrumb_container_middle = Frame(self.toolbar, background="#EFEFEF") self._breadcrumb_container_middle.grid(row=0, column=1, sticky='nsew') self._breadcrumb = Label(master=self._breadcrumb_container_middle, text='Preis letzter Bestellung: -.--€', font=Fonts.small(), foreground='black', background='#EFEFEF') self._breadcrumb.pack(side=LEFT, padx=10, fill='x', expand=1) self.toolbar.grid_rowconfigure(0, weight=1) self.toolbar.grid_columnconfigure( 0, weight=0) # Left Container -> fit self.toolbar.grid_columnconfigure( 1, weight=1) # Middle Container -> expand self.toolbar.grid_columnconfigure( 2, weight=0) # Right Container -> fit