HelloWorldScreenlet

Conky

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

0
6.0
Description:

This is a demonstration screenlet, not for use by normal users. The code is commented extensively to help developers understand how to code screenlets, and to provide them with an example of screenlet that has updating text on a simple background. Hopefully this demonstration screenlet will allow you to understand how a screenlet is coded and allow you to code desklets of your own to better Gnome.
Last changelog:

11 years ago

*Fixed Possible Memory Leak in draw_text() definition

**Changed the draw_text() definition to accept values for font type and the width of the "drawing area"

Whise

11 years ago

self.draw_text(ctx, '<b>' + self.mytext + '</b>', 10, 10, 10)


where did you find this? is it on the latest bzr? what does the 10,10,10 represent?

nice job

Report

Whise

11 years ago

nevermind i just saw you def...

you wrote it your self?

i should warn you that you shouldnt make people use yor funtion because of several things

you should check out this topic

http://forum.compiz-fusion.org/showthread.php?t=3576&highlight=memory+leak

because in the way you draw your text there is a memory leak , that can become very severe so i advise you to read the topic

also you should allow people to select the width of the text area pago allows you to do that

Report

C

mkoehle1

11 years ago

Whise,

Great catch - I hadn't thought about this. I fixed that problem in the draw_text() def, but I didn't add the option to change the text width yet. I'll add that in when I get a chance - Thanks for the pointer.

Report

Whise

11 years ago

could you also implement the font option? that would be nice, if you implement those 2 i think you should contact rix and ask him about implementing the draw_text function in the screenlets core, making the life easyier for devs

Report

C

mkoehle1

11 years ago

Whise,

I've changed the draw_text() definition to be as follows:

=====================================
def draw_text(self, ctx, value, x, y, width, font, size):
=====================================

The added options are 'width' and 'font', which are variables representing the width of the drawing area and the font type, respectively. Please tell me if there is anything else that you would like me to modify.

Report

Whise

11 years ago

seems really good now , if you can only add the option to set a default font in case the font doesnt get specified (maybe sans), after that maybe you should contact RYX and see if he can get this funtion into the core seems really helpfull

nice job

Report

Whise

11 years ago

ohh and i forgot , also there is need for the option for text color , maybe that should be specified outside the function

Report

Whise

11 years ago

sorry for the spelling :)

Report

C

mkoehle1

11 years ago

Whise,

No, it isn't part of the bzr, I just have it defined below:

=======================================

# This is a user defined function that will tell python how to draw the text onto the background
def draw_text(self, ctx, value, x, y, size):

=======================================

The 10,10,10 represents the x coordinate, y coordinate, and the font size. Therefore, I decided to have the drawing position start 10 pixels from left of the background and 10 pixels down from the top of the background, and I decided to use size 10 font. Thanks for asking for clarification.

Report

11 years ago

*Fixed Possible Memory Leak in draw_text() definition

**Changed the draw_text() definition to accept values for font type and the width of the "drawing area"

12345678910
product-maker Count:13 Rating: 6.00
File (click to download) Version Description Downloads Date Filesize DL OCS-Install
Pling
*Needs ocs-url or ocs-store to install things
Details
license
version
0.1
updated Oct 10 2007
added Oct 09 2007
downloads today
0
page views today 2