0
早安刪除GridBagSizer,完全wx.Python
我編碼使用wx.BoxSizer內wx.GridBagSizer的結果表。一旦我更新了新的數據,我想完全刪除GridBagSizer,創建一個新的GridBagsizer並在新的數據上顯示新的結果。但是,當我更新數據時,值正確更新,但新的GridBagSizer移動到一個位置,就好像以前的GridBagSizer仍然存在一樣。...
你能幫我嗎? 感謝
def actualiza_res(self, presas_sel):
self.presas_sel = presas_sel
esquema = self.link_principal.esquema
if esquema["modelos"] and esquema["res_prio"]==False:
self.gbsint.Clear(True)
self.gbsint.Layout()
self.Refresh()
self.Update()
self.gbsint=wx.GridBagSizer(vgap=10, hgap=10)
self.gbsint.Layout()
self.Refresh()
self.Update()
text11=wx.StaticText(self, -1,_('Current situation'))
font11 = wx.Font(12, wx.ROMAN, wx.NORMAL, wx.BOLD)
text11.SetFont(font11)
self.gbsint.Add(text11, (3, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40)
self.ct=['-']*(len(self.resct))
self.ec=['-']*len(self.resec)
self.ps=['-']*len(self.resps)
self.dpa=['-']*len(self.resdpa)
j=4
for res in range(len(self.ct)):
self.gbsint.Add(wx.StaticText(self, -1,str(esquema["modelos"][presas_sel[-1]]["CRIDPA"][2][res])),(j, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40)
j += 1
j=11
for res in range(len(self.ec)):
self.gbsint.Add(wx.StaticText(self, -1,str(esquema["modelos"][presas_sel[-1]]["CRIDPA"][2][res])),(j, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40)
j += 1
j=18
for res in range(len(self.ps)):
self.gbsint.Add(wx.StaticText(self, -1,str(esquema["modelos"][presas_sel[-1]]["CRIDPA"][2][res])),(j, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40)
j += 1
#self.totalcri=wx.StaticText(self, -1, _('-'), style=wx.ALIGN_CENTER)
self.gbsint.Add(wx.StaticText(self, -1,str(esquema["modelos"][presas_sel[-1]]["riesgo"][0])),(27, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40) #Total CRI
j=29
for res in range(len(self.dpa)):
self.gbsint.Add(wx.StaticText(self, -1,str(esquema["modelos"][presas_sel[-1]]["CRIDPA"][2][res])),(j, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40)
j += 1
#self.totaldpa=wx.StaticText(self, -1, _('-'), style=wx.ALIGN_CENTER)
self.gbsint.Add(wx.StaticText(self, -1,str(esquema["modelos"][presas_sel[-1]]["riesgo"][2])),(33, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40) #TOTalDPA
#self.totalr=wx.StaticText(self, -1, _('-'), style=wx.ALIGN_CENTER)
self.gbsint.Add(wx.StaticText(self, -1,str(esquema["modelos"][presas_sel[-1]]["riesgo"][4])),(34, 1), flag=wx.LEFT|wx.ALIGN_CENTER, border=40)#Clase
#Datos actuales de la presa
self.textos["presas"].SetLabel(str(esquema["modelos"][presas_sel[-1]]["presas"])) #Nombre de la presa
self.textos["Fecha ultima inspeccion"].SetLabel(str(esquema["modelos"][presas_sel[-1]]["Fecha ultima inspeccion"]))#ultima inspeccion
self.textos["riesgo"].SetLabel(str(esquema["modelos"][presas_sel[-1]]["riesgo"][-1])) #Classe
self.sizer_hor.Add(self.gbsint,flag=wx.ALIGN_LEFT)
self.SetupScrolling()
self.Refresh()
self.Layout()
self.Update()
如果您保存對網格包的引用,那麼您可以調用其「銷燬」方法將其刪除。請注意,您可能需要先移除其子女。 –