[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7800 - in grc/branches/grc_reloaded: . scripts src/gr
From: |
jblum |
Subject: |
[Commit-gnuradio] r7800 - in grc/branches/grc_reloaded: . scripts src/grc src/grc/platforms/gnuradio_python src/grc/platforms/gnuradio_python/blocks/variables src/grc/platforms/gnuradio_python/data src/grc_gnuradio/wxgui |
Date: |
Sat, 23 Feb 2008 16:15:05 -0700 (MST) |
Author: jblum
Date: 2008-02-23 16:15:05 -0700 (Sat, 23 Feb 2008)
New Revision: 7800
Modified:
grc/branches/grc_reloaded/scripts/grc
grc/branches/grc_reloaded/setup.py
grc/branches/grc_reloaded/src/grc/Constants.py
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/no_gui.tmpl
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl
grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/Controls.py
Log:
wxgui controls
Modified: grc/branches/grc_reloaded/scripts/grc
===================================================================
--- grc/branches/grc_reloaded/scripts/grc 2008-02-23 20:40:03 UTC (rev
7799)
+++ grc/branches/grc_reloaded/scripts/grc 2008-02-23 23:15:05 UTC (rev
7800)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/python
"""
Copyright 2008 Free Software Foundation, Inc.
This file is part of GNU Radio
Modified: grc/branches/grc_reloaded/setup.py
===================================================================
--- grc/branches/grc_reloaded/setup.py 2008-02-23 20:40:03 UTC (rev 7799)
+++ grc/branches/grc_reloaded/setup.py 2008-02-23 23:15:05 UTC (rev 7800)
@@ -26,18 +26,17 @@
VERSION = __import__('src/grc/Constants').VERSION
PACKAGES=[
-'grc',
-'grc.elements',
-'grc.gui',
-'grc.gui.elements',
-'grc.platforms',
-'grc.platforms.gnuradio_python',
+ 'grc',
+ 'grc.elements',
+ 'grc.gui',
+ 'grc.gui.elements',
+ 'grc.platforms',
+ 'grc.platforms.gnuradio_python',
-'grc_gnuradio',
-'grc_gnuradio.blks2',
-'grc_gnuradio.usrp',
-'grc_gnuradio.wxgui',
-
+ 'grc_gnuradio',
+ 'grc_gnuradio.blks2',
+ 'grc_gnuradio.usrp',
+ 'grc_gnuradio.wxgui',
]
DATA=[
Modified: grc/branches/grc_reloaded/src/grc/Constants.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/Constants.py 2008-02-23 20:40:03 UTC
(rev 7799)
+++ grc/branches/grc_reloaded/src/grc/Constants.py 2008-02-23 23:15:05 UTC
(rev 7800)
@@ -101,32 +101,9 @@
BLOCK_SELECTION_WINDOW_WIDTH = 250
BLOCK_SELECTION_WINDOW_HEIGHT = 250
-VARIABLE_MODIFICATION_WINDOW_WIDTH = 250
-VARIABLE_MODIFICATION_WINDOW_HEIGHT = 150
address@hidden
######################################################################################################
-## Constraints for the sliders in the runnable flow graph @{
-######################################################################################################
-
-##The number of tics for a slider.
-DEFAULT_SLIDER_STEPS = 100
-
-##The max width that a row of sliders can use.
-MAX_SLIDERS_WIDTH = 600
-
-##Slider width in pixels
-DEFAULT_SLIDER_WIDTH = 200
-##Slider width in pixels
-MAX_SLIDER_WIDTH = 300
-##Slider width in pixels
-MIN_SLIDER_WIDTH = 100
-
-##The height in pixels.
-SLIDER_HEIGHT = 20
address@hidden
-
-######################################################################################################
## Constraints on displayable labels and ports @{
######################################################################################################
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
===================================================================
--- grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
2008-02-23 20:40:03 UTC (rev 7799)
+++ grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/Generator.py
2008-02-23 23:15:05 UTC (rev 7800)
@@ -61,7 +61,9 @@
}
#build the template
t = Template(open(NO_GUI_TEMPLATE, 'r').read(),
namespace)
- elif self._flow_graph.get_option('generate_options') ==
'wx_gui':
+ elif self._flow_graph.get_option('generate_options') ==
'wx_gui':
+ imports.add('from grc_gnuradio.wxgui import Controls')
+ imports.add('import wx')
#separate variables with wx controls
sliders = filter(lambda v: v.get_key() ==
'variable_slider', variables)
buttons = filter(lambda v: v.get_key() ==
'variable_button', variables)
@@ -77,7 +79,6 @@
'blocks': blocks,
'connections':
self._flow_graph.get_connections(),
}
- imports.add('from grc import wxgui')
#build the template
t = Template(open(WX_GUI_TEMPLATE, 'r').read(),
namespace)
else: print self._flow_graph.get_option('generate_options')
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
2008-02-23 20:40:03 UTC (rev 7799)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/blocks/variables/variable_slider.xml
2008-02-23 23:15:05 UTC (rev 7800)
@@ -29,13 +29,13 @@
</param>
<param>
<name>Num Steps</name>
- <key>step</key>
+ <key>num_steps</key>
<value>100</value>
<type>int</type>
</param>
<check>$min <= $value <= $max</check>
<check>$min < $max</check>
- <check>0 < $step <= 1000</check>
+ <check>0 < $num_steps <= 1000</check>
<doc>
This block creates a variable with a slider.
The value must be a real number.
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/no_gui.tmpl
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/no_gui.tmpl
2008-02-23 20:40:03 UTC (rev 7799)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/no_gui.tmpl
2008-02-23 23:15:05 UTC (rev 7800)
@@ -1,3 +1,4 @@
+#!/usr/bin/python
########################################################
##Cheetah template - gnuradio_python - no_gui
##
@@ -33,8 +34,8 @@
tb = gr.top_block()
#for $con in $connections
-#set $source = $con.get_source()
-#set $sink = $con.get_sink()
+ #set $source = $con.get_source()
+ #set $sink = $con.get_sink()
$("tb.connect((%s, %s), (%s, %s))"%(
$source.get_parent().get_id(),
$source.get_key(),
Modified:
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl
===================================================================
---
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl
2008-02-23 20:40:03 UTC (rev 7799)
+++
grc/branches/grc_reloaded/src/grc/platforms/gnuradio_python/data/wx_gui.tmpl
2008-02-23 23:15:05 UTC (rev 7800)
@@ -1,3 +1,4 @@
+#!/usr/bin/python
########################################################
##Cheetah template - gnuradio_python - wx_gui
##
@@ -12,7 +13,7 @@
########################################################
#import time
#import os
-#from grc.Constants import WX_APP_ICON
+#from grc.Constants import WX_APP_ICON,MAIN_WINDOW_PREFIX
$('#'*40)
# Gnuradio Python Flow Graph (wx gui)
$('# Name: %s'%$flow_graph.get_option('name'))
@@ -23,33 +24,68 @@
$flow_graph.get_option('description')
$('"""')
-import wx
#for $imp in $imports
$imp
#end for
class Frame(wx.Frame):
- def __init__(self):
-
- wx.Frame.__init__(self, None , -1, 'xxx' + ' - Executing: ' +
'xxx')
+ def __init__(self):
+ wx.Frame.__init__(self, None , -1, $('"%s - Executing:
%s"'%($MAIN_WINDOW_PREFIX, $flow_graph.get_option('name'))))
#if $WX_APP_ICON
- self.SetIcon(wx.Icon($os.path.abspath($WX_APP_ICON),
wx.BITMAP_TYPE_ANY))
+ self.SetIcon(wx.Icon("$os.path.abspath($WX_APP_ICON)",
wx.BITMAP_TYPE_ANY))
#end if
- self.SetSizeHints(200, 100)
+ self.SetSizeHints(400, 100)
main_box = wx.BoxSizer(wx.VERTICAL)
+
+ def callback(): print "called!!!"
+
+#for $slider in $sliders
+ slider = Controls.Slider(
+ window=self,
+ callback=callback,
+ title="$slider.get_id()",
+ value=$slider.get_param('value').to_code(),
+ min=$slider.get_param('min').to_code(),
+ max=$slider.get_param('max').to_code(),
+ num_steps=$slider.get_param('num_steps').to_code(),
+ )
+ main_box.Add(slider, 0, wx.ALIGN_CENTER)
+#end for
+
+#for $drop_down in $drop_downs
+ drop_down = Controls.DropDown(
+ window=self,
+ callback=callback,
+ title="$drop_down.get_id()",
+ index=$drop_down.get_param('value_index').to_code(),
+ choices=$drop_down.get_param('choices').to_code(),
+ )
+ main_box.Add(drop_down, 0, wx.ALIGN_CENTER)
+#end for
+
+#for $button in $buttons
+ button = Controls.Button(
+ window=self,
+ callback=callback,
+ title="$button.get_id()",
+ on=$(button.get_param('value_index').to_code() == 'on'),
+ on_state=$button.get_param('off_value').to_code(),
+ off_state=$button.get_param('on_value').to_code(),
+ )
+ main_box.Add(button, 0, wx.ALIGN_CENTER)
+#end for
+
self.Bind(wx.EVT_CLOSE, self._quit)
self.SetSizerAndFit(main_box)
self.Show()
def _quit(self, event):
- """Exit the application."""
- self.Destroy() #destroy the wx frame
+ self.Destroy()
class App(wx.App):
- def __init__(self):
-
+ def __init__(self):
wx.App.__init__(self, 0)
def OnInit(self):
@@ -57,9 +93,8 @@
return True
if __name__ == '__main__':
-
app = App()
app.MainLoop()
- sys.exit(0)
+ exit(0)
Modified: grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/Controls.py
===================================================================
--- grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/Controls.py
2008-02-23 20:40:03 UTC (rev 7799)
+++ grc/branches/grc_reloaded/src/grc_gnuradio/wxgui/Controls.py
2008-02-23 23:15:05 UTC (rev 7800)
@@ -22,6 +22,9 @@
import wx
+MAX_STR_LEN = 23
+def trim(s): return str(s)[0:MAX_STR_LEN]
+
class Control(object):
"""Control base class"""
@@ -59,22 +62,29 @@
self.off_state = off_state
wx.BoxSizer.__init__(self, wx.VERTICAL)
#create label
- label = wx.StaticText(title)
+ label = wx.StaticText(self.get_window(), -1, trim(title))
self.Add(label, 0, wx.ALIGN_CENTER)
#create button
self.button = wx.Button(self.get_window(), -1, '')
- self.Bind(wx.EVT_CHOICE, self._handle_changed)
- self._handle_changed()
+ self.button.Bind(wx.EVT_BUTTON, self._handle_changed)
+ self.Add(self.button, 0, wx.ALIGN_CENTER)
+ self._set_button_label()
def _handle_changed(self, event=None):
"""!
A change is detected. Call the callback.
"""
self.state = not self.state
- self.button.SetLabel(str(self.get_value())[0:11])
+ self._set_button_label()
try: self.get_callback()()
except Exception, e: print 'Error in handle change: "%s".'%e
+ def _set_button_label(self):
+ """!
+ Set the button label to the current state.
+ """
+ self.button.SetLabel(trim(self.get_value()))
+
def get_value(self):
"""!
Use the state of the button to determine the value.
@@ -104,12 +114,12 @@
self.choices = choices
wx.BoxSizer.__init__(self, wx.VERTICAL)
#create label
- label = wx.StaticText(title)
+ label = wx.StaticText(self.get_window(), -1, trim(title))
self.Add(label, 0, wx.ALIGN_CENTER)
#create chooser
- self.chooser = wx.Choice.(self.get_window(), -1, choices)
+ self.chooser = wx.Choice(self.get_window(), -1,
choices=map(trim, choices))
self.Add(self.chooser, 0, wx.ALIGN_CENTER)
- self.Bind(wx.EVT_CHOICE, self._handle_changed)
+ self.chooser.Bind(wx.EVT_CHOICE, self._handle_changed)
self.chooser.SetSelection(index)
def _handle_changed(self, event=None):
@@ -154,14 +164,14 @@
#create gui elements
wx.BoxSizer.__init__(self, wx.VERTICAL)
label_text_sizer = wx.BoxSizer(wx.HORIZONTAL) #label and text
box container
- label = wx.StaticText(self.get_window(), -1, title + ' -> ')
- self.text_box = text_box = wx.TextCtrl(self.get_window(), -1,
value, style=wx.TE_PROCESS_ENTER)
+ label = wx.StaticText(self.get_window(), -1, trim(title) + ' ->
')
+ self.text_box = text_box = wx.TextCtrl(self.get_window(), -1,
str(value), style=wx.TE_PROCESS_ENTER)
text_box.Bind(wx.EVT_TEXT_ENTER, self._handle_enter) #bind
this special enter hotkey event
for obj in (label, text_box): #fill the container with label
and text entry box
label_text_sizer.Add(obj, 0,
wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL)
self.Add(label_text_sizer, 0, wx.ALIGN_CENTER)
#make the slider
- self.slider = slider = wx.Slider(self.get_window(), -1,
size=wx.Size(slider_width, SLIDER_HEIGHT), style=wx.SL_HORIZONTAL)
+ self.slider = slider = wx.Slider(self.get_window(), -1,
size=wx.Size(200, 20), style=wx.SL_HORIZONTAL)
try: slider.SetRange(0, num_steps)
except Exception, e:
sys.stderr.write('Slider, "%s", has too many
steps!\n'%id)
@@ -192,7 +202,7 @@
"""!
A scroll event is detected. Read the slider, call the callback.
"""
- new_value = str(self._get_slider_value()) #the new value
must be a string!
+ new_value = str(self.get_value()) #the new value must be
a string!
try: self.get_callback()()
except Exception, e: print 'Error in handle scroll: "%s".'%e
self._set_slider_value(new_value)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7800 - in grc/branches/grc_reloaded: . scripts src/grc src/grc/platforms/gnuradio_python src/grc/platforms/gnuradio_python/blocks/variables src/grc/platforms/gnuradio_python/data src/grc_gnuradio/wxgui,
jblum <=