-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.py
49 lines (39 loc) · 1.47 KB
/
template.py
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
#! python3
"""Template of Layer.
"""
import cv2
import wx
from mwx.controls import LParam
from mwx.graphman import Layer
class Plugin(Layer):
"""Plugin template ver.1
"""
menukey = "Plugins/&Templates/&template ver.1"
category = "Test"
caption = True
def Init(self):
self.ksize = LParam("ksize", (1,99,2), 13) # kernel window size
self.btn = wx.Button(self, label="Run", size=(-1,22))
self.btn.Bind(wx.EVT_BUTTON, lambda v: self.run())
self.layout(
(self.ksize, self.btn), # the list of objects stacked with the following style:
title="Gaussian blur", # subtitle of this layout group. otherwise None (no box)
row=1, expand=0, show=1, # grouping style: row means the horizontal stack size
type='vspin', # control type: slider[*], [hv]spin, choice
style='chkbox', # control style: None, chkbox, button
cw=-1, lw=36, tw=30 # w: width of [c]ontrol, [l]abel, [t]ext
)
## def Destroy(self):
## return Layer.Destroy(self)
def run(self):
k = self.ksize.value
src = self.graph.buffer
if src is None:
self.message("- No buffer")
return
dst = cv2.GaussianBlur(src, (k, k), 0.)
self.output.load(dst, name="*gauss*")
if __name__ == "__main__":
from mwx.testsuite import *
with Plugman() as frm:
frm.load_plug(Plugin, show=1)