Clutter import error

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

Clutter import error

Postby asmas » Tue Feb 09, 2010 5:38 pm

I've been trying to do the tutorial in LXF129. When I try to do the first clutter bit:
Code: Select all
...
>>> black = clutter.color(0,0,0,255)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'color'

I have tried this on Ubuntu & Arch. Does anyone no why this isn't working?
asmas
 
Posts: 8
Joined: Mon Dec 14, 2009 5:38 pm

Postby LeeNukes » Tue Feb 09, 2010 10:00 pm

Is something missing a set_color?
User avatar
LeeNukes
LXF regular
 
Posts: 954
Joined: Sun Jun 21, 2009 8:11 pm
Location: At the bar

Postby spaceyhase » Wed Feb 10, 2010 10:06 am

It's case sensitive, upper-case 'C'.

Code: Select all
black = clutter.Color(0,0,0,255)
spaceyhase
LXF regular
 
Posts: 116
Joined: Mon Jun 30, 2008 12:07 pm

Postby asmas » Wed Feb 10, 2010 5:15 pm

Thanks
asmas
 
Posts: 8
Joined: Mon Dec 14, 2009 5:38 pm

Postby asmas » Wed Feb 10, 2010 5:38 pm

When you run the listing on the CD, no clutter window appears?
asmas
 
Posts: 8
Joined: Mon Dec 14, 2009 5:38 pm

Postby spaceyhase » Wed Feb 10, 2010 7:23 pm

Yeah, big fail this month I reckon as the mag says there should be comments too for extra fun but it's just a dump of what was typed in the mag. It even has carriage returns throughout too... D'oh! If you stick a...

Code: Select all
clutter.main()


...at the end then the window sticks around long enough to see some action. But then it doesn't behave the same way as typing it in either, overlapping the animations. Erm.

I had some fun with mine. If you run it, hit 'space' in the window and it spins the text around, increments the story to the next one in the feed. It ain't perfect but I got bored ;)

Code: Select all
black = clutter.Color(0,0,0,255)
white = clutter.Color(255,255,255,255)
blue = clutter.Color(0,0,255,255)
d=360
story=0

def parseKeyPress(self, event):
    global d, story
    if event.keyval == clutter.keysyms.q:
        clutter.main_quit()
    elif event.keyval == clutter.keysyms.space:
          group.animate(clutter.LINEAR,500,'rotation-angle-y',d)
          d = -d
          story = story + 1;
          head.set_text(f.entries[story].summary)
          body.set_text(f.entries[story].summary)
    print 'event processed ', event.keyval

stage = clutter.Stage()
stage.set_size(400,60)
stage.set_color(white)
stage.connect('key-press-event', parseKeyPress)
stage.show_all()
ident=clutter.texture_new_from_file(img)

group=clutter.Group()
head=clutter.Text()
head.set_position(130,5)
head.set_color(blue)
head.set_text(f.entries[story].title)
body=clutter.Text()
body.set_max_length(75)
body.set_position(130,22)
body.set_size(250,100)
body.set_line_wrap(True)
body.set_text(f.entries[story].summary)
group.add(ident, head, body)
group.show_all()
stage.add(group)

clutter.main()


What I should have done is use 'Left' and 'Right' to go backwards and then forwards (forwards and then backwards, Eezer is the geezer who loves to muscle in... sorry!)
spaceyhase
LXF regular
 
Posts: 116
Joined: Mon Jun 30, 2008 12:07 pm

Postby evilnick » Sat Feb 13, 2010 2:12 pm

sorry about the typo - i reckon that fell foul of a spellchecker somewhere.

There was/is a longer version of this, briefly annotated and turned into a proper app. I think I sent it to Mike too late to put on the CD, but I if I can find it I will bung it up here. The code that was included was just the commandline stuff from the magazine, included to help in case of typesetting errors etc. ironically
User avatar
evilnick
Moderator
 
Posts: 151
Joined: Mon Apr 04, 2005 11:47 am
Location: LXF towers


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest