I figured it out.
The documentation is inaccurate. It only gives the functions as "()" that need
to be overloaded. This is not right. They need specific signatures of
getColumnCount(WModelIndex)
getRowCount(WModelIndex)
getData(WWModelIndex, int)
________________________________
From: Jason H <scorp...@yahoo.com>
To: "witty-interest@lists.sourceforge.net"
<witty-interest@lists.sourceforge.net>
Sent: Tuesday, October 1, 2013 3:09 PM
Subject: [Wt-interest] setModel(MyModel) crashes servlet
If I don't setModel, it is happy, when I do, it crashes. I'm used to models
with Qt...
Also when developing, sometimes I get an error, sometimes I get an empty page.
Are the errors going somewhere I do not know about?
from eu.webtoolkit.jwt importWtServlet
from eu.webtoolkit.jwt importWApplication
from eu.webtoolkit.jwt importWEnvironment
from eu.webtoolkit.jwt importWText
from eu.webtoolkit.jwt importWLineEdit
from eu.webtoolkit.jwt importWPushButton
from eu.webtoolkit.jwt importWHBoxLayout
from eu.webtoolkit.jwt importWVBoxLayout
from eu.webtoolkit.jwt importWComboBox
from eu.webtoolkit.jwt importWTableView
from eu.webtoolkit.jwt importWStringListModel
from eu.webtoolkit.jwt importWModelIndex
from eu.webtoolkit.jwt importWAbstractTableModel
from eu.webtoolkit.jwt importSide
from eu.webtoolkit.jwt importWBreak
from eu.webtoolkit.jwt importSignal
from eu.webtoolkit.jwt importOrientation
classWHello(WtServlet):
defcreateApplication(self,env):
return WHelloApplication(env)
classWHelloApplication(WApplication):
def__init__(self, env):
WApplication.__init__(self,env)
self.setTitle('HBaseDemo')
hbl = self.hbl = WHBoxLayout()
self.getRoot().setLayout(hbl)
vbl = self.vbl = WVBoxLayout()
hbl.addLayout(vbl)
vbl.addWidget(WText("Table Name:"))
tc = self.tableCombo = WComboBox()
vbl.addWidget(tc)
tv = self.tableView = WTableView()
hbl.addWidget(tv)
self.dataModel = HBaseTableModel()
tables = ['test', 'dummy1', 'dummy2']
fortablein tables:
tc.addItem(table)
self.fieldCombos = []
foriin range (0,10):
self.fieldCombos.append(WComboBox())
fc = self.fieldCombos[-1]
#fc.setVisible(False)
for field in ['cf1:a', 'cf1:b', 'cf1:c']:
pass
fc.addItem(field)
#fc.selectionChanged().addListener(self,SignalWrapper(self.selectField))
vbl.addWidget(fc)
#tc.selectionChanged().addListener(self,SignalWrapper(self.selectTable))
vbl.addStretch(9)
tv.setModel(self.dataModel) ## this will crash it
defselectTable(self):
columns=['anchor', 'content']
forfc inself.fieldsCombos:
fc.setVisible(False)
self.fieldCombos[0].clear()
forcolin columns:
pass
classSignalWrapper(Signal.Listener):
def__init__(self, function):
self.function=function
deftrigger(self,*args):
self.function(*args)
class HBaseTableModel(WAbstractTableModel):
def __init__(self):
self.data = []
for y in range (0, 100):
array = []
for x in range(ord('a'), ord('z')+1):
array.append( str((y*26)+x) )
self.data.append(array)
def getColumnCount(self):
return len(self.data[0])
def getRowCount(self):
return len(self.data)
def getData(self, modelIndex):
return self.data[modelIndex.getRow()][modelIndex.getColumn()]
def getHeaderData(self, section, orientation, role):
if orientation==Orientation.Horizontal:
return chr(section+ord('a'))
else:
return str(section)
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
witty-interest mailing list
witty-interest@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/witty-interest