Multiple wafer maps in GUI part 2
jpernia101 opened this issue · comments
okay so here's something that I've been stuck on, im trying to put multiple wafers in a wx frame. My approach was to declare a Main sizer and place 3 sizers horizontally inside this main sizer , then I was going to place the WaferMapPanel's inside these sizer. When I did it shows me the correct legends for each one but the wafer map is missing. maybe you can help me find something I may be missing .
Below is my code
`class F_WaferMaps ( wx.Frame ):
def __init__( self, parent, dateBegin , dateEnd):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 834,559 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer6 = wx.BoxSizer( wx.VERTICAL )
bSizer7 = wx.BoxSizer( wx.HORIZONTAL )
bSizer9 = wx.BoxSizer( wx.HORIZONTAL )
bSizer10 = wx.BoxSizer( wx.HORIZONTAL )
waferDesign = WaferInfo(die_size = (.3,.45),center_xy= (10 ,6.5), dia= 6.0 , edge_excl= 0.0 )
waferInfo = pd.read_excel("Copy of WS1 Summary Table_A1 Build_20180906.xlsx", index_col= None, na_values=['NA'] , usecols=[18,4,5,21,2])
df2 = waferInfo[(waferInfo.FILE_FINISH_TS >= dateBegin) & (waferInfo.FILE_FINISH_TS <= dateEnd) ]
waferSubSet = df2[['X_COORD', 'Y_COORD' , 'HB_NUM', 'FILE_FINISH_TS' , 'LOT_WF']]
df3 = waferSubSet[~(waferSubSet[['X_COORD', 'Y_COORD', 'LOT_WF']].duplicated(keep = 'last'))]
waferNum = 0
for lotID, wafNum in df3.groupby(['LOT_WF']):
df4 = wafNum[['X_COORD', 'Y_COORD', 'HB_NUM']]
print(wafNum)
print("\n")
my_list = df4.transform(tuple, axis=1).tolist()
self.panels = wm_core.WaferMapPanel(self, my_list, waferDesign, data_type='discrete'.lower())
if(waferNum % 3 == 0):
bSizer7.Add( self.panels, 0, wx.ALL, 5 )
elif(waferNum % 3 == 1):
bSizer9.Add( self.panels, 0, wx.ALL, 5 )
else:
bSizer10.Add( self.panels, 0, wx.ALL, 5
bSizer6.Add( bSizer7, 1, wx.EXPAND |wx.ALL, 5 )
bSizer6.Add( bSizer9, 1, wx.EXPAND |wx.ALL, 5 )
bSizer6.Add( bSizer10, 1, wx.EXPAND |wx.ALL, 5 )
self.SetSizer( bSizer6 )
self.Layout()
self.Centre( wx.BOTH )`
and the result ends up looking something like this
I think im very close but im missing something
I think your issue may be that you're overwriting self.panels
on each iteration of your loop. (also, a missing paren, but I assume that's just a transcription error). Instead of:
self.panels = wm_core.WaferMapPanel(self, my_list, waferDesign, data_type='discrete'.lower())
Try this:
temp_panel = wm_core.WaferMapPanel(self, my_list, waferDesign, data_type='discrete'.lower())
if(waferNum % 3 == 0):
bSizer7.Add( temp_panel, 0, wx.ALL, 5 )
elif(waferNum % 3 == 1):
bSizer9.Add( temp_panel, 0, wx.ALL, 5 )
else:
bSizer10.Add( temp_panel, 0, wx.ALL, 5 ) # added missing paren
#^
Alternatively, you may need to keep a reference to each panel individually. In that case, append them to a separate array attribute of the Frame:
self.panels = []
for lotID, wafNum in df3.groupby(['LOT_WF']):
...
temp_panel = wc_core.WaferMapPanel(...)
self.panels.append(temp_panel)
if(waferNum % 3 ...
You might consider a GridSizer
instead of multiple box sizers. It could make the code easier to implement and read.
Unrelated to the question, I highly recommend reading and following PEP8 (Python style guide).
Hey, thanks for the reply , I tried the suggestion above
temp_panel = wm_core.WaferMapPanel(self, my_list, waferDesign, data_type='discrete'.lower()) if(waferNum % 3 == 0): bSizer7.Add( temp_panel, 0, wx.ALL, 5 ) elif(waferNum % 3 == 1): bSizer9.Add( temp_panel, 0, wx.ALL, 5 ) else: bSizer10.Add( temp_panel, 0, wx.ALL, 5 )
but unfortunately it gave me the same results. Any other ideas that you may think off ?
i also went ahead and tried the grid approach , i'll go ahead and share my code and image to see if that helps
`def init( self, parent, dateBegin , dateEnd):
wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = wx.EmptyString, pos = wx.DefaultPosition, size = wx.Size( 834,559 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL )
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
bSizer6 = wx.BoxSizer( wx.VERTICAL )
gSizer2 = wx.GridSizer( 3, 4, 0, 0 )
waferDesign = WaferInfo(die_size = (.3,.45),center_xy= (10 ,6.5), dia= 6.0 , edge_excl= 0.0 )
waferInfo = pd.read_excel("Copy of WS1 Summary Table_A1 Build_20180906.xlsx", index_col= None, na_values=['NA'] , usecols=[18,4,5,21,2])
df2 = waferInfo[(waferInfo.FILE_FINISH_TS >= dateBegin) & (waferInfo.FILE_FINISH_TS <= dateEnd) ]
waferSubSet = df2[['X_COORD', 'Y_COORD' , 'HB_NUM', 'FILE_FINISH_TS' , 'LOT_WF']]
df3 = waferSubSet[~(waferSubSet[['X_COORD', 'Y_COORD', 'LOT_WF']].duplicated(keep = 'last'))]
waferNum = 0
for lotID, wafNum in df3.groupby(['LOT_WF']):
df4 = wafNum[['X_COORD', 'Y_COORD', 'HB_NUM']]
print(wafNum)
print("\n")
my_list = df4.transform(tuple, axis=1).tolist()
temp_panels = wm_core.WaferMapPanel(self, my_list, waferDesign, data_type='discrete'.lower())
if(waferNum % 3 == 0):
gSizer2.Add( temp_panels, 0, wx.ALL, 5 )
elif(waferNum % 3 == 1):
gSizer2.Add( temp_panels, 0, wx.ALL, 5 )
else:
gSizer2.Add( temp_panels, 0, wx.ALL, 5
bSizer6.Add(gSizer2,1,wx.EXPAND,5)
self.SetSizer( bSizer6 )
self.Layout()
self.Centre( wx.BOTH )`
Glad to hear you got it solved!
thanks for helping out man !