| I think you probably want a different method: callback button. See
the midi example at
http://git.sugarlabs.org/projects/csndsugui/repos/mainline/blobs/master/Playmidi.activity/playmidi.py
this line creates a callback button, which is used to load a CSD with
a particular midifile and create some play buttons etc.:
self.but = win.cbbutton(bbox, self.fcall, "load")
Victor
----- Original Message -----
From: "Art Hunkins"
To:
Sent: Thursday, April 02, 2009 10:08 PM
Subject: [Csnd] More csndsugui
> I'd appreciate help with the following code from anyone familiar with
> csndsugui and Python.
>
> This (vastl,y simplified) code does not work for me in Sugar (OLPC):
>
>
> import csndsugui
> from sugar.activity import activity
>
> class Waves(activity.Activity):
>
> def __init__(self, handle):
>
> activity.Activity.__init__(self, handle)
>
> win = csndsugui.CsoundGUI(self)
>
> box = win.box(True)
> win.text("Click on a version:", box)
> win.button(box, "button1", "CSD 1 ?")
> win.button(box, "button2", "CSD 2 ?")
> v1 = win.get_button_value("button1")
> v2 = win.get_button_value("button2")
> if v1:
> win.csd("CSD1.csd")
> win.button(box, "pan1", "Pan Control CSD 1?")
> win.button(box, "play1", "PLAY!")
> v1play = win.get_button_value("play1")
> if v1play: win.play()
> elif v2:
> win.csd("CSD2.csd")
> win.button("pan2", "Pan Control CSD 2?")
> win.button("play2", "PLAY!")
> v2play = win.get_button_value("play2")
> if v2play: win.play()
>
> The problem is with my GUI code (above); I'm relatively sure of what I'm
> doing with my .csd's, including their chnexport statements. I suspect the
> problems are with the v1 and v2 variables, as well as v1play and v2play
> above.
>
> The idea of the code is this: "button1" and "button2" wait for the user to
> press one - which selects the .csd to be performed. I'm completely unaware
> of how this API button_value may behave when a .csd is not yet compiled
> (as it is as yet unchosen).
>
> The play1 and play2 buttons also don't perform. The two pan controls are
> i-time variables and must be selected before play commences. Hence,
> play1/2 also must sit there, waiting. Neither button currently initiates
> play (even in a completely different version of this code which does not
> have a "button1" and "button2").
>
> Of course, what I'm trying to do may be impossible. As things stand, I do
> need two sets of GUI buttons that wait patiently for user presses before
> going on, and this is what I don't know how to do. FWIW, I've tried many
> variants of the above - including testing direct returns from the buttons,
> and designating v1/v2, for example, as win.v1 (or win.v2).
>
> TIA for a rescue (OLPCsound, not economic) -
>
> Art Hunkins
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
|