summaryrefslogtreecommitdiff
path: root/efl/ecore/efl.ecore_timer.pxi
diff options
context:
space:
mode:
authorDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
committerDavide Andreoli <dave@gurumeditation.it>2013-02-11 22:32:50 +0000
commit8b8639886059814a36f57164d5572e97bcb00a47 (patch)
tree1c5a170de002793c1402d6afcc16c63115d81caa /efl/ecore/efl.ecore_timer.pxi
Put in a first, still wip, version of the python bindings in a merged tree.
This is meant to be the 1.8 version of the wrappers and will include everything that now is in the python folder. Atm this include evas, ecore, edje, elementary and emotion (emotion still commented in the build couse it need some more testing). Eo is used as a base for all the objects that inherit from it in C, but in real nothing is used from Eo, it is used more like a container to share code between the libs. All the docs has been stripped out because we want to use the new sphinx style docs that Kay has done in his git repo. (Kay: please wait a little bit to include it, as working on the libs without docs is much more easy) The new wrappers include a new container module called efl and thus you can live with both the old and the new installation. This also means that you need to import the new modules as: "from efl import evas" (instead of the old "import evas") The idea here is that you can make your code works with both version doing something like: try: import evas except: from efl import evas ...like is done in the gtk bindings Some stuff has been leaved out on purpose, because was old stuff (like the hacked evas rotation stuff) or because was not working as expected (like all the ecore.evas.XXX modules). See the TODO.txt file for more info. Probably some stuff is out just because I missed them, let me know if you miss something. Improvements from the old version: - Py3 compatible (still some work to be done, but really only TODO, no problems to resolv) - Should also works on other platforms, like windoz (but not tested) - Unittests greatly improved, you can also run ALL tests at once - much more simpler :) I will contine the works in the next weeks and hope someone will help too. NOTE: I switched back to setup.py instead of autotools, because that is the right way to compile python stuff. So to build just use: python setup.py install or python3 setup.py install Enjoy davemds SVN revision: 83831
Diffstat (limited to 'efl/ecore/efl.ecore_timer.pxi')
-rw-r--r--efl/ecore/efl.ecore_timer.pxi91
1 files changed, 91 insertions, 0 deletions
diff --git a/efl/ecore/efl.ecore_timer.pxi b/efl/ecore/efl.ecore_timer.pxi
new file mode 100644
index 0000000..5c2b701
--- /dev/null
+++ b/efl/ecore/efl.ecore_timer.pxi
@@ -0,0 +1,91 @@
1# Copyright (C) 2007-2013 Gustavo Sverzut Barbieri, Ulisses Furquim
2#
3# This file is part of Python-Ecore.
4#
5# Python-Ecore is free software; you can redistribute it and/or
6# modify it under the terms of the GNU Lesser General Public
7# License as published by the Free Software Foundation; either
8# version 2.1 of the License, or (at your option) any later version.
9#
10# Python-Ecore is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# Lesser General Public License for more details.
14#
15# You should have received a copy of the GNU Lesser General Public License
16# along with this Python-Ecore. If not, see <http://www.gnu.org/licenses/>.
17
18# This file is included verbatim by efl.ecore.pyx
19
20
21cdef class Timer(Eo):
22 def __init__(self, double interval, func, *args, **kargs):
23 if not callable(func):
24 raise TypeError("Parameter 'func' must be callable")
25 self.func = func
26 self.args = args
27 self.kargs = kargs
28 self._set_obj(ecore_timer_add(interval, _ecore_task_cb, <void *>self))
29
30 def __str__(self):
31 return "%s Timer(func=%s, args=%s, kargs=%s)" % (Eo.__str__(self),
32 self.func, self.args, self.kargs)
33
34 def __repr__(self):
35 return "%s Timer(interval=%f, func=%s, args=%s, kargs=%s)" % (Eo.__repr__(self),
36 self.interval if self.obj else -1.0,
37 self.func, self.args, self.kargs)
38
39 cpdef object _task_exec(self):
40 return self.func(*self.args, **self.kargs)
41
42 def delete(self):
43 ecore_timer_del(self.obj)
44
45 def stop(self):
46 self.delete()
47
48 def freeze(self):
49 ecore_timer_freeze(self.obj)
50
51 def thaw(self):
52 ecore_timer_thaw(self.obj)
53
54 def interval_set(self, double t):
55 ecore_timer_interval_set(self.obj, t)
56
57 def interval_get(self):
58 return ecore_timer_interval_get(self.obj)
59
60 property interval:
61 def __get__(self):
62 return ecore_timer_interval_get(self.obj)
63
64 def __set__(self, double t):
65 ecore_timer_interval_set(self.obj, t)
66
67 def delay(self, double add):
68 ecore_timer_delay(self.obj, add)
69
70 def reset(self):
71 ecore_timer_reset(self.obj)
72
73 def ecore_timer_pending_get(self):
74 ecore_timer_pending_get(self.obj)
75
76 property pending:
77 def __get__(self):
78 return ecore_timer_pending_get(self.obj)
79
80
81def timer_add(double t, func, *args, **kargs):
82 return Timer(t, func, *args, **kargs)
83
84
85def timer_precision_get():
86 return ecore_timer_precision_get()
87
88
89def timer_precision_set(double value):
90 ecore_timer_precision_set(value)
91