File: ex_63c_change_value.py

package info (click to toggle)
sqlkit 0.9.5-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 8,184 kB
  • sloc: python: 17,477; sql: 166; makefile: 95; xml: 23; sh: 11
file content (56 lines) | stat: -rw-r--r-- 1,377 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""hooks/on_change_value

On change value works differently according to the type of the widget.
varchar/integer field will invoke it for each typed char
enum/foreign key fields invoke it when the item is choosen
table's widget invoke it when editing is terminated

"""
lay = """
{|.text  varchar10   varchar200
         text        - -
         uni
         uni_text    - -
         }

{|.date
         date        time
#         datetime    datetime_tz
         datetime    
         time_tz     interval
         }

{|.numbers
         integer
         float        numeric
         }
{|.boolean
         bool         bool_null
         }
         
"""

class Hooks(object):

    def on_change_value__text(self, sqlwidget, field_name, value, fkvalue, field):
        print "Changed: ", sqlwidget, field_name, value, fkvalue

    on_change_value__varchar10 = \
    on_change_value__date = \
    on_change_value__time = \
    on_change_value__datetime = \
    on_change_value__integer = \
    on_change_value__float = \
    on_change_value__numeric = \
    on_change_value__bool = \
    on_change_value__bool_null = on_change_value__text

t = SqlMask(model.AllTypes, layout=lay, dbproxy=db, hooks=Hooks() )

for name in ('text','date', 'numbers', 'boolean'):
    t.set_frame_label(name, name)
t.reload()


t1 = SqlTable(model.AllTypes, dbproxy=db, hooks=Hooks() )
t1.reload()