wxGlade syntax error

I was trying to follow a wxGlade tutorial, but got stuck

line 33 always give me a syntax error, do I have an identation problem?

#!/usr/bin/env python

-- coding: iso-8859-15 --

generated by wxGlade 0.6.3 on Sun Sep 07 13:07:52 2008

import wx

begin wxGlade: extracode

end wxGlade

import os as os

class MyFrame(wx.Frame):

def __init__(self, *args, **kwds):

    # begin wxGlade: MyFrame.__init__

    kwds["style"] = wx.DEFAULT_FRAME_STYLE

    wx.Frame.__init__(self, *args, **kwds)

    self.dImage = wx.StaticBitmap(self, -1,

wx.Bitmap(“C:\etemp\dThumb.jpg”, wx.BITMAP_TYPE_ANY))

    self.dSlider = wx.Slider(self, -1, 0, 0, 10,

style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LEFT|wx.SL_RIGHT)

    self.btnHead = wx.Button(self, -1, "Delete Head\n")

    self.btnThumb = wx.Button(self, -1, "ThumbNail\n")

    self.btnTail = wx.Button(self, -1, "Delete Tail\n")

    self.txtLog = wx.Button(self, -1, "")

    self.btnOK = wx.Button(self, -1, "Save OK")

    self.__set_properties()

    self.__do_layout()

    # end wxGlade

    self.valHead = 0

    self.valThumb = 0

    self.valTail = 0

    self.valSlider = 0

    self.fname = "HOUSEPART1"

         

def wx.EVT_BUTTON(self.self.btnTail.GetId(), self.pushTail)

def wx.EVT_BUTTON(self.self.btnHead.GetId(), self.pushHead)

def wx.EVT_BUTTON(self.self.btnThumb.GetId(), self.pushThumb)

def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)

def wx.EVT_SCROLL(self.self.dSlider.GetId(), self.onScroll)



def pushHead(self,event):

    self.self.txtLog.WriteText("Heads..\n")

    self.valHead= self.valSlider

   

def pushThumb(self,event):

    self.self.txtLog.WriteText("Thumb...\n")

    self.valThumb= self.valSlider

def pushTail(self,event):

    self.self.txtLog.WriteText("Tail\n")

    self.valTail= self.valSlider

def pushOK(self,event):

    self.self.txtLog.WriteText("OK \n")

    # save .jpg of frame valThumb

    strval=('0'+str(self.valThumb).strip())[-2:]

    cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480

-ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo
c:\etemp\dthumb.jpg"%self.fname,%(strval)

    # now copy Video file from frames  valHead to valTail

    strval1=('0'+str(self.valHead).strip())[-2:]

    strval2=('0'+str(self.valTail).strip())[-2:]

    # make sure valTail is filled in properly or use something to

get total no of frames

    # and calc diff between Head and Tail as the no frames

    nframes = strval2 - strval1

    cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480

-ss 00:00:%s -an -r 1 -vframes %s -y -vcodec mjpeg -f rawvideo
c:\etemp\dthumb.jpg"%(self.fname,strval1,nframes)

def OnScroll(self,event):

    self.self.txtLog.WriteText("Scrolling\n")

    slider = evt.EventObject

    self.valThumb= slider.Value

    self.valSlider = slider.Value

    val = self.valThumb

    strval=('0'+str(val).strip())[-2:]

    #cmdstr=r"d:\download\ffmpeg\ffmpeg\bin\ffmpeg -y -i

c:\temp\v1.swf -an -s 160x120 -ss 00:00:%s -an -r 1 -vframes 1 -y
-vcodec png -f rawvideo c:\temp\thumbnail.png"%(strval)

    cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480

-ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo
c:\etemp\dthumb.jpg"%self.fname,%(strval)

    self.self.dImage.Picture = ""

    print cmdstr

    os.system(cmdstr)

    self.self.dImage.Picture = r"c:\etemp\dthumb.jpg"

def __set_properties(self):

    # begin wxGlade: MyFrame.__set_properties

    self.SetTitle("frame_1")

    self.dImage.SetMinSize((640,480))

    self.dSlider.SetMinSize((600, 32))

    # end wxGlade

def __do_layout(self):

    # begin wxGlade: MyFrame.__do_layout

    sizer_1 = wx.BoxSizer(wx.VERTICAL)

    sizer_2 = wx.BoxSizer(wx.HORIZONTAL)

    sizer_1.Add(self.dImage, 1, wx.EXPAND, 0)

    sizer_1.Add(self.dSlider, 0, 0, 0)

    sizer_2.Add(self.btnHead, 0, 0, 0)

    sizer_2.Add(self.btnThumb, 0, 0, 0)

    sizer_2.Add(self.btnTail, 0, 0, 0)

    sizer_2.Add(self.btnOK, 0, 0, 0)

    sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)

    self.SetSizer(sizer_1)

    sizer_1.Fit(self)

    self.Layout()

    # end wxGlade

end of class MyFrame

if name == “main”:

wxGTest1 = wx.PySimpleApp(0)

wx.InitAllImageHandlers()

frame_1 = MyFrame(None, -1, "")

wxGTest1.SetTopWindow(frame_1)

frame_1.Show()

wxGTest1.MainLoop()
···
**
Erik Vandamme
54 Hilltop Road - WAMBERAL NSW 2260 Australia
Skype - erik_vandamme
02 43843613 - 0406 042750**

erik1vandamme@gmail.com

Erik Vandamme wrote:

I was trying to follow a wxGlade tutorial, but got stuck line
33 always give me a syntax error, do I have an identation problem?

I think I can tell you which are the offending lines -

    def wx.EVT_BUTTON(self.self.btnTail.GetId(), self.pushTail)
    def wx.EVT_BUTTON(self.self.btnHead.GetId(), self.pushHead)
    def wx.EVT_BUTTON(self.self.btnThumb.GetId(), self.pushThumb)
    def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)
    def wx.EVT_SCROLL(self.self.dSlider.GetId(), self.onScroll)

The above is not valid python syntax. A 'def' statement must be followed by
a colon and a block of code.

Unfortunately I do not know wxGlade, so I cannot suggest a solution.

HTH

Frank Millman

Erik Vandamme wrote:

I was trying to follow a wxGlade tutorial, but got stuck
line 33 always give me a syntax error, do I have an identation problem?

If it was an indentation error, the error message should say so...

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.3 on Sun Sep 07 13:07:52 2008

import wx

# begin wxGlade: extracode
# end wxGlade
import os as os

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.dImage = wx.StaticBitmap(self, -1, wx.Bitmap("C:\\etemp\\dThumb.jpg", wx.BITMAP_TYPE_ANY))
        self.dSlider = wx.Slider(self, -1, 0, 0, 10, style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LEFT|wx.SL_RIGHT)
        self.btnHead = wx.Button(self, -1, "Delete Head\n")
        self.btnThumb = wx.Button(self, -1, "ThumbNail\n")
        self.btnTail = wx.Button(self, -1, "Delete Tail\n")
        self.txtLog = wx.Button(self, -1, "")
        self.btnOK = wx.Button(self, -1, "Save OK")

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
        self.valHead = 0
        self.valThumb = 0
        self.valTail = 0
        self.valSlider = 0
        self.fname = "HOUSEPART1"
             
None of these methods have a colon on the end, so they're not valid. I don't think you want to make methods called "wx.EVT_BUTTON" anyway as that's just bad form. If I comment these lines out, it finds another error in the pushOK method.

    def wx.EVT_BUTTON(self.self.btnTail.GetId(), self.pushTail)
    def wx.EVT_BUTTON(self.self.btnHead.GetId(), self.pushHead)
    def wx.EVT_BUTTON(self.self.btnThumb.GetId(), self.pushThumb)
    def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)
    def wx.EVT_SCROLL(self.self.dSlider.GetId(), self.onScroll)

       def pushHead(self,event):
        self.self.txtLog.WriteText("Heads..\n")
        self.valHead= self.valSlider
           def pushThumb(self,event):
        self.self.txtLog.WriteText("Thumb...\n")
        self.valThumb= self.valSlider

    def pushTail(self,event):
        self.self.txtLog.WriteText("Tail\n")
        self.valTail= self.valSlider

    def pushOK(self,event):
        self.self.txtLog.WriteText("OK \n")
        # save .jpg of frame valThumb
        strval=('0'+str(self.valThumb).strip())[-2:]
        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%self.fname,%(strval)

The line above needs to end like this: % (self.fname,strval)

        # now copy Video file from frames valHead to valTail
        strval1=('0'+str(self.valHead).strip())[-2:]
        strval2=('0'+str(self.valTail).strip())[-2:]
        # make sure valTail is filled in properly or use something to get total no of frames
        # and calc diff between Head and Tail as the no frames
        nframes = strval2 - strval1
        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes %s -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%(self.fname,strval1,nframes)

    def OnScroll(self,event):
        self.self.txtLog.WriteText("Scrolling\n")
        slider = evt.EventObject
        self.valThumb= slider.Value
        self.valSlider = slider.Value
        val = self.valThumb
        strval=('0'+str(val).strip())[-2:]
        #cmdstr=r"d:\download\ffmpeg\ffmpeg\bin\ffmpeg -y -i c:\temp\v1.swf -an -s 160x120 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec png -f rawvideo c:\temp\thumbnail.png"%(strval)

        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%self.fname,%(strval)

Same issue here...

        self.self.dImage.Picture = ""
        print cmdstr
        os.system(cmdstr)
        self.self.dImage.Picture = r"c:\etemp\dthumb.jpg"

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("frame_1")
        self.dImage.SetMinSize((640,480))
        self.dSlider.SetMinSize((600, 32))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_1.Add(self.dImage, 1, wx.EXPAND, 0)
        sizer_1.Add(self.dSlider, 0, 0, 0)
        sizer_2.Add(self.btnHead, 0, 0, 0)
        sizer_2.Add(self.btnThumb, 0, 0, 0)
        sizer_2.Add(self.btnTail, 0, 0, 0)
        sizer_2.Add(self.btnOK, 0, 0, 0)
        sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade

# end of class MyFrame

if __name__ == "__main__":
    wxGTest1 = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    wxGTest1.SetTopWindow(frame_1)
    frame_1.Show()
    wxGTest1.MainLoop()
*Erik Vandamme
54 Hilltop Road - WAMBERAL NSW 2260 Australia
erik1vandamme@gmail.com
Skype - erik_vandamme
02 43843613 - 0406 042750*
  
Hope that helps some...

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

I appreciate the "def"s are weird but thats what i got from that tutorial, I presume that the author is trying to define an "event" and then give the method for it... as in: and yeah I've tried with a colon, makes no difference
    def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)
    def pushOK(self,event):
        self.self.txtLog.WriteText("OK \n")
        # save .jpg of frame valThumb
        strval=('0'+str(self.valThumb).strip())[-2:]
        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%(self.fname,strval)

The line above needs to end like this: % (self.fname,strval) thnx I already figured that out as well

Mike Driscoll wrote:

···

Erik Vandamme wrote:

I was trying to follow a wxGlade tutorial, but got stuck
line 33 always give me a syntax error, do I have an identation problem?

If it was an indentation error, the error message should say so...

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.3 on Sun Sep 07 13:07:52 2008

import wx

# begin wxGlade: extracode
# end wxGlade
import os as os

class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MyFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.dImage = wx.StaticBitmap(self, -1, wx.Bitmap("C:\\etemp\\dThumb.jpg", wx.BITMAP_TYPE_ANY))
        self.dSlider = wx.Slider(self, -1, 0, 0, 10, style=wx.SL_HORIZONTAL|wx.SL_AUTOTICKS|wx.SL_LEFT|wx.SL_RIGHT)
        self.btnHead = wx.Button(self, -1, "Delete Head\n")
        self.btnThumb = wx.Button(self, -1, "ThumbNail\n")
        self.btnTail = wx.Button(self, -1, "Delete Tail\n")
        self.txtLog = wx.Button(self, -1, "")
        self.btnOK = wx.Button(self, -1, "Save OK")

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
        self.valHead = 0
        self.valThumb = 0
        self.valTail = 0
        self.valSlider = 0
        self.fname = "HOUSEPART1"
            
None of these methods have a colon on the end, so they're not valid. I don't think you want to make methods called "wx.EVT_BUTTON" anyway as that's just bad form. If I comment these lines out, it finds another error in the pushOK method.

    def wx.EVT_BUTTON(self.self.btnTail.GetId(), self.pushTail)
    def wx.EVT_BUTTON(self.self.btnHead.GetId(), self.pushHead)
    def wx.EVT_BUTTON(self.self.btnThumb.GetId(), self.pushThumb)
    def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)
    def wx.EVT_SCROLL(self.self.dSlider.GetId(), self.onScroll)

       def pushHead(self,event):
        self.self.txtLog.WriteText("Heads..\n")
        self.valHead= self.valSlider
           def pushThumb(self,event):
        self.self.txtLog.WriteText("Thumb...\n")
        self.valThumb= self.valSlider

    def pushTail(self,event):
        self.self.txtLog.WriteText("Tail\n")
        self.valTail= self.valSlider

    def pushOK(self,event):
        self.self.txtLog.WriteText("OK \n")
        # save .jpg of frame valThumb
        strval=('0'+str(self.valThumb).strip())[-2:]
        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%self.fname,%(strval)

The line above needs to end like this: % (self.fname,strval)

        # now copy Video file from frames valHead to valTail
        strval1=('0'+str(self.valHead).strip())[-2:]
        strval2=('0'+str(self.valTail).strip())[-2:]
        # make sure valTail is filled in properly or use something to get total no of frames
        # and calc diff between Head and Tail as the no frames
        nframes = strval2 - strval1
        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes %s -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%(self.fname,strval1,nframes)

    def OnScroll(self,event):
        self.self.txtLog.WriteText("Scrolling\n")
        slider = evt.EventObject
        self.valThumb= slider.Value
        self.valSlider = slider.Value
        val = self.valThumb
        strval=('0'+str(val).strip())[-2:]
        #cmdstr=r"d:\download\ffmpeg\ffmpeg\bin\ffmpeg -y -i c:\temp\v1.swf -an -s 160x120 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec png -f rawvideo c:\temp\thumbnail.png"%(strval)

        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%self.fname,%(strval)

Same issue here...

        self.self.dImage.Picture = ""
        print cmdstr
        os.system(cmdstr)
        self.self.dImage.Picture = r"c:\etemp\dthumb.jpg"

    def __set_properties(self):
        # begin wxGlade: MyFrame.__set_properties
        self.SetTitle("frame_1")
        self.dImage.SetMinSize((640,480))
        self.dSlider.SetMinSize((600, 32))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MyFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
        sizer_1.Add(self.dImage, 1, wx.EXPAND, 0)
        sizer_1.Add(self.dSlider, 0, 0, 0)
        sizer_2.Add(self.btnHead, 0, 0, 0)
        sizer_2.Add(self.btnThumb, 0, 0, 0)
        sizer_2.Add(self.btnTail, 0, 0, 0)
        sizer_2.Add(self.btnOK, 0, 0, 0)
        sizer_1.Add(sizer_2, 0, wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade

# end of class MyFrame

if __name__ == "__main__":
    wxGTest1 = wx.PySimpleApp(0)
    wx.InitAllImageHandlers()
    frame_1 = MyFrame(None, -1, "")
    wxGTest1.SetTopWindow(frame_1)
    frame_1.Show()
    wxGTest1.MainLoop()
*Erik Vandamme
54 Hilltop Road - WAMBERAL NSW 2260 Australia
erik1vandamme@gmail.com
Skype - erik_vandamme
02 43843613 - 0406 042750*
  
Hope that helps some...

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Yeah those "def's without colon look wierd, but thats what the author did!
see http://tutorial.jwcn.com/Web-Design/Python/Development/2007-08-25/3038.html

Frank Millman wrote:

···

Erik Vandamme wrote:
  

I was trying to follow a wxGlade tutorial, but got stuck line 33 always give me a syntax error, do I have an identation problem?

I think I can tell you which are the offending lines -

    def wx.EVT_BUTTON(self.self.btnTail.GetId(), self.pushTail)
    def wx.EVT_BUTTON(self.self.btnHead.GetId(), self.pushHead)
    def wx.EVT_BUTTON(self.self.btnThumb.GetId(), self.pushThumb)
    def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)
    def wx.EVT_SCROLL(self.self.dSlider.GetId(), self.onScroll)

The above is not valid python syntax. A 'def' statement must be followed by
a colon and a block of code.

Unfortunately I do not know wxGlade, so I cannot suggest a solution.

HTH

Frank Millman

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Hi Erik,

Yeah those "def's without colon look wierd, but thats what the author did!
see http://tutorial.jwcn.com/Web-Design/Python/Development/2007-08-25/3038.html

I'm getting an "Address Not Found" error for that link. Anyway, here's how you're supposed to do it:

<code>
# create button
btn = wx.Button(parent=myPanel, id=wx.ID_ANY, title='Push Me')

# bind event where self is a frame or top level widget
self.Bind(wx.EVT_BUTTON, self.onEvent, btn)
# or like this:
#self.btn.Bind(wx.EVT_BUTTON, self.onEvent)

def onEvent(self, event):
    # do something
    pass

</code>

I'm not sure what that author is smoking, but it must be good.

Mike

···

Frank Millman wrote:

Erik Vandamme wrote:

I was trying to follow a wxGlade tutorial, but got stuck line 33 always give me a syntax error, do I have an identation problem?

I think I can tell you which are the offending lines -

    def wx.EVT_BUTTON(self.self.btnTail.GetId(), self.pushTail)
    def wx.EVT_BUTTON(self.self.btnHead.GetId(), self.pushHead)
    def wx.EVT_BUTTON(self.self.btnThumb.GetId(), self.pushThumb)
    def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)
    def wx.EVT_SCROLL(self.self.dSlider.GetId(), self.onScroll)

The above is not valid python syntax. A 'def' statement must be followed by
a colon and a block of code.

Unfortunately I do not know wxGlade, so I cannot suggest a solution.

HTH

Frank Millman

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

</div>

Erik Vandamme wrote:

I appreciate the "def"s are weird but thats what i got from that tutorial, I presume that the author is trying to define an "event" and then give the method for it... as in: and yeah I've tried with a colon, makes no difference

I'm pretty sure python simply doesn't allow one to do that -- create a function directly in a modules namespace. You could do:

def MyFunc():
   whatever

wx.MyFunc = MyFunc

But I don't think that want you want anyway. There is either an error in the Tutorial, or you've misunderstood something. Which tutorial is this?

   def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)

This looks a whole lot like it should be simply:

     wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)

though the "self.self" looks fishy too, so I"m going to guess:

     wx.EVT_BUTTON(self.btnOK.GetId(), self.pushOK)

which means: 'bind the button event from self.btnOK to the self.pushOK method'

However, there is a newer syntax for doing this, that I like better:

     self.btnOK.Bind(wx.EVT_BUTTON, self.pushOK)

See:
   wxPython Style Guide - wxPyWiki

Just a note about learning -- you've got an awful lot of code here for something that is completely non-functional. I strongly suggest that you start with a really, really simple app - just a frame and maybe a panel, and add your bits one by one -- one button with one callback, and get each piece working before you put it all together.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Thanks Chris, after reorganising the code like this: i get
AttributeError: 'MyFrame' object has no attribute 'onScroll'

       self.fname = "HOUSEPART1"
        self.btnOK.Bind(wx.EVT_BUTTON,self.pushOK)
        self.btnTail.Bind(wx.EVT_BUTTON,self.pushTail)
        self.btnHead.Bind(wx.EVT_BUTTON, self.pushHead)
        self.btnThumb.Bind(wx.EVT_BUTTON, self.pushThumb)
        self.dSlider.Bind(wx.EVT_SCROLL, self.onScroll)
      def OnScroll(self,event):
        self.self.txtLog.WriteText("Scrolling\n")
        slider = evt.EventObject
        self.valThumb= slider.Value
        self.valSlider = slider.Value
        val = self.valThumb
        strval=('0'+str(val).strip())[-2:]
        #use ffmpeg tto make a sigle frame thumbnail at that location
        cmdstr=r"c:\ffmpeg\ffmpeg -y -i c:\etemp\%s.avi -an -s 640x480 -ss 00:00:%s -an -r 1 -vframes 1 -y -vcodec mjpeg -f rawvideo c:\etemp\dthumb.jpg"%(self.fname,strval)
        self.self.dImage.Picture = ""
        print cmdstr
        os.system(cmdstr)
        self.self.dImage.Picture = r"c:\etemp\dthumb.jpg"

     def pushHead(self,event):
        self.self.txtLog.WriteText("Heads..\n")
        self.valHead= self.valSlider
       
*Erik Vandamme
54 Hilltop Road - WAMBERAL NSW 2260 Australia
erik1vandamme@gmail.com
Skype - erik_vandamme
02 43843613 - 0406 042750*

Christopher Barker wrote:

···

Erik Vandamme wrote:

I appreciate the "def"s are weird but thats what i got from that tutorial, I presume that the author is trying to define an "event" and then give the method for it... as in: and yeah I've tried with a colon, makes no difference

I'm pretty sure python simply doesn't allow one to do that -- create a function directly in a modules namespace. You could do:

def MyFunc():
  whatever

wx.MyFunc = MyFunc

But I don't think that want you want anyway. There is either an error in the Tutorial, or you've misunderstood something. Which tutorial is this?

   def wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)

This looks a whole lot like it should be simply:

    wx.EVT_BUTTON(self.self.btnOK .GetId(), self.pushOK)

though the "self.self" looks fishy too, so I"m going to guess:

    wx.EVT_BUTTON(self.btnOK.GetId(), self.pushOK)

which means: 'bind the button event from self.btnOK to the self.pushOK method'

However, there is a newer syntax for doing this, that I like better:

    self.btnOK.Bind(wx.EVT_BUTTON, self.pushOK)

See:
  wxPython Style Guide - wxPyWiki

Just a note about learning -- you've got an awful lot of code here for something that is completely non-functional. I strongly suggest that you start with a really, really simple app - just a frame and maybe a panel, and add your bits one by one -- one button with one callback, and get each piece working before you put it all together.

-Chris

Erik Vandamme wrote:

Thanks Chris, after reorganising the code like this: i get
AttributeError: 'MyFrame' object has no attribute 'onScroll'

it's a typo:

you use "onScroll" here:

       self.dSlider.Bind(wx.EVT_SCROLL, self.onScroll)

and "OnScroll" here:

   def OnScroll(self,event):

(different case of the "O")

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Thnx Chris, funny that the spe context IDE does not help me properly ther , i.e. I type self then the dot and then use the dropdown... a bit disappointing (i have a fysiological problem with eye focus and these type or errors are very hard to catch for me)

Christopher Barker wrote:

···

Erik Vandamme wrote:

Thanks Chris, after reorganising the code like this: i get
AttributeError: 'MyFrame' object has no attribute 'onScroll'

it's a typo:

you use "onScroll" here:

       self.dSlider.Bind(wx.EVT_SCROLL, self.onScroll)

and "OnScroll" here:

   def OnScroll(self,event):

(different case of the "O")

-Chris

Mike Driscoll schrieb:

Hi Erik,

Yeah those "def's without colon look wierd, but thats what the author did!
see http://tutorial.jwcn.com/Web-Design/Python/Development/2007-08-25/3038.html

I assume the correct URL is

http://tutorial.jcwcn.com/Web-Design/Python/Development/2007-08-25/3038.html
                  X

But there are correct functions:

  wx.EVT_BUTTON(self,self.button_1.GetId(), self.pushA)

  def pushA(self, event):
      self.text_ctrl_1.WriteText("You pressed A\n")

Egon

Egon,

Mike Driscoll schrieb:

Hi Erik,

Yeah those "def's without colon look wierd, but thats what the author did!
see http://tutorial.jwcn.com/Web-Design/Python/Development/2007-08-25/3038.html

I assume the correct URL is

http://tutorial.jcwcn.com/Web-Design/Python/Development/2007-08-25/3038.html

                 X

But there are correct functions:

    wx.EVT_BUTTON(self,self.button_1.GetId(), self.pushA)

    def pushA(self, event):
        self.text_ctrl_1.WriteText("You pressed A\n")

Egon

You are correct. Those are fine. But in the previous post, their were goofy functions that were like this:

def wx.EVT_BUTTON(something, something)

That's not a good idea...

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org