def _create_dialog_inventory(self): """ Creates a dialog for display what items need to be inventoried. """ if self.tools.get_out(): self._create_dialog_msg(False, "There are items still checked out.") else: window = self._setup_dialog(w=700, h=550) frame_inv = Frame(window) frame_inv.pack() Label(frame_inv, text="Inventory").pack() frame_items = Frame(frame_inv) frame_items.pack() self.inventory.intersection_update(self.tools.get_tools()) shelf_tmp = Shelf(frame_items, self.inventory) self._grid_buttons(shelf_tmp) button_done = Button(frame_inv, text="Done", command=window.destroy) button_done.bind("<Return>", lambda e: window.destroy()) button_done.bind("<KP_Enter>", lambda e: window.destroy()) button_done.pack() window.wait_window(window)
def _check_out(self): """ Allows the user to check out items. """ logger.debug("Enter") item_lists = [ self.common_tools, self.uncommon_tools, self.common_keys, self.uncommon_keys ] item_set = Shelf() for item in item_lists: item_set.extend( item.items_out()) # Update latest checked out items. item_set.update_names() item_set_names = self.tools.trim_items(item_set.items_out_by_name()) # Make sure we have some items checked out. if not item_set_names: self._create_dialog_msg( False, "Please either hit 'Cancel' or select some items to check out." ) return item_set.remove_clicks() for item in item_set_names: if 'laptop' in item or 'lrduo' in item: self._create_dialog_acknowledge( ) # Should display only if a fluke or laptop is in the items list break self.tools.checkout_items(self.current_user, item_set_names, self._get_building_number()) self.inventory.update(item_set_names) self._switch_frame('login') logger.debug("Exit")
def _create_dialog_items_out(self): """ Creates a dialog for displaying who has what checked out. """ logger.debug("Enter") window = self._setup_dialog(w=700, h=550) frame_holder = [] if self.tools.transactions != {}: for user in self.tools.transactions.keys(): Label(window, text='%s - %s' % (user.capitalize(), self.tools.get_building_by_user(user))).pack() tmp = Frame(window) tmp.pack() items = self.tools.transactions[user][-1] shelf_tmp = Shelf(tmp, items) shelf_tmp.remove_clicks() self._grid_buttons(shelf_tmp) else: Label(window, text="No items are currently out.").pack() button_ok = Button(window, text="Ok", command=window.destroy) button_ok.bind("<Return>", lambda e: window.destroy()) button_ok.bind("<KP_Enter>", lambda e: window.destroy()) button_ok.focus_set() button_ok.pack() window.wait_window(window) logger.debug("Exit")
def _create_frame_in(self, name): """ Creates and returns the check-in frame. """ logger.debug("Enter") frame = Frame(self.parent, name=name) button_all = Button(frame, text="Check All", command=self._check_in) button_all.bind("<Return>", lambda e: self._check_in()) button_all.bind("<KP_Enter>", lambda e: self._check_in()) button_all.focus_set() button_all.pack() frame_items_out = Frame(frame) frame_items_out.pack() items_out = self.tools.get_out_by_user(self.current_user) self.items_out = Shelf(frame_items_out, items_out) self._grid_buttons(self.items_out) if len(self.items_out) == 0: Label(frame_items_out, text="You have no items to check in.").pack() button_some = Button(frame, text="Check Selected", command=lambda: self._check_in(all=False)) button_some.bind("<Return>", lambda e: self._check_in(all=False)) button_some.bind("<KP_Enter>", lambda e: self._check_in(all=False)) button_some.pack() button_cancel = Button(frame, text="Cancel", command=self._cancel) button_cancel.bind("<Return>", lambda e: self._cancel()) button_cancel.bind("<KP_Enter>", lambda e: self._cancel()) button_cancel.pack() return frame
def _create_frame_out(self, name): """ Creates and returns the check out frame. """ logger.debug("Enter") def _split_shelves(items, split): return items[:split], items[split:] frame = Frame(self.parent, name=name) # Display two pages of items wrapped with a labeled box. frame_items = Frame(frame, name="items") frame_items.pack() frame_tools = LabelFrame(frame_items, text="Tools", name="frame_tools") frame_tools.pack(side=LEFT, anchor=N) frame_common_tools = Frame(frame_tools, name="common_tools") frame_common_tools.pack() button_tools_expand = Button(frame_tools, text="Expand") button_tools_expand.pack() frame_uncommon_tools = Frame(frame_tools, name="uncommon_tools") frame_keys = LabelFrame(frame_items, text="Keys", name="frame_keys") frame_keys.pack(side=RIGHT, anchor=N) frame_common_keys = Frame(frame_keys, name="common_keys") frame_common_keys.pack() button_keys_expand = Button(frame_keys, text="Expand") button_keys_expand.pack() frame_uncommon_keys = Frame(frame_keys, name="uncommon_keys") button_tools_expand['command'] = lambda: self._expand( button_tools_expand, frame_uncommon_tools) button_tools_expand.bind( "<Return>", lambda e: self._expand(button_tools_expand, frame_uncommon_tools)) button_tools_expand.bind( "<KP_Enter>", lambda e: self._expand(button_tools_expand, frame_uncommon_tools)) button_keys_expand['command'] = lambda: self._expand( button_keys_expand, frame_uncommon_keys) button_keys_expand.bind( "<Return>", lambda: self._expand(button_keys_expand, frame_uncommon_keys)) button_keys_expand.bind( "<KP_Enter>", lambda: self._expand(button_keys_expand, frame_uncommon_keys)) tools = self.tools.get_tools() common_tools, uncommon_tools = _split_shelves(tools, COMMON_TOOLS) keys = self.tools.get_keys() common_keys, uncommon_keys = _split_shelves(keys, COMMON_KEYS) self.common_tools = Shelf(frame_common_tools, common_tools) self.uncommon_tools = Shelf(frame_uncommon_tools, uncommon_tools) self.common_keys = Shelf(frame_common_keys, common_keys) self.uncommon_keys = Shelf(frame_uncommon_keys, uncommon_keys) self._grid_buttons(self.common_tools) self._grid_buttons(self.uncommon_tools) self._grid_buttons(self.common_keys) self._grid_buttons(self.uncommon_keys) items_out = self.tools.get_out() self.common_tools.mark_out(items_out) self.uncommon_tools.mark_out(items_out) self.common_keys.mark_out(items_out) self.uncommon_keys.mark_out(items_out) frame_buttons = Frame(frame) frame_buttons.pack() button_out = Button(frame_buttons, text="Check Out", command=lambda: self._check_out()) button_out.bind("<Return>", lambda e: self._check_out()) button_out.bind("<KP_Enter>", lambda e: self._check_out()) button_out.pack() button_cancel = Button(frame_buttons, text="Cancel", command=self._cancel) button_cancel.bind("<Return>", lambda e: self._cancel()) button_cancel.bind("<KP_Enter>", lambda e: self._cancel()) button_cancel.pack() logger.debug("Exit") return frame