Beispiel #1
0
    def __init__(
            self,
            master,
            items_cb,
            label_text="",
            add_cb=None,
            del_cb=None,
            edit_cb=None,
            raise_cb=None,
            lower_cb=None,
            #en_ckb=None,
            rem_sp=None,
            ep_cb=None,
            add_lbl="\u002b",
            del_lbl="\u2212",
            edit_lbl="\u270e",
            raise_lbl="\u2b06",
            lower_lbl="\u2b07",
            ep_lbl="Export PDF",
            extra_btns=None):
        super(ListScreen, self).__init__(master)
        self.master = master
        self.bgcolor = master.bgcolor
        self.configure(bg=self.bgcolor)
        self.items_cb = items_cb
        self.add_cb = add_cb
        self.del_cb = del_cb
        self.edit_cb = edit_cb
        self.raise_cb = raise_cb
        self.lower_cb = lower_cb
        self.rem_sp = rem_sp
        self.ep_cb = ep_cb
        self.sel_rem = 700
        self.extra_btns = []
        self.items = []

        btnwidth = 150
        if label_text:
            self.lbl = Label(self, text=label_text)
        self.upbtn = RectButton(self,
                                text="\u25b2",
                                state=DISABLED,
                                repeatdelay=500,
                                repeatinterval=100,
                                command=self.handle_button_up)
        self.lbox = Listbox(self,
                            width=40,
                            height=5,
                            fg="#000000",
                            bg="#ffffff")
        self.dnbtn = RectButton(self,
                                text="\u25bc",
                                state=DISABLED,
                                repeatdelay=500,
                                repeatinterval=100,
                                command=self.handle_button_dn)
        if self.add_cb:
            self.addbtn = RectButton(self,
                                     text=add_lbl,
                                     width=btnwidth,
                                     command=self.handle_button_add)
        if self.edit_cb:
            self.editbtn = RectButton(self,
                                      text=edit_lbl,
                                      width=btnwidth,
                                      command=self.handle_button_edit)
        if self.del_cb:
            self.delbtn = RectButton(self,
                                     text=del_lbl,
                                     width=btnwidth,
                                     command=self.handle_button_del)
        if self.raise_cb:
            self.raisebtn = RectButton(self,
                                       text=raise_lbl,
                                       width=btnwidth,
                                       command=self.handle_button_raise)
        if self.lower_cb:
            self.lowerbtn = RectButton(self,
                                       text=lower_lbl,
                                       width=btnwidth,
                                       command=self.handle_button_lower)
        if self.rem_sp:
            self.remainspin = TouchSpinner(
                self,
                width=150,
                value=self.sel_rem,
                minval=-50,
                maxval=5000,
                incdecval=50,
                format="Restinhalt: %d",
                changecmd=self.handle_remaining_change)
        if self.ep_cb:
            self.epbtn = RectButton(self,
                                    text=ep_lbl,
                                    width=btnwidth,
                                    command=self.handle_button_ep)

        if extra_btns:
            self.extra_btns = []
            for d in extra_btns:
                txt = d['name']
                cb = d['callback']
                btn = RectButton(
                    self,
                    text=txt,
                    width=btnwidth,
                    command=lambda x=cb: self.handle_button_extra(x))
                btn.en_cb = en
                self.extra_btns.append(btn)
        backbtn = RectButton(self,
                             text="\u23ce",
                             width=120,
                             command=self.handle_button_back)
        self.lbox.bind('<<ListboxSelect>>', self.listbox_select)

        if label_text:
            self.lbl.grid(column=1, row=1, columnspan=3, sticky=N + W)
        self.upbtn.grid(column=1, row=2, sticky=S + E + W)
        self.lbox.grid(column=1,
                       row=3,
                       rowspan=95,
                       padx=2,
                       pady=1,
                       sticky=N + S + E + W)
        self.dnbtn.grid(column=1, row=98, sticky=N + E + W)
        if self.add_cb:
            self.addbtn.grid(column=3, row=3, pady=5, sticky=N + W)
        if self.edit_cb:
            self.editbtn.grid(column=3, row=4, pady=5, sticky=N + W)
        if self.del_cb:
            self.delbtn.grid(column=3, row=5, pady=5, sticky=N + W)
        if self.raise_cb:
            self.raisebtn.grid(column=3, row=7, pady=5, sticky=N + W)
        if self.lower_cb:
            self.lowerbtn.grid(column=3, row=8, pady=5, sticky=N + W)
        if self.rem_sp:
            self.remainspin.grid(column=3, row=13, rowspan=3, padx=20, pady=10)
        if self.ep_cb:
            self.epbtn.grid(column=3, row=16, pady=5, sticky=N + W)

        for n, btn in enumerate(self.extra_btns):
            btn.grid(column=3, row=15 + n, pady=5, sticky=N + W)
        backbtn.grid(column=3, row=98, sticky=S + E)

        self.columnconfigure(0, minsize=10)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, minsize=10)
        self.columnconfigure(3, weight=1)
        self.columnconfigure(4, minsize=10)

        self.rowconfigure(0, minsize=10)
        self.rowconfigure(6, weight=1)
        self.rowconfigure(9, weight=1)
        self.rowconfigure(97, weight=1)
        self.rowconfigure(99, minsize=10)

        self.update_listbox()
Beispiel #2
0
    def __init__(self,
                 master,
                 items_cb,
                 label_text="",
                 add_cb=None,
                 del_cb=None,
                 edit_cb=None,
                 raise_cb=None,
                 lower_cb=None,
                 add_lbl="\u2795",
                 del_lbl="\u2796",
                 edit_lbl="\u270e",
                 raise_lbl="\u2b06",
                 lower_lbl="\u2b07",
                 extra_btns=None):
        super(ListScreen, self).__init__(master)
        self.master = master
        self.items_cb = items_cb
        self.add_cb = add_cb
        self.del_cb = del_cb
        self.edit_cb = edit_cb
        self.raise_cb = raise_cb
        self.lower_cb = lower_cb
        self.extra_btns = []
        self.items = []

        btnwidth = 150
        if label_text:
            self.lbl = Label(self, text=label_text)
        self.upbtn = RectButton(self,
                                text="\u25b2",
                                state=DISABLED,
                                repeatdelay=500,
                                repeatinterval=100,
                                command=self.handle_button_up)
        self.lbox = Listbox(self,
                            width=40,
                            height=5,
                            fg="#000000",
                            bg="#ffffff")
        self.dnbtn = RectButton(self,
                                text="\u25bc",
                                state=DISABLED,
                                repeatdelay=500,
                                repeatinterval=100,
                                command=self.handle_button_dn)
        if self.add_cb:
            self.addbtn = RectButton(self,
                                     text=add_lbl,
                                     width=btnwidth,
                                     command=self.handle_button_add)
        if self.edit_cb:
            self.editbtn = RectButton(self,
                                      text=edit_lbl,
                                      width=btnwidth,
                                      command=self.handle_button_edit)
        if self.del_cb:
            self.delbtn = RectButton(self,
                                     text=del_lbl,
                                     width=btnwidth,
                                     command=self.handle_button_del)
        if self.raise_cb:
            self.raisebtn = RectButton(self,
                                       text=raise_lbl,
                                       width=btnwidth,
                                       command=self.handle_button_raise)
        if self.lower_cb:
            self.lowerbtn = RectButton(self,
                                       text=lower_lbl,
                                       width=btnwidth,
                                       command=self.handle_button_lower)
        if extra_btns:
            self.extra_btns = []
            for d in extra_btns:
                txt = d['name']
                cb = d['callback']
                en = d.get('enable_cb', None)
                btn = RectButton(
                    self,
                    text=txt,
                    width=btnwidth,
                    command=lambda x=cb: self.handle_button_extra(x))
                btn.en_cb = en
                self.extra_btns.append(btn)
        backbtn = RectButton(self,
                             text="\u23ce",
                             width=120,
                             command=self.handle_button_back)
        self.lbox.bind('<<ListboxSelect>>', self.listbox_select)

        if label_text:
            self.lbl.grid(column=1, row=1, columnspan=3, sticky=N + W)
        self.upbtn.grid(column=1, row=2, sticky=S + E + W)
        self.lbox.grid(column=1,
                       row=3,
                       rowspan=95,
                       padx=2,
                       pady=1,
                       sticky=N + S + E + W)
        self.dnbtn.grid(column=1, row=98, sticky=N + E + W)
        if self.add_cb:
            self.addbtn.grid(column=3, row=3, pady=5, sticky=N + W)
        if self.edit_cb:
            self.editbtn.grid(column=3, row=4, pady=5, sticky=N + W)
        if self.del_cb:
            self.delbtn.grid(column=3, row=5, pady=5, sticky=N + W)
        if self.raise_cb:
            self.raisebtn.grid(column=3, row=7, pady=5, sticky=N + W)
        if self.lower_cb:
            self.lowerbtn.grid(column=3, row=8, pady=5, sticky=N + W)
        for n, btn in enumerate(self.extra_btns):
            btn.grid(column=3, row=10 + n, pady=5, sticky=N + W)
        backbtn.grid(column=3, row=98, sticky=S + E)

        self.columnconfigure(0, minsize=10)
        self.columnconfigure(1, weight=1)
        self.columnconfigure(2, minsize=10)
        self.columnconfigure(3, weight=1)
        self.columnconfigure(4, minsize=10)

        self.rowconfigure(0, minsize=10)
        self.rowconfigure(6, weight=1)
        self.rowconfigure(9, weight=1)
        self.rowconfigure(97, weight=1)
        self.rowconfigure(99, minsize=10)

        self.update_listbox()