Hier ist die Tabelle, die ich bisher erstellt habe.Wie können Sie mit python's wx.grid Spalten zusammenführen?
Hier ist, was ich mag es, schauen möchte mit den Spalten verschmolzen.
Ich möchte die Spalten gestern und heute über drei Spalten jeweils verschmelzen. Gestern wäre also über Equity, Volatilität und Cash. Dann auch für Heute. Ich habe eine Funktion namens wx.grid.SetColSize(self, int col, int width)
gefunden, aber es hatte keine Wirkung. Weiß jemand, wie man das macht?
Hier ist auch mein Code.
import wx
import wx.grid as gridlib
class MyForm(wx.Frame):
def __init__(self):
"""Constructor"""
wx.Frame.__init__(self, parent=None, title="Strategies' Allocations")
self.panel = wx.Panel(self)
button_refresh = wx.Button(self.panel, id=wx.ID_ANY, label='Refresh')
button_refresh.Bind(wx.EVT_BUTTON, self.refresh)
self.myGrid1 = gridlib.Grid(self.panel)
self.myGrid1.CreateGrid(2, 6)
self.myGrid1.SetRowLabelSize(60)
self.myGrid1.SetRowLabelValue(0, "")
self.myGrid1.SetRowLabelValue(1, "ABRVXX")
for i in range(6):
self.myGrid1.SetColSize(i, 60)
self.myGrid1.SetColLabelValue(0, "")
self.myGrid1.SetColLabelValue(1, "Yesterday")
self.myGrid1.SetColLabelValue(2, "")
self.myGrid1.SetColLabelValue(3, "")
self.myGrid1.SetColLabelValue(4, "Today")
self.myGrid1.SetColLabelValue(5, "")
self.myGrid1.SetCellValue(0, 0, "Equity")
self.myGrid1.SetCellValue(0, 1, "Volatility")
self.myGrid1.SetCellValue(0, 2, "Cash")
self.myGrid1.SetCellValue(0, 3, "Equity")
self.myGrid1.SetCellValue(0, 4, "Volatility")
self.myGrid1.SetCellValue(0, 5, "Cash")
self.myGrid1.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
self.myGrid1.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_TOP)
# ******************************* #
self.myGrid2 = gridlib.Grid(self.panel)
self.myGrid2.CreateGrid(2, 6)
for i in range(6):
self.myGrid2.SetColSize(i, 60)
self.myGrid2.SetColLabelValue(0, "")
self.myGrid2.SetColLabelValue(1, "Yesterday")
self.myGrid2.SetColLabelValue(2, "")
self.myGrid2.SetColLabelValue(3, "")
self.myGrid2.SetColLabelValue(4, "Today")
self.myGrid2.SetColLabelValue(5, "")
self.myGrid2.SetCellValue(0, 0, "Treasury")
self.myGrid2.SetCellValue(0, 1, "Volatility")
self.myGrid2.SetCellValue(0, 2, "Cash")
self.myGrid2.SetCellValue(0, 3, "Treasury")
self.myGrid2.SetCellValue(0, 4, "Volatility")
self.myGrid2.SetCellValue(0, 5, "Cash")
self.myGrid2.SetRowLabelSize(60)
self.myGrid2.SetRowLabelValue(0, "")
self.myGrid2.SetRowLabelValue(1, "ABRXIV")
self.myGrid2.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
self.myGrid2.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_TOP)
# ****************************** #
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.myGrid1, 1, wx.TOP|wx.ALIGN_CENTRE, 2)
sizer.Add(self.myGrid2, 1, wx.TOP|wx.ALIGN_CENTRE, 2)
sizer.Add(button_refresh, 1, wx.RIGHT|wx.LEFT|wx.TOP|wx.BOTTOM|wx.EXPAND|wx.ALIGN_CENTRE, 50)
self.panel.SetSizer(sizer)
self.panel.SetSize((500,400))
self.SetSize((500,400))
self.panel.Layout()
def refresh(self, event):
pass
if __name__ == "__main__":
app = wx.App()
frame = MyForm().Show()
app.MainLoop()
nicht sicher, was du meinst. Können Sie mit den Daten im Raster einen Screenshot mit den gesuchten Daten erstellen? – Igor
@Igor Ich habe einen Screenshot hinzugefügt, um zu zeigen, was ich möchte. –