Notices


Reply
Thread Tools
tso's Avatar
Posts: 4,783 | Thanked: 1,253 times | Joined on Aug 2007 @ norway
#41
iirc, the french tried a base ten calendar and clock at some point.

it ould also be displaying internet time, @0000 was the format...
 
fpp's Avatar
Posts: 2,853 | Thanked: 968 times | Joined on Nov 2005
#42
Originally Posted by TrueJournals View Post
I hate to be a nit-picker here, but... daperl: from my understanding of python (and I could be wrong, I'm still learning), items in parentheses () are a tuple, while items in brackets [] are a list. So, in this case, the items need to be in a tuple, not a list. Not a big deal here, but the terminology changes what you can do with the items. (Reference Link)
You're quite right. Although tuples are, in effect, like immutable lists, they're not equivalent in this case.

The other data structure commonly used for string formatting is the Python 'dictionary', especially when there are many variables and/or some of them are used multiple times. The placeholders are then named after the dict keys and their type, as in :

Code:
values = {'name':'Joe', 'score':10, 'rank':'first'}
print "%(name)s scored %(score)d and ranked %(rank)s, congrats %(name)s !" % values
A commonly used dict is the one returned by locals(), which contains all local variables in context.
 

The Following 2 Users Say Thank You to fpp For This Useful Post:
Posts: 2 | Thanked: 3 times | Joined on Dec 2008
#43
ciao ciroip =) (and first post, btw).

Nice little clock and very useful. Looking in your code, I've noticed quite a bit of redundant code, so, I did a little bit of cleaning (too much loop unrolling ): http://python.pastebin.com/f6bdc2e1d .


EDIT: now with a more flexible event handling, you could even save a little bit of battery life increasing the delay for the redraw of the clock : http://python.pastebin.com/m363e32c .

Last edited by plop; 2008-12-16 at 21:19.
 

The Following User Says Thank You to plop For This Useful Post:
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#44
Originally Posted by fpp View Post
You're quite right. Although tuples are, in effect, like immutable lists, they're not equivalent in this case.

The other data structure commonly used for string formatting is the Python 'dictionary', especially when there are many variables and/or some of them are used multiple times. The placeholders are then named after the dict keys and their type, as in :

Code:
values = {'name':'Joe', 'score':10, 'rank':'first'}
print "%(name)s scored %(score)d and ranked %(rank)s, congrats %(name)s !" % values
A commonly used dict is the one returned by locals(), which contains all local variables in context.
That's clean. But I'm still confused why the variable substitution operator (%) doesn't recognize a list as a sequence. That doesn't make sense to me. Does that make sense to you? And if so, why? Thanks.
__________________
N9: Go white or go home
 
ciroip's Avatar
Posts: 334 | Thanked: 366 times | Joined on Nov 2008 @ Italy
#45
Originally Posted by plop View Post
ciao ciroip =) (and first post, btw).

Nice little clock and very useful. Looking in your code, I've noticed quite a bit of redundant code, so, I did a little bit of cleaning (too much loop unrolling ): http://python.pastebin.com/f6bdc2e1d .


EDIT: now with a more flexible event handling, you could even save a little bit of battery life increasing the delay for the redraw of the clock : http://python.pastebin.com/m363e32c .
Welcome to the forum
AAAHAHA, my code in thewild!!, Ashame, ashame. I knew my solution was crap (merda in italian, vedasi comment in the code...) but I was anxious to see that numbers moving a bit Ill study your code. Thank you
__________________
I can't do it. No one can help.
[SIGPIC][/SIGPIC]

Flip Alarm Clock - 3DMania Theme - Synesthesia - Deluxepain
http://ciroip.blogspot.com/
http://twitter.com/ciroippolito
 

The Following User Says Thank You to ciroip For This Useful Post:
qole's Avatar
Moderator | Posts: 7,109 | Thanked: 8,820 times | Joined on Oct 2007 @ Vancouver, BC, Canada
#46
Don't be ashamed, ciroip!

You asked developers to write the code for you, but nobody did, so you wrote it yourself! Excellent!

Now your achievement has motivated developers to fix your code. Everybody wins!

Especially me!
__________________
qole.org --- twitter --- Easy Debian wiki page
Please don't send me a private message, post to the appropriate thread.
Thank you all for your donations!
 

The Following 6 Users Say Thank You to qole For This Useful Post:
lcuk's Avatar
Posts: 1,635 | Thanked: 1,816 times | Joined on Apr 2008 @ Manchester, England
#47
ciroip,
do not be ashamed, when a diamond comes out of the ground it is uneven and dull.

its easier to spot a mistake than come up with the rough draft

thanks for starting this
__________________
liqbase sketching the future.
like what i say? hit the Thanks, thanks!
twitter.com/lcuk
 

The Following 5 Users Say Thank You to lcuk For This Useful Post:
ciroip's Avatar
Posts: 334 | Thanked: 366 times | Joined on Nov 2008 @ Italy
#48
Originally Posted by qole View Post
Don't be ashamed, ciroip!
You asked developers to write the code for you, but nobody did, so you wrote it yourself! Excellent!
Now your achievement has motivated developers to fix your code. Everybody wins!
Especially me!
ciroip,
do not be ashamed, when a diamond comes out of the ground it is uneven and dull.
its easier to spot a mistake than come up with the rough draft
thanks for starting this
ok guys, this is becoming odd, lets drop the argument here
__________________
I can't do it. No one can help.
[SIGPIC][/SIGPIC]

Flip Alarm Clock - 3DMania Theme - Synesthesia - Deluxepain
http://ciroip.blogspot.com/
http://twitter.com/ciroippolito
 

The Following User Says Thank You to ciroip For This Useful Post:
Posts: 1,097 | Thanked: 650 times | Joined on Nov 2007
#49
Initially I thought that Alat was built in when I say the Alarm Off /On graphic.
But I guess that is only a graphic and is not a workable "switch as yet", Am I right ?

Also while I would love to have the alarm feature (I loved the clock so much - that I woke up quite a few times on the first night to look at the time in big clear letters - thus losing good sleep :-) , the nice clear interface made me think this would work very well as a stop-watch too - if that feature is built in (maybe).

Maybe clicking the full-screen button could start/stop the stopwatch - just a thought.

But I love this clock at last and having an alarm would make it replace the large statusbar alarm system for me (which bugs me in that it kills the sound on my tablet each time).
 

The Following User Says Thank You to nilchak For This Useful Post:
fpp's Avatar
Posts: 2,853 | Thanked: 968 times | Joined on Nov 2005
#50
Originally Posted by qwerty12 View Post
Indeed, sure I can . I'm making a package now of ciroip's new version (thank you ciroip for the path modification!) and will relax the versions.
I've lowered it to 2.5.1, should be fine for both diablo and chinook. Pygame version is the same so no changes there.
Yup, works fine on both now, thanks a lot !

Tiny request for the next version : escape key exits app ? :-)
 
Reply

Tags
clock, flip clock


 
Forum Jump


All times are GMT. The time now is 19:53.