def refreshSubtypes(self): self.subtypeAutoComp.grid_forget() self.subtypeAutoComp = Combobox_Autocomplete( self.EFValues, dao.getSubtypes(), highlightthickness=1 ) self.subtypeAutoComp.grid(row=8, column=1, sticky="w", pady=5) self.subtypeAutoComp.bind("<FocusIn>", self.addEditedVal)
def createSideBar(self): # todo get from backend self.choices = xmlParser.selection self.buttons = Frame(self.window) self.buttons.grid(row=0, column=2, sticky="n") filter = LabelFrame(self.buttons, text="Filter") filter.grid(row=1, column=0, pady=5) Label(filter, text="Type").grid(row=1, column=0, sticky="w") Label(filter, text="Subtype").grid(row=2, column=0, sticky="w") self.typeSel = StringVar(window) self.typeSel.set("gun") OptionMenu(filter, self.typeSel, *self.choices).grid( row=1, column=1, sticky="w", padx=5 ) self.subtypeSel = Combobox_Autocomplete( filter, dao.getSubtypes(), highlightthickness=1, width=15 ) self.subtypeSel.grid(row=2, column=1, sticky="w", pady=5, padx=5) buttons = Frame(filter) buttons.grid(row=4, columnspan=2) Button(buttons, text="Filter", width=12, command=self.viewCategroy).grid(pady=5) Button( self.buttons, text="view linked items", width=12, command=self.viewLinked ).grid(row=3) Button( self.buttons, text="search by name", width=12, command=self.searchByName ).grid(row=4)
def checkForDatabase(self): try: dao.getNominalByType("weapon") self.connectionOK = True except Exception: self.window.withdraw() self.openConnectionWindow() self.window.deiconify() try: dao.getSubtypes() except Exception: windows.showUpgradeError(self.window) if windows.askUser("Upgrade", "Do you want to upgrade your Database?"): self.upgradeDB()
def createEntryBar(self): self.entryFrame = Frame(self.window) self.entryFrame.grid(row=0, column=0, sticky="nw") self.EFValues = Frame(self.entryFrame) self.EFValues.grid(padx=8, pady=6) Label(self.EFValues, text="name").grid(row=0, column=0, sticky="w", pady=5) Label(self.EFValues, text="nominal").grid(row=1, column=0, sticky="w", pady=5) Label(self.EFValues, text="min").grid(row=2, column=0, sticky="w", pady=5) Label(self.EFValues, text="restock").grid(row=3, column=0, sticky="w", pady=5) Label(self.EFValues, text="lifetime").grid(row=4, column=0, sticky="w", pady=5) Label(self.EFValues, text="Usages").grid(row=5, column=0, sticky="w", pady=5) Label(self.EFValues, text="Tiers").grid(row=6, column=0, sticky="w", pady=5) Label(self.EFValues, text="Type").grid(row=7, column=0, sticky="w", pady=5) Label(self.EFValues, text="Subtype").grid(row=8, column=0, sticky="w", pady=5) Label(self.EFValues, text="rarity").grid(row=9, column=0, sticky="w", pady=5) Label(self.EFValues, text="mod").grid(row=10, column=0, sticky="w", pady=5) Label(self.EFValues, text="trader").grid(row=11, column=0, sticky="w", pady=5) self.name_text = StringVar() self.nameEntry = Entry(self.EFValues, textvariable=self.name_text) self.nameEntry.grid(row=0, column=1, sticky="w") self.nominal_text = StringVar() self.nominalEntry = Entry( self.EFValues, textvariable=self.nominal_text, width=8 ) self.nominalEntry.grid(row=1, column=1, sticky="w") self.nominalEntry.bind("<FocusIn>", self.addEditedVal) self.nominalEntry.val = self.nominal_text self.min_text = StringVar() self.minEntry = Entry(self.EFValues, textvariable=self.min_text, width=8) self.minEntry.grid(row=2, column=1, sticky="w") self.minEntry.bind("<FocusIn>", self.addEditedVal) self.minEntry.val = self.min_text self.restock_text = StringVar() self.restockEntry = Entry( self.EFValues, textvariable=self.restock_text, width=8 ) self.restockEntry.grid(row=3, column=1, sticky="w") self.restockEntry.bind("<FocusIn>", self.addEditedVal) self.restockEntry.val = self.min_text self.lifetime_text = StringVar() self.lifetimeEntry = Entry( self.EFValues, textvariable=self.lifetime_text, width=8 ) self.lifetimeEntry.grid(row=4, column=1, sticky="w") self.lifetimeEntry.bind("<FocusIn>", self.addEditedVal) self.lifetimeEntry.val = self.lifetime_text self.usageListBox = Listbox( self.EFValues, height=len(categories.usages), selectmode="multiple", exportselection=False, ) self.usageListBox.grid(row=5, column=1, pady=5, sticky="w") self.usageListBox.bind("<FocusIn>", self.addEditedVal) self.tierListBox = Listbox( self.EFValues, height=4, selectmode="multiple", exportselection=False ) self.tierListBox.grid(row=6, column=1, pady=5, sticky="w") self.tierListBox.bind("<FocusIn>", self.addEditedVal) windows.updateListBox(self.usageListBox, categories.usages) windows.updateListBox(self.tierListBox, categories.tiers) self.typeEntrySel = StringVar() self.typeEntrySel.set("") self.typeEntrySel.trace("w", self.typeSelChange) self.typeOption = OptionMenu( self.EFValues, self.typeEntrySel, *xmlParser.selection[:-1] ) self.typeOption.grid(row=7, column=1, sticky="w", pady=5) self.subtypeAutoComp = Combobox_Autocomplete( self.EFValues, dao.getSubtypes(), highlightthickness=1 ) self.subtypeAutoComp.grid(row=8, column=1, sticky="w", pady=5) self.subtypeAutoComp.bind("<FocusIn>", self.addEditedVal) self.raritySel = StringVar() self.raritySel.set("undefined") self.rarityTrace = self.raritySel.trace("w", self.raritySelChange) self.rarityOption = OptionMenu( self.EFValues, self.raritySel, *rarities9.values() ) self.rarityOption.grid(row=9, column=1, sticky="w", pady=5) self.mod_text = StringVar() self.modEntry = Entry(self.EFValues, textvariable=self.mod_text, width=14) self.modEntry.grid(row=10, column=1, sticky="w", pady=5) self.modEntry.bind("<ButtonRelease-1>", self.addEditedVal) self.modEntry.val = self.mod_text self.EFCheckboxe = Frame(self.entryFrame) self.EFCheckboxe.grid(row=1, column=0, columnspan=2, sticky="w") ######################################################### self.trader_text = StringVar() self.traderEntry = Entry(self.EFValues, textvariable=self.trader_text) self.traderEntry.grid(row=11, column=1, sticky="w") self.traderEntry.bind("<FocusIn>", self.addEditedVal) self.traderEntry.val = self.trader_text self.EFCheckboxe = Frame(self.entryFrame) self.EFCheckboxe.grid(row=1, column=0, columnspan=2, sticky="w") ########################################################## self.deLoot = IntVar() self.deLootOption = Checkbutton( self.EFCheckboxe, text="Dynamic Event", variable=self.deLoot ) self.deLootOption.grid(row=0, column=0, sticky="w") self.deLootOption.bind( "<Button-1>", lambda e: self.addEditedVal(self.deLootOption.focus_set()) ) self.deLootOption.val = self.deLoot self.cargo = IntVar() self.cargoOption = Checkbutton( self.EFCheckboxe, text="Count in Cargo", variable=self.cargo ) self.cargoOption.grid(row=1, column=0, sticky="w") self.cargoOption.bind( "<Button-1>", lambda e: self.addEditedVal(self.cargoOption.focus_set()) ) self.cargoOption.val = self.cargo self.hoarder = IntVar() self.hoarderOption = Checkbutton( self.EFCheckboxe, text="Count in Hoarder", variable=self.hoarder ) self.hoarderOption.grid(row=2, column=0, sticky="w") self.hoarderOption.bind( "<Button-1>", lambda e: self.addEditedVal(self.hoarderOption.focus_set()) ) self.hoarderOption.val = self.hoarder self.map = IntVar() self.mapOption = Checkbutton( self.EFCheckboxe, text="Count in Map", variable=self.map ) self.mapOption.grid(row=3, column=0, sticky="w") self.mapOption.bind( "<Button-1>", lambda e: self.addEditedVal(self.mapOption.focus_set()) ) self.mapOption.val = self.map self.player = IntVar() self.playerOption = Checkbutton( self.EFCheckboxe, text="Count in Player", variable=self.player ) self.playerOption.grid(row=4, column=0, sticky="w") self.playerOption.bind( "<Button-1>", lambda e: self.addEditedVal(self.playerOption.focus_set()) ) self.playerOption.val = self.player Button(self.entryFrame, text="Update", width=12, command=self.updateSel).grid( row=3, column=0, pady=9 ) Button(self.entryFrame, text="Delete", width=12, command=self.deleteSel).grid( row=4, column=0, pady=5 )