Skip to content

Commit

Permalink
Added Right Click "Add Rotation" menu option
Browse files Browse the repository at this point in the history
  • Loading branch information
computergeek1507 authored and Bouni committed Mar 28, 2022
1 parent b8a5fc2 commit adb6705
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 14 additions & 1 deletion mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def update_library(self, e=None):

def manage_rotations(self, e=None):
"""Manage rotation corrections."""
RotationManagerDialog(self).ShowModal()
RotationManagerDialog(self, "").ShowModal()

def calculate_costs(self, e):
"""Hopefully we will be able to calculate the part costs in the future."""
Expand Down Expand Up @@ -833,6 +833,15 @@ def paste_part_lcsc(self, e):
self.store.set_lcsc(reference, lcsc)
self.populate_footprint_list()

def add_part_rot(self, e):
for item in self.footprint_list.GetSelections():
row = self.footprint_list.ItemToRow(item)
if row == -1:
return
footp = self.footprint_list.GetTextValue(row, 2)
if footp != "":
RotationManagerDialog(self, "^" + footp).ShowModal()

def OnRightDown(self, e):
conMenu = wx.Menu()
cpmi = wx.MenuItem(conMenu, wx.NewId(), "Copy LCSC")
Expand All @@ -843,6 +852,10 @@ def OnRightDown(self, e):
conMenu.Append(ptmi)
conMenu.Bind(wx.EVT_MENU, self.paste_part_lcsc, ptmi)

crmi = wx.MenuItem(conMenu, wx.NewId(), "Add Rotation")
conMenu.Append(crmi)
conMenu.Bind(wx.EVT_MENU, self.add_part_rot, crmi)

self.footprint_list.PopupMenu(conMenu)
conMenu.Destroy() # destroy to avoid memory leak

Expand Down
4 changes: 2 additions & 2 deletions rotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


class RotationManagerDialog(wx.Dialog):
def __init__(self, parent):
def __init__(self, parent, footprint):
wx.Dialog.__init__(
self,
parent,
Expand Down Expand Up @@ -58,7 +58,7 @@ def __init__(self, parent):
self.regex = wx.TextCtrl(
self,
wx.ID_ANY,
"",
footprint,
wx.DefaultPosition,
HighResWxSize(parent.window, wx.Size(200, 24)),
)
Expand Down

0 comments on commit adb6705

Please sign in to comment.