summaryrefslogtreecommitdiff
path: root/gr-wxgui/src/python/slider.py
diff options
context:
space:
mode:
authorManoj Gudi2013-10-07 20:19:55 +0530
committerManoj Gudi2013-10-07 20:20:35 +0530
commit1826d0763c8595997f5f4af1fdb0354e9c0998ad (patch)
treeacbd852cd5a1bf17241b1038b5e37a0e72e64612 /gr-wxgui/src/python/slider.py
parent452defdb4a78e9e826740ddf4b9673e926c568a4 (diff)
parent24b640997ba7fee0c725e65f401f5cbebdab8d08 (diff)
downloadgnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.gz
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.tar.bz2
gnuradio-1826d0763c8595997f5f4af1fdb0354e9c0998ad.zip
README change
Diffstat (limited to 'gr-wxgui/src/python/slider.py')
-rw-r--r--gr-wxgui/src/python/slider.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/gr-wxgui/src/python/slider.py b/gr-wxgui/src/python/slider.py
new file mode 100644
index 000000000..e8cdcfcac
--- /dev/null
+++ b/gr-wxgui/src/python/slider.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+
+import wx
+
+def slider(parent, min, max, callback):
+ """
+ Return a wx.Slider object.
+
+ @param min: minimum slider value
+ @type min: float
+ @param max: maximum slider value
+ @type max: float
+ @param callback: function of one arg invoked when slider moves.
+ @rtype: wx.Slider
+ """
+ new_id = wx.NewId()
+ s = wx.Slider(parent, new_id, (max+min)/2, min, max, wx.DefaultPosition,
+ wx.Size(250,-1), wx.SL_HORIZONTAL | wx.SL_LABELS)
+ wx.EVT_COMMAND_SCROLL(parent, new_id,
+ lambda evt : callback(evt.GetInt()))
+ return s
+
+
+# ----------------------------------------------------------------
+# Demo app
+# ----------------------------------------------------------------
+if __name__ == '__main__':
+
+ from gnuradio.wxgui import stdgui
+
+ class demo_graph(stdgui.gui_flow_graph):
+
+ def __init__(self, frame, panel, vbox, argv):
+ stdgui.gui_flow_graph.__init__ (self, frame, panel, vbox, argv)
+
+ vbox.Add(slider(panel, 23, 47, self.my_callback1), 1, wx.ALIGN_CENTER)
+ vbox.Add(slider(panel, -100, 100, self.my_callback2), 1, wx.ALIGN_CENTER)
+
+ def my_callback1(self, val):
+ print "cb1 = ", val
+
+ def my_callback2(self, val):
+ print "cb2 = ", val
+
+ def main ():
+ app = stdgui.stdapp (demo_graph, "Slider Demo")
+ app.MainLoop ()
+
+ main ()