author | Radek Brich <radek.brich@devl.cz> |
Sun, 27 Jan 2013 23:51:59 +0100 | |
changeset 70 | db2eab0beb45 |
parent 64 | 03f591f5fe5c |
child 73 | 85a282b5e4fc |
permissions | -rw-r--r-- |
0 | 1 |
# -*- coding: utf-8 -*- |
2 |
||
43
369c8ef5070a
Rename emitter module to events.
Radek Brich <radek.brich@devl.cz>
parents:
41
diff
changeset
|
3 |
from tuikit.events import Emitter, Event, DrawEvent, FocusEvent, KeyboardEvent, MouseEvent |
18
e6c3a5ee91aa
Eliminate relative imports.
Radek Brich <radek.brich@devl.cz>
parents:
16
diff
changeset
|
4 |
from tuikit.common import Coords, Size |
0 | 5 |
|
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
6 |
import logging |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
7 |
|
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
8 |
|
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
9 |
class Widget(Emitter): |
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
10 |
|
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
11 |
'''Base class for all widgets.''' |
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
12 |
|
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
13 |
def __init__(self): |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
14 |
#: Widget name is used for logging etc. Not visible anywhere. |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
15 |
self.name = None |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
16 |
|
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
17 |
#: Parent widget. |
0 | 18 |
self.parent = None |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
19 |
|
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
20 |
#: Top widget (same for every widget in one application). |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
21 |
self._top = None |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
22 |
|
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
23 |
#: Floating widget |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
24 |
self.floater = False |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
25 |
|
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
26 |
### placing and size |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
27 |
# Position inside parent widget. Modified by layout manager. |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
28 |
self._pos = Coords() |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
29 |
# Actual size. Modified only by layout manager. |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
30 |
self._size = Size(10, 10) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
31 |
self._size.add_handler('change', lambda ev: self.emit('resize')) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
32 |
#: Default (natural) size of Widget. |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
33 |
self._default_size = Size(1, 1) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
34 |
self._default_size.add_handler('change', lambda ev: self._sizereq.update(self._default_size)) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
35 |
#: Size request. Equals to default size, unless changed by user. |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
36 |
#: Size request will be fulfilled by layout manager when possible. |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
37 |
self._sizereq = Size(1, 1) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
38 |
self._sizereq.add_handler('change', lambda ev: self.emit('sizereq')) |
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
39 |
#: Minimal size of widget. Under normal circumstances |
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
40 |
#: widget will never be sized smaller than this. |
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
41 |
#: Tuple (w, h). Both must be integers >= 1. |
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
39
diff
changeset
|
42 |
self.sizemin = Size(1, 1) |
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
43 |
#: Maximum size of widget. Widget will never be sized bigger than this. |
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
44 |
#: Tuple (w, h). Integers >= 1 or None (meaning no maximum size or infinite). |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
45 |
self.sizemax = Size(None, None) |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
46 |
|
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
47 |
|
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
48 |
#: Allow keyboard focus for this widget. |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
49 |
self.allow_focus = False |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
50 |
|
15 | 51 |
#: Dictionary containing optional parameters for layout managers etc. |
52 |
self.hints = {} |
|
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
53 |
|
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
54 |
#: Hidden widget does not affect layout. |
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
55 |
self.hidden = False |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
56 |
|
44
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
57 |
#: Cursor is position where text input will occur, |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
58 |
#: i.e. classic blinking cursor in console. |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
59 |
#: None means no cursor (hidden). |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
60 |
self.cursor = None |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
61 |
|
44
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
62 |
# See spot property. |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
63 |
self._spot = Coords() |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
64 |
|
0 | 65 |
# redraw request |
66 |
self._redraw = True |
|
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
67 |
|
0 | 68 |
# event handlers |
32
088b92ffb119
Clean up, refactoring. Rename EventSource to Emitter, begin merging emit() method with handle().
Radek Brich <radek.brich@devl.cz>
parents:
18
diff
changeset
|
69 |
self.add_events( |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
70 |
'resize', Event, |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
71 |
'draw', DrawEvent, |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
72 |
'keypress', KeyboardEvent, |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
73 |
'mousedown', MouseEvent, |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
74 |
'mouseup', MouseEvent, |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
75 |
'mousemove', MouseEvent, |
44
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
76 |
'mousewheel', MouseEvent, |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
77 |
'sizereq', Event, |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
78 |
'spotmove', Event, |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
79 |
'focus', FocusEvent, |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
80 |
'unfocus', FocusEvent) |
0 | 81 |
|
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
82 |
### placing and size |
0 | 83 |
|
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
84 |
@property |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
85 |
def x(self): |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
86 |
return self._pos.x |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
87 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
88 |
@property |
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
89 |
def y(self): |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
90 |
return self._pos.y |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
91 |
|
64
03f591f5fe5c
Drop Container.offset, add special layout for that - OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
63
diff
changeset
|
92 |
def move(self, x=None, y=None): |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
93 |
if self.floater: |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
94 |
self._pos.update(x, y) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
95 |
if self.parent: |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
96 |
self.parent.move_child(self, x, y) |
16
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
97 |
|
8791a7da6835
Update VerticalLayout/HorizontalLayout. Add layout demo. Add Size, Borders to common. Update Coords, Rect.
Radek Brich <radek.brich@devl.cz>
parents:
15
diff
changeset
|
98 |
@property |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
99 |
def width(self): |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
100 |
return self._size.w |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
101 |
|
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
102 |
@property |
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
103 |
def height(self): |
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
104 |
return self._size.h |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
105 |
|
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
106 |
def resize(self, w=None, h=None): |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
107 |
"""Set size request. |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
108 |
|
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
109 |
It's up to parent container if request will be fulfilled. |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
110 |
|
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
111 |
""" |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
112 |
self._sizereq.update(w, h) |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
113 |
|
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
39
diff
changeset
|
114 |
@property |
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
39
diff
changeset
|
115 |
def sizereq(self): |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
116 |
"""Size request. |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
117 |
|
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
118 |
This is default size of the widget. Will be fulfilled if possible. |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
119 |
Size(w, h). Integers >= 1 or None (meaning use minumal size). |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
120 |
|
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
121 |
""" |
40
5faa38c10b67
Add ScrollView widget. Update Emitter, rename "on_event" methods to "_handle_event". Update VScrollbar, Layout.
Radek Brich <radek.brich@devl.cz>
parents:
39
diff
changeset
|
122 |
return self._sizereq |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
123 |
|
62
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
124 |
def on_sizereq(self, ev): |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
125 |
# floater is not managet by layout, |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
126 |
# always set its size to sizereq |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
127 |
if self.floater: |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
128 |
logging.getLogger('tuikit').info('xy') |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
129 |
self._size.update(self._sizereq) |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
130 |
|
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
131 |
### misc |
2f61931520c9
Rework layouts: Layout is now normal Container which places its children upon resize event.
Radek Brich <radek.brich@devl.cz>
parents:
59
diff
changeset
|
132 |
|
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
133 |
@property |
44
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
134 |
def spot(self): |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
135 |
"""Spot of visibility. |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
136 |
|
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
137 |
This is one point which should be always visible. |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
138 |
It affects scrolling (moving spot in widget placed in ScrollView scrolls the view). |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
139 |
|
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
140 |
""" |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
141 |
return self._spot |
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
142 |
|
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
143 |
|
d77f1ae3786c
Add Widget.spot property. TreeView: move spot with cursor node. ScrollView: scroll when spot moves.
Radek Brich <radek.brich@devl.cz>
parents:
43
diff
changeset
|
144 |
@property |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
145 |
def top(self): |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
146 |
"""Top widget (same for every widget in one application).""" |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
147 |
return self._top |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
148 |
|
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
149 |
@top.setter |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
150 |
def top(self, value): |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
151 |
self._set_top(value) |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
152 |
|
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
153 |
def _set_top(self, value): |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
154 |
"""Real setter for top. Allows override.""" |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
155 |
self._top = value |
0 | 156 |
|
157 |
||
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
158 |
### events |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
159 |
|
0 | 160 |
def redraw(self, parent=True): |
161 |
self._redraw = True |
|
162 |
if parent and self.parent: |
|
163 |
self.parent._redraw = True |
|
164 |
||
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
165 |
def draw(self, driver, x, y): |
36 | 166 |
"""Draw the widget. |
167 |
||
168 |
This method should not be overriden by subclasses, |
|
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
44
diff
changeset
|
169 |
use on_draw method instead. |
36 | 170 |
|
171 |
""" |
|
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
172 |
if self.hidden: |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
173 |
return True |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
174 |
|
70
db2eab0beb45
Update drivers: Rename setcolor to defcolor, add real setcolor which ignores color stack.
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
175 |
driver.clipstack.push(x, y, self.width, self.height) |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
176 |
self.emit('draw', driver, x, y) |
70
db2eab0beb45
Update drivers: Rename setcolor to defcolor, add real setcolor which ignores color stack.
Radek Brich <radek.brich@devl.cz>
parents:
64
diff
changeset
|
177 |
driver.clipstack.pop() |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
178 |
|
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
179 |
if self.has_focus(): |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
180 |
if self.cursor: |
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
181 |
cx, cy = self.cursor |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
182 |
driver.showcursor(x + cx, y + cy) |
5
ae128c885d0f
New GridLayout. Change cursor behavior (hide on unfocus event). Change resize event to propagate through containers. Change container clipping - allowlayout=false children are clipped without borders. More Widget doc.
Radek Brich <radek.brich@devl.cz>
parents:
2
diff
changeset
|
183 |
else: |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
184 |
driver.hidecursor() |
0 | 185 |
|
45
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
44
diff
changeset
|
186 |
def on_mousedown(self, ev): |
43b2279b06e1
Clean up Emitter class, simplify event handling. Fix Container.focusnext() method. Add events test (handler auto-registration, order).
Radek Brich <radek.brich@devl.cz>
parents:
44
diff
changeset
|
187 |
self.grab_focus() |
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
188 |
|
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
189 |
|
0 | 190 |
### focus |
191 |
||
192 |
||
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
193 |
def can_focus(self): |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
194 |
return not self.hidden and self.allow_focus |
0 | 195 |
|
196 |
||
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
197 |
def has_focus(self): |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
198 |
if self.parent is None: |
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
199 |
return True |
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
200 |
return (self.parent.has_focus() \ |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
201 |
and self.parent.focuschild == self) |
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
202 |
|
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
203 |
def set_focus(self): |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
204 |
"""Focus the widget. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
205 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
206 |
This changes focus state of parent widget, |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
207 |
but it does not check if parent widget actually |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
208 |
has focus. It still works if it has not, |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
209 |
but keyboard events will go to really focused widget, |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
210 |
not this one. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
211 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
212 |
See also grab_focus() which cares about parents. |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
213 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
214 |
""" |
63
2a0e04091898
Rework MenuBar. Add MenuButton. Add mouse event cascading to floaters.
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
215 |
if self.parent is None: |
2a0e04091898
Rework MenuBar. Add MenuButton. Add mouse event cascading to floaters.
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
216 |
return |
2a0e04091898
Rework MenuBar. Add MenuButton. Add mouse event cascading to floaters.
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
217 |
if not self.can_focus() or self.parent.focuschild == self: |
1
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
218 |
return |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
219 |
oldfocuschild = self.parent.focuschild |
34
e3beacd5e536
Update event propagation, keypress event, focusing.
Radek Brich <radek.brich@devl.cz>
parents:
33
diff
changeset
|
220 |
self.parent.focuschild = self |
41
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
221 |
if oldfocuschild: |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
222 |
oldfocuschild.emit('unfocus', new=self) |
37b7dfc3eae6
Update Emitter: All event handlers now have exactly one argument: object inherited from Event class, which carries any data.
Radek Brich <radek.brich@devl.cz>
parents:
40
diff
changeset
|
223 |
self.emit('focus', old=oldfocuschild) |
0 | 224 |
|
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
225 |
def grab_focus(self): |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
226 |
"""Focus the widget and its parents.""" |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
227 |
if self.parent and not self.parent.has_focus(): |
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
228 |
self.parent.grab_focus() |
63
2a0e04091898
Rework MenuBar. Add MenuButton. Add mouse event cascading to floaters.
Radek Brich <radek.brich@devl.cz>
parents:
62
diff
changeset
|
229 |
self.set_focus() |
38
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
230 |
|
c6e170452c7f
Documentation, fix names of focus methods.
Radek Brich <radek.brich@devl.cz>
parents:
36
diff
changeset
|
231 |
|
9
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
232 |
### |
7175ed629a76
Added ComboBox, HorizontalLayout, TreeNode, TreeModel, TreeView. Widget is now descendant of EventSource. Improved color management (color prefixes).
Radek Brich <radek.brich@devl.cz>
parents:
5
diff
changeset
|
233 |
|
0 | 234 |
def enclose(self, x, y): |
235 |
if self.hidden: |
|
236 |
return False |
|
237 |
if x < self.x or y < self.y \ |
|
238 |
or x >= self.x + self.width or y >= self.y + self.height: |
|
239 |
return False |
|
240 |
return True |
|
241 |
||
242 |
||
243 |
def screentest(self, y, x): |
|
244 |
sy, sx = self.screenyx() |
|
245 |
if y < sy or x < sx or y >= sy + self.height or x >= sx + self.width: |
|
246 |
return False |
|
247 |
return True |
|
248 |
||
249 |
||
250 |
def screenyx(self): |
|
251 |
if self.parent: |
|
252 |
y,x = self.parent.screenyx() |
|
253 |
return self.y + y, self.x + x |
|
254 |
return self.y, self.x |
|
1
69318aba22bf
Menu development. New focus. Easier imports from tuikit package.
Radek Brich <radek.brich@devl.cz>
parents:
0
diff
changeset
|
255 |
|
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
256 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
257 |
def hide(self): |
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
258 |
'''Hide widget. Convenience method.''' |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
259 |
self.hidden = True |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
260 |
self.redraw() |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
261 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
262 |
|
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
263 |
def show(self): |
13
19ebde2fd594
Add more generated documentation.
Radek Brich <radek.brich@devl.cz>
parents:
9
diff
changeset
|
264 |
'''Show widget. Convenience method.''' |
2
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
265 |
self.hidden = False |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
266 |
self.redraw() |
684cdc352562
Menu, Window and other improvements.
Radek Brich <radek.brich@devl.cz>
parents:
1
diff
changeset
|
267 |
|
64
03f591f5fe5c
Drop Container.offset, add special layout for that - OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
63
diff
changeset
|
268 |
def bring_up(self): |
03f591f5fe5c
Drop Container.offset, add special layout for that - OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
63
diff
changeset
|
269 |
if self.parent: |
03f591f5fe5c
Drop Container.offset, add special layout for that - OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
63
diff
changeset
|
270 |
self.parent.bring_up_child(self) |
03f591f5fe5c
Drop Container.offset, add special layout for that - OffsetLayout.
Radek Brich <radek.brich@devl.cz>
parents:
63
diff
changeset
|
271 |
|
59 | 272 |
|
273 |
## timeout ## |
|
274 |
||
275 |
def add_timeout(self, delay, callback): |
|
276 |
"""Register callback to be called after delay seconds. |
|
277 |
||
278 |
delay -- in seconds, float |
|
279 |
callback -- function to be called with no parameters |
|
280 |
||
281 |
""" |
|
282 |
self.top.timer.add_timeout(delay, callback) |
|
283 |
||
284 |
def remove_timeout(self, callback): |
|
285 |
"""Unregister callback previously registered with add_timeout.""" |
|
286 |
self.top.timer.remove_timeout(callback) |
|
287 |