Exemplo n.º 1
0
 async def _():
     counter = 5
     lib.stdout.write(f"Global shutdown in {counter}s")
     lib.AsyncTk().forward("global_shutdown", counter)
     lib.AsyncTk().forward("print_daily_sales")
     while counter > 0:
         lib.stdout.write(f"{counter}s", replace=3)
         await asyncio.sleep(1)
         counter -= 1
Exemplo n.º 2
0
 def __init__(self, ticket, ticket_no, index, name, deliver):
     self.item = lib.AsyncTk().forward("filter", ticket, ticket_no, index,
                                       0)
     self.addon1 = lib.AsyncTk().forward("filter", ticket.addon1, ticket_no,
                                         index, 1)
     self.addon2 = lib.AsyncTk().forward("filter", ticket.addon2, ticket_no,
                                         index, 2)
     self.ticket_no = ticket_no
     self.index = index
     self.name = name
     self.deliver = deliver
Exemplo n.º 3
0
 def recenter(self, *args):
     self.scroller.offset = 0
     super().update(lib.AsyncTk().forward("tickets"))
     while True:
         if any(
                 item.parameters.get("status") == lib.TICKET_COMPLETE
                 for item in self.scroller.get()):
             self.scroller.advance()
             super().update(lib.AsyncTk().forward("tickets"))
             continue
         return
Exemplo n.º 4
0
    def set_keypress_bind(self, notebook, tabname, on_enter=lambda: None):
        def input_condition():
            return notebook.current() == tabname

        return self.price_input.set_keypress_bind(lib.AsyncTk(),
                                                  condition=input_condition,
                                                  on_enter=on_enter)
Exemplo n.º 5
0
    def update(self, ticket):
        order_queue = lib.AsyncTk().forward("order_queue")
        name = order_queue[str(ticket.ticket_no)]["name"]
        deliver = order_queue[str(ticket.ticket_no)]["deliver"]
        if not ticket:
            return self.reset()
        self.ticket = ticket
        self["relief"] = tk.RIDGE
        self.ticket_no["relief"] = tk.RAISED

        text = "{:03d}".format(ticket.ticket_no)
        if name:
            text += f": {name}"
        self.ticket_no["text"] = text
        self.item_info.update(ticket)
        self.addon1_info.update(ticket.addon1)
        self.addon2_info.update(ticket.addon2)

        if deliver:
            self.deliver.grid()
            self.deliver.lift()
            self["bg"] = "red"
            self.ticket_no["bg"] = "red"
        else:
            self.deliver.grid_remove()
            self["bg"] = "white smoke"
            self.ticket_no["bg"] = "white smoke"
Exemplo n.º 6
0
 def open_drawer(self):
     label = lib.LabelButton(self,
                             text="Open Drawer",
                             font=ToggleFrame.font,
                             command=functools.partial(
                                 lib.AsyncTk().forward, "open_drawer"))
     label.grid(row=0, column=3, sticky="nswe", padx=3, pady=3, ipadx=5)
Exemplo n.º 7
0
    def _item_select_add(self, item=lib.NULL_MENU_ITEM):
        if self.counter == 0:
            result = self._add_ticket(item)
            self.case = self.get_case(item)
            if self.case == 2:
                self._highlight_last_added()
                if item.options:
                    EditOptions(lib.AsyncTk(), result)
                return

        self._add_to_ticket(item)
        self._highlight_last_added()
        self._lift(self.counter + 1)
        self.counter += 1
        if self.counter == 3 and Order():
            self.counter = 0
            GroupEditOptions(lib.AsyncTk(), Order()[-1])
Exemplo n.º 8
0
 def advance(self, *args):        
     completed = self.widgets[0].ticket
     # no ticket showed on screen. nothing to do
     if completed is None:
         return        
     lib.AsyncTk().forward("set_ticket_status", 
             completed.index, 
             lib.TICKET_COMPLETE)
Exemplo n.º 9
0
 def daily_sales_printer(self):
     command = functools.partial(lib.AsyncTk().forward, "print_daily_sales")
     label = tk.Label(self, text="Daily Sales", font=ToggleFrame.font)
     button = lib.LabelButton(self,
                              text="Print",
                              command=command,
                              font=ToggleFrame.font)
     label.grid(row=1, column=1, sticky="nswe", padx=3, pady=3)
     button.grid(row=1, column=2, sticky="nswe", padx=3, pady=3)
Exemplo n.º 10
0
 def add_invoice_printer(self):
     command = functools.partial(lib.AsyncTk().forward, "print_invoice")
     label = tk.Label(self, text="Invoice Receipt", font=ToggleFrame.font)
     button = lib.LabelButton(self,
                              text="Print",
                              command=command,
                              font=ToggleFrame.font)
     label.grid(row=0, column=1, sticky="nswe", padx=3, pady=3)
     button.grid(row=0, column=2, sticky="nswe", padx=3, pady=3)
Exemplo n.º 11
0
 def update(self):
     num = 0
     for i, ticket in enumerate(lib.AsyncTk().forward("tickets")):
         if i < self.show_num:
             self.widgets[i].update(ticket)
             self.widgets[i].pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
             num = i + 1
     
     for widget in self.widgets[num: ]:
         widget.pack_forget()
Exemplo n.º 12
0
 def update(self):
     network, server, client = lib.AsyncTk().forward(
         "get_connection_status")
     self.network_indicator.set(network)
     self.server_indicator.set(server)
     if client is None:
         client = False
     else:
         client = "POS" in client
     self.pos_indicator.set(client)
Exemplo n.º 13
0
 def __init__(self, parent, **kwargs):
     super().__init__(parent,
         width=11,
         font=self.font,
         state=tk.DISABLED,
         disabledbackground="white",
         disabledforeground="black",
         relief=tk.RIDGE, **kwargs)
     self._time = tk.StringVar(self)
     self["textvariable"] = self._time
     lib.AsyncTk().add_task(self.update_time())
Exemplo n.º 14
0
 async def _():
     counter = 5
     lib.stdout.write(f"Restart in {counter}s")
     while counter > 0:
         lib.stdout.write(f"{counter}s", replace=3)
         await asyncio.sleep(1)
         counter -= 1
     lib.AsyncTk().destroy(shutdown=False)
     await asyncio.sleep(1)
     main = sys.executable
     os.execl(main, main, *sys.argv)
Exemplo n.º 15
0
    def update(self):
        size = len(Order())
        if self.current_order_len != size:
            self.current_order_len = size
            self.reset()

        # make sure main course items are not set as addon
        for i, ticket in enumerate(Order()):
            if ticket.addon1.category and ticket.addon1.category not in Order.no_addons:
                lib.AsyncTk().forward("stdout").info(
                    f"Invalid addon ({ticket.addon1.name}) selected for '{ticket.name}'"
                )
                Order()[i] = ticket.set(1, lib.NULL_MENU_ITEM)
                self.rewind()

            if ticket.addon2.category and ticket.addon2.category not in Order.no_addons:
                lib.AsyncTk().forward("stdout").info(
                    f"Invalid addon ({ticket.addon2.name}) selected for '{ticket.name}'"
                )
                Order()[i] = ticket.set(2, lib.NULL_MENU_ITEM)
                self.rewind()
Exemplo n.º 16
0
 def __init__(self, parent, **kwargs):
     super().__init__(parent, **kwargs)
     self.grid_columnconfigure(0, weight=1)
     self.network_status = NetworkStatus(self,
                                         relief=tk.RIDGE,
                                         bd=2,
                                         font=self.font,
                                         bg="grey16")
     self.network_status.grid(row=0, column=0, sticky="w", pady=5, padx=2)
     self.clock = lib.Clock(self, font=self.font)
     self.print_toggle = lib.ToggleSwitch(
         self,
         "print",
         font=self.font,
         state=lib.AsyncTk().forward("print"))
     self.print_toggle.grid(row=0, column=1, sticky="w", padx=5)
     self.clock.grid(row=0, column=2, sticky="w", padx=5)
Exemplo n.º 17
0
def main(protocol, ncol, geometry=None):
    app = lib.AsyncTk(protocol())
    if lib.DEBUG:
        fullscreen = False
        assert geometry is not None
    else:
        fullscreen = True
        geometry = f"{app.winfo_screenwidth()}x{app.winfo_screenheight()}"
        # set baudrate for printer
        subprocess.call("stty -F /dev/serial0 19200", shell=True)

    app.attributes("-fullscreen", fullscreen)
    app.geometry(geometry)
    app.resizable(False, False)
    app.grid_columnconfigure(0, weight=1)
    app.grid_rowconfigure(0, weight=1)

    queue = LineDisplay.TicketQueue(app,
                                    functools.partial(LineDisplay.TicketInfo,
                                                      ncol=ncol),
                                    5,
                                    orient=tk.VERTICAL,
                                    reverse=True)
    titlebar = LineDisplay.TitleBar(app, bg="grey16")
    queue.grid(row=0, column=0, sticky="nswe")
    queue.grid_inner(columnspan=2, sticky="nswe")
    titlebar.grid(row=1, column=0, sticky="we")
    queue.update()
    titlebar.update()
    app.bind("<KP_Enter>", queue.on_enter)
    app.bind("<KP_0>", titlebar.toggle_print)
    app.bind("<KP_Insert>", titlebar.toggle_print)

    app.bind("<KP_Begin>", queue.recenter)
    app.bind("<KP_5>", queue.recenter)
    app.delegate.shutdown(cleanup=app.destroy)
    app.mainloop()
Exemplo n.º 18
0
 def toggle_print(self, *args):
     self.print_toggle.command()
     lib.AsyncTk().forward("set_print", self.print_toggle)
Exemplo n.º 19
0
 def add_payment_option(self, option):
     widget = PaymentOptionFrame(self.interior, option)
     EditorDelegate().add_payment_option(widget.payment_type)
     lib.AsyncTk().forward("stdout").info(f"Added Payment Option '{option}'")
     self.widgets.append(widget)
     self.grid_widgets()
Exemplo n.º 20
0
 def update(self):
     super().update(lib.AsyncTk().forward("tickets"))
Exemplo n.º 21
0
 def __init__(self, parent, **kwargs):
     super().__init__(parent, **kwargs)
     self.show_num = lib.AsyncTk().forward("show_num_tickets")
     self.widgets = [TicketInfoFrame(self) for i in range(self.show_num)]
     self.bind("<KP_Enter>", self.advance)
Exemplo n.º 22
0
 def update(self):
     lib.AsyncTk().add_task(self.clock.update())
     self.network_status.update()
Exemplo n.º 23
0
 def total(self):
     return lib.AsyncTk().forward("get_total", self, self.addon1,
                                  self.addon2)
Exemplo n.º 24
0
 def destroy(self):
     lib.AsyncTk().remove(self.update_func)
     super().destroy()
Exemplo n.º 25
0
 def remove(self):
     type(self).lst.remove(self)
     EditorDelegate().remove_payment_option(self.payment_type)
     lib.AsyncTk().forward("stdout").info(f"Removed payment option '{self.payment_type}'")
     self.destroy()
Exemplo n.º 26
0
 def on_enter(self, event):
     lib.AsyncTk().forward("set_item_status", self.scroller.get(),
                           lib.TICKET_COMPLETE)