File tree 1 file changed +25
-1
lines changed 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
2
Core Python sources of the pyframebuffer module.
3
3
"""
4
+ import functools
4
5
from pyframebuffer .color import getColorValue
5
6
6
7
import _pyfb as fb # type: ignore
7
8
8
- __all__ = ["openfb" , "MAX_FRAMEBUFFERS" ]
9
+ __all__ = ["openfb" , "MAX_FRAMEBUFFERS" , "fbuser" ]
9
10
MAX_FRAMEBUFFERS = fb .MAX_FRAMEBUFFERS
10
11
11
12
@@ -204,3 +205,26 @@ def openfb(num):
204
205
@return The Framebuffer object
205
206
"""
206
207
return Framebuffer (fbnum = num )
208
+
209
+
210
+ def fbuser (fn ):
211
+ """
212
+ Decorator to open a framebuffer via the Decorator API.
213
+
214
+ @param fn The function to wrap
215
+
216
+ @return The wrapper function
217
+ """
218
+ @functools .wraps (fn )
219
+ def wrapper (* args , ** kwargs ):
220
+ argl = list (args )
221
+ fbnum = argl [0 ]
222
+ ret_val = None
223
+ with openfb (fbnum ) as fb_obj :
224
+ argl [0 ] = fb_obj
225
+ args = tuple (argl )
226
+ ret_val = fn (* args , ** kwargs )
227
+
228
+ return ret_val
229
+
230
+ return wrapper
You can’t perform that action at this time.
0 commit comments