aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Stack <bgstack15@gmail.com>2024-04-02 21:31:28 -0400
committerB. Stack <bgstack15@gmail.com>2024-04-02 21:31:28 -0400
commit90ae52e2f0668ebe646ee81a5e626f0253fd7051 (patch)
treec02cbbf6aa8f51aac6671eb18d9c5320335edbb5
parenttk: add levelsets (diff)
downloadsrb_lib-90ae52e2f0668ebe646ee81a5e626f0253fd7051.tar.gz
srb_lib-90ae52e2f0668ebe646ee81a5e626f0253fd7051.tar.bz2
srb_lib-90ae52e2f0668ebe646ee81a5e626f0253fd7051.zip
tk: add level names only, and minor improvements to grid spacing
-rwxr-xr-xsrb_tk.py51
1 files changed, 36 insertions, 15 deletions
diff --git a/srb_tk.py b/srb_tk.py
index aedee55..fc86e70 100755
--- a/srb_tk.py
+++ b/srb_tk.py
@@ -26,6 +26,8 @@
# Dependencies:
# dep-devuan: python3-tkinter, python3-pil.imagetk
# rec-devuan: python3-cairosvg
+# Documentation:
+# spinbox appears to way too wide by default, even without a .grid(sticky="EW"). Try defining on the spinbox object at instantiation width=3
import tkinter as tk
from pathlib import Path
import tkinter.filedialog, srb_lib, os, time
@@ -135,6 +137,7 @@ class App(tk.Frame):
self.chk_silent = tk.Checkbutton(self.master,text="silent",variable=self.silent)
self.chk_silent.grid(row=2,column=1)
self.frm_profiles = tk.Frame(self.master) #,borderwidth=1,background="green")
+ # WORKHERE: firm up column/placement of things so there is less whitespace.
self.frm_profiles.grid(row=3,column=0,columnspan=2)
# investigate radio button key-bind, up-down, to increment/decrement choice?
self.rad_prof1 = stk.Radiobutton(self.frm_profiles,value=1,text="Profile 1",variable=self.selected_profile,underline=8)
@@ -144,7 +147,7 @@ class App(tk.Frame):
self.chk_prof1_tut = stk.Checkbutton(self.frm_profiles,text="tutorial",variable=self.prof1tut,func=self.load_form_into_data)
#self.hook_checkbox_enter_keys(self.chk_prof1_tut,self.load_form_into_data)
self.chk_prof1_tut.grid(row=0,column=3)
- self.ent_prof1name = stk.Entry(self.frm_profiles,textvariable=self.prof1name,func=self.load_form_into_data)
+ self.ent_prof1name = stk.Entry(self.frm_profiles,textvariable=self.prof1name,func=self.load_form_into_data,width=11)
self.ent_prof1name.bind("<Key-Return>",self.load_form_into_data)
self.ent_prof1name.bind("<Key-KP_Enter>",self.load_form_into_data)
self.ent_prof1name.grid(row=0,column=4)
@@ -156,7 +159,7 @@ class App(tk.Frame):
self.chk_prof2_tut = stk.Checkbutton(self.frm_profiles,text="tutorial",variable=self.prof2tut,func=self.load_form_into_data)
#self.hook_checkbox_enter_keys(self.chk_prof2_tut,self.load_form_into_data)
self.chk_prof2_tut.grid(row=1,column=3)
- self.ent_prof2name = stk.Entry(self.frm_profiles,textvariable=self.prof2name,func=self.load_form_into_data)
+ self.ent_prof2name = stk.Entry(self.frm_profiles,textvariable=self.prof2name,func=self.load_form_into_data,width=11)
self.ent_prof2name.bind("<Key-Return>",self.load_form_into_data)
self.ent_prof2name.grid(row=1,column=4)
self.rad_prof3 = stk.Radiobutton(self.frm_profiles,value=3,text="Profile 3",variable=self.selected_profile,underline=8)
@@ -167,14 +170,14 @@ class App(tk.Frame):
self.chk_prof3_tut = stk.Checkbutton(self.frm_profiles,text="tutorial",variable=self.prof3tut,func=self.load_form_into_data)
#self.hook_checkbox_enter_keys(self.chk_prof3_tut,self.load_form_into_data)
self.chk_prof3_tut.grid(row=2,column=3)
- self.ent_prof3name = stk.Entry(self.frm_profiles,textvariable=self.prof3name,func=self.load_form_into_data)
+ self.ent_prof3name = stk.Entry(self.frm_profiles,textvariable=self.prof3name,func=self.load_form_into_data,width=11)
self.ent_prof3name.bind("<Key-Return>",self.load_form_into_data)
self.ent_prof3name.grid(row=2,column=4)
#self.selected_profile.set(1) # purposefully do not set this value.
# one profile, so we will have to use the value of self.selected_profile
- self.frm_curprof = tk.Frame(self.master)
- self.frm_curprof.grid(row=4,column=0,rowspan=5)
+ self.frm_curprof = tk.Frame(self.master,background="red")
+ self.frm_curprof.grid(row=4,column=0,rowspan=22)
# most form fields are inside the current profile
self.lbl_money = tk.Label(self.frm_curprof,text="Money")
self.lbl_money.grid(row=0,column=0)
@@ -191,15 +194,15 @@ class App(tk.Frame):
self.opt_equ_weapon.grid(row=1,column=1,sticky="ew")
self.lbl_health = tk.Label(self.frm_curprof,text="Health")
self.lbl_health.grid(row=2,column=0)
- self.spn_health = stk.Spinbox(self.frm_curprof,from_=1,to=4,textvariable=self.health)
+ 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.lbl_stunt = tk.Label(self.frm_curprof,text="Stunt")
self.lbl_stunt.grid(row=3,column=0)
- self.spn_stunt = stk.Spinbox(self.frm_curprof,from_=1,to=4,textvariable=self.stunt)
+ 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.lbl_gun = tk.Label(self.frm_curprof,text="Gun")
self.lbl_gun.grid(row=4,column=0)
- self.spn_gun = stk.Spinbox(self.frm_curprof,from_=1,to=5,textvariable=self.gun)
+ 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)
self.lbl_pur = tk.Label(self.frm_curprof,text="Purchased: Weapons")
self.lbl_pur.grid(row=5,column=0)
@@ -238,23 +241,41 @@ class App(tk.Frame):
# level and levelsets
self.frm_levels = tk.Frame(self.master,borderwidth=1,background="green")
- self.frm_levels.grid(row=0,column=3,rowspan=len(srb_lib.LEVELS))
+ self.frm_levels.grid(row=0,column=3,rowspan=len(srb_lib.LEVELS)+4)
# WORKHERE
self.lbl_levelsets = []
self.spn_levelsets = []
self.lbl_levelsets_name = tk.Label(self.frm_levels,text="Billboard")
self.lbl_levelsets_name.grid(row=0,column=0,sticky="EW")
- self.lbl_levelsets_available_levels = tk.Label(self.frm_levels,text="Available levels")
- self.lbl_levelsets_available_levels.grid(row=0,column=1,columnspan=2,sticky="EW")
+ self.lbl_levelsets_available_levels = tk.Label(self.frm_levels,text="Available")
+ self.lbl_levelsets_available_levels.grid(row=0,column=1,columnspan=2)
+ self.lbl_levels_name = tk.Label(self.frm_levels,text="Level")
+ self.lbl_levels_name.grid(row=0,column=3,sticky="EW")
+ self.lbl_levels = []
+ x = 1
for i in range(0,len(srb_lib.LEVELSETS)):
tl = srb_lib.get_levelset_info(i)[0]
# WORKHERE: will have to set up variables for all this stuff, and then populate this stuff only on the load_form_into_data_for_profile.
#tl_status = srb_lib.get_levelset_status(self.bdata,profile_id,tl,silent=True)
self.lbl_levelsets.append(tk.Label(self.frm_levels,text=tl["name"]))
- self.lbl_levelsets[i].grid(row=i+1,column=0,sticky="EW")
- self.spn_levelsets.append(stk.Spinbox(self.frm_levels,textvariable=self.levelset_status_ints[i],from_=0,to=tl["l"])) #func=self.load_form_into_data,
- self.spn_levelsets[i].grid(row=i+1,column=1,sticky="EW")
- tk.Label(self.frm_levels,text="/ " + str(tl["l"])).grid(row=i+1,column=2,sticky="EW")
+ self.lbl_levelsets[i].grid(row=x,column=0,sticky="EW")
+ self.spn_levelsets.append(stk.Spinbox(self.frm_levels,textvariable=self.levelset_status_ints[i],from_=0,to=tl["l"],width=2))
+ self.spn_levelsets[i].grid(row=x,column=1)
+ tk.Label(self.frm_levels,text="/ " + str(tl["l"])).grid(row=x,column=2,sticky="EW")
+ print(f"For levelset {tl},")
+ these_levels = [k for k in srb_lib.LEVELS if k["setid"] == tl["id"]]
+ sorted(these_levels,key=lambda i: i["id"])
+ y = 0
+ for j in these_levels:
+ print(f"Process level {j}")
+ self.lbl_levels.append(tk.Label(self.frm_levels,text=j["name"]))
+ self.lbl_levels[-1].grid(row=x,column=3)
+ x += 1
+ x += 1
+ # end for-i-in-levelsets
+ #for i in range(0,len(srb_lib.LEVELS)):
+ # tl = srb_lib.get_level_info(i)[0]
+ # self.lbl_levels.append(tk.Label(self.frm_levels
# status bar
self.status = stk.StatusBar(self.master,var=self.statustext)
bgstack15