Anybody knows what is wrong with this script?

Hi everybody!

I would like to know why my script doesn´t work, I am really lost!...Thank
you very much! : )

from wxPython.wx import *
from wxPython.lib.mixins.listctrl import wxColumnSorterMixin,
wxListCtrlAutoWidthMixin

class MainWindow(wxFrame):
    def __init__(self,parent,id):

        wxFrame.__init__(self,parent,-4, "SirFinder",size =
(500,250),style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
        self.CenterOnScreen()
        #self.panelA = wxWindow(self, -1, wxPyDefaultPosition,
wxPyDefaultSize, wxSIMPLE_BORDER)

        datosLista={1:("Elemento1", "Elemento2"),2:("ElementoA",
"ElementoB"),}

        self.lista = wxListCtrl(self)
        self.lista.InsertColumn(0, "PrimeraColumna")
        self.lista.InsertColumn(1, "SegundaColumna")

        items=datosLista.items()
        for x in range(len(items)):
            key, data = items[x]
            self.lista.SetStringItem(x,0,data[0])
            self.lista.SetStringItem(x,2,data[1])
            self.lista.SetItemData(x,key)

        self.lista.SetColumnWidth(0, wxLIST_AUTOSIZE)
        self.lista.SetColumnWidth(1, wxLIST_AUTOSIZE)

        self.currentItem = 0

#Programa de prueba

···

#-----------------------------
app = wxPySimpleApp()
frame = MainWindow(None, -1)
frame.Show(1)
app.MainLoop()

Mar Castillo
email: mcastillo@genomica.es

Hi Mar,

The demo is your friend, looking at your code it looks like the "listctrl" demo under Core Windows/Controls is what you are looking for.

See you
Werner

Mar Castillo wrote:

···

Hi everybody!

I would like to know why my script doesn´t work, I am really lost!...Thank
you very much! : )

from wxPython.wx import *
from wxPython.lib.mixins.listctrl import wxColumnSorterMixin,
wxListCtrlAutoWidthMixin

class MainWindow(wxFrame):
   def __init__(self,parent,id):

       wxFrame.__init__(self,parent,-4, "SirFinder",size =
(500,250),style=wxDEFAULT_FRAME_STYLE|wxNO_FULL_REPAINT_ON_RESIZE)
       self.CenterOnScreen()
       #self.panelA = wxWindow(self, -1, wxPyDefaultPosition,
wxPyDefaultSize, wxSIMPLE_BORDER)

       datosLista={1:("Elemento1", "Elemento2"),2:("ElementoA",
"ElementoB"),}

       self.lista = wxListCtrl(self)
       self.lista.InsertColumn(0, "PrimeraColumna")
       self.lista.InsertColumn(1, "SegundaColumna")

       items=datosLista.items()
       for x in range(len(items)):
           key, data = items
           self.lista.SetStringItem(x,0,data[0])
           self.lista.SetStringItem(x,2,data[1])
           self.lista.SetItemData(x,key)

       self.lista.SetColumnWidth(0, wxLIST_AUTOSIZE)
       self.lista.SetColumnWidth(1, wxLIST_AUTOSIZE)

       self.currentItem = 0

#Programa de prueba
#-----------------------------
app = wxPySimpleApp()
frame = MainWindow(None, -1)
frame.Show(1)
app.MainLoop()

Mar Castillo
email: mcastillo@genomica.es

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org

Mar Castillo wrote:

Hi everybody!

I would like to know why my script doesn´t work, I am really lost!...Thank
you very much! : )

I think the traceback is clear enough. You need to use the wxLC_REPORT style.

Traceback (most recent call last):
   File "tmp/test/mar.py", line 32, in ?
     frame = MainWindow(None, -1)
   File "tmp/test/mar.py", line 14, in __init__
     self.lista.InsertColumn(0, "PrimeraColumna")
   File "/usr/lib/python2.3/site-packages/wxPython/controls2.py", line 613, in InsertColumn
     val = controls2c.wxListCtrl_InsertColumn(self, *_args, **_kwargs)
wxPython.wxc.wxPyAssertionError: C++ assertion "wxAssertFailure" failed in /usr/src/redhat/BUILD/wxPythonSrc-2.4.2.4/src/generic/listctrl.cpp(5179): can't add column in non report mode

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!