Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Lazzarini <Victor.Lazzarini@nuim.ie>2008-03-18 22:34:30 (GMT)
committer Victor Lazzarini <Victor.Lazzarini@nuim.ie>2008-03-18 22:34:30 (GMT)
commitd8532436debf2a491e5a2ad7a276b95449be5bc1 (patch)
treee3adfeee062920abc03f953ae961ebf5b31e8a37
parent071fc9b4a2589643658f9ca78a63d65b97d26e9a (diff)
added optional labels to widgets (for future internationalisation)
-rwxr-xr-xSynth.activity/csndsugui.py43
-rwxr-xr-xcsndsugui.py43
2 files changed, 54 insertions, 32 deletions
diff --git a/Synth.activity/csndsugui.py b/Synth.activity/csndsugui.py
index f4c8b10..803152e 100755
--- a/Synth.activity/csndsugui.py
+++ b/Synth.activity/csndsugui.py
@@ -26,7 +26,7 @@
# file might be covered by the GNU Lesser General Public License.
#
#
-# version 0.1.1 14/03/08
+# version 0.1.2 18/03/08
import pygtk
pygtk.require('2.0')
@@ -161,7 +161,6 @@ class BasicGUI:
# box: parent box
# callback: click callback
# title: if given, the button name
- # in order of creation.
# returns the widget instance
def cbbutton(self,box,callback,title=""):
self.cbbutts = self.cbbutts + 1
@@ -180,12 +179,16 @@ class BasicGUI:
# name. Otherwise a default name is
# given, BN, where N is button number
# in order of creation.
+ # label: if given, an alternative button name,
+ # which will be displayed instead of title
# returns the widget instance
- def button(self,box, title=""):
+ def button(self,box, title="",label=""):
self.butts = self.butts + 1
if title == "":
title = "B%d" % self.butts
- butt = gtk.Button(" %s " % title)
+ if label == "": name = title
+ else: name = label
+ butt = gtk.Button(" %s " % name)
butt.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color(0xFFFF,0,0, 1))
butt.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0xFFFF, 2))
box.pack_start(butt, False, False, 5)
@@ -197,9 +200,7 @@ class BasicGUI:
# creates a mbutton (sending a message)
#
# box: parent box
- # title: if given, the button name,
- # which will also be the bus channel
- # name. Otherwise a default name is
+ # title: if given, the button name, otherwise a default name is
# given, BN, where N is button number
# in order of creation.
# mess: message to be sent when button is clicked
@@ -240,8 +241,12 @@ class BasicGUI:
# creates a filechooser button
# title: button name, also file bus channel name
# box: parent box
- def filechooser(self,box,title):
- butt = gtk.Button(title)
+ # label: if given, alternative name, for display purposes only
+ # otherwise button will display its title
+ def filechooser(self,box,title,label=""):
+ if label == "": name = title
+ else: name = label
+ butt = gtk.Button(name)
box.pack_start(butt, False, False, 5)
self.buttons.append([butt,title])
butt.connect("clicked", self.fbuttcallback)
@@ -264,9 +269,10 @@ class BasicGUI:
# vert: vertical slider (True), else horiz.
# linear: linear response (True), else exponential (zero or negative
# ranges are not allowed)
- # dwid: display width in pixels
+ # dwid: display width in pixels
+ # label: if given, the alternative slider name, for display only
# returns the widget instance
- def slider(self,init, start, end, x, y, box, title="",vert=True,linear=True,dwid=100):
+ def slider(self,init, start, end, x, y, box, title="",vert=True,linear=True,dwid=100,label=""):
self.slids = self.slids + 1
if title == "":
title = "S%d" % self.slids
@@ -305,9 +311,11 @@ class BasicGUI:
slider.set_range(pos, end)
pos = end*math.log(init/start,end/start)
slider.set_value(pos)
-
+
+ if label == "": name = title
+ else: name = label
entry.set_text("%f" % init)
- label = gtk.Label(title)
+ label = gtk.Label(name)
slider.set_size_request(x,y)
box.pack_start(slider, False, False, 5)
box.pack_start(entry, False, False, 2)
@@ -328,13 +336,14 @@ class BasicGUI:
# step, page: small and large step sizes
# box: parent box
# accel: acceleration or 'climb rate' (0.0-1.0)
- # title: if given, the slider name,
+ # title: if given, the spin button name,
# which will also be the bus channel
# name. Otherwise a default name is
# given, SPN, where N is spin number
# in order of creation.
+ # label: if given, the alternative name for the widget, for display only.
# returns the widget instance
- def spin(self,init, start, end, step, page, box, accel=0, title=""):
+ def spin(self,init, start, end, step, page, box, accel=0,title="",label=""):
self.spinbs = self.spinbs + 1
if title == "":
title = "SP%d" % self.spinbs
@@ -349,7 +358,9 @@ class BasicGUI:
else:
spin.set_digits(0)
- label = gtk.Label(title)
+ if label == "": name = title
+ else: name = label
+ label = gtk.Label(name)
box.pack_start(spin, False, False, 5)
box.pack_start(label, False, False, 2)
self.spins.append([spin,title,init])
diff --git a/csndsugui.py b/csndsugui.py
index f4c8b10..803152e 100755
--- a/csndsugui.py
+++ b/csndsugui.py
@@ -26,7 +26,7 @@
# file might be covered by the GNU Lesser General Public License.
#
#
-# version 0.1.1 14/03/08
+# version 0.1.2 18/03/08
import pygtk
pygtk.require('2.0')
@@ -161,7 +161,6 @@ class BasicGUI:
# box: parent box
# callback: click callback
# title: if given, the button name
- # in order of creation.
# returns the widget instance
def cbbutton(self,box,callback,title=""):
self.cbbutts = self.cbbutts + 1
@@ -180,12 +179,16 @@ class BasicGUI:
# name. Otherwise a default name is
# given, BN, where N is button number
# in order of creation.
+ # label: if given, an alternative button name,
+ # which will be displayed instead of title
# returns the widget instance
- def button(self,box, title=""):
+ def button(self,box, title="",label=""):
self.butts = self.butts + 1
if title == "":
title = "B%d" % self.butts
- butt = gtk.Button(" %s " % title)
+ if label == "": name = title
+ else: name = label
+ butt = gtk.Button(" %s " % name)
butt.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color(0xFFFF,0,0, 1))
butt.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0xFFFF, 2))
box.pack_start(butt, False, False, 5)
@@ -197,9 +200,7 @@ class BasicGUI:
# creates a mbutton (sending a message)
#
# box: parent box
- # title: if given, the button name,
- # which will also be the bus channel
- # name. Otherwise a default name is
+ # title: if given, the button name, otherwise a default name is
# given, BN, where N is button number
# in order of creation.
# mess: message to be sent when button is clicked
@@ -240,8 +241,12 @@ class BasicGUI:
# creates a filechooser button
# title: button name, also file bus channel name
# box: parent box
- def filechooser(self,box,title):
- butt = gtk.Button(title)
+ # label: if given, alternative name, for display purposes only
+ # otherwise button will display its title
+ def filechooser(self,box,title,label=""):
+ if label == "": name = title
+ else: name = label
+ butt = gtk.Button(name)
box.pack_start(butt, False, False, 5)
self.buttons.append([butt,title])
butt.connect("clicked", self.fbuttcallback)
@@ -264,9 +269,10 @@ class BasicGUI:
# vert: vertical slider (True), else horiz.
# linear: linear response (True), else exponential (zero or negative
# ranges are not allowed)
- # dwid: display width in pixels
+ # dwid: display width in pixels
+ # label: if given, the alternative slider name, for display only
# returns the widget instance
- def slider(self,init, start, end, x, y, box, title="",vert=True,linear=True,dwid=100):
+ def slider(self,init, start, end, x, y, box, title="",vert=True,linear=True,dwid=100,label=""):
self.slids = self.slids + 1
if title == "":
title = "S%d" % self.slids
@@ -305,9 +311,11 @@ class BasicGUI:
slider.set_range(pos, end)
pos = end*math.log(init/start,end/start)
slider.set_value(pos)
-
+
+ if label == "": name = title
+ else: name = label
entry.set_text("%f" % init)
- label = gtk.Label(title)
+ label = gtk.Label(name)
slider.set_size_request(x,y)
box.pack_start(slider, False, False, 5)
box.pack_start(entry, False, False, 2)
@@ -328,13 +336,14 @@ class BasicGUI:
# step, page: small and large step sizes
# box: parent box
# accel: acceleration or 'climb rate' (0.0-1.0)
- # title: if given, the slider name,
+ # title: if given, the spin button name,
# which will also be the bus channel
# name. Otherwise a default name is
# given, SPN, where N is spin number
# in order of creation.
+ # label: if given, the alternative name for the widget, for display only.
# returns the widget instance
- def spin(self,init, start, end, step, page, box, accel=0, title=""):
+ def spin(self,init, start, end, step, page, box, accel=0,title="",label=""):
self.spinbs = self.spinbs + 1
if title == "":
title = "SP%d" % self.spinbs
@@ -349,7 +358,9 @@ class BasicGUI:
else:
spin.set_digits(0)
- label = gtk.Label(title)
+ if label == "": name = title
+ else: name = label
+ label = gtk.Label(name)
box.pack_start(spin, False, False, 5)
box.pack_start(label, False, False, 2)
self.spins.append([spin,title,init])