From: Lee C. <LeeCausier@GameBox.net> - 2003-05-30 13:55:13
|
Hi, I saw the df plugin that displays diskfree as an item in the menu you get when you press e on a dir and wondered how easy it would be to make an idlebar version so I can see it all the time. With a little help, I managed to cook up something (very reminiscent of the clock idlebar plugin) but it's still pretty naff. It currently only works while playing music as I cant figure out how to get the current dir any other way. Here's my (somewhat rubbish) code... class df(IdleBarPlugin): def __init__(self): IdleBarPlugin.__init__(self) self.DFFONT = 'skins/fonts/Trebuchet_MS.ttf' if not os.path.isfile(self.DFFONT): # XXX Get this from the skin, but for now this will allow it to work self.DFFONT = config.OSD_DEFAULT_FONTNAME def draw(self, (type, object)): if type == 'player': dirname = object.menuw.all_items[object.menuw.selected].name diskfree = '%i of %i Mb free' % \ ( (( util.freespace(object.filename) / 1024) / 1024), ((util.totalspace(object.filename) /1024) /1024)) osd.drawstring(diskfree,osd.width-160,20,fgcolor=0xffffff,font=self.DFFONT,ptsize=12) else: osd.drawstring('diskspace is unknown',osd.width-160,20,fgcolor=0xffffff,font=self.DFFONT,ptsize=12) As you can see I cheat by using the filename of the current song to find the freespace and totalspace. I also changed the hard-coded 580 x co-ordinate to osd.width-160; which I also did with the clock... I think it makes sense as the clock looks silly in the middle at higher resolutions and looks even more daft when it has the am/pm cut off in 640x480. If you have any comments, suggestions or improvements, I'd be more than happy to hear them. If you think this is a good idea, please let me know as I would like to know just how dumb it is or if it might prove useful to someone, somewhere, in a rather peculiar set of circumstances, rather like Tom Lehrer's The Elements song... ``There's antimony, arsenic, aluminum, selenium, And hydrogen and oxygen and nitrogen and rhenium And nickel, neodymium, neptunium, germanium, And iron, americium, ruthenium, uranium, Europium, zirconium, lutetium, vanadium And lanthanum and osmium and astatine and radium And gold, protactinium and indium and gallium (inhale) And iodine and thorium and thulium and thallium. And I'm sure you know the rest or don't care to ;). Lee Causier. |