[POS-commit] Kiwi/tests/Proxies Separator.py,NONE,1.1

kiko at async.com.br kiko at async.com.br
Wed May 21 02:53:50 BRST 2003


Update of /cvs/Kiwi/tests/Proxies
In directory anthem:/tmp/cvs-serv16479/tests/Proxies

Added Files:
	Separator.py 
Log Message:
Implement Views.set_decimal_separator, and implement decimal separator
for CListDelegate. This unfortunately invovled a BIG FAT HACK to CList
itself, which is avoidable but very hard to get right (the solution is
to keep metadata organized correctly, but I'll only fix it when it bites
me). I've done the usual random testing on consave, and added a testcase
which does seem to work nicely.

The CListDelegate handling has XXXs galore. A minor cleanup was done
there (kgetattr is now called directly for fetching data).


--- NEW FILE: Separator.py ---
#!/usr/bin/env python
import sys, pprint
sys.path.insert(0, "../..")

DEBUG = 0
if len(sys.argv) > 1:
    DEBUG = 1

from mx import DateTime

from Kiwi.initgtk import gtk
from Kiwi.Proxies import Proxy
from Kiwi.FrameWork import Model
from Kiwi.Views import set_decimal_separator

class Foo(Model):
    A = 10.10

class EntryProxy(Proxy):
    widgets = [":A"]
    def __init__(self, model):
        self.set_numeric("A")
        self._build()
        Proxy.__init__(self, model, delete_handler=gtk.mainquit)
        gtk.idle_add(self.focus_topmost)

    def _build(self):
        self.win = gtk.GtkWindow()
        self.A = gtk.GtkEntry()
        self.win.add(self.A)

set_decimal_separator(",")
f = Foo()
c = EntryProxy(f)
assert c.A.get_text() == "10,1", c.A.get_text()
assert f.A == 10.1

set_decimal_separator("X")
f = Foo()
c = EntryProxy(f)
assert c.A.get_text() == "10X1", c.A.get_text()
assert f.A == 10.1

set_decimal_separator(".")
f = Foo()
c = EntryProxy(f)
assert c.A.get_text() == "10.1", c.A.get_text()
assert f.A == 10.1

set_decimal_separator("X")
f = Foo()
c = EntryProxy(f)
c.set_decimal_separator(".")
c.update("A") # Trigger view refresh
assert c.A.get_text() == "10.1", c.A.get_text()
assert f.A == 10.1

print "Separator OK"



More information about the POS-commit mailing list