|
|
#14 (permalink) |
|
Débutant
![]() Date d'inscription: avril 2005
Localisation: NEVEZ finistere sud
Messages: 1 472
Pouvoir de réputation: 94
![]() |
Je suppose que c'est celui ci que tu veux,c'est un peu long,mais je colle tout quand même,si ça n'est pas celui là tu me fais signe.
# Analog Clock 0.1 # 2004, Ido Abramovich <idoa01 at yahoo dot com> # # A SuperKaramba analog clock # # Copyright (C) 2004 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA #this import statement allows access to the karamba functions import karamba import time import math HOUR = 3 MIN = 4 SEC = 5 T_W = 0 T_H = 1 T_BG = 2 T_HOUR = 3 T_MIN = 4 T_SEC = 5 EXTRA_HEIGHT = 0 # When adding new themes, remember to add a line to the theme chooser code in themecommand (menuOptionChanged function) # the first number in the list is the width and the second is the height themes = { "chromeTheme" : [267,267,"ChromeClock.png","ChromeHourHand.png","Ch romeMinHand.png","ChromeSecHand.png"] } # This class represents a clock hand class Hand: def __init__(self, widget, picture, width, height): self.picture = karamba.createImage(widget,0,0,picture) self.show = 1 self.height = height self.width = width def hideHand(self, widget): if (self.show == 1): self.show = 0 karamba.hideImage(widget,self.picture) def showHand(self, widget): if (self.show == 0): self.show = 1 karamba.showImage(widget,self.picture) def resize(self,widget,nWidth,nHeight): self.height = nHeight self.width = nWidth karamba.resizeImage(widget,self.picture,self.width ,self.height) def replacePicture(self, widget, nPicture, nHeight, nWidth): karamba.deleteImage(widget,self.picture) self.picture = karamba.createImage(widget, 0, 0, nPicture) if (self.show == 0): karamba.hideImage(widget,self.picture) self.height = nHeight self.width = nWidth def rotate(self, widget, deg): karamba.rotateImage(widget, self.picture, int(deg)) w = karamba.getImageWidth(widget,self.picture) h = karamba.getImageHeight(widget,self.picture) karamba.moveImage(widget, self.picture, -((w-self.width)/2), -((h-self.height)/2)) class HourHand(Hand): def advance(self, widget, hours, minutes, seconds): if (self.show == 1): deg = hours*30 + minutes*0.5 + seconds*0.0083 Hand.rotate(self,widget,deg) class MinHand(Hand): def advance(self, widget, hours, minutes, seconds): if (self.show == 1): deg = minutes*6 + seconds*0.1 Hand.rotate(self,widget,deg) class SecHand(Hand): def advance(self, widget, hours, minutes, seconds): if (self.show == 1): deg = seconds*6 Hand.rotate(self,widget,deg) class ClockWork: def __init__(self,widget,theme): global _width,_height self.background = karamba.createImage(widget, 0, 0, theme[T_BG]) self.defWidth = theme[T_W] self.defHeight = theme[T_H] self.bgWidth = _width self.bgHeight = _height self.minHand = MinHand(widget,theme[T_MIN],_width,_height) self.hourHand = HourHand(widget,theme[T_HOUR],_width,_height) self.secHand = SecHand(widget,theme[T_SEC],_width,_height) if (self.bgWidth != theme[T_W]) or (self.bgHeight != theme[T_H]): self.resize(widget,self.bgWidth,self.bgHeight) # karamba.attachClickArea(widget,self.background) self.advance(widget) def advance(self,widget): time_tuple = time.localtime() hours = time_tuple[HOUR] minutes = time_tuple[MIN] seconds = time_tuple[SEC] self.minHand.advance(widget,hours,minutes,seconds) self.hourHand.advance(widget,hours,minutes,seconds ) self.secHand.advance(widget,hours,minutes,seconds) def changeTheme(self, widget, theme): karamba.deleteImage(widget,self.background) self.background = karamba.createImage(widget, 0, 0, theme[T_BG]) # karamba.attachClickArea(widget,self.background) self.defWidth = self.bgWidth = theme[T_W] self.defHeight = self.bgHeight = theme[T_H] karamba.writeConfigEntry(widget,"width",str(self.d efWidth)) karamba.writeConfigEntry(widget,"height",str(self. defHeight)) karamba.resizeWidget(widget,self.defWidth,self.def Height+EXTRA_HEIGHT) self.minHand.replacePicture(widget,theme[T_MIN],theme[T_W],theme[T_H]) self.hourHand.replacePicture(widget,theme[T_HOUR],theme[T_W],theme[T_H]) self.secHand.replacePicture(widget,theme[T_SEC],theme[T_W],theme[T_H]) def hideSec(self, widget): self.secHand.hideHand(widget) def showSec(self, widget): self.secHand.showHand(widget) self.advance(widget) def resize(self, widget, nWidth, nHeight): self.bgWidth = nWidth self.bgHeight = nHeight karamba.resizeImage(widget,self.background,self.bg Width,self.bgHeight) self.minHand.resize(widget,nWidth,nHeight) self.hourHand.resize(widget,nWidth,nHeight) self.secHand.resize(widget,nWidth,nHeight) def defaultDim(self, widget): self.resize(widget,self.defWidth,self.defHeight) karamba.resizeWidget(widget,self.defWidth,self.def Height+EXTRA_HEIGHT) karamba.writeConfigEntry(widget,"width",str(self.d efWidth)) karamba.writeConfigEntry(widget,"height",str(self. defHeight)) #this is called when you widget is initialized def initWidget(widget): global clock,_height,_width,hide karamba.addMenuConfigOption(widget,"theme","Select Theme") karamba.addMenuConfigOption(widget,"hide","Hide Seconds") karamba.addMenuConfigOption(widget,"resize","Resiz e Applet") karamba.addMenuConfigOption(widget,"resizePercenta ge","Resize Applet - percentage") karamba.addMenuConfigOption(widget,"defdim","Resto re Default Dimensions") themeName = None themeName = karamba.readConfigEntry(widget,"theme") if themeName == None: themeName = "chromeTheme" _width = None _width = karamba.readConfigEntry(widget,"width") if _width == None: _width = themes[themeName][T_W] else: _width = int(_width) _height = None _height = karamba.readConfigEntry(widget,"height") if _height == None: _height = themes[themeName][T_H] else: _height = int(_height) ## load the clock ## karamba.resizeWidget(widget, _width, _height+EXTRA_HEIGHT) clock = ClockWork(widget,themes[themeName]) hide = None hide = karamba.readConfigEntry(widget, "hide") if hide == None: hide=0 menuOptionChanged(widget,"hide",hide) #the update interval is specified in the .theme file def widgetUpdated(widget): clock.advance(widget) #This gets called everytime our widget is clicked. #Notes: # widget = reference to our widget # x = x position (relative to our widget) # y = y position (relative to our widget) # botton = button clicked: # 1 = Left Mouse Button # 2 = Middle Mouse Button # 3 = Right Mouse Button, but this will never happen # because the right mouse button brings up the # Karamba menu. # 4,5 = Scroll wheel up and down def widgetClicked(widget, x, y, button): pass #This gets called everytime our widget is clicked. #Notes # widget = reference to our widget # x = x position (relative to our widget) # y = y position (relative to our widget) # botton = button being held: # 0 = No Mouse Button # 1 = Left Mouse Button # 2 = Middle Mouse Button # 3 = Right Mouse Button, but this will never happen # because the right mouse button brings up the # Karamba menu. def widgetMouseMoved(widget, x, y, button): #Warning: Don't do anything too intensive here #You don't want to run some complex piece of code everytime the mouse moves pass #This gets called when an item is clicked in a popup menu you have created. # menu = a reference to the menu # id = the number of the item that was clicked. def menuItemClicked(widget, menu, id): pass #This gets called when an item is clicked in the theme CONFIGURATION menu, #not the popup menus that you create. # key = the reference to the configuration key that was changed # value = the new value (true or false) that was selected def menuOptionChanged(widget, key, value): global themepid,widthpid,heightpid,resizePercentpid themepid = None widthpid = None heightpid = None resizePercentpid = None themecommand = ["kdialog", "--title", "Theme Selector", "--radiolist", "Please select a theme to use:", "chromeTheme", "Chrome Theme", "off"] widthcommand = ["kdialog", "--title", "Resize applet", "--inputbox", "Please enter desired width:"] percentcommand = ["kdialog","--title","Resize applet", "--inputbox", "Please enter the desired resizing percentage:"] if (key == "theme"): themepid = karamba.executeInteractive(widget, themecommand) karamba.setMenuConfigOption(widget, "theme", "0") elif (key=="hide"): if value==0: clock.showSec(widget) else: clock.hideSec(widget) karamba.writeConfigEntry(widget, "hide", str(value)) elif (key == "resize"): karamba.setMenuConfigOption(widget, "resize", "0") widthpid = karamba.executeInteractive(widget, widthcommand) elif (key == "resizePercentage"): karamba.setMenuConfigOption(widget, "resizePercentage", "0") resizePercentpid = karamba.executeInteractive(widget,percentcommand) elif (key == "defdim"): clock.defaultDim(widget) karamba.setMenuConfigOption(widget, "defdim", "0") #This gets called when a meter (image, text, etc) is clicked. # NOTE you must use attachClickArea() to make a meter # clickable. # widget = reference to your theme # meter = the meter clicked # button = the button clicked (see widgetClicked for button numbers) def meterClicked(widget, meter, button): global meterClockpid meterClockpid = None clockCommand = "kdesu kcmshell clock" if (meter == clock.background) and (button == 1): karamba.execute(clockCommand) #This gets called when a command you have executed with executeInteractive() outputs something #to stdout. This way you can get the output of for example kdialog without freezing up the widget #waiting for kdialog to end. # widget = reference to your theme # pid = process number of the program outputting (use this if you execute more than out process) # output = the text the program outputted to stdout def commandOutput(widget, pid, output): global clock,_width,_height,themepid, widthpid, heightpid, resizePercentpid if pid == themepid: chosenTheme = output.replace('\n','') karamba.writeConfigEntry(widget, "theme", chosenTheme) clock.changeTheme(widget,themes[chosenTheme]) karamba.redrawWidget(widget) elif pid == widthpid: _width = int(output) heightcommand = ["kdialog", "--title", "Resize applet", "--inputbox", "Please enter desired height:"] heightpid = karamba.executeInteractive(widget, heightcommand) elif pid == heightpid: _height = int(output) karamba.resizeWidget(widget, _width, _height+EXTRA_HEIGHT) clock.resize(widget,_width,_height) karamba.writeConfigEntry(widget,"width",str(_width )) karamba.writeConfigEntry(widget,"height",str(_heig ht)) elif pid == resizePercentpid: _width = int(_width*int(output)/100) _height = int(_height*int(output)/100) karamba.resizeWidget(widget, _width, _height+EXTRA_HEIGHT) clock.resize(widget,_width,_height) karamba.writeConfigEntry(widget,"width",str(_width )) karamba.writeConfigEntry(widget,"height",str(_heig ht)) #This gets called when an item is dropped on this widget. # NOTE you have to call acceptDrops() before your widget will accept drops. # widget = reference to your theme # dropText = the text of the dropped item (probably a URL to it's location in KDE) def itemDropped(widget, dropText): pass #This gets called when a new program is LOADING in KDE. When it is done #loading, startupRemoved() is called, followed by taskAdded(). # widget = reference to your widget # task = A refence to the task that is starting. def startupAdded(widget, startup): pass #This gets called when a new program is done LOADING in KDE. # widget = reference to your widget # task = A refence to the task that just finished loading. def startupRemoved(widget, startup): pass #This is called every time a new task (program) is started in KDE. # widget = reference to your widget # task = A refence to the new task. Call getTaskInfo() with this reference # to get the name, etc of this new task. def taskAdded(widget, task): pass #This is called everytime a task (program) is closed in KDE. # widget = reference to your widget # task = A refence to the task. def taskRemoved(widget, task): pass #This is called everytime a different task gains focus (IE, the user clicks #on a different window). # widget = reference to your widget # task = A refence to the task. Call getTaskInfo() with this reference # to get the name, etc of this new task. def activeTaskChanged(widget, task): pass # This will be printed when the widget loads. print "analogClock v0.1, Copyright (C) 2004, idoa01 at yahoo dot com" print "Use on your own risk - no warranty included (not that anything should go wrong)" print "This piece of code is licensed under the GPL license - which you will find in the file 'GPL'" print " " print "Just don't forget to have a nice day! |
|
|
|
|
|
#15 (permalink) |
|
Débutant
![]() Date d'inscription: avril 2005
Localisation: NEVEZ finistere sud
Messages: 1 472
Pouvoir de réputation: 94
![]() |
Daccord c'est celui ci:
KARAMBA X=500 Y=500 W=267 H=267 INTERVAL=1000 LOCKED=true #CLICKAREA X=0 Y=0 W=267 H=267 ONCLICK="kdesu kcmshell clock" #text x=75 y=152 sensor=time format="dd/MM/yyyy" color=152,19,18 shadow=0 font="venus rising" fontsize=18 align="center" |
|
|
|
|
|
#16 (permalink) |
|
Linux-fighter
![]() Date d'inscription: novembre 2005
Localisation: 44
Messages: 430
Pouvoir de réputation: 38
![]() |
Chez moi ça marche aussi !
http://img254.imageshack.us/img254/9334/clockxg7.jpg
__________________
J'aime Linux : la plupart du temps, je ne comprends rien à ce que je fais et ça marche quand même... Windows c'est l'inverse : en principe je comprends ce que je fais mais ça ne marche jamais… |
|
|
|
![]() |
|
|
|||
|
||||
| Outils de la discussion | |
| Modes d'affichage | |
Discussions similaires
|
||||
| Discussion | Auteur | Forum | Réponses | Dernier message |
| rpms de mandriva 2007 sur la 2006? | bellete | Distributions Linux | 4 | 15/01/2007 20h14 |
| Installation de Mandriva sur D: | cyber_k | Distributions Linux | 74 | 13/04/2006 17h22 |
| Optimiser la gestion de la mémoire | colaphi | Windows XP | 5 | 10/04/2006 18h15 |
| [Répondu]Prog Donnant Des Info Sur La Ram | foufou55 | Autres applications | 2 | 07/08/2004 12h17 |
| Problème Avec De La Ram Sur Portable | wolvie | Processeurs - cartes méres - mémoires | 1 | 30/01/2004 20h32 |