Am 05.05.2016 um 15:23 schrieb john:
On 05/05/2016 01:26 AM, Sibylle Koczian wrote:
I get other Dabo problems, though, which I'll show as soon as I've got a small example.
At the moment it's only one problem: dForm.next() doesn't work with Dabo 2. Example given below.
Oh I tried all of the solutions in the link I provided. As the link suggested it's not just wxPython but almost any GTK program I ran - including gedit.
Yes, I saw it. Nothing like that with XFCE.
The only issue with just commenting out the SetBitmaps() is you will lose function. The checkbox and the icons are suppose to be there and work. That said, on production code I remove/replace the tools under the 'File' menu so I guess you don't really need the icons because the hot-key will work.
I've never yet used them, I think, so that's not a show stopper.
One other hint - I deleted all of the pyc files. After restarting and completing the re-compile I got a very noticeable increase in performance. I used 'find / -name "*.pyc" -delete.
That deletes all pyc files, my own and those belonging to Python itself, right? Should be repeated before every start of a Python application, shouldn't it? Or only after changes?
Here is my example for dForm.next, reasonably small, I hope. Clicking ">" gives this exception:
Traceback (most recent call last): File "/home/sib/src/neues_dabo2/dabo/ui/uiwx/dControlMixin.py", line 27, in _onWxHit self.raiseEvent(dEvents.Hit, evt, *args, **kwargs) File "/home/sib/src/neues_dabo2/dabo/ui/uiwx/dPemMixin.py", line 1086, in raiseEvent super(dPemMixin, self).raiseEvent(eventClass, nativeEvent, *args, **kwargs) File "/home/sib/src/neues_dabo2/dabo/lib/eventMixin.py", line 81, in raiseEvent bindingFunction(event) File "./testnumtx_sqlite.py", line 96, in onNext self.next() File "/home/sib/src/neues_dabo2/dabo/ui/uiwx/dForm.py", line 362, in next self._moveRecordPointer(bizobj.__next__, dataSource) File "/home/sib/src/neues_dabo2/dabo/ui/uiwx/dForm.py", line 271, in _moveRecordPointer response = func(*args, **kwargs) File "/home/sib/src/neues_dabo2/dabo/biz/dBizobj.py", line 359, in __next__ next(self._CurrentCursor) StopIteration
Clicking the other buttons works as expected.
SQLite database textnum.sqlite:
CREATE TABLE foo ( pkid INTEGER PRIMARY KEY, name VARCHAR(30), number INTEGER); INSERT INTO foo (name, number) VALUES ('red', 2); INSERT INTO foo (name, number) VALUES ('green', 8); INSERT INTO foo (name, number) VALUES ('yellow', 7); INSERT INTO foo (name) VALUES ('blue');
Connection file (with my path to the database):
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <connectiondefs xmlns="http://www.dabodev.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dabodev.com conn.xsd" xsi:noNamespaceSchemaLocation = "http://dabodev.com/schema/conn.xsd">
<connection dbtype="SQLite"> <name>textnum_conn</name> <host></host> <database>../../sqlite_db/textnum.sqlite</database> <user></user> <password></password> <port></port> </connection> </connectiondefs>
Dabo script:
#!/usr/bin/env python # -*- coding: utf-8 -*-
import dabo dabo.ui.loadUI("wx")
class BizFoo(dabo.biz.dBizobj):
def afterInit(self): self.DataSource = "foo" self.KeyField = "pkid" self.addFrom("foo") self.addField("pkid") self.addField("name") self.addField("number")
self.DataStructure = ( ("pkid", "I", True, "foo", "pkid"), ("name", "C", False, "foo", "name"), ("number", "I", False, "foo", "number"), )
class TestForm(dabo.ui.dForm):
def afterInit(self): self.Sizer = dabo.ui.dSizer("v") pn = dabo.ui.dPanel(self) self.Sizer.append1x(pn) pn.Sizer = vsp = dabo.ui.dSizer("v") grpn = self.makeGridPanel(pn) vsp.append1x(grpn, border=10) recpn = self.makeRecordPanel(pn) vsp.append1x(recpn, border=10) btx = self.makeButtonBox(pn) vsp.append(btx, 0, "x", border=10) self.layout()
def afterInitAll(self): self.requery()
def createBizobjs(self): self.Application.addConnectFile("textnum_sqlite.cnxml") conn = self.Application.getConnectionByName("textnum_conn") biz = BizFoo(conn) self.addBizobj(biz)
def makeGridPanel(self, parent): rpn = dabo.ui.dPanel(parent) rpn.Sizer = vs = dabo.ui.dSizer("v") gr = dabo.ui.dGrid(rpn, AlternateRowColoring=True, ColumnCount=3, SelectionMode="Row", DataSource="foo") cols = [("ID", "pkid"), ("Name", "name"), ("Number", "number")] for (i, (cpt, fld)) in enumerate(cols): gr.Columns[i].Caption = cpt gr.Columns[i].DataField = fld vs.append1x(gr) return rpn
def makeRecordPanel(self, parent): rpn = dabo.ui.dPanel(parent) rpn.Sizer = gs = dabo.ui.dGridSizer(MaxCols=2, HGap=3, VGap=3) gs.append(dabo.ui.dLabel(rpn, Caption="ID")) gs.append(dabo.ui.dTextBox(rpn, DataSource="foo", DataField="pkid", ReadOnly=True), "x") gs.append(dabo.ui.dLabel(rpn, Caption="Name")) gs.append(dabo.ui.dTextBox(rpn, DataSource="foo", DataField="name"), "x") gs.append(dabo.ui.dLabel(rpn, Caption="Number")) gs.append(dabo.ui.dTextBox(rpn, DataSource="foo", DataField="number"), "x") gs.setColExpand(True, 1) return rpn
def makeButtonBox(self, parent): rpn = dabo.ui.dPanel(parent) rpn.Sizer = hs = dabo.ui.dSizer("h") hs.append(dabo.ui.dButton(rpn, Caption="|<", OnHit=self.onFirst), "x") hs.append(dabo.ui.dButton(rpn, Caption="<", OnHit=self.onPrior), "x") hs.append(dabo.ui.dButton(rpn, Caption=">", OnHit=self.onNext), "x") hs.append(dabo.ui.dButton(rpn, Caption=">|", OnHit=self.onLast), "x") hs.append(dabo.ui.dButton(rpn, Caption="Save", OnHit=self.onSave), "x") hs.append(dabo.ui.dButton(rpn, Caption="Cancel", OnHit=self.onCancel), "x") return rpn
def onSave(self, evt): self.save()
def onCancel(self, evt): self.cancel()
def onNext(self, evt): self.next()
def onPrior(self, evt): self.prior()
def onFirst(self, evt): self.first()
def onLast(self, evt): self.last()
if __name__ == "__main__": app = dabo.dApp() app.MainFormClass = TestForm app.start()
Greetings, Sibylle