[pygtk] Funny Indent

Mats Taraldsvik mats.taraldsvik at bickeringleague.net
Thu Apr 16 22:29:23 WST 2009


If you use gedit, there is a plugin, Draw Spaces, that draws tabs and
spaces. Incredibly useful for python programming...

Mats

On Wed, 2009-04-15 at 14:18 -0400, Steve McClure wrote:
> 
> On Apr 15, 2009, at 1:57 PM, Nawal Husnoo wrote:
> 
> > Dear PyGTK users,
> > 
> > I have never used PyGTK, and I only wanted to extract some gstreamer
> > webcam code from a script I found on:
> > 
> > http://giss.tv/wiki/index.php/Streaming_Tools#GStreamer_2
> > 
> > 
> > I have removed most of the codes I don't need, but I'm puzzled by
> > the indentation used:
> > 
> > class GTK_Main:
> > 
> >     def __init__(self):
> >         window = gtk.Window(gtk.WINDOW_TOPLEVEL)
> >         window.set_title("Webcam Streamer")
> >         window.set_default_size(1024, 768)
> > 
> >         window.connect("destroy", gtk.main_quit, "WM destroy")
> >                 self.sstate = 'preparing'
> > <<<<======================================
> > 
> >                 red=gtk.gdk.color_parse('grey')
> >                 eb=gtk.EventBox()
> >                 eb.modify_bg(gtk.STATE_NORMAL, red)
> >                 window.add(eb)
> > 
> >         windows = gtk.ScrolledWindow()
> >         windows.set_size_request(600, 400)
> >         eb.add(windows)
> > 
> > 
> > Could anyone tell me if this has something to do with PyGTK itself
> > or if it's something deeper in Python? If I remove the "extra"
> > indent, and run the code, it gives this error:
> > 
> >   File "./Webcamstream-v4l2.pys", line 29
> >     red=gtk.gdk.color_parse('grey')
> >     ^
> > IndentationError: unexpected indent
> > 
> > 
> > If I remove the indent in all 5 indented lines, it complains in the
> > same way with the next one:
> > 
> >   File "./Webcamstream-v4l2.pys", line 34
> >     windows = gtk.ScrolledWindow()
> >     ^
> > IndentationError: unexpected indent
> > 
> > Any ideas?
> 
> 
> Your .pys file has mixed tabs and spaces.  If by "remove the indent in
> all 5 indented lines" you actually replaced the spaces with tabs, I
> think you would find the code worked as expected.  It looks like the
> tab spacing is expected to be 8 here.
> 
> > 
> > Thanks,
> > 
> > Nawal.
> > 
> > -- 
> > The best way to predict the future is to invent it. - Alan Kay
> > http://www.galileon.co.uk/
> > <Webcamstream-v4l2.pys>_______________________________________________
> > pygtk mailing list   pygtk at daa.com.au
> > http://www.daa.com.au/mailman/listinfo/pygtk
> > Read the PyGTK FAQ: http://faq.pygtk.org/
> 
> --
> Steve McClure
> smcclure at racemi.com
> 
> _______________________________________________
> pygtk mailing list   pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/



More information about the pygtk mailing list