Skip to content

Commit

Permalink
Highlight non-entries
Browse files Browse the repository at this point in the history
  • Loading branch information
MitjaNemec committed Aug 6, 2023
1 parent b2cfe6b commit 14cb4e7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 9 deletions.
67 changes: 59 additions & 8 deletions action_place_footprints.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(self, parent, placer, ref_fp, user_units):
self.list_sheetsChoices = None
self.config_filename = os.path.join(self.placer.project_folder, 'place_footprints.ini')
self.logger = logging.getLogger(__name__)
self.background_color = self.lbl_x_mag.GetBackgroundColour()

footprints = self.placer.get_footprints_on_sheet(self.ref_fp.sheet_id)
self.height, self.width = self.placer.get_footprints_bounding_box_size(footprints)
Expand Down Expand Up @@ -137,15 +138,38 @@ def __init__(self, parent, placer, ref_fp, user_units):

def on_ok(self, event):
# test if all entries have numbers, if they don't then don't do anything
invalid_entry = False
if self.val_x_mag.GetValue() == '':
return
self.val_x_mag.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_x_mag.SetBackgroundColour(self.background_color)

if self.val_y_angle.GetValue() == '':
return
self.val_y_angle.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_y_angle.SetBackgroundColour(self.background_color)

if self.val_nth.GetValue() == '':
return
self.val_nth.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_nth.SetBackgroundColour(self.background_color)

if self.val_rotate.GetValue() == '':
return
self.val_rotate.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_rotate.SetBackgroundColour(self.background_color)

if self.com_arr.GetStringSelection() != 'Linear' and self.val_columns_rad_step.GetValue() == '':
self.val_columns_rad_step.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_columns_rad_step.SetBackgroundColour(self.background_color)

if invalid_entry:
return

# clear highlights
Expand Down Expand Up @@ -325,6 +349,8 @@ def __init__(self, parent, placer, ref_fp, user_units):
self.user_units = user_units
self.config_filename = os.path.join(self.placer.project_folder, 'place_footprints.ini')
self.logger = logging.getLogger(__name__)
self.background_color = self.lbl_x_mag.GetBackgroundColour()
self.logger.info(repr(self.background_color))

# grab footprint data
self.ref_fp = ref_fp
Expand Down Expand Up @@ -453,15 +479,40 @@ def on_selected(self, event):
pcbnew.Refresh()

def on_ok(self, event):
invalid_entry = False

self.logger.info(repr(self.val_x_mag.GetValue()))
if self.val_x_mag.GetValue() == '':
return
self.val_x_mag.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_x_mag.SetBackgroundColour(self.background_color)

if self.val_y_angle.GetValue() == '':
return
self.val_y_angle.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_y_angle.SetBackgroundColour(self.background_color)

if self.val_nth.GetValue() == '':
return
self.val_nth.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_nth.SetBackgroundColour(self.background_color)

if self.val_rotate.GetValue() == '':
return
self.val_rotate.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_rotate.SetBackgroundColour(self.background_color)

if self.com_arr.GetStringSelection() != 'Linear' and self.val_columns_rad_step.GetValue() == '':
self.val_columns_rad_step.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_HIGHLIGHT))
invalid_entry = True
else:
self.val_columns_rad_step.SetBackgroundColour(self.background_color)

if invalid_entry:
return

# clear highlights
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.1.0
2.1.1

0 comments on commit 14cb4e7

Please sign in to comment.