Skip to content

Commit ecf06bb

Browse files
committed
Tiny display / behavior cleanups to "Set Binds Location" dialog
1 parent 7265422 commit ecf06bb

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

BindControl.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22
import sys, os, platform, re
3-
from pathlib import Path, PureWindowsPath
3+
from pathlib import Path
44

55
import wx
66
import wx.lib.mixins.inspection
@@ -395,6 +395,7 @@ def OnProfDirButton(self, _ = None):
395395
config = wx.ConfigBase.Get()
396396
bindpath = config.Read('BindPath')
397397
separator = "\\" if platform.system() == "Windows" else "/"
398+
if bindpath[-1:] == separator: separator = ''
398399

399400
dirSizer = wx.BoxSizer(wx.HORIZONTAL)
400401
dirSizer.Add(wx.StaticText(ProfDirDialog, -1,
@@ -443,6 +444,10 @@ def OnProfDirButton(self, _ = None):
443444

444445
# need this out here in case we cancelled on a previously-blank one.
445446
# This is very very unlikely to happen and awful if it does.
447+
#
448+
# TODO-ish: if they erase an existing valid one or otherwise cause an
449+
# error, and then hit "cancel" this gets triggered, which is not
450+
# perfect - this logic needs a little smartening.
446451
if PathText.HasErrors(): return self.OnProfDirButton()
447452

448453
self.CheckProfDirButtonErrors()
@@ -501,10 +506,11 @@ def OnPathTextChanged(self, evt):
501506
else:
502507
textctrl.RemoveError('spaces')
503508

504-
if PureWindowsPath(value).is_reserved():
505-
textctrl.AddError('reserved', 'The name you have selected is a reserved filename in Windows. Please select another.')
506-
else:
507-
textctrl.RemoveError('reserved')
509+
if platform.system() == 'Windows':
510+
if os.path.isreserved(value):
511+
textctrl.AddError('reserved', 'The name you have selected is a reserved filename in Windows. Please select another.')
512+
else:
513+
textctrl.RemoveError('reserved')
508514

509515
if value: # don't do this check if it's blank
510516
exists = None

UI/ErrorControls.py

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ class ErrorControlMixin:
77
SetToolTip : Callable
88
GetTextCtrl : Callable
99
HasTextCtrl : Callable
10+
Refresh : Callable
1011

1112
def __init__(self, *args, **kwargs):
1213
super().__init__(*args, **kwargs)
@@ -24,6 +25,7 @@ def AddWarning(self, errname, tooltip = None):
2425
self.StylingTarget().SetBackgroundColour((255,255,200))
2526
self.Warnings[errname] = tooltip
2627
self.SetErrorToolTip()
28+
self.Refresh()
2729

2830
def RemoveWarning(self, errname):
2931
self.Warnings.pop(errname, None)
@@ -32,11 +34,13 @@ def RemoveWarning(self, errname):
3234
elif not self.Errors:
3335
self.StylingTarget().SetOwnBackgroundColour((255,255,200))
3436
self.SetErrorToolTip()
37+
self.Refresh()
3538

3639
def AddError(self, errname, tooltip = None):
3740
self.StylingTarget().SetBackgroundColour((255,200,200))
3841
self.Errors[errname] = tooltip
3942
self.SetErrorToolTip()
43+
self.Refresh()
4044

4145
def RemoveError(self, errname):
4246
self.Errors.pop(errname, None)
@@ -45,6 +49,7 @@ def RemoveError(self, errname):
4549
elif not self.Errors:
4650
self.StylingTarget().SetOwnBackgroundColour((255,255,200))
4751
self.SetErrorToolTip()
52+
self.Refresh()
4853

4954
# TODO pick one of these next two and stick with it
5055
def HasAnyError(self): return self.Errors != {}
@@ -56,6 +61,7 @@ def ClearErrors(self):
5661
errors = list(self.Errors)
5762
for error in errors: self.RemoveError(error)
5863
self.SetErrorToolTip()
64+
self.Refresh()
5965

6066
def StylingTarget(self):
6167
return self.GetTextCtrl() if (isinstance(self, wx.PickerBase) and self.HasTextCtrl()) else self

0 commit comments

Comments
 (0)