OK
Rating:
1.97
Thread Listing » General AWN Discussion
first applet - Dilbert comic fetcher
#13301 by cj13 (0.3168) posted on 1:10pm Friday, October 12th, 2007
**UPDATED 2-19-08
[Q]



Hello all.
[Q]



I have taken the weather applet and modified it a good amount to create an applet that grabs the daily Dilbert strip and displays it. Down load it here:
[Q]






I am just learning python, so I probably left some code in that is unnecessary, but it seems to work for me.
[Q]



The strip appears very large because I had to make the window big enough for the Sunday version of the comic. I tried to find an easy way to get the width and height from a .gif file, so that I could have the window sized to the original size of the picture. But I didnt have any luck finding how to do this.
[Q]



I would also like to add the option of selecting other comics in the future.
[Q]



On a side note, since the clock, weather, and volume applets have been created, I have done away with the gnome-bar, but was still using screenlets to get the daily Dilbert strip. I wanted to stop using screenlets because I dont want the strip on my desktop all of the time. Now I have eliminated screenlets and the gnome-bar, so my desktop is clean, with just AWN sitting there...Nice...
[Q]



*Edited at 11:48am, 02/19/08
Score: 0 points
Any particular reason?
#13302 by isaac_j87 (1.0000) posted on 1:11pm Friday, October 12th, 2007
Haha cool!
[Q]



Could you post a screenshot as well? thanks!
[Q]

--
-Isaac
Score: 0 points
Any particular reason?
#13308 by plunn (1.0000) posted on 2:39pm Friday, October 12th, 2007
Nice... Dilbert :-)
[Q]



Can I learn more english :-)
[Q]



[Q]

Score: 0 points
Any particular reason?
#13324 by pavpanchekha (1.0000) posted on 5:00pm Friday, October 12th, 2007
Mind if I play around with it?
[Q]

Score: 0 points
Any particular reason?
#13329 by cj13 (0.3168) posted on 5:49pm Friday, October 12th, 2007
Not at all. Please do with it what you want.
[Q]

Score: 0 points
Any particular reason?
#13330 by pavpanchekha (1.0000) posted on 6:07pm Friday, October 12th, 2007
Fixed quite a few things, btu introduces a few more bugs. Currently works a lot better. Fixed:
[Q]



* Auto-resizes dialog; comic not streched.
* Unnecessary code removed
* Polls for comic once, then once an hour. It doesn't freeze when you click it, because it has already cached the comic strip.
* Doesn't disappear when you mouse off of the icon. However, now it doesn't disappear when it loses focus.
[Q]



I'm trying to continue eliminating unnecessary code, but other than that I'll fix a few things and release it.
[Q]



Great job on the applet, cj. I have no idea how you got the getdilbert.py but the applet all together looks good.
[Q]

Score: 0 points
Any particular reason?
#13331 by cj13 (0.3168) posted on 6:19pm Friday, October 12th, 2007
Sounds great. I am interested in seeing how you made it auto-resize.
I found the code for the getdilbert.py somewhere online, but honestly dont know where now. (I have been to so many sites trying to figure out how to do it.) I made a few modifications to it, but not many.
[Q]



You probably noticed how I used the Image.open('./dilbert.gif').save('./dilbert.gif')
to resave the image as a gif. The reason for this was that the code would not display the Sunday (jpg) file, so I used the above line to save as a gif. (in the line the first dilbert.gif is actually whatever image is pulled down (whether gif or jpg), just named dilbert.gif.)
[Q]



Sounds confusing, and probably not even close to the "correct" way to make it work, but it seems to work.
[Q]

Score: 0 points
Any particular reason?
#13332 by pavpanchekha (1.0000) posted on 6:27pm Friday, October 12th, 2007
cj13 said:
You probably noticed how I used the Image.open('./dilbert.gif').save('./dilbert.gif')
to resave the image as a gif. The reason for this was that the code would not display the Sunday (jpg) file, so I used the above line to save as a gif. (in the line the first dilbert.gif is actually whatever image is pulled down (whether gif or jpg), just named dilbert.gif.)
[Q]



Ah interesting. I thought that line was just completely random...
(Commented it out and it worked, you know)
[Q]



cj13 said:
Sounds great. I am interested in seeing how you made it auto-resize.
I found the code for the getdilbert.py somewhere online, but honestly dont know where now. (I have been to so many sites trying to figure out how to do it.) I made a few modifications to it, but not many.
[Q]



The autoresize is fairly easy:
dim = Image.size on the downloaded image
self.set_size_request(dim[0], dim[1])
#since self = your vbox
[Q]



The new version coming, one bug:
can't make the box disappear on unfocus. Its really weird.
[Q]



Just a few more minutes now.
[Q]

Score: 0 points
Any particular reason?
#13334 by pavpanchekha (1.0000) posted on 6:48pm Friday, October 12th, 2007



Sorry for butchering a large part of it (if I did).
[Q]



Should work well except for two bugs:
* Dialog doesn't disappear on focus-out-event
* Can't get awn-manager to recognize the correct icon, so for generic image icon used.
[Q]

Score: 0 points
Any particular reason?
#13350 by isaac_j87 (1.0000) posted on 2:04am Saturday, October 13th, 2007
pavpanchekha said:
Should work well except for two bugs:
* Dialog doesn't disappear on focus-out-event
* Can't get awn-manager to recognize the correct icon, so for generic image icon used.
[Q]



I worked on this applet. I was wondering, how did you guys want the dialog to work? Do you guys want to have the dialog open when the icon is clicked and you have to click it again to close or it stays open only if you hover over the icon.
[Q]



I fixed the focus out. It now loses focus.
[Q]

--
-Isaac
Score: 0 points
Any particular reason?
#13369 by pavpanchekha (1.0000) posted on 5:30am Saturday, October 13th, 2007
Will, I was going for (see the tarball above) click to open and then click or focus out to close.
[Q]



Release your tarball?
[Q]

Score: 0 points
Any particular reason?
#13381 by cj13 (0.3168) posted on 7:12am Saturday, October 13th, 2007
Can't get awn-manager to recognize the correct icon, so for generic image icon used.
[Q]



I think that changing the line Icon=image to Icon=./comic/images/kmouth.png in the comic.desktop file will fix the above problem.
[Q]



I really have no preference on the dialog out event. The box could either disappear when you move the mouse off of it (which is how I originally had it) or when you click again. Whatever you guys think is best.
[Q]

Score: 0 points
Any particular reason?
#13383 by pavpanchekha (1.0000) posted on 7:29am Saturday, October 13th, 2007
cj13 said:
I think that changing the line Icon=image to Icon=./comic/images/kmouth.png in the comic.desktop file will fix the above problem.
[Q]



K, will do as soon as isaac posts his fixed tar
[Q]

Score: 0 points
Any particular reason?
#13391 by isaac_j87 (1.0000) posted on 9:24am Saturday, October 13th, 2007
pavpanchekha said:
K, will do as soon as isaac posts his fixed tar
[Q]



okay, I've decided to have the box disappear to when you move off. I also implemented awn-effects so that the dilbert icon doesn't move and drains color when you hover over it...and when you move off the color returns!
[Q]

--
-Isaac
Score: 0 points
Any particular reason?
#13393 by isaac_j87 (1.0000) posted on 9:50am Saturday, October 13th, 2007
cj13 said:
I think that changing the line Icon=image to Icon=./comic/images/kmouth.png in the comic.desktop file will fix the above problem.
[Q]



Unfortunately it doesn't...I've tried everything :(
[Q]

--
-Isaac
Score: 0 points
Any particular reason?
#13407 by cj13 (0.3168) posted on 11:21am Saturday, October 13th, 2007
I changed the line to Icon=./comic/images/kmouth.png, dropped the new tarball in the applet window, closed preferences, and when I reopen preferences, the dilbert icon is correct.
[Q]



Score: 0 points
Any particular reason?
#13413 by isaac_j87 (1.0000) posted on 11:43am Saturday, October 13th, 2007
cj13 said:
I changed the line to Icon=./comic/images/kmouth.png, dropped the new tarball in the applet window, closed preferences, and when I reopen preferences, the dilbert icon is correct.
[Q]



Oh it is? Okay sounds good...I clean up my changes and post a new tarball. :)
[Q]

--
-Isaac
Score: 0 points
Any particular reason?
#13483 by cj13 (0.3168) posted on 7:53am Sunday, October 14th, 2007
I just updated the applet.
[Q]



It now hides on focus_out.
[Q]



More importantly, it now shows the Sunday comic (jpg). (I dont know if you guys noticed the applet didnt work today, because the Sunday comics are jpg instead of gif files.)
[Q]

Score: 0 points
Any particular reason?
#13507 by cj13 (0.3168) posted on 10:45am Sunday, October 14th, 2007
Just updated it again.
Now you can rt-click and select Dilbert, Peanuts, or Wizard of ID.
[Q]

Score: 0 points
Any particular reason?
#13527 by plunn (1.0000) posted on 12:48pm Sunday, October 14th, 2007
For me Dilbert is broken...
[Q]



Traceback (most recent call last):
File "/home/plun/.config/awn/applets/comic/comic.py", line 34, in ?
import comicdialog
File "/home/plun/.config/awn/applets/comic/comicdialog.py", line 28, in ?
import Image
ImportError: No module named Image
[Q]



?
[Q]



*Edited at 12:49pm, 10/14/07
Score: 0 points
Any particular reason?
#13545 by cj13 (0.3168) posted on 2:28pm Sunday, October 14th, 2007
This is beyond what I know about python. For any of you programmers, could it be that the Image command requires a certain package be installed?
[Q]

Score: 0 points
Any particular reason?
#13547 by c.atterly (0.9959) posted on 2:30pm Sunday, October 14th, 2007
cj13 said:
This is beyond what I know about python. For any of you programmers, could it be that the Image command requires a certain package be installed?
[Q]



Sounds like you need PIL (Python Image Library). python-imaging, I believe.
[Q]

--
-Chaz
Score: 0 points
Any particular reason?
#13549 by Timon (1.0000) posted on 3:38pm Sunday, October 14th, 2007
If you guys are eager to learn some python, I think this applet is a nice way to go. I think that with a little tweaking you can implement support for other well known comics.
[Q]



That feature would really add something, so that it can be part of the awn applets package?
[Q]

Score: 0 points
Any particular reason?
#13550 by cj13 (0.3168) posted on 3:49pm Sunday, October 14th, 2007
If anyone wants another comic besides the 3 currently listed, let me know.
[Q]

Score: 0 points
Any particular reason?
#13551 by plunn (1.0000) posted on 4:08pm Sunday, October 14th, 2007
c.atterly said:
Sounds like you need PIL (Python Image Library). python-imaging, I believe.
[Q]



Yup... Thanks !
[Q]






Very nice "cj13" ... :-)
[Q]



Score: 0 points
Any particular reason?
#13659 by cj13 (0.3168) posted on 4:50pm Monday, October 15th, 2007
I have updated the applet with The Born Loser strip, plus have added the option in rt-click menu to enable/disable popping the strip up when hovering over the icon.
[Q]

Score: 0 points
Any particular reason?
#13756 by c.atterly (0.9959) posted on 2:21pm Tuesday, October 16th, 2007
I don't know how the current code works, but it might be nice to have a generic way to add a comic, ie give the web address of the daily page and a regular expression to grab the URL of the image.
[Q]



This would make it incredibly easy for almost anyone to add comics, and it could come with a list of all the common ones people have added.
[Q]

--
-Chaz
Score: 0 points
Any particular reason?
#13863 by baldmonkey (0.4036) posted on 10:08pm Wednesday, October 17th, 2007
I would love it if someone could modify this to get the Cyanide and Happiness comic here.
[Q]

Score: 0 points
Any particular reason?
#19528 by blackvd (0.1973) posted on 3:03pm Sunday, February 03rd, 2008
( no avatar )
Where is the config file located? I would like to change the icon and modify to fetch a comic of my choice. Is that easy to do even? Thanks.
[Q]

Score: 0 points
Any particular reason?
#20221 by cj13 (0.3168) posted on 11:52am Tuesday, February 19th, 2008
The Comic applet has been updated to include the license info to all of the files.
[Q]



I also changed the hover on icon effect so that the comic does not pop-up when hovered. I personally like the feature of it popping up on hover, so there is an option in the rt-click menu to allow the user to turn this back on if desired.
[Q]

Score: 0 points
Any particular reason?
#20223 by pavpanchekha (1.0000) posted on 2:09pm Tuesday, February 19th, 2008
Updated where? I don't see this updated anywhere.
[Q]

Score: 0 points
Any particular reason?
#20225 by moonbeam (1.0000) posted on 2:24pm Tuesday, February 19th, 2008
( no avatar )
pavpanchekha said:
Updated where? I don't see this updated anywhere.
[Q]



Looks like the download link at the top of the this thread. And in the DEV read thread...
[Q]
Score: 0 points
Any particular reason?
#20227 by pavpanchekha (1.0000) posted on 2:38pm Tuesday, February 19th, 2008
cj13 said:
The Comic applet has been updated to include the license info to all of the files.
[Q]



Thank you, this is extremely helpful.
[Q]



cj13 said:
I also changed the hover on icon effect so that the comic does not pop-up when hovered. I personally like the feature of it popping up on hover, so there is an option in the rt-click menu to allow the user to turn this back on if desired.
[Q]



This is still not correct behavior. To summarize the correct behavior:
[Q]



The dialog opens on click.
It will stay open until: the icon is clicked again; or the dialog loses focus.
If the mouse leaves the icon, there should be no effect.
[Q]



Also, a few other points about your applet:
1. Do not save files in the home folder. Your applet defaults to this.
2. There should be no terminal output. Your applet currently outputs two urls.
3. Your applet imports wnck. There is no reason at all to import it.
4. Your applet imports the Image library. All that it is used for can be done (more easily) with gtk.gdk. In general, please try to keep imports at a minimum. The main file also imports a few things that are not needed.
5. Please NEVER mix spaces and tabs in your source code. In Python, this is especially a pain. Your text editor should have a function to convert tabs to spaces.
[Q]



*Edited at 3:15pm, 02/19/08
Score: 0 points
Any particular reason?
#20228 by pavpanchekha (1.0000) posted on 2:39pm Tuesday, February 19th, 2008
I will add the correct licensing information to all relevant files. I will, however, not update anything else (most of what I mentioned above has already been fixed by me). If there are any other changes you want included, please tell me.
[Q]

Score: 0 points
Any particular reason?
#20229 by moonbeam (1.0000) posted on 2:54pm Tuesday, February 19th, 2008
( no avatar )
pavpanchekha said:
The dialog opens on click.
It will stay open until: the icon is clicked again; or the dialog loses focus.
If the mouse leaves the icon, there should be no effect.
[Q]



I believe this is a hold over from the weather applet. It does the same thing.
[Q]


Score: 0 points
Any particular reason?
#20232 by cj13 (0.3168) posted on 3:33pm Tuesday, February 19th, 2008
Thanks for the info pavpanchekha. If you have already fixed most of these problems, can you share your updated file so that I can link to it here? I really don't have time to mess with it now, and I have absolutely no problem with you or anyone else fixing it or modifying it.
[Q]



Thanks again.
[Q]

Score: 0 points
Any particular reason?
#20233 by pavpanchekha (1.0000) posted on 3:43pm Tuesday, February 19th, 2008
cj13 said:
Thanks for the info pavpanchekha. If you have already fixed most of these problems, can you share your updated file so that I can link to it here? I really don't have time to mess with it now, and I have absolutely no problem with you or anyone else fixing it or modifying it.
[Q]



It's been committed to trunk. So if you look in the comic directory there you should see all of the updated files.
[Q]

Score: 0 points
Any particular reason?
Thread Listing » General AWN Discussion » first applet - Dilbert comic fetcher

Post A Reply:

Anonymous posting has been disabled. Please register first before attempting to post.
Powered by Metaforum ©2004-2010
Get your own Free AJAX Forum Messageboard by visiting the offical site.
.