Retourner au contenu. Retourner à la navigation

 

MaoPost Python Gtk

by xeo @ 07/06/2007
Récupération du MaoPost du jour avec python-gtk
Cette application en PyGtk, permet de récupérer et d'afficher l'affiche MaoPost du jour.

#!/usr/bin/env python
import os
import time
import urllib2
import gtk

class appgui:
def destroy(self, w):
gtk.main_quit()

def __init__(self):
global maoLocalPic
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.image = gtk.Image()

self.window.add(self.image)
self.window.connect("destroy", self.destroy)

self.image.set_from_file(maoLocalPic)

self.image.show()
self.window.show()

def main(self):
gtk.main()

def download():
global maoLocalPic
if not os.path.exists( maoLocalPic ):
maoTxt = urllib2.urlopen("http://www.maopost.com/widget/widget.txt").read()
maoRemotePic = maoTxt.split()[0]

remoteFile = urllib2.urlopen(maoRemotePic)
localFile = open(maoLocalPic, "w")

localFile.write( remoteFile.read() )

remoteFile.close()
localFile.close()

if __name__ == '__main__' :
maoLocalPic = "/tmp/mao-" + time.strftime("%m-%d-%y", time.localtime()) + ".jpg"
download()
app=appgui()
app.main()
Par xeo Dernière modification 07/06/2007 13:14
Navigation
Actualités
09/05/2008 OpenOffice.org 3.0 bêta disponible au téléchargement
08/05/2008 Sortie de VirtualBox 1.6
07/05/2008 Portes ouvertes Ubuntu 8.04 (Hardy Heron) le 17 mai 2008 au parc scientifique de l'EPFL
06/05/2008 Wine passe en code freeze
06/05/2008 Mandriva et l'Éducation Nationale renouvellent leur partenariat
Plus d'actualités...
Articles
21/02/2008 GNU / Screen
03/09/2007 The Linux File System Encryption API
11/08/2007 Surveillance réseau avec Snort
10/08/2007 Première approche de Xen
10/08/2007 Première approche sur LVM
More articles
Tips
28/04/2008 Mozilla Firefox : Google Talk et Facebook Chat
22/04/2008 Sed : Rechercher du texte entre deux chaines de caractères
04/04/2008 Gérer son(ses) écran(s) avec xrandr
26/03/2008 Tips sur l'historique de vos commandes
13/02/2008 Linux-Unix Cheat Sheets
More tips
Codes
09/04/2008 Chapitre 13 - Administration DNS et DHCP
09/04/2008 Chapitre 06 - Service web avec Apache
04/04/2008 Chapitre 09 - PureFTPd
04/04/2008 Chapitre 06 - Scripting Bash
01/04/2008 Chapitre 20 - Haute Disponibilité
More codes
Courses
13/09/2006 Module 3
23/02/2006 Module 2
23/02/2006 Module 1
More courses
Formation Linux

Supinfo Training Center has the first Linux Certification. The training is 13 days and allow you to pass the LPI 101 and 102.

more info
 
 
Vous êtes ici :
Codes MaoPost Python Gtk