wxpython-users,
I am having
a problem using wx.Grid.
Depending
upon the length of the cell text, I see one or two extra lines in the cell.
GridCellAutoWrapStringRenderer() appears to be causing this problem.
Can someone explain why and is there a
solution?
Thanks,
Bruce
Below is sample code to show the problem:
import wx
import wx.grid as gridlib
using wxPython version 2.8.10.1
class GridTest(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, title="Grid Test - Merge Cells", size=(600,300))
panel = wx.Panel(self)
someGrid = gridlib.Grid(panel)
someGrid.CreateGrid(6,8)
# Cell 1,2 - OK
someGrid.SetCellFont(1, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(1, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(1, 2,"No Extra Lines")
# Cell 2,2 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(2, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(2, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(2, 2,"oops, there is an extra line")
someGrid.SetCellEditor(2, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(2, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 3,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(3, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(3, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(3, 2, 1, 2)
someGrid.SetCellValue (3, 2, "Why is there an extra line in this cell?")
someGrid.SetCellEditor(3, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(3, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 4,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra two lines in cell
someGrid.SetCellFont(4, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(4, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(4, 2, 1, 2)
someGrid.SetCellValue (4, 2, "Now this, why is there an extra two lines in this cell?")
someGrid.SetCellEditor(4, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(4, 2, gridlib.GridCellAutoWrapStringRenderer())
someGrid.AutoSizeRows(setAsMin=False)
someGrid.ForceRefresh()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(someGrid)
panel.SetSizer(sizer)
if name == “main”:
app = wx.PySimpleApp()
frame = GridTest()
frame.Show()
app.MainLoop()
wxpython-users,
I am having
a problem using wx.Grid.
Depending
upon the length of the cell text, I see one or two extra lines in the cell.
GridCellAutoWrapStringRenderer() appears to be causing this problem.
Can someone explain why and is there a
solution?
Thanks,
Bruce
Below is sample code to show the problem:
import wx
import wx.grid as gridlib
using wxPython version 2.8.10.1
class GridTest(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, title="Grid Test - Merge Cells", size=(600,300))
panel = wx.Panel(self)
someGrid = gridlib.Grid(panel)
someGrid.CreateGrid(6,8)
# Cell 1,2 - OK
someGrid.SetCellFont(1, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(1, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(1, 2,"No Extra Lines")
# Cell 2,2 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(2, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(2, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(2, 2,"oops, there is an extra line")
someGrid.SetCellEditor(2, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(2, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 3,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(3, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(3, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(3, 2, 1, 2)
someGrid.SetCellValue (3, 2, "Why is there an extra line in this cell?")
someGrid.SetCellEditor(3, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(3, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 4,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra two lines in cell
someGrid.SetCellFont(4, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(4, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(4, 2, 1, 2)
someGrid.SetCellValue (4, 2, "Now this, why is there an extra two lines in this cell?")
someGrid.SetCellEditor(4, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(4, 2, gridlib.GridCellAutoWrapStringRenderer())
someGrid.AutoSizeRows(setAsMin=False)
someGrid.ForceRefresh()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(someGrid)
panel.SetSizer(sizer)
if name == “main”:
app = wx.PySimpleApp()
frame = GridTest()
frame.Show()
app.MainLoop()
wxpython-users,
I am having
a problem using wx.Grid.
Depending
upon the length of the cell text, I see one or two extra lines in the cell.
GridCellAutoWrapStringRenderer() appears to be causing this problem.
Can someone explain why and is there a
solution?
Thanks,
Bruce
Below is sample code to show the problem:
import wx
import wx.grid as gridlib
using wxPython version 2.8.10.1
class GridTest(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, title="Grid Test - Merge Cells", size=(600,300))
panel = wx.Panel(self)
someGrid = gridlib.Grid(panel)
someGrid.CreateGrid(6,8)
# Cell 1,2 - OK
someGrid.SetCellFont(1, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(1, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(1, 2,"No Extra Lines")
# Cell 2,2 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(2, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(2, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(2, 2,"oops, there is an extra line")
someGrid.SetCellEditor(2, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(2, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 3,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(3, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(3, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(3, 2, 1, 2)
someGrid.SetCellValue (3, 2, "Why is there an extra line in this cell?")
someGrid.SetCellEditor(3, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(3, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 4,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra two lines in cell
someGrid.SetCellFont(4, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(4, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(4, 2, 1, 2)
someGrid.SetCellValue (4, 2, "Now this, why is there an extra two lines in this cell?")
someGrid.SetCellEditor(4, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(4, 2, gridlib.GridCellAutoWrapStringRenderer())
someGrid.AutoSizeRows(setAsMin=False)
someGrid.ForceRefresh()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(someGrid)
panel.SetSizer(sizer)
if name == “main”:
app = wx.PySimpleApp()
frame = GridTest()
frame.Show()
app.MainLoop()
wxpython-users,
I am having
a problem using wx.Grid.
Depending
upon the length of the cell text, I see one or two extra lines in the cell.
GridCellAutoWrapStringRenderer() appears to be causing this problem.
Can someone explain why and is there a
solution?
Thanks,
Bruce
Below is sample code to show the problem:
import wx
import wx.grid as gridlib
using wxPython version 2.8.10.1
class GridTest(wx.Frame):
def __init__(self):
wx.Frame.__init__(self, parent=None, title="Grid Test - Merge Cells", size=(600,300))
panel = wx.Panel(self)
someGrid = gridlib.Grid(panel)
someGrid.CreateGrid(6,8)
# Cell 1,2 - OK
someGrid.SetCellFont(1, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(1, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(1, 2,"No Extra Lines")
# Cell 2,2 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(2, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(2, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellValue(2, 2,"oops, there is an extra line")
someGrid.SetCellEditor(2, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(2, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 3,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra line in cell
someGrid.SetCellFont(3, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(3, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(3, 2, 1, 2)
someGrid.SetCellValue (3, 2, "Why is there an extra line in this cell?")
someGrid.SetCellEditor(3, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(3, 2, gridlib.GridCellAutoWrapStringRenderer())
# Cell 4,2&3 - Not OK when GridCellAutoWrapStringRenderer() is used, extra two lines in cell
someGrid.SetCellFont(4, 2, wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Tahoma'))
someGrid.SetCellAlignment(4, 2, wx.ALIGN_LEFT, wx.ALIGN_TOP)
someGrid.SetCellSize(4, 2, 1, 2)
someGrid.SetCellValue (4, 2, "Now this, why is there an extra two lines in this cell?")
someGrid.SetCellEditor(4, 2, gridlib.GridCellAutoWrapStringEditor())
someGrid.SetCellRenderer(4, 2, gridlib.GridCellAutoWrapStringRenderer())
someGrid.AutoSizeRows(setAsMin=False)
someGrid.ForceRefresh()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(someGrid)
panel.SetSizer(sizer)
if name == “main”:
app = wx.PySimpleApp()
frame = GridTest()
frame.Show()
app.MainLoop()
···
On Sunday, March 4, 2012 3:19:15 PM UTC-5, bruce g wrote:
On Sunday, March 4, 2012 3:19:15 PM UTC-5, bruce g wrote:
On Sunday, March 4, 2012 3:19:15 PM UTC-5, bruce g wrote:
On Sunday, March 4, 2012 3:19:15 PM UTC-5, bruce g wrote: