Update app.py
This commit is contained in:
33
app.py
33
app.py
@@ -6,15 +6,15 @@ import tab_time_discovery, tab_id_review, tab_unused_review, tab_category_sorter
|
||||
# Start Database
|
||||
SorterEngine.init_db()
|
||||
|
||||
st.set_page_config(layout="wide", page_title="Turbo Sorter Pro DB")
|
||||
st.set_page_config(layout="wide", page_title="Turbo Sorter Pro DB v10.0")
|
||||
|
||||
# --- GLOBAL SESSION INITIALIZATION ---
|
||||
# All indexes must be initialized here to avoid AttributeErrors
|
||||
# Initializes all indexes to prevent AttributeErrors
|
||||
if 'history' not in st.session_state: st.session_state.history = []
|
||||
if 'idx_time' not in st.session_state: st.session_state.idx_time = 0 # Fix for Tab 1
|
||||
if 'idx_id' not in st.session_state: st.session_state.idx_id = 0 # Fix for Tab 2
|
||||
if 'idx_unused' not in st.session_state: st.session_state.idx_unused = 0 # Fix for Tab 3
|
||||
if 'idx_cat' not in st.session_state: st.session_state.idx_cat = 0 # Fix for Tab 4
|
||||
if 'idx_time' not in st.session_state: st.session_state.idx_time = 0
|
||||
if 'idx_id' not in st.session_state: st.session_state.idx_id = 0
|
||||
if 'idx_unused' not in st.session_state: st.session_state.idx_unused = 0
|
||||
if 'idx_cat' not in st.session_state: st.session_state.idx_cat = 0
|
||||
|
||||
# --- Sidebar ---
|
||||
profiles = SorterEngine.load_profiles()
|
||||
@@ -29,6 +29,10 @@ naming_mode = st.sidebar.radio("Naming Mode", ["id", "original"], index=0 if p_d
|
||||
path_rv_t = st.sidebar.text_input("Review Target", value=p_data.get("rev_t", os.path.join(path_t, "selected_target")))
|
||||
path_rv_c = st.sidebar.text_input("Review Control", value=p_data.get("rev_c", os.path.join(path_t, "selected_control")))
|
||||
|
||||
# ID Logic
|
||||
id_val = st.sidebar.number_input("Next ID Number", value=SorterEngine.get_max_id_number(path_t) + 1)
|
||||
prefix = f"id{int(id_val):03d}_"
|
||||
|
||||
if st.sidebar.button("💾 Save Profile"):
|
||||
prof_name = st.sidebar.text_input("Profile Name", key="save_prof_input")
|
||||
if prof_name:
|
||||
@@ -36,14 +40,15 @@ if st.sidebar.button("💾 Save Profile"):
|
||||
st.sidebar.success(f"Profile {prof_name} Saved!")
|
||||
st.rerun()
|
||||
|
||||
if st.sidebar.button("↶ UNDO", use_container_width=True, disabled=not st.session_state.history):
|
||||
SorterEngine.revert_action(st.session_state.history.pop())
|
||||
st.rerun()
|
||||
|
||||
# --- Tabs ---
|
||||
t1, t2, t3, t4 = st.tabs(["🕒 1. Discovery", "🆔 2. ID Review", "♻️ 3. Unused", "📂 4. Category Sorter"])
|
||||
|
||||
with t1: tab_time_discovery.render(path_t, 40, 50, "id001_")
|
||||
with t2: tab_id_review.render(path_rv_t, path_rv_c, 40)
|
||||
with t3: tab_unused_review.render(path_rv_t, path_rv_c, 40)
|
||||
with t4: tab_category_sorter.render(path_t, path_out, 40, naming_mode)
|
||||
with t1:
|
||||
tab_time_discovery.render(path_t, 40, 50, prefix)
|
||||
with t2:
|
||||
# FIX: Added 'prefix' as the required positional argument
|
||||
tab_id_review.render(path_rv_t, path_rv_c, 40, prefix)
|
||||
with t3:
|
||||
tab_unused_review.render(path_rv_t, path_rv_c, 40)
|
||||
with t4:
|
||||
tab_category_sorter.render(path_t, path_out, 40, naming_mode)
|
||||
Reference in New Issue
Block a user