I know that I should not do it but my browser refuse to load the demo so…
import wx
import wx.grid as gridlib
RS = [(0,‘Glicemia’,None,),
(1,‘Azotemia’,35.8,),
(2,‘UREA’,None,),
(3,‘ALT’,38,),
(4,‘AST’,45,),]
class MyForm(wx.Frame):
def init(self):
wx.Frame.init(self, parent=None, title=“Simple App”, size=(200,200))
panel = wx.Panel(self)
self.Bind(wx.EVT_CLOSE, self.OnExit)
self.grid = gridlib.Grid(panel, size=(400,200))
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.grid)
panel.SetSizer(sizer)
def OnCreateGrid(self,rs):
labels = [‘’,‘’, ‘result’, ]
lines = len(rs)
self.grid.CreateGrid(lines,len(labels))
for row in range(len(labels)):
self.grid.SetColLabelValue(row, labels[row])
test =
for i in rs:
test.append(i[1])
for row in range(len(test)):
self.grid.SetRowLabelValue(row, test[row])
self.grid.SetColMinimalAcceptableWidth(0)
self.grid.SetColSize(0,0)
self.grid.SetColSize(1,0)
self.grid.SetColLabelSize(30)
self.grid.SetRowLabelSize(100)
self.grid.SetRowLabelAlignment(wx.ALIGN_LEFT,-1)
self.grid.SetColFormatFloat(2, width=-1, precision=2)
def OnOpen(self,):
self.OnCreateGrid(RS)
try:
for row,rec in enumerate(RS):
#print row
#print rec
for col,value in enumerate(rec):
self.grid.SetCellValue(row, col,“%s” % value )
self.grid.SetCellEditor(row, 2, gridlib.GridCellFloatEditor())
except:
pass
def OnExit(self,event):
self.Destroy()
if name == “main”:
app = wx.PySimpleApp()
frame = MyForm()
frame.OnOpen()
frame.Show()
app.MainLoop()
···
Il giorno giovedì 21 marzo 2013 12:44:20 UTC-4, beppe ha scritto:
hi to all
I have a problem with wx.Grid during data entry
I’ve set
self.grid.SetColFormatFloat(2, width=-1, precision=2)
and
self.grid.SetCellEditor(row, 2, gridlib.GridCellFloatEditor())
when I open the frame I’ve some cell values set to None
and in this cells I’ve to write something like 80.5 or 37.1
but when I start to write I can insert only a character like 8 or 3
when I pass on another cell and I return on the cell where I was inserting
I can insert, fynally my value 80.5 or 37.1
pratically if the value of the cell is None I can insert only a character
suggestions?
I attach a demo to reproduce the problem.
In the demo if you try to modify Azotemia, ALT and AST you can do it
but if you try to modify Glicemia or Urea you you don’t succeed in inserting more than a character
regards
beppe