Skip to content

Commit

Permalink
Readonly removed from path entries, and some resizing beauty fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Square789 committed Jul 12, 2022
1 parent 9fcc756 commit b7f0fa6
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Expand Up @@ -128,8 +128,7 @@ dmypy.json
.vscode/

# Local ideas/garbage
_*.png
_*.txt
/_*

# nuitka build
nuitka_build/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -29,7 +29,7 @@ python script that runs
`from demomgr.main_app import MainApp; MainApp()`.

## Installation instructions (exe):
There is an experimental [nuitka](https://nuitka.net/) build of Demomgr available in the "Releases" section for Windows.
For Windows, there is an experimental [nuitka](https://nuitka.net/) build of Demomgr available in the [Releases](https://github.com/Square789/Demomgr/releases/) section.
Extract it to a good place for programs to be and run the contained `demomgr.exe`.

## Getting started:
Expand Down
1 change: 1 addition & 0 deletions demomgr/dialogues/_diagresult.py
Expand Up @@ -19,6 +19,7 @@ class DIAGSIG:
SUCCESS = 0x0
FAILURE = 0x1


class DiagResult():
"""
Should be attribute of a dialog to inform of that dialog's state.
Expand Down
2 changes: 1 addition & 1 deletion demomgr/dialogues/bulk_operator.py
Expand Up @@ -199,7 +199,7 @@ def body(self, master):
self.target_path_frame = ttk.Frame(option_frame, style = "Contained.TFrame")
self.target_path_frame.grid_columnconfigure(0, weight = 1)
self.target_entry = ttk.Entry(
self.target_path_frame, textvariable = self.target_directory_var, state = "readonly"
self.target_path_frame, textvariable = self.target_directory_var
)
self.target_sel_button = ttk.Button(
self.target_path_frame, text = "Select target...", command = self._select_target
Expand Down
34 changes: 22 additions & 12 deletions demomgr/dialogues/settings.py
Expand Up @@ -8,6 +8,7 @@
from demomgr import constants as CNST
from demomgr.helpers import convertunit, frmd_label, int_validator
from demomgr.tk_widgets import PasswordButton
from demomgr.tk_widgets.misc import DynamicLabel

_TK_VARTYPES = {
"str": tk.StringVar,
Expand Down Expand Up @@ -88,9 +89,12 @@ def body(self, master):
display_labelframe, variable = self.lazyreload_var, text = "Lazy reload of main demo view",
style = "Contained.TCheckbutton"
)
lazyreload_txt = ttk.Label(
display_labelframe, text = "Will not reload the entire directory on minor\n" \
"changes such as bookmark modification.", justify = tk.LEFT, style = "Contained.TLabel"
lazyreload_txt = DynamicLabel(
200, 300, display_labelframe,
text = (
"Will not reload the entire directory on minor changes such as "
"bookmark modification."
), justify = tk.LEFT, style = "Contained.TLabel"
)
lazyreload_btn.grid(sticky = "w", ipadx = 4, pady = (2, 0))
lazyreload_txt.grid(sticky = "w", padx = (8, 0)) # Lazy reload
Expand Down Expand Up @@ -130,7 +134,7 @@ def body(self, master):
("File manager:", self.file_manager_path_var, False),
)):
desc_label = ttk.Label(path_labelframe, style = "Contained.TLabel", text = name)
path_entry = ttk.Entry(path_labelframe, state = "readonly", textvariable = tk_var)
path_entry = ttk.Entry(path_labelframe, textvariable = tk_var)
if dir_only:
# ugly parameter binding
def _tmp_handler(var = tk_var):
Expand Down Expand Up @@ -227,9 +231,6 @@ def _tmp_handler(var = tk_var):
"File manager": (file_manager_labelframe, ),
}
self._create_tk_var("int", "_selectedpane_var", 0)
self._selected_pane = next(iter(self._INTERFACE)) # Yields first key
# Only useful so deleting widgets for the first time in
# self._reload_options_panel will not throw AttributeErrors

sidebar_outerframe = ttk.Frame(mainframe, style = "Border.TFrame")
sidebar_outerframe.grid_columnconfigure(0, weight = 1)
Expand All @@ -249,8 +250,6 @@ def _handler(self = self, k = k):
if i == 0 or i == self.ui_remember[0]:
tmp_inibtn = curbtn

tmp_inibtn.invoke()

sidebar.grid(column = 0, row = 0, sticky = "nesw", padx = 1, pady = 1)
sidebar_outerframe.grid(column = 0, row = 0, sticky = "nesw")
suboptions_pane.grid(column = 1, row = 0, sticky = "nesw")
Expand All @@ -259,9 +258,11 @@ def _handler(self = self, k = k):
btconfirm = ttk.Button(master, text = "Save", command = lambda: self.done(1))
btcancel = ttk.Button(master, text = "Cancel", command = lambda: self.done(0))

btconfirm.grid(column = 0, row = 1, padx = (0, 3), pady = (3, 0), sticky = "news")
btconfirm.grid(column = 0, row = 1, padx = (0, 3), pady = (3, 0), sticky = "news")
btcancel.grid(column = 1, row = 1, padx = (3, 0), pady = (3, 0), sticky = "news")

tmp_inibtn.invoke()

def _create_tk_var(self, type_, name, inivalue):
"""
Creates a tkinter variable of type "str", "int", "bool", "double",
Expand Down Expand Up @@ -316,8 +317,17 @@ def _reload_options_pane(self, key):
Clears and repopulates right pane with the widgets in
self._INTERFACE[`key`]
"""
for widget in self._INTERFACE[self._selected_pane]:
widget.grid_forget()
if self._selected_pane == key:
return

# When the user resizes the window, other panes will produce an ugly
# amount of empty space. This resets user-requested width.
self.wm_geometry("")

if self._selected_pane is not None:
for widget in self._INTERFACE[self._selected_pane]:
widget.grid_forget()

self._selected_pane = key
for i, widget in enumerate(self._INTERFACE[key]):
pady = (
Expand Down
10 changes: 9 additions & 1 deletion demomgr/main_app.py
Expand Up @@ -314,6 +314,15 @@ def _setupgui(self):
self.listbox.bind("<<MultiframeSelect>>", self._mfl_select_callback)
self.listbox.bind("<<MultiframeRightclick>>", self._mfl_rc_callback)

# # This will force the root window's dimensions to its initially requested one.
# # Prevents irritating resize of the window for long paths that get written to the
# # statusbar.
# self.root.update()
# self.root.wm_geometry(self.root.wm_geometry())

# You know, it's actually much easier to just not put the paths onto the statusbar, so
# I did that instead lul

def _mfl_rc_callback(self, event):
context_menus.multiframelist_cb(event, self.listbox, self.demooperations)

Expand Down Expand Up @@ -794,7 +803,6 @@ def setstatusbar(self, data, timeout = None):
"""Set statusbar text to data (str)."""
self.statusbarlabel.after_cancel(self.after_handle_statusbar)
self.statusbarlabel.config(text = str(data))
self.statusbarlabel.update()
if timeout is not None:
self.after_handle_statusbar = self.statusbarlabel.after(
timeout, lambda: self.setstatusbar(CNST.STATUSBARDEFAULT)
Expand Down
11 changes: 2 additions & 9 deletions demomgr/threads/read_folder.py
Expand Up @@ -59,11 +59,7 @@ def run(self):
self.__stop(None, None, None, THREADSIG.FAILURE)
return

self.queue_out_put(
THREADSIG.INFO_STATUSBAR,
f"Reading demo information from {self.targetdir} ...",
None,
)
self.queue_out_put(THREADSIG.INFO_STATUSBAR, f"Reading demo information...", None)
starttime = time.time()

try:
Expand All @@ -74,10 +70,7 @@ def run(self):
]
except FileNotFoundError:
self.__stop(
f"ERROR: Current directory {self.targetdir!r} does not exist.",
None,
None,
THREADSIG.FAILURE,
f"ERROR: Selected directory does not exist.", None, None, THREADSIG.FAILURE
)
return
except OSError as exc:
Expand Down
8 changes: 5 additions & 3 deletions demomgr/tk_widgets/key_value_display.py
Expand Up @@ -152,7 +152,7 @@ def __init__(self, kvd, id_, **kwargs):
self.entry = ttk.Entry(kvd.innerframe, state = "readonly")

for w in (self.label, self.entry):
prepend_bindtags(w, f"scroll{format(crunch_window_path(kvd._w))}")
prepend_bindtags(w, f"scroll{crunch_window_path(kvd._w)}")

self.label.grid(column = 0, row = kvd.length, sticky = "w")
self.entry.grid(column = 1, row = kvd.length, sticky = "ew")
Expand Down Expand Up @@ -217,8 +217,10 @@ def __init__(self, parent, styleobj, inipairs = None, *args, **kwargs):
self.innerframe.bind("<Configure>", self._frame_cnf_callback)
self.innerframe.grid_columnconfigure((0, 1), weight = 1, pad = 50)

self.tk.eval(SCROLLCOMMAND.format(w = f"scroll{crunch_window_path(self._w)}",
tw = self.canvas._w))
self.tk.eval(SCROLLCOMMAND.format(
w = f"scroll{crunch_window_path(self._w)}",
tw = self.canvas._w,
))
prepend_bindtags(self.innerframe, f"scroll{crunch_window_path(self._w)}")
prepend_bindtags(self.canv_scrollbar, f"scroll{crunch_window_path(self._w)}")

Expand Down
1 change: 1 addition & 0 deletions demomgr/tk_widgets/misc.py
Expand Up @@ -46,4 +46,5 @@ def _reconfigure(self, e):
self._block_reconfigure = True
# Hardcoded 5, who cares, good enough for the places it's used in.
self.configure(wraplength = max(self._min_wl, e.widget.winfo_width() - 5))
e.widget.update_idletasks()
self._block_reconfigure = False

0 comments on commit b7f0fa6

Please sign in to comment.