471,353 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,353 software developers and data experts.

tkSnack and Pmw Scrollcanvas

Thanks in advance,
Hi, I am trying to put tkSnack's Minwave.py demo into Pmw
Scrollcanvas, without success.
I have included the sample, the error message and the documentation
tkSnack says should work.

Can someone tell me what I am doing wrong? and If someone has some
sample code it would be greatly appreciated.

Roger

============ Code Here ===========
from Tkinter import *
import tkSnack
import Pmw

root = Tk()
Pmw.initialise()
tkSnack.initializeSnack(root)
sc = Pmw.ScrolledCanvas(root, borderframe=0, labelpos=N,
label_text='ScrolledCanvas', usehullsize=1,
hull_width=40, hull_height=200)

s = tkSnack.Sound(load='r3.wav')

tkSnack.createWaveform(sc._canvas, sound=s, width=400)

sc.pack(padx = 5, pady = 5, fill = 'both', expand = 1)
sc.resizescrollregion()

root.mainloop()

=====================
Error Msg:
Traceback (most recent call last):
File "D:\ROGER\Python\tkinter\scrollcanvas3.py", line 16, in
<module>
tkSnack.createWaveform(sc._canvas, sound=s, width=400)
File "C:\Python25\lib\tkSnack.py", line 552, in createWaveform
return canvas._create('waveform', args, kw)
File "C:\Python25\lib\lib-tk\Tkinter.py", line 2138, in _create
cnf = args[-1]
IndexError: tuple index out of range

===========================
>From the tkSnack documentation:
Putting SnackCanvas items on regular Canvases
It's possible to draw these new canvas items onto any canvas in your
program, not just those that are instances of SnackCanvas. You might
need to do this if you're using elaborations or subclasses of Canvas
that have been written by other people, for example, if you want to
draw a waveform on a ScrolledCanvas from the Python Megawidget
collection.

To accomplish this, tkSnack provides module-level versions of
create_waveform , create_section, and create_spectrogram. Simply use
the non-Snack canvas as the first argument. Instead of:

NonSnackCanvas.create_waveform(sound=tada)

use:

tkSnack.createWaveform(NonSnackCanvas, sound=tada)

If you're using Pmw Scrolled Canvas, remember that you're drawing onto
the ScrolledCanvas's Canvas object. In that case, you'll need to do:

tkSnack.createWaveform(myScrolledCanvas._canvas, sound=tada)
Roger

Jun 6 '07 #1
0 1131

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Dfenestr8 | last post: by
4 posts views Thread by Carlos P. | last post: by
6 posts views Thread by Todd Stephens | last post: by
1 post views Thread by jmdeschamps | last post: by
reply views Thread by Justin Shaw | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.