problems with wxGrid in wxPython

Problems on Windows
Configuration: Windows 2000, wxPython 2.5.3.1, Python 2.3.4

In Windows wxGrid cannot handle unicode text and fails with an exception.


Traceback (most recent call last):
File "grid_test.py", line 37, in ?
app = TestGUI(0)
File "D:\Progs\PYTHON~1\Lib\site-packages\wx-2.5.3-msw-unicode\wx\_core.py", line 5301, in __init__
self._BootstrapApp()
File "D:\Progs\PYTHON~1\Lib\site-packages\wx-2.5.3-msw-unicode\wx\_core.py", line 4980, in _BootstrapApp
return _core_.PyApp__BootstrapApp(*args, **kwargs)
File "grid_test.py", line 32, in OnInit
frame = TestMainFrame()
File "grid_test.py", line 16, in __init__
grid.SetCellValue(0, 0, u'Piet\u016bs'.encode('UTF-8 '))
File "D:\Progs\PYTHON~1\Lib\site-packages\wx-2.5.3-msw-unicode\wx\grid.py", line 1896, in SetCellValue
return _grid.Grid_SetCellValue(*args, **kwargs)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 4: ordinal not in range(128)


Problems on Linux
Configuration: Debian, Python 2.3.5, wxpython 2.5.3.2
LC_CTYPE=en_US.UTF-8

This were I get strange behaviour. The text in a grid is displayed fine using the default font. As soon as I make any modification to the font the text is no longer displayed correctly.

Link to test program: http://bro1.centras.info/temppy/grid_test.py

Test program listing

from wxPython.wx import *
from wxPython.html import *
from wxPython.grid import *


class TestMainFrame(wxFrame):

def __init__(self):

wxFrame.__init__(self, None, -1, "Test grid", size = wxSize(400, 500))
wxGrid(self, -1)
sizer = wxFlexGridSizer(2, 1)
grid = wxGrid(self, -1, size = (500, 400))
grid.CreateGrid(1, 1)
b = wxButton(self, 1, "Change font")
grid.SetCellValue(0, 0, u'Piet\u016bs'.encode('UTF-8 '))
sizer.Add(grid)
sizer.Add(b)
self.SetSizer(sizer)
sizer.Fit(self)
EVT_BUTTON(self, 1, self.OnFont)
self.grid = grid

def OnFont(self, event):
myfont = self.grid.GetCellFont(0, 0)
myfont.SetUnderlined(True)
self.grid.SetCellFont(0, 0, myfont)
self.grid.ForceRefresh()

class TestGUI(wxApp):
def OnInit(self):
frame = TestMainFrame()
frame.Show(True)
self.SetTopWindow(frame)
return True

app = TestGUI(0)
app.MainLoop()

Komentarai

Populiarūs šio tinklaraščio įrašai

Rinkimai - aš unikalus balsuotojas