chachachacha | 3 Dec 04:25 2009
Picon

Python with Snack


Hi everyone,

I have been trying to install the Snack library (so I can run it with Python
2.5.4).  I have Windows Vista and have been trying to install through the
command line.  I have downloaded the source release for Snack Version 2.2.10
from the page http://www.speech.kth.se/snack/download.html

The downloaded folder is on my desktop in a folder called snack.  Through
the command line, I tried to install the program:
C:\Users\user\Desktop\snack\python\setup.py install

It returns with:
running install
running build
running build_py
file tkSnack.py (for module tkSnack) not found
file tkSnack.py (for module tkSnack) not found
running install_lib
warning: install_lib: 'build\lib' does not exist --no Python modules to
install

running install_egg_info
Writing C:\Python25\Lib\site-packages\tkSnack-2.2.10-py2.5.egg-info

I've also just tried to do:
C:\Users\user\Desktop\snack\python\python.py install
This didn't work either

I am very inexperienced in programming but am very eager to learn.  I know
(Continue reading)

Michael Lange | 3 Dec 16:40 2009
Picon

Re: Python with Snack

Hi,

On Wed, 2 Dec 2009 19:25:32 -0800 (PST)
chachachacha <chao.albert <at> gmail.com> wrote:

> 
> Hi everyone,
> 
> I have been trying to install the Snack library (so I can run it with
> Python 2.5.4).  I have Windows Vista and have been trying to install
> through the command line.  I have downloaded the source release for
> Snack Version 2.2.10 from the page
> http://www.speech.kth.se/snack/download.html
> 
> The downloaded folder is on my desktop in a folder called snack.
> Through the command line, I tried to install the program:
> C:\Users\user\Desktop\snack\python\setup.py install
> 
> It returns with:
> running install
> running build
> running build_py
> file tkSnack.py (for module tkSnack) not found
> file tkSnack.py (for module tkSnack) not found
> running install_lib
> warning: install_lib: 'build\lib' does not exist --no Python modules
> to install
> 
> running install_egg_info
> Writing C:\Python25\Lib\site-packages\tkSnack-2.2.10-py2.5.egg-info
(Continue reading)

Kevin Walzer | 3 Dec 16:54 2009

Re: Python with Snack

On 12/3/09 10:40 AM, Michael Lange wrote:

>>
>
> I don't know what's going wrong here, but I think it should be fine to
> simply copy the tkSnack module into Python's site-packages folder.
>

Will distutils/setuptools actually build the binary Snack library? It's 
a Tcl/Tk library, not a Python library. tkSnack.py is just a wrapper. 
The OP is probably better off downloading the Windows binary, installing 
it in the appropriate directory (wherever the other Tcl/Tk libs are on 
his system), and then trying to install tkSnack.py.

--

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com
Russell E. Owen | 3 Dec 22:32 2009

Re: Python with Snack

In article <4B17DF49.4030906 <at> codebykevin.com>,
 Kevin Walzer <kw <at> codebykevin.com> wrote:

> On 12/3/09 10:40 AM, Michael Lange wrote:
> >
> > I don't know what's going wrong here, but I think it should be fine to
> > simply copy the tkSnack module into Python's site-packages folder.
> >
> 
> Will distutils/setuptools actually build the binary Snack library? It's 
> a Tcl/Tk library, not a Python library. tkSnack.py is just a wrapper. 
> The OP is probably better off downloading the Windows binary, installing 
> it in the appropriate directory (wherever the other Tcl/Tk libs are on 
> his system), and then trying to install tkSnack.py.

I agree. I am pretty sure distutils will not build the snack library.

I used to install it on Windows by downloading the binary release for 
windows with python (but it only goes up to Python 2.3). Then follow the 
instructions on the web site: "Installation (with Python)".

But...I recommend not using snack at all. It appears to have been 
abandoned.

I used to use it, but switched to pygame. I chose pygame because (like 
snack, except snack is no longer maintained):
- It is fully cross-platform (Mac, unix and windows)
- It plays sounds asynchronously
- It is released and well maintained
- It is easy to use and easy to install
(Continue reading)

John McMonagle | 4 Dec 02:24 2009
Picon

Re: Python with Snack

chachachacha wrote:
> Hi everyone,
> 
> I have been trying to install the Snack library (so I can run it with Python
> 2.5.4).  I have Windows Vista and have been trying to install through the
> command line.  I have downloaded the source release for Snack Version 2.2.10
> from the page http://www.speech.kth.se/snack/download.html
> 
> The downloaded folder is on my desktop in a folder called snack.  Through
> the command line, I tried to install the program:
> C:\Users\user\Desktop\snack\python\setup.py install
> 
> It returns with:
> running install
> running build
> running build_py
> file tkSnack.py (for module tkSnack) not found
> file tkSnack.py (for module tkSnack) not found
> running install_lib
> warning: install_lib: 'build\lib' does not exist --no Python modules to
> install
> 
> running install_egg_info
> Writing C:\Python25\Lib\site-packages\tkSnack-2.2.10-py2.5.egg-info
> 
> I've also just tried to do:
> C:\Users\user\Desktop\snack\python\python.py install
> This didn't work either
> 
> I am very inexperienced in programming but am very eager to learn.  I know
(Continue reading)

chachachacha | 4 Dec 07:42 2009
Picon

Re: Python with Snack


Hi everyone.  Thanks for your responses!

So I did manage to get Snack installed.  It turned out to be a very simple
process (arg...).  As Russell points out, the binaries stopped at python
2.3.  However, as suggested by Michael, I was able to copy the snacklib into
the Tcl folder.  I then copied the tkSnack.py into the Lib folder.

Problem is, as Russell points out, Snack is out of date.  I was trying to
use it to do audio event analysis.  I wanted to use sound to detect when
heaters in a building would turn on.  With the help of Snack (the Wavesurfer
extension of snack), I have identified the frequencies produced when the
heaters turn on.  However, there seems to be no way of getting the actual
values of frequencies (at least, none that I could figure out)!

What I need still is a way to tell the computer:  Listen (as computers can
do this non-stop) until you hear the heaters turn on.  At this moment,
record the time and date.

I will take a look at pygame.
Thanks again for everyone's responses!
-Al

Russell E. Owen-4 wrote:
> 
> In article <4B17DF49.4030906 <at> codebykevin.com>,
>  Kevin Walzer <kw <at> codebykevin.com> wrote:
> 
>> On 12/3/09 10:40 AM, Michael Lange wrote:
>> >
(Continue reading)

Vasilis Vlachoudis | 4 Dec 16:53 2009
Picon
Picon

Cursor coordinates

Hi all,

I have a canvas with some editable text (with create_text) in it.
How can I get the cursor coordinates x,y from the canvas?
The index() function returns only the character index, is there a way to 
convert the position of a character into x,y coordinates or bbox?

Vasilis
Michael O'Donnell | 4 Dec 19:31 2009
Picon
Picon

Re: Cursor coordinates

Hi Vasilis,

A general method on all widgets;  w.winfo_pointerxy()

   Returns a tuple (x, y) containing the coordinates of the mouse
pointer relative  to w's root window.
   If the mouse pointer isn't on the same screen, returns (-1, -1).

Use this method on you canvas.
If you canvas is scrolled, then you need to adjust these coordinates
(since the top-left corner of the visible canvas may not be (0,0) of
the canvas coordinates)
So do something like:

        x,y=canv.winfo_pointerxy()
        x= canv.canvasx(x)
        y= canv.canvasy(y)

Note also you can bind methods to events
(not only clicks on your canas, but also movement)
When the method is called, it gets an event object as one
parameter, and this event object includes the x and y of the cursor

Mick

I am workin from memory here, so don't tak my word for it.

On Fri, Dec 4, 2009 at 4:53 PM, Vasilis Vlachoudis
<Vasilis.Vlachoudis <at> cern.ch> wrote:
> Hi all,
(Continue reading)

Michael Lange | 4 Dec 20:39 2009
Picon

Re: Cursor coordinates

Hi,

On Fri, 4 Dec 2009 19:31:07 +0100
"Michael O'Donnell" <michael.odonnell <at> uam.es> wrote:

> Hi Vasilis,
> 
> A general method on all widgets;  w.winfo_pointerxy()
> 
>    Returns a tuple (x, y) containing the coordinates of the mouse
> pointer relative  to w's root window.
>    If the mouse pointer isn't on the same screen, returns (-1, -1).
> 
(...)

I think Vasilis meant how to find the coords of the text's insertion
cursor, not the mouse pointer coords ? I don't know if this is possible
though.

Michael
Vasilis Vlachoudis | 4 Dec 20:49 2009
Picon
Picon

Re: Cursor coordinates

Thank you Michael, I was looking also for that function but for another task.

On my previous email I was asking to find the position (x,y) of the text-cursor or alternative the bbox of a single character from a text element inside a canvas. In my project I have created a full text editor inside the canvas for floating text elements.

# create a text element
txt = canvas.create_text(xt,yt,text="blahblah)

# place the cursor on the fifth character
canvas.focus(txt)
canvas.icursor(txt, 5)

# get the position
print "cursor character position=",canvas.index(txt, INDEX)

But how do I get the canvas x,y of the cursor?

Currently I am making a binary search within the limits of the bounding box searching for the x,y corresponding to the character location returned by the index() method.

I was asking if there is an existing function like the index() but to return the x,y position in the canvas.

Cheers
Vasilis

-----Original Message-----
From: micko.madrid <at> gmail.com on behalf of Michael O'Donnell
Sent: Fri 4/12/2009 19:31
To: Vasilis Vlachoudis
Cc: tkinter-discuss <at> python.org
Subject: Re: [Tkinter-discuss] Cursor coordinates

Hi Vasilis,

A general method on all widgets;  w.winfo_pointerxy()

   Returns a tuple (x, y) containing the coordinates of the mouse
pointer relative  to w's root window.
   If the mouse pointer isn't on the same screen, returns (-1, -1).

Use this method on you canvas.
If you canvas is scrolled, then you need to adjust these coordinates
(since the top-left corner of the visible canvas may not be (0,0) of
the canvas coordinates)
So do something like:

        x,y=canv.winfo_pointerxy()
        x= canv.canvasx(x)
        y= canv.canvasy(y)

Note also you can bind methods to events
(not only clicks on your canas, but also movement)
When the method is called, it gets an event object as one
parameter, and this event object includes the x and y of the cursor

Mick

I am workin from memory here, so don't tak my word for it.



On Fri, Dec 4, 2009 at 4:53 PM, Vasilis Vlachoudis
<Vasilis.Vlachoudis <at> cern.ch> wrote:
> Hi all,
>
> I have a canvas with some editable text (with create_text) in it.
> How can I get the cursor coordinates x,y from the canvas?
> The index() function returns only the character index, is there a way to
> convert the position of a character into x,y coordinates or bbox?
>
> Vasilis
>
> _______________________________________________
> Tkinter-discuss mailing list
> Tkinter-discuss <at> python.org
> http://mail.python.org/mailman/listinfo/tkinter-discuss
>

_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss <at> python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss

Gmane