Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: Re: csndsugui

Date2009-03-26 03:45
From"Art Hunkins"
Subject[Csnd] Re: Re: Re: csndsugui
Here's the essence:

v1 = 0
while True:
  v1 = win.button(fb1, "", "PLAY!")
  if v1 == 0:
    continue
  break
print "Finished!"

The idea is an infinite loop which only gets broken when the button is 
pressed.

As it is, the code fails with the message, "'int' object is not iterable".

If I leave out "v1 = 0" the loop falls through immediately, printing 
"Finished" without pressing the button.

There's clearly something basic I don't understand, probably having to do 
with the win.button line. Perhaps variables output by widgets only get sent 
to the API and the .csd file, and are unavailable to the Python code itself?

If so, is there any method for holding in a loop with csndsugui until a GUI 
button is pressed?

Art Hunkins

----- Original Message ----- 
From: "Michael Gogins" 
To: 
Sent: Wednesday, March 25, 2009 4:14 PM
Subject: [Csnd] Re: Re: csndsugui


Give us the code that is not working, and maybe we can see what is wrong.

Regards,
Mike

On Wed, Mar 25, 2009 at 4:00 PM, Andres Cabrera  
wrote:
> Yes, since it's python, you can use ordinary python syntax.
>
> Cheers,
> Andrés
>
> On 3/25/09, Art Hunkins  wrote:
>> Is it possible to use "while" and/or "if" constructions in csndsugui? I 
>> need
>> some sort of conditional to work with.
>>
>> (With what I've come up with so far, the script seems to blast through 
>> the
>> conditional with nary a blink.)
>>
>> Art Hunkins
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>
>
> --
>
>
> Andrés
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
> csound"



-- 
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com


Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
csound"= 


Date2009-03-26 03:48
FromAndres Cabrera
Subject[Csnd] Re: Re: Re: Re: csndsugui
Hi Art,

I'm not really sure, but I would think there is a callback function
you can set for the button, which will be called when the button is
pressed, instead of having to loop. This is event driven programming,
which is surely something new if you've programmed mostly Csound.

Cheers,
Andrés

On Wed, Mar 25, 2009 at 10:45 PM, Art Hunkins  wrote:
> Here's the essence:
>
> v1 = 0
> while True:
>  v1 = win.button(fb1, "", "PLAY!")
>  if v1 == 0:
>   continue
>  break
> print "Finished!"
>
> The idea is an infinite loop which only gets broken when the button is
> pressed.
>
> As it is, the code fails with the message, "'int' object is not iterable".
>
> If I leave out "v1 = 0" the loop falls through immediately, printing
> "Finished" without pressing the button.
>
> There's clearly something basic I don't understand, probably having to do
> with the win.button line. Perhaps variables output by widgets only get sent
> to the API and the .csd file, and are unavailable to the Python code itself?
>
> If so, is there any method for holding in a loop with csndsugui until a GUI
> button is pressed?
>
> Art Hunkins
>
> ----- Original Message ----- From: "Michael Gogins"
> 
> To: 
> Sent: Wednesday, March 25, 2009 4:14 PM
> Subject: [Csnd] Re: Re: csndsugui
>
>
> Give us the code that is not working, and maybe we can see what is wrong.
>
> Regards,
> Mike
>
> On Wed, Mar 25, 2009 at 4:00 PM, Andres Cabrera 
> wrote:
>>
>> Yes, since it's python, you can use ordinary python syntax.
>>
>> Cheers,
>> Andrés
>>
>> On 3/25/09, Art Hunkins  wrote:
>>>
>>> Is it possible to use "while" and/or "if" constructions in csndsugui? I
>>> need
>>> some sort of conditional to work with.
>>>
>>> (With what I've come up with so far, the script seems to blast through
>>> the
>>> conditional with nary a blink.)
>>>
>>> Art Hunkins
>>> Send bugs reports to this list.
>>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>>> csound"
>>
>>
>> --
>>
>>
>> Andrés
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>
>
>
> --
> Michael Gogins
> Irreducible Productions
> http://www.michael-gogins.com
> Michael dot Gogins at gmail dot com
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"=
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>



-- 


Andrés