Exemplo n.º 1
0
 def update_distributionLst(self):
     self.distLst.delete(0, END)
     if self.profile.get() == 'All users':
         values = get_names(
             DistSet, system_id=self.system.get())
     else:
         user_id = get_id_from_index(self.profile.get(), self.profile_idx)
         values = get_names(
             DistSet, system_id=self.system.get(), user_id=user_id)
     for v in sorted(values):
         self.distLst.insert(END, v)
Exemplo n.º 2
0
 def update_gridLst(self):
     self.gridLst.delete(0, END)
     if self.distr_record:
         values = get_names(
             DistGrid, distset_id=self.distr_record.did)
         for v in sorted(values):
             self.gridLst.insert(END, v)
Exemplo n.º 3
0
 def display_mattypes(self):
     mlogger.debug('Displaying mattypes.')
     self.mattypeOutLst.delete(0, END)
     self.mattypeInLst.delete(0, END)
     mattypes = get_names(MatType)
     for mattype in sorted(mattypes):
         self.mattypeOutLst.insert(END, mattype)
Exemplo n.º 4
0
 def display_audiences(self):
     mlogger.debug('Displaying audiences.')
     self.audnOutLst.delete(0, END)
     self.audnInLst.delete(0, END)
     audns = get_names(Audn)
     for audn in sorted(audns):
         self.audnOutLst.insert(END, audn)
Exemplo n.º 5
0
 def display_library(self):
     mlogger.debug('Displaying library.')
     enable_widgets(self.libraryFrm.winfo_children())
     self.libOutLst.delete(0, END)
     self.libInLst.delete(0, END)
     libraries = get_names(Library)
     for library in libraries:
         self.libOutLst.insert(END, library)
Exemplo n.º 6
0
 def get_comboboxes_values(self):
     mlogger.info('SearchView getting comoboxes values')
     self.system_names = get_names(System)
     self.library_names = get_names(Library)
     self.lang_names = get_names(Lang)
     self.vendor_names = get_names(Vendor)
     self.audn_names = get_names(Audn)
     self.mattype_names = get_names(MatType)
     self.fund_codes = get_codes(Fund)
     self.profile_names = get_names(User)
Exemplo n.º 7
0
    def populate_detail_list(self, redo_detail_frame=True, *args):
        mlogger.debug('Populating detail list.')
        # destroy any detail frame that may display
        # previous data
        if redo_detail_frame:
            self.recreate_details_frame()
        else:
            mlogger.debug('Details frame preserved.')

        # detelet current detail list
        self.detLst.delete(0, END)

        # repopulate
        model, kwargs = self.get_corresponding_model()
        if model is not None:
            values = get_names(model, **kwargs)
            for v in values:
                self.detLst.insert(END, v)
Exemplo n.º 8
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        # use in prod
        w, h = self.winfo_screenwidth() - 600, self.winfo_screenheight() - 100
        self.geometry("%dx%d+0+0" % (w, h))

        # container where frames are stacked
        container = Frame(self)
        container.columnconfigure(1, minsize=150)
        container.grid(padx=10)
        # bind shared data between windows
        self.activeW = StringVar()
        self.profile = StringVar()
        self.profile.trace("w", self.profile_observer)
        self.system = IntVar()  # BPL 1, NYPL 2
        self.system.trace("w", self.system_observer)
        self.active_id = IntVar()

        img = Image.open("./icons/App-personal-icon.png")
        profileImg = ImageTk.PhotoImage(img)
        profile = Menubutton(container, image=profileImg)
        profile.grid(row=0, column=0, sticky="nw")
        profile.image = profileImg

        self.profileLbl = Label(container, textvariable=self.profile)
        self.profileLbl.grid(row=0, column=1, columnspan=3, sticky="snw")

        profile.menu = Menu(profile, tearoff=0)
        profile["menu"] = profile.menu

        # pull from datastore as tuple(did, name)
        users = get_names(User)
        users.insert(0, "All users")
        for name in users:
            profile.menu.add_radiobutton(label=name,
                                         variable=self.profile,
                                         value=name)

        systemLbl = Label(container, text="System:")
        systemLbl.grid(row=0, column=4, sticky="snw")

        bplBtn = Radiobutton(container,
                             text="BPL",
                             variable=self.system,
                             value=1)
        bplBtn.grid(row=0, column=5, sticky="snw")
        nypBtn = Radiobutton(container,
                             text="NYPL",
                             variable=self.system,
                             value=2)
        nypBtn.grid(row=0, column=6, sticky="snw")

        self.state = False
        self.bind("<F11>", self.toggle_fullscreen)
        self.bind("<Escape>", self.end_fullscreen)

        Separator(container, orient=HORIZONTAL).grid(row=1,
                                                     column=0,
                                                     columnspan=7,
                                                     sticky="snew")

        # set up menu bar
        menubar = Menu(self)
        navig_menu = Menu(menubar, tearoff=0)
        navig_menu.add_command(label="Home",
                               command=lambda: self.show_frame("HomeView"))
        navig_menu.add_command(label="Import",
                               command=lambda: self.show_frame("ImportView"))
        navig_menu.add_command(label="Carts",
                               command=lambda: self.show_frame("CartsView"))
        navig_menu.add_command(
            label="Reports", command=lambda: self.show_frame("ReportWizView"))
        navig_menu.add_command(label="Grids",
                               command=lambda: self.show_frame("GridView"))
        navig_menu.add_command(label="Funds",
                               command=lambda: self.show_frame("FundView"))
        navig_menu.add_command(label="Tables",
                               command=lambda: self.show_frame("TableView"))
        navig_menu.add_command(label="Settings",
                               command=lambda: self.show_frame("SettingsView"))

        navig_menu.add_separator()
        navig_menu.add_command(label="Exit", command=self.quit)
        menubar.add_cascade(label="Menu", menu=navig_menu)

        menubar.add_command(label="Search",
                            command=lambda: SearchView(self, **self.app_data))

        help_menu = Menu(menubar, tearoff=0)
        help_menu.add_command(label="Help index", command=self.open_help)
        help_menu.add_command(label="Updates", command=self.check_for_updates)
        help_menu.add_separator()
        help_menu.add_command(label="About", command=self.open_about)
        menubar.add_cascade(label="Help", menu=help_menu)

        self.config(menu=menubar)

        # profiles index for quick reference
        self.profile_idx = create_name_index(User)

        # profile & system
        user_data = shelve.open(USER_DATA)
        try:
            self.profile.set(user_data["profile"])
            self.system.set(user_data["system"])
        except KeyError:
            pass
        user_data.close()

        # create icons and share them among widgets
        img = Image.open("./icons/Action-edit-add-iconM.png")
        addImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-reload-iconM.png")
        editImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-cancel-iconM.png")
        deleteImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-ok-iconM.png")
        saveImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-ok-iconS.png")
        saveImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-button-info-iconM.png")
        helpImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-arrow-blue-double-down-iconM.png")
        copyImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-arrow-blue-double-down-iconS.png")
        copyImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-viewmag-iconM.png")
        viewImgM = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-viewmag-iconS.png")
        viewImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-floppy-iconM.png")
        marcImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-spreadsheet-iconM.png")
        sheetImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-proxy-iconM.png")
        linkImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-arrow-blue-left-iconS.png")
        previousImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-arrow-blue-right-iconS.png")
        nextImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-arrow-blue-double-left-iconS.png")
        startImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-arrow-blue-double-right-iconS.png")
        endImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-browser-iconM.png")
        sierraImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-cancel-iconS.png")
        deleteImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-reload-iconS.png")
        editImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/playstation-triangle-icon.png")
        notFoundImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/playstation-circle-icon.png")
        foundImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/playstation-cross-icon.png")
        notcheckedImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Letter-C-icon.png")
        babeldupImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-edit-add-iconS.png")
        addImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-remove-iconS.png")
        removeImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-web-iconM.png")
        validationImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-kgoldrunner-gold-iconM.png")
        fundImgM = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-viewmag-iconM.png")
        loadImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-ark-iconM.png")
        importImg = ImageTk.PhotoImage(img)
        img = Image.open("./icons/ChainLink-LINK-icon.png")
        linkImgS = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-calc-iconM.png")
        calcImgM = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-arrow-right-iconM.png")
        runImgM = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-build-iconM.png")
        downloadImgM = ImageTk.PhotoImage(img)
        img = Image.open("./icons/App-ksirtet-iconM.png")
        gridImgM = ImageTk.PhotoImage(img)
        img = Image.open("./icons/Action-run-iconM.png")
        customImgM = ImageTk.PhotoImage(img)

        self.app_data = {
            "activeW": self.activeW,
            "profile": self.profile,
            "profile_idx": self.profile_idx,
            "system": self.system,
            "active_id": self.active_id,
            "systemBtns": [bplBtn, nypBtn],
            "img": {
                "add": addImg,
                "addS": addImgS,
                "edit": editImg,
                "editS": editImgS,
                "delete": deleteImg,
                "deleteS": deleteImgS,
                "save": saveImg,
                "saveS": saveImgS,
                "help": helpImg,
                "copy": copyImg,
                "copyS": copyImgS,
                "view": viewImgM,
                "viewS": viewImgS,
                "marc": marcImg,
                "sheet": sheetImg,
                "link": linkImg,
                "linkS": linkImgS,
                "load": loadImg,
                "import": importImg,
                "previous": previousImg,
                "next": nextImg,
                "start": startImg,
                "end": endImg,
                "sierra": sierraImg,
                "notfound": notFoundImg,
                "found": foundImg,
                "notchecked": notcheckedImg,
                "babeldup": babeldupImg,
                "removeS": removeImgS,
                "valid": validationImg,
                "fundM": fundImgM,
                "calcM": calcImgM,
                "runM": runImgM,
                "downloadM": downloadImgM,
                "gridM": gridImgM,
                "customM": customImgM,
            },
        }

        # spawn Babel frames
        self.frames = {}
        for F in (
                FundView,
                GridView,
                HomeView,
                ReportWizView,
                TableView,
                ImportView,
                CartsView,
                CartView,
                SettingsView,
        ):
            page_name = F.__name__
            frame = F(parent=container, controller=self, **self.app_data)
            self.frames[page_name] = frame

            # put all windows in the same location
            frame.grid(row=1,
                       column=0,
                       columnspan=20,
                       sticky="snew",
                       padx=5,
                       pady=5)

        # lift to the top main window
        self.show_frame("HomeView")