TemplateScreenlet from screenlets.org does not work on Ubuntu Hardy?

Asked by Glenn J. Mason

I'm new to Screenlet development, and Python, but I'm trying to take the TemplateScreenlet from screenlets.org and make something simple.

The Template itself doesn't work -- complains that it is unable to load the 'default' theme.

When I modify to remove theme references, it complains that there is no self.draw_text function ... confused!

The start of the constructor, showing theming (hopefully) switched off:

 # constructor
 def __init__ (self, **keyword_args):
  #call super (width/height MUST match the size of graphics in the theme)
  screenlets.Screenlet.__init__(self, width=200, height=200,
   uses_theme=False, **keyword_args)
  # set theme
  #self.theme_name = "default"
  # add option group

The on_draw function, which complains that draw_text doesn't exist:

 def on_draw (self, ctx):
  """In here we draw"""
                """In here we load the theme"""
  # if theme is loaded
  #if self.theme:
  # set scale rel. to scale-attribute
  ctx.scale(self.scale, self.scale)
  ctx.set_source_rgba(self.color_example[2], self.color_example[1], self.color_example[0],0.4)
  #if self.hover:
   #self.theme.draw_rounded_rectangle(ctx,0,0,20,self.width,self.height)
  #self.draw_circle(ctx,0,0,self.width,self.height)
  # TEST: render example-bg into context (either PNG or SVG)
  #self.theme.render(ctx, 'example-bg')
  ctx.set_source_rgba( self.color_example[0], self.color_example[1], self.color_example[2],self.color_example[3])
  self.draw_text(ctx, self.test_text, 0, 0, self.font_example , 10,self.width,pango.ALIGN_LEFT)
  self.draw_line(ctx,0,40,self.width,0,1)
  self.draw_text(ctx, 'timer - ' + str(self.number), 0, 130, self.font_example , 10, self.width,pango.ALIGN_LEFT)

  #self.draw_text(ctx, self.theme_name, 0, 50, self.font_example , 10, self.width,pango.ALIGN_LEFT)

  self.draw_text(ctx, 'mouse x ' + str(self.mousex ) + ' \n mouse y ' + str(self.mousey ) , 0, 170, self.font_example , 10,self.width,pango.ALIGN_LEFT)

  # render svg-file
  #self.theme['example-bg.svg'].render_cairo(ctx)
  # render png-file
  #ctx.set_source_surface(self.theme['example-test.png'], 0, 0)
  ctx.paint()

Question information

Language:
English Edit question
Status:
Solved
For:
Screenlets Edit question
Assignee:
No assignee Edit question
Solved by:
Glenn J. Mason
Solved:
Last query:
Last reply:
Revision history for this message
Glenn J. Mason (glennji) said :
#1

(eeek! So much for indenting. Does it still make something like sense? I don't yet know enough to ask intelligent questions.)

Revision history for this message
Glenn J. Mason (glennji) said :
#2

Ah, I have to implement my own draw_text -- it's not a built-in function of Screenlets?