Csound Csound-dev Csound-tekno Search About

[Csnd] tkinter within csound

Date2008-10-08 13:45
Fromkind beta
Subject[Csnd] tkinter within csound

hello.

is it possible to use tkinter within csound?
i use the csound 5.09, python 2.52 and winXP.

the following code:
----
pyinit
pyruni {{
from Tkinter import *
gusi = Tk()
}}
----
produces the following message:
----
INIT ERROR in instr 0: pyruni: python exception
pyruni "
from Tkinter import *
gusi = Tk()
"
header init errors
-----

the csound example file ievent.orc form /Csound/examples/py/ievent.orc
produces the same error message.

can anyone tell me, what it takes to make this work?


i posted this in the csound forum, but now i realised that more is happening on this list...



Date2008-10-08 14:04
From"Oeyvind Brandtsegg"
Subject[Csnd] Re: tkinter within csound
AttachmentsNone  

Date2008-10-08 14:05
From"Andres Cabrera"
Subject[Csnd] Re: tkinter within csound
AttachmentsNone  

Date2008-10-08 14:26
Fromkind beta
Subject[Csnd] AW: Re: tkinter within csound
thanks, oeyvind.

--- Oeyvind Brandtsegg <obrandts@gmail.com> schrieb am Mi, 8.10.2008:
Von: Oeyvind Brandtsegg <obrandts@gmail.com>
Betreff: [Csnd] Re: tkinter within csound
An: csound@lists.bath.ac.uk
Datum: Mittwoch, 8. Oktober 2008, 15:04

Just a wild guess, I'm not able to test something right now:

I think your error stems from the pyinit statement, not related to
tkinter, but related to running python inside csound.
yes, i guess so, because the csound example prouces the same error message ievent.orc

---------------------------
pyinit

pyruni  {{
import csound
from random import random

for i in range(800):
        csound.ievent(1, i * .2,     0.05, 6.8 + random() * 3,   70.0)
        csound.ievent(1, i * .2,     0.05, 8.8 + random() * 3,   70.0)
}}
---------------------

Do your Csound version have the py opcodes ?
(run csound -z and see if you can find pyinit in the displayed list,
if you have pyinit you probably also have about 90 to 100 other py
opcodes in the same list)

yes, the py opcodes are there. pyinit and pyruni work fine. but code containig import or from import.

i run the csound from the csound5gui, could this be the problem?

thanks,
ancel

best
Oeyvind

2008/10/8 kind beta <kindbeta@yahoo.de>:
> hello.
>
> is it possible to use tkinter within csound?
> i use the csound 5.09, python 2.52 and winXP.
>
> the following code:
> ----
> pyinit
> pyruni {{
> from Tkinter import *
> gusi = Tk()
> }}
> ----
> produces the following message:
> ----
> INIT ERROR in instr 0: pyruni: python exception
> pyruni "
> from Tkinter import *
> gusi = Tk()
> "
> header init errors
> -----
>
> the csound example file ievent.orc form /Csound/examples/py/ievent.orc
> produces the same error message.
>
> can anyone tell me, what it takes to make this work?
>
> i posted this in the csound forum, but now i realised that more is
happening
> on this list...
>


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


Date2008-10-08 14:30
From"Oeyvind Brandtsegg"
Subject[Csnd] Re: AW: Re: tkinter within csound
AttachmentsNone  

Date2008-10-08 14:33
FromVictor Lazzarini
Subject[Csnd] Re: AW: Re: tkinter within csound
I'm guessing this might be a problem, because FLTK does not interact well with
other GUIs (it's a complicated story). Try running from the
command-line.

At 14:26 08/10/2008, you wrote:
>i run the csound from the csound5gui, could this be the problem?

Victor Lazzarini
Music Technology Laboratory
Music Department
National University of Ireland, Maynooth 


Date2008-10-08 16:09
Fromkind beta
Subject[Csnd] AW: Re: AW: Re: tkinter within csound
thanks all.


I'm guessing this might be a problem, because FLTK does not interact well
with
other GUIs (it's a complicated story). Try running from the
command-line.
no, from the command line it isnt working too.

ok, since im quite new to csound and python, this is the content of the test.csd file:
-----------------
<CsoundSynthesizer>
<CsInstruments>

sr=44100
ksmps=128
nchnls=2

pyinit

pyruni {{
from Tkinter import *
root = Tk()
root.mainloop() 
}}

instr 1
pyruni {{

print "pyruni works"}}
endin

</CsInstruments>

<CsScore>
i 1 0 1
</CsScore>
</CsoundSynthesizer>
-----------------

to start it from command line i type: csound test.csd right?


without root = Tk() and root.mainloop()  it is working.
but when i add root = Tk() this error message emerge:
-----------------------------
INIT ERROR in instr 0: pyruni: python exception
        pyruni  "
from Tkinter import *
root = Tk()
root.mainloop()
"
Traceback (most recent call last):
  File "<string>", line 3, in <module>
  File "C:\Python25\Lib\lib-tk\Tkinter.py", line 1631, in __init__
    baseName = os.path.basename(sys.argv[0])
AttributeError: 'module' object has no attribute 'argv'
header init errors
Csound tidy up: Segmentation violation
inactive allocs returned to freespace
end of score.              overall amps:      0.0      0.0
           overall samples out of range:        0        0
2 errors in performance

------

best
ancel







Date2008-10-08 17:09
Fromkind beta
Subject[Csnd] AW: Re: tkinter within csound
It seems to say there's a problem with the python tkinter module when
used within csound. Maybe you want to try using the tclcsound modues
for tcl/tk?
i bought a book and started learning python last week...
you think tcl is better for scripting gui´s within csound and csound~ ?




Date2008-10-08 23:22
From"Andres Cabrera"
Subject[Csnd] Re: AW: Re: tkinter within csound
AttachmentsNone  

Date2008-10-09 00:06
From"Brian Redfern"
Subject[Csnd] Re: Re: AW: Re: tkinter within csound
AttachmentsNone  

Date2008-10-09 08:11
FromErnesto Illescas-Pel‡áez
Subject[Csnd] Re: Re: Re: AW: Re: tkinter within csound
Hi Brian,

I also think that wxpython is good for guis. I never used pygame, but I 
know somenone who did it and still preferred wx. He's not good at 
answering mails, but I'll ask him and, if I get a reply I will post it here.
Greetings,

Ernesto

Brian Redfern wrote:
> I wonder if anyone has experimented with building a ui using pygame with csound?
>
> On Wed, Oct 8, 2008 at 3:22 PM, Andres Cabrera  wrote:
>   
>> Not necessarily, I mentioned tclcsound since you seemed interested in
>> tcl/tk. One way to build gui's for csound is using wxpython.
>>
>> Cheers,
>> Andres
>>
>> On Wed, Oct 8, 2008 at 11:09 AM, kind beta  wrote:
>>     
>>> It seems to say there's a problem with the python tkinter module when
>>> used within csound. Maybe you want to try using the tclcsound modues
>>> for tcl/tk?
>>>
>>> i bought a book and started learning python last week...
>>> you think tcl is better for scripting gui´s within csound and csound~ ?
>>>
>>>
>>>
>>>
>>>       
>>
>> --
>>
>>
>> Andrés
>>
>>
>> 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"
>   

Date2008-10-09 09:47
Fromkind beta
Subject[Csnd] AW: Re: AW: Re: tkinter within csound

thanks, andreas.
but with wxpython i get the same errors.

i just tried it wit the demo code for wxpython:
-----------------------------------------
<CsoundSynthesizer>
<CsInstruments>

sr=44100
ksmps=128
nchnls=2

pyinit

pyruni {{

import  wx

#----------------------------------------------------------------------

class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1,
                         style=wx.NO_FULL_REPAINT_ON_RESIZE)
        self.log = log

        b = wx.Button(self, 10, "Default Button", (20, 20))
        self.Bind(wx.EVT_BUTTON, self.OnClick, b)
        b.SetDefault()
        b.SetSize(b.GetBestSize())

    def OnClick(self, event):
        self.log.write("Click! (%d)\n" % event.GetId())

#----------------------------------------------------------------------

def runTest(frame, nb, log):
    win = TestPanel(nb, log)
    return win

#----------------------------------------------------------------------


if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
}}

instr 1

pyruni {{

print "pyruni works"}}
endin

</CsInstruments>

<CsScore>
i 1 0 1
</CsScore>
</CsoundSynthesizer>
---------------------

and the error masage was:
<CsoundSynthesizer>
<CsInstruments>

sr=44100
ksmps=128
nchnls=2

pyinit

pyruni {{

import  wx

#----------------------------------------------------------------------

class TestPanel(wx.Panel):
    def __init__(self, parent, log):
        wx.Panel.__init__(self, parent, -1,
                         style=wx.NO_FULL_REPAINT_ON_RESIZE)
        self.log = log

        b = wx.Button(self, 10, "Default Button", (20, 20))
        self.Bind(wx.EVT_BUTTON, self.OnClick, b)
        b.SetDefault()
        b.SetSize(b.GetBestSize())

    def OnClick(self, event):
        self.log.write("Click! (%d)\n" % event.GetId())

#----------------------------------------------------------------------

def runTest(frame, nb, log):
    win = TestPanel(nb, log)
    return win

#----------------------------------------------------------------------


if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])
}}

instr 1

pyruni {{

print "pyruni works"}}
endin

</CsInstruments>

<CsScore>
i 1 0 1
</CsScore>
</CsoundSynthesizer>
------------------------------

are you using wxpython within csound?


--- Andres Cabrera <mantaraya36@gmail.com> schrieb am Do, 9.10.2008:
Von: Andres Cabrera <mantaraya36@gmail.com>
Betreff: [Csnd] Re: AW: Re: tkinter within csound
An: csound@lists.bath.ac.uk
Datum: Donnerstag, 9. Oktober 2008, 0:22

Not necessarily, I mentioned tclcsound since you seemed interested in
tcl/tk. One way to build gui's for csound is using wxpython.

Cheers,
Andres

On Wed, Oct 8, 2008 at 11:09 AM, kind beta <kindbeta@yahoo.de> wrote:
> It seems to say there's a problem with the python tkinter module when
> used within csound. Maybe you want to try using the tclcsound modues
> for tcl/tk?
>
> i bought a book and started learning python last week...
> you think tcl is better for scripting gui´s within csound and csound~ ?
>
>
>
>



--


Andrés


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


Date2008-10-09 20:04
From"Brian Redfern"
Subject[Csnd] Re: AW: Re: AW: Re: tkinter within csound
AttachmentsNone  

Date2008-10-11 19:55
From"Chuckk Hubbard"
Subject[Csnd] Re: Re: AW: Re: AW: Re: tkinter within csound
AttachmentsNone  

Date2008-10-12 05:46
From"Brian Redfern"
Subject[Csnd] Re: Re: Re: AW: Re: AW: Re: tkinter within csound
AttachmentsNone  

Date2008-10-12 19:39
From"Oeyvind Brandtsegg"
Subject[Csnd] Re: AW: Re: AW: Re: tkinter within csound
AttachmentsNone