wx.griwx Float Editor fail when a cell value is None

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

beppe wrote:

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

The attachment is missing.

···

--
Robin Dunn
Software Craftsman

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

Fynally…the demo attached…

simpleapp.py (1.89 KB)

···

Il giorno giovedì 21 marzo 2013 17:44:20 UTC+1, 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

beppe wrote:

    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

Fynally...the demo attached...

wx._core.PyAssertionError: C++ assertion "Assert failure" failed at /BUILD/wxPython-src-2.9.5.0.b20121231/src/generic/grideditors.cpp(910) in BeginEdit(): this cell doesn't have float value

The GridCellFloatEditor doesn't know how to deal with a "None" string value, which shouldn't be too surprising. You can use an empty string value for those cells instead.

···

Il giorno gioved� 21 marzo 2013 17:44:20 UTC+1, beppe ha scritto:

--
Robin Dunn
Software Craftsman

Beppe,

> 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

If you plan on writing an electronic medical record using
wxPython you might want to take a look at GNUmed

  http://www.gnumed.de

Karsten

···

--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346

Thanks I ve resolve using ifnull function in the query that retrive my recordset and now it works fine.Yes I am working with a research team that focused its efforts on the study of skin limphome writing an application like a lims and I know Gnumed that is inspiration for my work.