word wrapping yum
This commit is contained in:
51
gui.py
51
gui.py
@@ -1349,11 +1349,25 @@ class App:
|
|||||||
def _rebuild_disc_list(self):
|
def _rebuild_disc_list(self):
|
||||||
if not dpg.does_item_exist("disc_scroll"):
|
if not dpg.does_item_exist("disc_scroll"):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _toggle_read(s, a, idx):
|
||||||
|
# Save edit box content before switching to read mode
|
||||||
|
tag = f"disc_content_{idx}"
|
||||||
|
if dpg.does_item_exist(tag) and not self.disc_entries[idx].get("read_mode", False):
|
||||||
|
self.disc_entries[idx]["content"] = dpg.get_value(tag)
|
||||||
|
self.disc_entries[idx]["read_mode"] = not self.disc_entries[idx].get("read_mode", False)
|
||||||
|
self._rebuild_disc_list()
|
||||||
|
|
||||||
dpg.delete_item("disc_scroll", children_only=True)
|
dpg.delete_item("disc_scroll", children_only=True)
|
||||||
for i, entry in enumerate(self.disc_entries):
|
for i, entry in enumerate(self.disc_entries):
|
||||||
collapsed = entry.get("collapsed", False)
|
collapsed = entry.get("collapsed", False)
|
||||||
|
read_mode = entry.get("read_mode", False)
|
||||||
ts_str = entry.get("ts", "")
|
ts_str = entry.get("ts", "")
|
||||||
|
|
||||||
|
preview = entry["content"].replace("\n", " ")[:60]
|
||||||
|
if len(entry["content"]) > 60:
|
||||||
|
preview += "..."
|
||||||
|
|
||||||
with dpg.group(parent="disc_scroll"):
|
with dpg.group(parent="disc_scroll"):
|
||||||
with dpg.group(horizontal=True):
|
with dpg.group(horizontal=True):
|
||||||
dpg.add_button(
|
dpg.add_button(
|
||||||
@@ -1369,6 +1383,12 @@ class App:
|
|||||||
width=120,
|
width=120,
|
||||||
callback=self._make_disc_role_cb(i),
|
callback=self._make_disc_role_cb(i),
|
||||||
)
|
)
|
||||||
|
if not collapsed:
|
||||||
|
dpg.add_button(
|
||||||
|
label="[Edit]" if read_mode else "[Read]",
|
||||||
|
user_data=i,
|
||||||
|
callback=_toggle_read
|
||||||
|
)
|
||||||
if ts_str:
|
if ts_str:
|
||||||
dpg.add_text(ts_str, color=(120, 120, 100))
|
dpg.add_text(ts_str, color=(120, 120, 100))
|
||||||
if collapsed:
|
if collapsed:
|
||||||
@@ -1379,30 +1399,29 @@ class App:
|
|||||||
)
|
)
|
||||||
dpg.add_button(
|
dpg.add_button(
|
||||||
label="[+ Max]",
|
label="[+ Max]",
|
||||||
user_data=f"disc_content_{i}",
|
callback=lambda s, a, u, idx=i: _show_text_viewer(f"Entry #{idx+1}", self.disc_entries[idx]["content"])
|
||||||
callback=lambda s, a, u, idx=i: _show_text_viewer(f"Entry #{idx+1}", dpg.get_value(u) if dpg.does_item_exist(u) else "")
|
|
||||||
)
|
)
|
||||||
dpg.add_button(
|
dpg.add_button(
|
||||||
label="Del",
|
label="Del",
|
||||||
width=36,
|
width=36,
|
||||||
callback=self._make_disc_remove_cb(i),
|
callback=self._make_disc_remove_cb(i),
|
||||||
)
|
)
|
||||||
|
dpg.add_text(preview, color=(160, 160, 150))
|
||||||
if collapsed:
|
|
||||||
with dpg.group(horizontal=True):
|
|
||||||
dpg.add_spacer(width=28) # Indent text past the expand/collapse button
|
|
||||||
dpg.add_text(entry["content"], wrap=0, color=(200, 200, 200))
|
|
||||||
|
|
||||||
with dpg.group(tag=f"disc_body_{i}", show=not collapsed):
|
with dpg.group(tag=f"disc_body_{i}", show=not collapsed):
|
||||||
dpg.add_input_text(
|
if read_mode:
|
||||||
tag=f"disc_content_{i}",
|
with dpg.child_window(height=150, border=True):
|
||||||
default_value=entry["content"],
|
dpg.add_text(entry["content"], wrap=0, color=(200, 200, 200))
|
||||||
multiline=True,
|
else:
|
||||||
width=-1,
|
dpg.add_input_text(
|
||||||
height=100,
|
tag=f"disc_content_{i}",
|
||||||
callback=self._make_disc_content_cb(i),
|
default_value=entry["content"],
|
||||||
on_enter=False,
|
multiline=True,
|
||||||
)
|
width=-1,
|
||||||
|
height=150,
|
||||||
|
callback=self._make_disc_content_cb(i),
|
||||||
|
on_enter=False,
|
||||||
|
)
|
||||||
dpg.add_separator()
|
dpg.add_separator()
|
||||||
|
|
||||||
def _make_disc_role_cb(self, idx: int):
|
def _make_disc_role_cb(self, idx: int):
|
||||||
|
|||||||
Reference in New Issue
Block a user