Re: [Python] Garbage collection and OS
raffaello wrote: > Is it true that when an object is destroyed in a Python application > the garbage collector does NOT give back the occupied memory to the > Operating System as long as the application is running, but keeps it > at the disposal of the same application? [Switching to Italian language :-) ] Era vero fino alla versione 2.4 dell'interprete; dalla 2.5 la memoria non più usata viene effettivamente restituita al sistema operativo. http://evanjones.ca/python-memory-part3.html -- Nicola Larosa - http://www.tekNico.net/ The Chinese built the Great Wall early in our civilization not to keep the Mongol hordes out, but to keep the newly enslaved and dubious peasants, the pawns of the new civilization, in. To keep them from Just Walking Away. - Dave Pollard, December 2007 ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Tkinter
Mauro Maccari ha scritto: > Grazie Daniele, era proprio ciò di cui avevo bisogno! Mi fa piacere! Ehi, ci vediamo al Pycon Due? http://www.pycon.it/ A presto! -- Daniele Varrazzo - Develer S.r.l. http://www.develer.com ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] R: suoni
renzo wrote: > Ho usato questo programmino trovato su internet Non hai detto se hai risolto o meno. Se non hai risolto, e` perche` non hai installato python-gst Enrico ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Tkinter
Grazie Daniele, era proprio ciò di cui avevo bisogno! Il 11/04/08, Daniele Varrazzo<[EMAIL PROTECTED]> ha scritto: > <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> > Message-ID: <[EMAIL PROTECTED]> > X-Sender: [EMAIL PROTECTED] > Received: from 82.111.147.97 [82.111.147.97] with HTTP/1.1 (POST); Fri, 11 > Apr > 2008 17:51:11 +0200 > User-Agent: RoundCube Webmail/0.1 > Content-Type: text/plain; charset="UTF-8" > Content-Transfer-Encoding: 8bit > > > On Fri, 11 Apr 2008 16:21:16 +0200, "Mauro Maccari" > > <[EMAIL PROTECTED]> wrote: > > > ciao Daniele > > penso che la soluzione più facile sia richiamare il loop degli eventi > > visto che la funzione > > dura poco. > > > Non puoi "richiamare" il loop degli eventi: quello gira da se', e *deve* > girare, altrimenti tutto freezza. > > Se hai una funzione long running, quello che puoi fare e' di quando in > quando lanciare un process_events() (nome inventato, ma qualcosa omologa > c'e' in tutti i framework UI che conosco, immagino sia anche in tkinter). > > la tua funzione non dura poco, perche' > > > while self.run: > print "On" > > > dura potenzialmente per sempre: ovvero finche' il checkbox e' flaggato. > (tra l'altro vale sempre true perche' "self.run" e' un oggetto, non un > numero o un bool: devi fare "self.run.get()"). E' il singolo 'print "On"' a > durare poco, ed e' solo questo da far chiamare periodicamente dal > framework. > > Lo snippet seguente funziona come ti aspetti. Non uso "idle" ma uso un > timer che chiama periodicamente la funzione se il flag e' checkato. Nota > che il trigger scatta una sola volta, quindi per ottenere la periodicita' > occorre registrarlo nuovamente ogni volta che scatta (finestra.after) > > > from Tkinter import * > class Application(Frame): > > def __init__(self, master): > > frame = Frame() > frame.pack(padx = 50, pady = 20) > > self.run = IntVar() > self.running=Checkbutton(frame, text="ON/OFF", fg="red", > > variable=self.run, command=self.report) > > self.running.grid(row=0 , column=0) > > > def report(self): > if self.run.get(): > print "On" > finestra.after(200, func=app.report) > > > finestra = Tk() > app = Application(finestra) > finestra.mainloop() > > > Ref. http://infohost.nmt.edu/tcc/help/pubs/tkinter/universal.html > > > -- > Daniele Varrazzo - Develer S.r.l. > http://www.develer.com > > > ___ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > > -- Mandare alle persone documenti in formato Word ha effetti negativi, perché questa pratica le spinge ad usare software Microsoft. Di fatto, diventi un puntello del monopolio di Microsoft. Questo specifico problema è un notevole ostacolo ad una più ampia adozione del software libero. Vorresti per favore riconsiderare l'uso del formato Word per comunicare con altre persone? ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Garbage collection and OS
On Fri, Apr 11, 2008 at 7:24 PM, raffaello <[EMAIL PROTECTED]> wrote: > Scusami, Enrico, hai ragione. > Cercherò di spiegarmi meglio dicendo cosa voglio ottenere. > Scrivo dei programmi in wx.Python basati su una frame principale e su > numerose frame secondarie destinate a operazioni usate raramente. > Se la memoria usata da queste finestre secondarie NON viene restituita > all'OS alla distruzione dell'oggetto, ma è trattenuta a disposizione del > programma, tanto vale nascondere e mostrare le frame senza ripetere ogni > volta il lavoro di inizializzazione. Io mi preoccuperei di questi problemi solo ed esclusivamente se si dimostra che la mia applicazione è troppo lenta/occupa troppa memoria. Di base userei la strategia più semplice e basta. -- VENITE A PYCON 2! ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Garbage collection and OS
Scusami, Enrico, hai ragione. Cercherò di spiegarmi meglio dicendo cosa voglio ottenere. Scrivo dei programmi in wx.Python basati su una frame principale e su numerose frame secondarie destinate a operazioni usate raramente. Se la memoria usata da queste finestre secondarie NON viene restituita all'OS alla distruzione dell'oggetto, ma è trattenuta a disposizione del programma, tanto vale nascondere e mostrare le frame senza ripetere ogni volta il lavoro di inizializzazione. 2008/4/11, enrico franchi <[EMAIL PROTECTED]>: > > On Fri, Apr 11, 2008 at 4:38 PM, raffaello <[EMAIL PROTECTED]> > wrote: > > > Is it true that when an object is destroyed in a Python application > > the garbage collector does NOT give back the occupied memory to the > > Operating System as long as the application is running, but keeps it at > the > > disposal of the same application? > > > 1. Since this is an italian mailing list, Italian or Python should be > preferred (writing prose in Python is quite hard, though). > 2. It is not true that the behaviour you described is part of > *Python*. However, as far as I know this was (and may be as well) the > behaviour of the interpreter. This is a reasonable behaviour. > > > > -- > -enrico > ___ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
[Python] R: suoni
Ho usato questo programmino trovato su internet ## import threading import os ( GSTPLAY, WINPLAY, NOENGINE ) = range(3) try: import gst import gobject ENGINE = GSTPLAY except ImportError: try: import winsound ENGINE = WINPLAY except ImportError: ENGINE = NOENGINE class __GstPlayThread(threading.Thread): def __init__(self, ply): self.ply = ply threading.Thread.__init__(self) def run(self): self.ply.set_state(gst.STATE_PLAYING) def bus_event(bus, message): t = message.type if t == gst.MESSAGE_EOS: self.ply.set_state(gst.STATE_NULL) return True self.ply.get_bus().add_watch(bus_event) def __gstplay(filename): cwd = os.getcwd() location = os.path.join(cwd, filename) ply = gst.element_factory_make("playbin", "player") ply.set_property("uri", "file://" + location) pt = __GstPlayThread(ply) pt.start() def __winplay(filename): cwd = os.getcwd() location = os.path.join(cwd, filename) import thread def wplay(): winsound.PlaySound(location, winsound.SND_FILENAME) thread.start_new_thread(wplay, ()) if ENGINE == GSTPLAY: play = __gstplay pass elif ENGINE == WINPLAY: play = __winplay else: def play(filename): pass ### -Messaggio originale- Da: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Per conto di Massimiliano Giovine Inviato: giovedì 10 aprile 2008 23.38 A: Discussioni generali sul linguaggio Python Oggetto: Re: [Python] suoni Usa la libreria SDL_mixer, è molto comoda per caricare file audio... 2008/4/10, enrico franchi <[EMAIL PROTECTED]>: > On Fri, Apr 11, 2008 at 6:54 PM, renzo <[EMAIL PROTECTED]> wrote: > > > Ho la necessità di far suonare un file wav sotto linux > > > SDL dovrebbe fare al caso tuo. > > > > Con windows ci sono riuscito > > > Che libreria hai usato? > > > > -- > VENITE TUTTI A PYCON 2! > ___ > Python mailing list > Python@lists.python.it > http://lists.python.it/mailman/listinfo/python > -- -Massimiliano Giovine Aksel Peter Jørgensen dice: "Why make things difficult, when it is possible to make them cryptic and totally illogic, with just a little bit more effort?" Blog: http://opentalking.blogspot.com Il vero programmatore: http://www.arcetri.astro.it/~comore/true_programmer.txt ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Garbage collection and OS
On Fri, Apr 11, 2008 at 4:38 PM, raffaello <[EMAIL PROTECTED]> wrote: > Is it true that when an object is destroyed in a Python application > the garbage collector does NOT give back the occupied memory to the > Operating System as long as the application is running, but keeps it at the > disposal of the same application? 1. Since this is an italian mailing list, Italian or Python should be preferred (writing prose in Python is quite hard, though). 2. It is not true that the behaviour you described is part of *Python*. However, as far as I know this was (and may be as well) the behaviour of the interpreter. This is a reasonable behaviour. -- -enrico ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Tkinter
<[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Message-ID: <[EMAIL PROTECTED]> X-Sender: [EMAIL PROTECTED] Received: from 82.111.147.97 [82.111.147.97] with HTTP/1.1 (POST); Fri, 11 Apr 2008 17:51:11 +0200 User-Agent: RoundCube Webmail/0.1 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit On Fri, 11 Apr 2008 16:21:16 +0200, "Mauro Maccari" <[EMAIL PROTECTED]> wrote: > ciao Daniele > penso che la soluzione più facile sia richiamare il loop degli eventi > visto che la funzione > dura poco. Non puoi "richiamare" il loop degli eventi: quello gira da se', e *deve* girare, altrimenti tutto freezza. Se hai una funzione long running, quello che puoi fare e' di quando in quando lanciare un process_events() (nome inventato, ma qualcosa omologa c'e' in tutti i framework UI che conosco, immagino sia anche in tkinter). la tua funzione non dura poco, perche' while self.run: print "On" dura potenzialmente per sempre: ovvero finche' il checkbox e' flaggato. (tra l'altro vale sempre true perche' "self.run" e' un oggetto, non un numero o un bool: devi fare "self.run.get()"). E' il singolo 'print "On"' a durare poco, ed e' solo questo da far chiamare periodicamente dal framework. Lo snippet seguente funziona come ti aspetti. Non uso "idle" ma uso un timer che chiama periodicamente la funzione se il flag e' checkato. Nota che il trigger scatta una sola volta, quindi per ottenere la periodicita' occorre registrarlo nuovamente ogni volta che scatta (finestra.after) from Tkinter import * class Application(Frame): def __init__(self, master): frame = Frame() frame.pack(padx = 50, pady = 20) self.run = IntVar() self.running=Checkbutton(frame, text="ON/OFF", fg="red", variable=self.run, command=self.report) self.running.grid(row=0 , column=0) def report(self): if self.run.get(): print "On" finestra.after(200, func=app.report) finestra = Tk() app = Application(finestra) finestra.mainloop() Ref. http://infohost.nmt.edu/tcc/help/pubs/tkinter/universal.html -- Daniele Varrazzo - Develer S.r.l. http://www.develer.com ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
[Python] Garbage collection and OS
Is it true that when an object is destroyed in a Python application the garbage collector does NOT give back the occupied memory to the Operating System as long as the application is running, but keeps it at the disposal of the same application? ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Tkinter
ciao Daniele penso che la soluzione più facile sia richiamare il loop degli eventi visto che la funzione dura poco. come faccio a richiamarlo? questo è il codice: from Tkinter import * class Application(Frame): def __init__(self, master): frame = Frame() frame.pack(padx = 50, pady = 20) self.run = IntVar() self.running=Checkbutton(frame, text="ON/OFF", fg="red", variable = self.run, command=self.start) self.running.grid(row=0 , column=0) def start(self): while self.run: print "On" finestra = Tk() app = Application(finestra) finestra.mainloop() grazie ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Tkinter
On Fri, 11 Apr 2008 15:10:48 +0200, "Mauro Maccari" <[EMAIL PROTECTED]> wrote: > Ciao ragazzi, mi sto esercitando con Tkinter ma c'è una cosa che non > riesco a fare. > Quando spunto un checkbox vorrei chiamare una funzione che gira di > continuo fin quando il checkbox non viene deselezionato. > > Ho fatto una piccola interfaccia ma selezionando il checkbox inizia la > funzione ma non riesco più a deselezionare il widget. > dove sbaglio? Ciao Mauro! se la tua funzione gira di continuo, non dai modo al loop degli eventi di essere eseguito. Questo e' un comportamento comune a tutte le interfacce grafiche: o fai in modo che il loop degli eventi chiami periodicamente la tua funzione (che non deve durare tanto) o, se la funzione dura tanto, devi dire esplicitamente al loop degli eventi di processare gli eventi sospesi di quando in quando. Non conosco tkinter, quindi non so come si chiama un eventuale hook che ti offre. In altri sistemi di UI si chiama "idle" di solito, ed e' un evento che viene generato periodicamente per permettere di effettuare compiti in parallelo senza usare esplicitamente thread diversi. Dovresti agganciarti ad "idle" e controllare da li' se il checkbox e' flaggato, nel qual caso fare un pezzetto del lavoro. -- Daniele Varrazzo - Develer S.r.l. http://www.develer.com ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
[Python] Tkinter
Ciao ragazzi, mi sto esercitando con Tkinter ma c'è una cosa che non riesco a fare. Quando spunto un checkbox vorrei chiamare una funzione che gira di continuo fin quando il checkbox non viene deselezionato. Ho fatto una piccola interfaccia ma selezionando il checkbox inizia la funzione ma non riesco più a deselezionare il widget. dove sbaglio? grazie ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Python e animare immagini
Era tardi quindi ho glissato. In realtà ci sono diversi modi: 1) Ti fai l'animazione in avi/mpeg e la carichi per esempio con il binding SDL per Python 2) usi una libreria per costruire GUI come wxPython per esempio: ti carichi le immagini in memoria, forse non ti servono nemmeno tutte, usi un wxTimer che a scatti a intervalli regolari e vai ad aggiornare il device context, creandoti un tuo controllo animazione. 3) Se non sbaglio wxPython ha una specie di media player wx.media.MediaCtrl che consente di caricare i video e quindi le animazioni, che ti fai con programmi piu adatti tra cui per esempio VideoEditMagic o Adobe Premiere, tanto per citarne alcuni che ho usato e con cui mi sono trovato bene. 4) Usi pygame vedi il link: http://www.pygame.org/docs/tut/MoveIt.html Ce + di un modo basta che scegli quello che secondo te ci metti di meno. Ciao, Giorgio. --- Giorgio Zoppi [EMAIL PROTECTED] ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python
Re: [Python] Python e animare immagini
2008/4/11 Matteo Buferli <[EMAIL PROTECTED]>: > Cerchero' qualche frammento di codice sul web, se comunque hai modo di > esplicare la tua risposta mi farebbe piacere. ti ha detto una libreria grafica. carichi le immagini una dopo l'altra alla pressione di un tasto. Dirti di più vuole dire fartelo: ci si mette meno a scriverlo che a scrivere come farlo. -- -enrico ___ Python mailing list Python@lists.python.it http://lists.python.it/mailman/listinfo/python