diff options
-rwxr-xr-x | srb_tk.py | 32 |
1 files changed, 20 insertions, 12 deletions
@@ -214,31 +214,37 @@ class App(tk.Frame): self.frm_curprof.grid(row=4,column=0,rowspan=22,columnspan=2) # most form fields are inside the current profile self.img_money = get_srb_image("money.png",20,16) - self.lbl_money = tk.Label(self.frm_curprof,text="Money",image=self.img_money,compound="left") + self.lbl_money = tk.Label(self.frm_curprof,text="Money",image=self.img_money,compound="right") self.lbl_money.grid(row=0,column=0) self.ent_money = stk.Entry(self.frm_curprof,textvariable=self.money,func=self.load_form_into_data) #self.ent_money.bind("<Key-Return>",self.load_form_into_data) self.ent_money.grid(row=0,column=1) - self.lbl_equ_weapon = tk.Label(self.frm_curprof,text="Equipped weapon") + self.lbl_equ_weapon = tk.Label(self.frm_curprof,text="Equipped weapon",compound="right") self.lbl_equ_weapon.grid(row=1,column=0) # list of names equippable_weapons = [i["name"] for i in srb_lib.WEAPONS if i["e"]] + self.img_equ_weapon = get_srb_image("balloon-none.png",16,16) self.opt_equ_weapon = tk.OptionMenu(self.frm_curprof,self.equipped_weapon,*equippable_weapons) # the indicatoron,padx,pady and grid sticky are incredibly useful and hard to find in the docs - self.opt_equ_weapon.config(indicatoron=False,padx=1,pady=1,takefocus=1) + self.opt_equ_weapon.config(indicatoron=False,padx=1,pady=1,takefocus=1,compound="left") self.opt_equ_weapon.grid(row=1,column=1,sticky="ew") + ow = self.opt_equ_weapon.nametowidget(self.opt_equ_weapon.menuname) + self.img_weapons = [] + for i in equippable_weapons: + self.img_weapons.append(get_srb_image(i+".png",16,16)) + ow.entryconfigure(i,image=self.img_weapons[-1],compound="left") self.img_health = get_srb_image("health.png",16,16) - self.lbl_health = tk.Label(self.frm_curprof,text="Health",image=self.img_health,compound="left") + self.lbl_health = tk.Label(self.frm_curprof,text="Health",image=self.img_health,compound="right") self.lbl_health.grid(row=2,column=0) self.spn_health = stk.Spinbox(self.frm_curprof,from_=1,to=4,textvariable=self.health,width=2) self.spn_health.grid(row=2,column=1) self.img_stunt = get_srb_image("stunt.png",16,16) - self.lbl_stunt = tk.Label(self.frm_curprof,text="Stunt",image=self.img_stunt,compound="left") + self.lbl_stunt = tk.Label(self.frm_curprof,text="Stunt",image=self.img_stunt,compound="right") self.lbl_stunt.grid(row=3,column=0) self.spn_stunt = stk.Spinbox(self.frm_curprof,from_=1,to=4,textvariable=self.stunt,width=2) self.spn_stunt.grid(row=3,column=1) self.img_gun = get_srb_image("gun.png",19,16) - self.lbl_gun = tk.Label(self.frm_curprof,text="Gun",image=self.img_gun,compound="left") + self.lbl_gun = tk.Label(self.frm_curprof,text="Gun",image=self.img_gun,compound="right") self.lbl_gun.grid(row=4,column=0) self.spn_gun = stk.Spinbox(self.frm_curprof,from_=1,to=5,textvariable=self.gun,width=2) self.spn_gun.grid(row=4,column=1) @@ -557,7 +563,7 @@ class App(tk.Frame): self.health, self.stunt, self.gun, - self.equipped_weapon, + self.equipped_weapon #self.prof1name, # do not trace the profile names, because it prevents spaces ending on the variables #self.prof2name, #self.prof3name, @@ -609,16 +615,18 @@ class App(tk.Frame): if not self.bdata: return "No file loaded." profile_id = self.selected_profile.get() - #print(f"debug: Using profile_id {profile_id}") - #print(f"debug: arg1 {arg1}") - #print(f"debug: arg2 {arg2}") - #print(f"debug: arg3 {arg3}") if profile_id >= 1 and profile_id <= 3: self.mark_traces(False) # money self.money.set(srb_lib.get_money(self.bdata,profile_id)) # equipped weapon - self.equipped_weapon.set(srb_lib.get_weapon(self.bdata,profile_id)) + w, _ = srb_lib.get_weapon_info(srb_lib.get_weapon(self.bdata,profile_id)) + self.equipped_weapon.set(w["name"]) + self.img_equ_weapon = get_srb_image(w["name"]+".png",16,16) + # sets it on the label + #self.lbl_equ_weapon.config(image=self.img_equ_weapon) + # sets it on the item in the drop-down + self.opt_equ_weapon.config(image=self.img_equ_weapon) # plane stats stat, _ = srb_lib.get_plane_stat(self.bdata,profile_id,"health") self.health.set(stat) |