Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion gooey/gui/containers/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,22 @@ def __init__(self, buildSpec, *args, **kwargs):
# self.Bind(wx.EVT_CLOSE, self.onClose)

# TODO: handle child focus for per-field level validation.
# self.Bind(wx.EVT_CHILD_FOCUS, self.handleFocus)
self.Bind(wx.EVT_CHILD_FOCUS, self.handleFocus)

if self.buildSpec.get('auto_start', False):
self.onStart()

def handleFocus(self, event):
"""
Handle focus event for per-field level validation.
"""
child = event.GetWindow()
if isinstance(child, wx.TextCtrl): # Sample validation for text inputs
value = child.GetValue()
if not value: # Simple validation to check if the field is empty
wx.MessageBox('This field cannot be empty!', 'Validation Error', wx.OK | wx.ICON_ERROR)
child.SetFocus() # Keep focus on the field until valid
event.Skip() # Ensure the event is not blocked

def applyConfiguration(self):
self.SetTitle(self.buildSpec['program_name'])
Expand Down