Main index > Python programming > nothing appearing, i'm confused

By cs-cam (Desklet Author), on Mon Oct 17 11:26:50 2005: nothing appearing, i'm confused.

I'm lost. In deskicon (tarball can be found here), in Events._display(), if I paint the buffer transparent black before I draw everything else, nothing appears! The drawing of the icons etc is done after painting everything transparent and I can't find why it won't display. I might be just tired but I'm trying to do it the same way as I do it in desknotes and that works fine...

Here is _display() as it stands (different from in the tarball I think):

Code:


        def _display(self):
                if self.i.update():
                        x, y = self.i.dimensions()
                        if (x, y) != (self.x, self.y):
                                self.x = x
                                self.y = y
                                adesklets.window_resize(self.x, self.y)
                        
                        adesklets.context_set_image(self.buffer)
                        adesklets.context_set_color(0,0,0,0)
                        adesklets.context_set_blend(False)
                        adesklets.image_fill_rectangle(0,0,self.x,self.y)
                        adesklets.context_set_blend(True)
                        
                        self.i.render()
                        
                        adesklets.context_set_image(0)
                        adesklets.context_set_blend(False)
                        adesklets.blend_image_onto_image(self.buffer,1,0,0,self.x,self.y,0,0,self.x,self.y)
                        adesklets.context_set_blend(True)
                        adesklets.fonts_reset_all()
                else:
                        return


self.i.render() is where the drawing takes place. Am I stupid?

Thanks for any help :wink:

By syfou (Core Developer & Desklet Author), on Mon Oct 17 11:52:41 2005.

As far as I see, this code snippet is perfectly fine regarding the graphic operation itself --- but by running the whole deskicon code, it seems the content of the self.i.update() block never get executed, since self.i.update() seems to always be False. Just replace it temporarily by:

Code:


if True:
   self.x, self.y = self.i.dimensions()
   [...]


And you will see :D . Yours,

By cs-cam (Desklet Author), on Mon Oct 17 19:29:16 2005.

Does that work for you at your end? self.i.update() is certainly returning True and the code block is being executed which is the reason I am so confused as to why it's not appearing as it should. If I change the opening code this this:

Code:


        def _display(self):
                updated = self.i.update()
                print updated
                if updated:
                        [...]


Then in the terminal I get printed:

Code:


[cam@sylvester deskicon-0.0.1]$ python deskicon.py
Do you want to (r)egister this desklet or to (t)est it? t
Now testing...
============================================================
If you do not see anything (or just an initial flicker
in the top left corner of your screen), try `--help',
and see the FAQ: `info adesklets'.
============================================================
True
False
False
False
False


Which shows it initially returns True which means great, lets draw the desklet and thereafter False so lets not because nothing has changed. The changing factor here is the small code block before self.i.render() that paints the buffer transparent black to start drawing with a clean background. If I remove that block the desklet contents show as they should. For the static icon that is all that is needed but with the mount icon, when it gets updated (ie. the partition it's monitoring is mounted/umounted) then it draws the new text over the old text and renders the lot unreadable.

Even after a good nights sleep I can't see where I've messed up but if you remove this block of code, it will work like it should but break the possibility of any dynamic icons :(

Code:


                        adesklets.context_set_image(self.buffer)
                        adesklets.context_set_color(0,0,0,0)
                        adesklets.context_set_blend(False)
                        adesklets.image_fill_rectangle(0,0,self.x,self.y)
                        adesklets.context_set_blend(True)

By syfou (Core Developer & Desklet Author), on Mon Oct 17 19:53:32 2005.

cs-cam wrote:


Then in the terminal I get printed: [...]

When I do this, I just get a succession of "False" outputted.

cs-cam wrote:


Does that work for you at your end?

I am afraid it does: when I keep the block in, forcing its execution at each alarm cycle, I get a correct print out of the screen (and sometimes random crashes with incorrect sequences of commands); so I do not believe the problem to be from my side of things...

By cs-cam (Desklet Author), on Mon Oct 17 20:06:55 2005.

Alright, back to the drawing board ;) Thanks for taking to time to test it :)


adesklets is proud to be hosted on:

SourceForge.net Logo

Back to adesklets.sf.net.