def populate(self, data): self._data = data if data == None: # null check self.set_defaults() return for k, v in data.items(): if k == "name": # non-null self._nameLabel.config(text=v) elif k == "img": if v == None: # null check v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=300) elif k == "location": # non-null self._locPreview.populate(v) elif k == "description": if v == None: # null check v = BaseView.EMPTY_STR utility.update_text(self._descText, v) elif k == "notes": if v == None: # null check v = BaseView.EMPTY_STR utility.update_text(self._notesText, v) elif k == "sells": self._update_inventory()
def populate(self, data): self._data = data if data == None: # null check self.set_defaults() return for k, v in data.items(): if k == "img": if v == None: # null check v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=300) elif k == "name": # non-null self._nameLabel.config(text=v) elif k == "description": if v == None: # null check v = "" utility.update_text(self._descText, v) elif k == "notes": if v == None: # null check v = "" utility.update_text(self._notesText, v) elif k == "stores": if v == None: # null check v = [] utility.update_combobox(self._storeCombo, [store["name"] for store in v]) elif k == "creatures": if v == None: # null check v = [] utility.update_combobox( self._inhabitantCombo, [creature["creature"]["name"] for creature in v])
def populate(self, data): for k, v in data.items(): if k == "name": # non-null self._nameLabel.config(text=v) elif k == "img": if v == None: # null check v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=30)
def set_defaults(self): utility.update_img(self._imgLabel, BaseView.DEFAULT_IMG, maxSize=300) utility.update_img(self._nameLabel, BaseView.RARITY_IMG[None], maxSize=30) utility.update_text(self._descText, BaseView.EMPTY_STR) utility.update_text(self._notesText, BaseView.EMPTY_STR) utility.update_combobox(self._equipCombo, []) utility.update_combobox(self._dropCombo, []) utility.update_combobox(self._attacksCombo, []) utility.update_combobox(self._inhabitsCombo, [])
def _create_widgets(self): self._imgLabel = Label(self) self._nameLabel = Label(self, text=SimpleItemView.NAME_FORMAT.format( "Name", BaseView.DEFAULT)) self._valueLabel = Label(self, compound=LEFT) utility.update_img(self._valueLabel, BaseView.VALUE_IMG, maxSize=30) self._imgLabel.grid(row=0, column=0, sticky=N + W + E + S) self._nameLabel.grid(row=0, column=1, sticky=W) if self._omniscient: self._valueLabel.grid(row=0, column=2, sticky=W)
def populate(self, data): self._data = data if data == None: # null check self.set_defaults() return for k, v in data.items(): if k == "name": # non-null self._nameLabel.config(text=v) elif k == "img": if v == None: # null check v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=300) elif k == "isSpell": # non-null utility.update_img(self._nameLabel, BaseView.WAND_IMG[v], maxSize=30) self._show_spell_fields(v) elif k == "description": if v == None: # null check v = BaseView.EMPTY_STR utility.update_text(self._descText, v) elif k == "notes": if v == None: # null check v = BaseView.EMPTY_STR utility.update_text(self._notesText, v) elif k == "dmg": if v == None: # null check v = BaseView.DEFAULT self._dmgLabel.config(text=AttackView.DMG.format(v)) elif k == "channel": if v == None: # null check v = BaseView.DEFAULT self._channelLabel.config(text=AttackView.CHANNEL.format(v)) elif k == "creatures": # non-null utility.update_combobox(self._creatureCombo, [creature["name"] for creature in v]) elif k == "weapons": # non-null utility.update_combobox(self._weaponCombo, [item["name"] for item in v]) elif k == "costs": # non-null utility.update_combobox(self._costCombo, [cost["item"]["name"] for cost in v])
def populate(self, data): self._data = data if data == None: self.set_defaults() return name = "" for k, v in data.items(): if k == "name": name = v elif k == "img": if v == None: v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize = 30) elif k == "isSpell": if v == None: v = False utility.update_img(self._spellLabel, BaseView.WAND_IMG[v], maxSize = 30) self._nameLabel.config(text = name)
def populate(self, data): self._data = data if data == None: self.set_defaults() return name = "" hd = BaseView.DEFAULT for k, v in data.items(): if k == "name": name = v elif k == "img": if v == None: v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=30) elif k == "hd": if v != None: hd = v self._nameLabel.config( text=SimpleCreatureView.NAME_FORMAT.format(name, hd))
def populate(self, data): self._data = data if data == None: self.set_defaults() return name = "" location = "" for k, v in data.items(): if k == "name": # non-null name = v elif k == "location": # non-null if isinstance(v, str): # from simple store location = v else: # from full store location = v["name"] elif k == "img": if v == None: # null check v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=30) self._nameLabel.config( text=SimpleStoreView.NAME_FORMAT.format(name, location))
def populate(self, data): self._data = data if data == None: self.set_defaults() return name = "" itemType = 0 for k, v in data.items(): if k == "name": name = v elif k == "img": if v == None: v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=30) elif k == "type": if v != None: itemType = v elif k == "value": if v == None: v = BaseView.DEFAULT self._valueLabel.config(text=v) self._nameLabel.config(text=SimpleItemView.NAME_FORMAT.format( name, BaseView.TYPE_MAP[itemType]))
def set_defaults(self): utility.update_img(self._imgLabel, BaseView.DEFAULT_IMG, maxSize=300) utility.update_text(self._descText, BaseView.EMPTY_STR) utility.update_text(self._notesText, BaseView.EMPTY_STR) utility.update_combobox(self._storeCombo, []) utility.update_combobox(self._inhabitantCombo, [])
def set_defaults(self): utility.update_img(self._imgLabel, BaseView.DEFAULT_IMG, maxSize=300) utility.update_text(self._descText, BaseView.EMPTY_STR) utility.update_text(self._notesText, BaseView.EMPTY_STR)
def set_defaults(self): utility.update_img(self._imgLabel, BaseView.DEFAULT_IMG, maxSize=30) self._nameLabel.config( text=SimpleItemView.NAME_FORMAT.format("Name", BaseView.DEFAULT)) self._valueLabel.config(text=BaseView.DEFAULT)
def populate(self, data): self._data = data if data == None: # null check self.set_defaults() return # forget conditional fields self._weaponFrame.grid_forget() self._armorFrame.grid_forget() self._consumableFrame.grid_forget() for k, v in data.items(): if k == "name": # non-null self._nameLabel.config(text=v) elif k == "img": if v == None: # null check v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=300) elif k == "rarity": # null accepted utility.update_img(self._nameLabel, BaseView.RARITY_IMG[v], maxSize=30) elif k == "description": if v == None: # null check v = BaseView.EMPTY_STR utility.update_text(self._descText, v) elif k == "notes": if v == None: # null check v = BaseView.EMPTY_STR utility.update_text(self._notesText, v) elif k == "type": # non-null if v == 1: self._consumableFrame.grid(row=6, column=0, columnspan=5, sticky=W + E) elif v == 2: self._armorFrame.grid(row=6, column=0, columnspan=5, sticky=W + E) elif v == 3: self._weaponFrame.grid(row=6, column=0, columnspan=5, sticky=W + E) elif k == "value": if v == None: # null check v = BaseView.DEFAULT self._valLabel.config(text=v) elif k == "ac": if v == None: # null check v = BaseView.DEFAULT self._acLabel.config(text=ItemView.AC.format(v)) elif k == "slot": if v == None: # null check v = BaseView.DEFAULT self._armorSlot.config(text=ItemView.SLOT.format(v)) self._weaponSlot.config(text=ItemView.SLOT.format(v)) elif k == "dmg": if v == None: # null check v = BaseView.DEFAULT self._weaponDmg.config(text=ItemView.DMG.format(v)) elif k == "crit": if v == None: # null check v = BaseView.DEFAULT self._weaponCrit.config(text=ItemView.CRIT.format(v)) elif k == "ammo": # null accepted self._weaponAmmoPreview.populate(v) elif k == "range": if v == None: # null check v = BaseView.DEFAULT self._weaponRange.config(text=ItemView.RANGE.format(v)) elif k == "effect": if v == None: # null check v = BaseView.EMPTY_STR utility.update_text(self._effectText, v) elif k == "equippedBy": # non-null utility.update_combobox( self._equipCombo, [creature["creature"]["name"] for creature in v]) elif k == "droppedBy": # non-null utility.update_combobox( self._dropCombo, [creature["creature"]["name"] for creature in v]) elif k == "ammoFor": # non-null utility.update_combobox(self._ammoCombo, [item["name"] for item in v]) elif k == "spellCost": # non-null utility.update_combobox( self._spellCombo, [spell["spell"]["name"] for spell in v]) elif k == "soldAt": # non-null utility.update_combobox(self._soldAtCombo, [ "{} ({})".format(store["store"]["name"], store["store"]["location"]) for store in v ]) elif k == "attacks": # non-null utility.update_combobox(self._weaponAttackCombo, [attack["name"] for attack in v])
def set_defaults(self): utility.update_img(self._imgLabel, BaseView.DEFAULT_IMG, maxSize = 30) utility.update_img(self._spellLabel, BaseView.WAND_IMG[False], maxSize = 30) self._nameLabel.config(text = "Name")
def _create_widgets(self): # left frame self._leftFrame = Frame(self) self._imgLabel = Label(self._leftFrame) self._creatureLabel = Label(self._leftFrame, text="Used by Creature", font=BaseView.NORMAL_FONT) self._creatureVar = StringVar(self) self._creatureCombo = Combobox(self._leftFrame, state="readonly", textvariable=self._creatureVar) self._creaturePreview = SimpleCreatureView(self._leftFrame) self._leftSep1 = Separator(self._leftFrame, orient="horizontal") self._weaponLabel = Label(self._leftFrame, text="Used by Weapon:", font=BaseView.NORMAL_FONT) self._weaponVar = StringVar(self) self._weaponCombo = Combobox(self._leftFrame, state="readonly", textvariable=self._weaponVar) self._weaponPreview = SimpleItemView(self._leftFrame) # right frame self._rightFrame = Frame(self) self._nameLabel = Label(self._rightFrame, compound=LEFT, text="Name", font=BaseView.LARGE_FONT) utility.update_img(self._nameLabel, BaseView.WAND_IMG[False], maxSize=30) self._rightSep1 = Separator(self._rightFrame, orient="vertical") self._channelLabel = Label(self._rightFrame, text=AttackView.CHANNEL.format( BaseView.DEFAULT), font=BaseView.BOLD_FONT) self._descLabel = Label(self._rightFrame, text="Description:", font=BaseView.NORMAL_FONT) self._descFrame = Frame(self._rightFrame) self._descText = Text(self._descFrame, width=50, height=4, state=DISABLED, wrap=WORD, font=BaseView.NORMAL_FONT) self._descScroll = Scrollbar(self._descFrame, command=self._descText.yview) self._descText.config(yscrollcommand=self._descScroll.set) self._notesLabel = Label(self._rightFrame, text="Notes:", font=BaseView.NORMAL_FONT) self._notesFrame = Frame(self._rightFrame) self._notesText = Text(self._notesFrame, width=50, height=4, state=DISABLED, wrap=WORD, font=BaseView.NORMAL_FONT) self._notesScroll = Scrollbar(self._notesFrame, command=self._notesText.yview) self._notesText.config(yscrollcommand=self._notesScroll.set) self._dmgLabel = Label(self._rightFrame, text=AttackView.DMG.format(BaseView.DEFAULT), font=BaseView.BOLD_FONT) self._rightSep2 = Separator(self._rightFrame, orient="horizontal") self._costLabel = Label(self._rightFrame, text="Casting Cost:", font=BaseView.NORMAL_FONT) self._costVar = StringVar(self) self._costCombo = Combobox(self._rightFrame, state="readonly", textvariable=self._costVar) self._costPreview = SimpleItemView(self._rightFrame) self._costQtyLabel = Label(self._rightFrame, text=AttackView.QTY.format( BaseView.DEFAULT), font=BaseView.NORMAL_FONT) # placement: scrollbars self._descText.grid(row=0, column=0, sticky=N + W + E + S) self._descScroll.grid(row=0, column=1, sticky=N + S) self._notesText.grid(row=0, column=0, sticky=N + W + E + S) self._notesScroll.grid(row=0, column=1, sticky=N + S) # placement: left frame self._imgLabel.grid(row=0, column=0, columnspan=2, sticky=N + W + E + S) self._creatureLabel.grid(row=1, column=0, sticky=N + W) self._creatureCombo.grid(row=1, column=1, sticky=E) self._creaturePreview.grid(row=2, column=0, columnspan=2, sticky=W + E) self._weaponLabel.grid(row=3, column=0, sticky=N + W) self._weaponCombo.grid(row=3, column=1, sticky=E) self._weaponPreview.grid(row=4, column=0, columnspan=2, sticky=W + E) # placement: right frame self._nameLabel.grid(row=0, column=0, sticky=W) self._descLabel.grid(row=1, column=0, columnspan=3, sticky=W) self._descFrame.grid(row=2, column=0, columnspan=3, sticky=W) self._notesLabel.grid(row=3, column=0, columnspan=3, sticky=W) self._notesFrame.grid(row=4, column=0, columnspan=3, sticky=W) self._dmgLabel.grid(row=5, column=0, columnspan=3, sticky=N + W) self._show_spell_fields(False) self._leftFrame.grid(row=0, column=0, sticky=N + W) self._rightFrame.grid(row=0, column=1, sticky=N + W)
def _create_widgets(self): # left frame self._leftFrame = Frame(self) self._imgLabel = Label(self._leftFrame) self._equipLabel = Label(self._leftFrame, text="Equipped by", font=BaseView.NORMAL_FONT) self._equipVar = StringVar(self) self._equipCombo = Combobox(self._leftFrame, state="readonly", textvariable=self._equipVar) self._equipPreview = SimpleCreatureView(self._leftFrame) self._equipChance = Label(self._leftFrame, text=ItemView.EQUIP_CHANCE.format( BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._equipNotesLabel = Label(self._leftFrame, text="Notes:", font=BaseView.NORMAL_FONT) self._equipNotesFrame = Frame(self._leftFrame) self._equipNotes = Text(self._equipNotesFrame, width=30, height=2, state=DISABLED, wrap=WORD, font=BaseView.NORMAL_FONT) self._equipNotesScroll = Scrollbar(self._equipNotesFrame, command=self._equipNotes.yview) self._equipNotes.config(yscrollcommand=self._equipNotesScroll.set) self._leftSep1 = Separator(self._leftFrame, orient="horizontal") self._dropLabel = Label(self._leftFrame, text="Dropped by:", font=BaseView.NORMAL_FONT) self._dropVar = StringVar(self) self._dropCombo = Combobox(self._leftFrame, state="readonly", textvariable=self._dropVar) self._dropPreview = SimpleCreatureView(self._leftFrame) self._dropChance = Label(self._leftFrame, text=ItemView.DROP_CHANCE.format( BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._dropNotesFrame = Frame(self._leftFrame) self._dropNotesLabel = Label(self._leftFrame, text="Notes:", font=BaseView.NORMAL_FONT) self._dropNotes = Text(self._dropNotesFrame, width=30, height=2, state=DISABLED, wrap=WORD, font=BaseView.NORMAL_FONT) self._dropNotesScroll = Scrollbar(self._dropNotesFrame, command=self._dropNotes.yview) self._dropNotes.config(yscrollcommand=self._dropNotesScroll.set) self._leftSep2 = Separator(self._leftFrame, orient="horizontal") self._ammoLabel = Label(self._leftFrame, text="Ammo for:", font=BaseView.NORMAL_FONT) self._ammoVar = StringVar(self) self._ammoCombo = Combobox(self._leftFrame, state="readonly", textvariable=self._ammoVar) self._ammoPreview = SimpleItemView(self._leftFrame) # right frame self._rightFrame = Frame(self) self._nameLabel = Label(self._rightFrame, compound=LEFT, text="Name", font=BaseView.LARGE_FONT) self._rightSep1 = Separator(self._rightFrame, orient="vertical") self._valLabel = Label(self._rightFrame, compound=LEFT, text=BaseView.DEFAULT, font=BaseView.BOLD_FONT) utility.update_img(self._valLabel, BaseView.VALUE_IMG, maxSize=30) self._descLabel = Label(self._rightFrame, text="Description:", font=BaseView.NORMAL_FONT) self._descFrame = Frame(self._rightFrame) self._descText = Text(self._descFrame, width=50, height=4, state=DISABLED, wrap=WORD, font=BaseView.NORMAL_FONT) self._descScroll = Scrollbar(self._descFrame, command=self._descText.yview) self._descText.config(yscrollcommand=self._descScroll.set) self._notesLabel = Label(self._rightFrame, text="Notes:", font=BaseView.NORMAL_FONT) self._notesFrame = Frame(self._rightFrame) self._notesText = Text(self._notesFrame, width=50, height=4, state=DISABLED, wrap=WORD, font=BaseView.NORMAL_FONT) self._notesScroll = Scrollbar(self._notesFrame, command=self._notesText.yview) self._notesText.config(yscrollcommand=self._notesScroll.set) self._rightSep2 = Separator(self._rightFrame, orient="horizontal") self._soldAtLabel = Label(self._rightFrame, text="Sold at:", font=BaseView.NORMAL_FONT) self._soldAtVar = StringVar(self) self._soldAtCombo = Combobox(self._rightFrame, state="readonly", textvariable=self._soldAtVar) self._soldAtPreview = SimpleStoreView(self._rightFrame) self._soldAtPrice = Label(self._rightFrame, text=ItemView.PRICE.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._rightSep3 = Separator(self._rightFrame, orient="vertical") self._soldAtQty = Label(self._rightFrame, text=ItemView.QTY.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._rightSep4 = Separator(self._rightFrame, orient="vertical") self._stockDays = Label(self._rightFrame, text=ItemView.STOCK_DAYS.format( BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._rightSep5 = Separator(self._rightFrame, orient="horizontal") self._spellLabel = Label(self._rightFrame, text="Used in Spell:") self._spellVar = StringVar(self) self._spellCombo = Combobox(self._rightFrame, state="readonly", textvariable=self._spellVar) self._spellPreview = SimpleAttackView(self._rightFrame) self._spellQty = Label(self._rightFrame, text=ItemView.QTY.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) # weapon frame self._weaponFrame = Frame(self._rightFrame) self._weaponSlot = Label(self._weaponFrame, text=ItemView.SLOT.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._weaponRange = Label(self._weaponFrame, text=ItemView.RANGE.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._weaponAmmoLabel = Label(self._weaponFrame, text="Ammo:", font=BaseView.NORMAL_FONT) self._weaponAmmoPreview = SimpleItemView(self._weaponFrame) self._weaponSep1 = Separator(self._weaponFrame, orient="vertical") self._weaponDmg = Label(self._weaponFrame, text=ItemView.DMG.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._weaponCrit = Label(self._weaponFrame, text=ItemView.CRIT.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._weaponAttackLabel = Label(self._weaponFrame, text="Attacks:", font=BaseView.NORMAL_FONT) self._weaponAttackVar = StringVar(self) self._weaponAttackCombo = Combobox(self._weaponFrame, state="readonly", textvariable=self._weaponAttackVar) self._weaponAttackPreview = SimpleAttackView(self._weaponFrame) self._weaponSep2 = Separator(self._weaponFrame, orient="horizontal") # armor frame self._armorFrame = Frame(self._rightFrame) self._acLabel = Label(self._armorFrame, text=ItemView.AC.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._armorSep1 = Separator(self._armorFrame, orient="vertical") self._armorSlot = Label(self._armorFrame, text=ItemView.SLOT.format(BaseView.DEFAULT), font=BaseView.NORMAL_FONT) self._armorSep2 = Separator(self._armorFrame, orient="horizontal") # consumable frame self._consumableFrame = Frame(self._rightFrame) self._effectLabel = Label(self._consumableFrame, text="Effect:", font=BaseView.NORMAL_FONT) self._effectText = Text(self._consumableFrame, width=50, height=3, state=DISABLED, wrap=WORD, font=BaseView.NORMAL_FONT) self._effectScroll = Scrollbar(self._consumableFrame, command=self._effectText.yview) self._effectText.config(yscrollcommand=self._effectScroll.set) self._consumableSep1 = Separator(self._consumableFrame, orient="horizontal") # placement: scrollbars self._equipNotes.grid(row=0, column=0, sticky=N + W + E + S) self._equipNotesScroll.grid(row=0, column=1, sticky=N + S) self._dropNotes.grid(row=0, column=0, sticky=N + W + E + S) self._dropNotesScroll.grid(row=0, column=1, sticky=N + S) self._descText.grid(row=0, column=0, sticky=N + W + E + S) self._descScroll.grid(row=0, column=1, sticky=N + S) self._notesText.grid(row=0, column=0, sticky=N + W + E + S) self._notesScroll.grid(row=0, column=1, sticky=N + S) # placement: weapon frame self._weaponSlot.grid(row=0, column=0, sticky=N + W) self._weaponRange.grid(row=1, column=0, sticky=N + W) self._weaponAmmoLabel.grid(row=2, column=0, sticky=N + W) self._weaponAmmoPreview.grid(row=3, column=0, sticky=W + E) self._weaponDmg.grid(row=0, column=2, columnspan=2, sticky=N + W) self._weaponCrit.grid(row=1, column=2, columnspan=2, sticky=N + W) self._weaponAttackLabel.grid(row=2, column=2, sticky=N + W) self._weaponAttackCombo.grid(row=2, column=3, sticky=E) self._weaponAttackPreview.grid(row=3, column=2, columnspan=2, sticky=W + E) self._weaponSep1.grid(row=0, column=1, rowspan=4, sticky=N + S) self._weaponSep2.grid(row=4, column=0, columnspan=4, sticky=W + E) # placement: armor frame self._acLabel.grid(row=0, column=0, sticky=N + W) self._armorSep1.grid(row=0, column=1, sticky=N + E + S) self._armorSlot.grid(row=0, column=2, sticky=E) self._armorSep2.grid(row=1, column=0, columnspan=3, sticky=W + E) # placement: consumable frame self._effectLabel.grid(row=0, column=0, columnspan=2, sticky=N + W) self._effectText.grid(row=1, column=0, sticky=N + W + E + S) self._effectScroll.grid(row=1, column=1, sticky=N + S) self._consumableSep1.grid(row=2, column=0, columnspan=2, sticky=W + E) # placement: left frame self._imgLabel.grid(row=0, column=0, columnspan=2, sticky=N + W + E + S) self._equipLabel.grid(row=1, column=0, sticky=N + W) self._equipCombo.grid(row=1, column=1, sticky=E) self._equipPreview.grid(row=2, column=0, columnspan=2, sticky=W + E) self._equipChance.grid(row=3, column=0, columnspan=2, sticky=N + W) self._equipNotesLabel.grid(row=4, column=0, columnspan=2, sticky=N + W) self._equipNotesFrame.grid(row=5, column=0, columnspan=2, sticky=N + W + E) self._leftSep1.grid(row=6, column=0, columnspan=2, sticky=W + E) self._dropLabel.grid(row=7, column=0, sticky=N + W) self._dropCombo.grid(row=7, column=1, sticky=E) self._dropPreview.grid(row=8, column=0, columnspan=2, sticky=W + E) self._dropChance.grid(row=9, column=0, columnspan=2, sticky=N + W) self._dropNotesLabel.grid(row=10, column=0, columnspan=2, sticky=N + W) self._dropNotesFrame.grid(row=11, column=0, columnspan=2, sticky=N + W + E) self._leftSep2.grid(row=12, column=0, columnspan=2, sticky=W + E) self._ammoLabel.grid(row=13, column=0, sticky=N + W) self._ammoCombo.grid(row=13, column=1, sticky=E) self._ammoPreview.grid(row=14, column=0, columnspan=2, sticky=W + E) # placement: right frame self._nameLabel.grid(row=0, column=0, columnspan=3, sticky=W) self._rightSep1.grid(row=0, column=3, sticky=N + E + S) self._valLabel.grid(row=0, column=4, sticky=E) self._descLabel.grid(row=1, column=0, columnspan=5, sticky=W) self._descFrame.grid(row=2, column=0, columnspan=5, sticky=W) self._notesLabel.grid(row=3, column=0, columnspan=5, sticky=W) self._notesFrame.grid(row=4, column=0, columnspan=5, sticky=W) self._rightSep2.grid(row=5, column=0, columnspan=5, sticky=W + E) # empty row for special frames self._soldAtLabel.grid(row=7, column=0, columnspan=2, sticky=N + W) self._soldAtCombo.grid(row=7, column=2, columnspan=3, sticky=E) self._soldAtPreview.grid(row=8, column=0, columnspan=5, sticky=W + E) self._soldAtPrice.grid(row=9, column=0, sticky=N + W) self._rightSep3.grid(row=9, column=1, sticky=N + E + S) self._soldAtQty.grid(row=9, column=2, sticky=N + W) self._rightSep4.grid(row=9, column=3, sticky=N + E + S) self._stockDays.grid(row=9, column=4, sticky=N + E) self._rightSep5.grid(row=10, column=0, columnspan=5, sticky=W + E) self._spellLabel.grid(row=11, column=0, columnspan=2, sticky=N + W) self._spellCombo.grid(row=11, column=2, columnspan=3, sticky=E) self._spellPreview.grid(row=12, column=0, columnspan=5, sticky=W + E) self._spellQty.grid(row=13, column=0, columnspan=5, sticky=N + W) self._leftFrame.grid(row=0, column=0, sticky=N + W) self._rightFrame.grid(row=0, column=1, sticky=N + W)
def populate(self, data): self._data = data if data == None: # null check self.set_defaults() return for k, v in data.items(): if k == "img": if v == None: # null check v = BaseView.DEFAULT_IMG utility.update_img(self._imgLabel, v, maxSize=300) elif k == "rarity": # null accepted utility.update_img(self._nameLabel, BaseView.RARITY_IMG[v], maxSize=30) elif k == "name": # non-null self._nameLabel.config(text=v) elif k == "description": if v == None: # null check v = "" utility.update_text(self._descText, v) elif k == "notes": if v == None: # null check v = "" utility.update_text(self._notesText, v) elif k == "hd": if v == None: # null check v = BaseView.DEFAULT self._hdLabel.config(text=CreatureView.HD_FMT.format(v)) elif k == "hp": if v == None: # null check v = BaseView.DEFAULT self._hpLabel.config(text=CreatureView.HP_FMT.format(v)) elif k == "ac": if v == None: # null check v = BaseView.DEFAULT self._acLabel.config(text=CreatureView.AC_FMT.format(v)) elif k == "xp": if v == None: # null check v = BaseView.DEFAULT self._xpLabel.config(text=CreatureView.XP_FMT.format(v)) elif k == "basicAttack": if v == None: # null check v = BaseView.DEFAULT self._basicAttack.config( text=CreatureView.BASIC_ATTACK.format(v)) elif k == "equips": if v == None: # null check v = [] utility.update_combobox(self._equipCombo, [equip["item"]["name"] for equip in v]) elif k == "drops": if v == None: # null check v = [] utility.update_combobox(self._dropCombo, [drop["item"]["name"] for drop in v]) elif k == "attacks": if v == None: # null check v = [] utility.update_combobox(self._attacksCombo, [attack["name"] for attack in v]) elif k == "inhabits": if v == None: # null check v = [] utility.update_combobox(self._inhabitsCombo, [loc["location"]["name"] for loc in v])