Re: [Tutor] Web Stats
Kent Johnson wrote: On Wed, Jun 11, 2008 at 3:58 PM, Stephen Nelson-Smith <[EMAIL PROTECTED]> wrote: Hello, This has to include resources which have not been visited, as the point is to clean out old stuff. wouldn't a 'find' for files with a an ancient access time be a better way of finding out? Also, http://ch.tudelft.nl/~arthur/webcheck/ is useful if you have the site up and running. It will give you some statistics about broken pages and old ones. -- ~noufal http://nibrahim.net.in/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] If You Wish Microsoft Voices For Your Programming
Hi! Below is the settings to use the built in SAPI 5 voices. It will also read any other voices loaded into the SAPI 5 and stores the list of all of them. You can change the names of the methods if you so desire. I am giving you an example of how to set up your voices. NOTE: The pitch of the voices has to be an XML command and it is built into the speech or Speak method. You will need to understand the XML commands if you wish to use the added XML features. Pitch is just one and there is one for spell, bookmarks, and so on... Bruce #DRIVERS FOR SAPI 5 AND VOICES! #NOTE THE CONSTANTS AND IN THE SPEAK FUNCTION AND THE ADDING/OR OF THE VALUES. from comtypes.client import CreateObject import _winreg class constants4tts: Wait = -1 Sync = 0 Async = 1 Purge = 2 Is_filename = 4 XML = 8 Not_XML = 16 Persist = 32 Punc = 64 class SynthDriver(): name="sapi5" description="Microsoft Speech API version 5 (sapi.SPVoice)" _pitch = 0 _voices = [] _wait = -1 #WAIT INDEFINITELY _sync = 0 #WAIT UNTIL SPEECH IS DONE. _async = 1 #DO NOT WAIT FOR SPEECH _purge = 2 #CLEAR SPEAKING BUFFER _is_filename = 4 #OPEN WAV FILE TO SPEAK OR SAVE TO WAV FILE _xml = 8 #XML COMMANDS, PRONUNCIATION AND GRAMMER. _not_xml = 16 #NO XML COMMANDS _persist_xml = 32 #Changes made in one speak command persist to other calls to Speak. _punc = 64 #PRONOUNCE ALL PUNCTUATION! def check(self): try: r=_winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT,"SAPI.SPVoice") r.Close() return True except: return False #INITIALIZE ENGINE! def init(self): try: self.tts = CreateObject( 'sapi.SPVoice') self._voice=1 self._voiceCount = len(self.tts.GetVoices()) for v in range(self._voiceCount): self._voices.append( self.tts.GetVoices()[v]) return True except: return False #TERMINATE INSTANCE OF ENGINE! def terminate(self): del self.tts #NUMBER OF VOICES FOR ENGINE! def getVoiceCount(self): return len(self.tts.GetVoices()) #NAME OF A VOICE NUMBER! def getVoiceName(self, num): return self.tts.GetVoices()[num-1].GetDescription() #WHAT IS VOICE RATE? def getRate(self): "MICROSOFT SAPI 5 RATE IS -10 TO 10" return (self.tts.rate) #WHAT IS THE VOICE PITCH? def getPitch(self): "PITCH FOR MICROSOFT SAPI 5 IS AN XML COMMAND!" return self._pitch #GET THE ENGINE VOLUME! def getVolume(self): "MICROSOFT SAPI 5 VOLUME IS 1% TO 100%" return self.tts.volume #GET THE VOICE NUMBER! def getVoiceNum(self): return self._voice #SET A VOICE BY NAME! def setVoiceByName(self, name): "VOICE IS SET BY NAME!" for i in range( self._voiceCount): vp = self.tts.GetVoices()[ i].GetDescription().find( name) if vp>0: self.tts.Voice = self._voices[i] #self.tts.Voice = self.tts.GetVoices()[i] self.tts.Speak( "%s Set!" % name) self._voice=i+1 break if i >= self._voiceCount: self.tts.Speak( "%s Not Found!" % name) #USED FOR BOOKMARKING AND USE LATER! def _get_lastIndex(self): bookmark=self.tts.status.LastBookmark if bookmark!="" and bookmark is not None: return int(bookmark) else: return -1 #NOW SET ENGINE PARMS! #SET THE VOICE RATE! def setRate(self, rate): "MICROSOFT SAPI 5 RATE IS -10 TO 10" if rate > 10: rate = 10 if rate < -10: rate = -10 self.tts.Rate = rate #SET PITCH OF THE VOICE! def setPitch(self, value): "MICROSOFT SAPI 5 pitch is really controled with xml around speECH TEXT AND IS -10 TO 10" if value > 10: value = 10 if value < -10: value = -10 self._pitch=value #SET THE VOICE VOLUME! def setVolume(self, value): "MICROSOFT SAPI 5 VOLUME IS 1% TO 100%" self.tts.Volume = value #CREATE ANOTHER INSTANCE OF A VOICE! def createVoice(self, value=1): if value > self.getVoiceCount: value = self.getVoiceCount if value < 1: value = 1 new_tts = CreateObject( 'sapi.SPVoice') return (new_tts.GetVoices()[ value-1]) #SPEAKING TEXT! #SPEAK TEXT USING BOOKMARKS AND PITCH! def SpeakText(self, text, wait=False, index=None): "SPEAK TEXT AND XML FOR PITCH MUST REPLACE ANY <> SYMBOLS BEFORE USING XML BRACKETED TEXT" flags = constants4tts.XML text = text.replace( "<", "<") pitch = ((self._pitch*2)-100)/10 if isinstance(index, int): bookmarkXML = "" % index #NOTE \" FOR XML FORMAT CONVERSION! else: bookmarkXML = "" flags = constants4tts.XML if wait is False: flags += constants4tts.Async self.
Re: [Tutor] curses delwin functionality?
> I'm trying to get my hands on some curses experiences in Python. > > The examples I found don't really tell me how to get rid of subwindows and > restore the underlying window again. Is there something that replaces the > curses functionality "delwin"? > Thanks for any help! I had the same question, and I performed some simple experiments. 1) Re-assignment. I ran this and watched python's memory usage. It was completely flat. for i in range(1,5): stdscr.refresh() win = curses.newwin(10,1,0,2*2*i) win.bkgd(' ',curses.A_REVERSE) win.refresh() curses.napms(1) It seems that python calls the underlying curses API delwin(some_window) when some_window goes out of scope. Thus, there is no need to call something like it explicitly. Hope this helps. -j ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tkinter problem
I'm trying to learn to use Tkinter from "Thinking in Tkinter" and don't seem to be able to get the examples to work the way they are supposed to. I have the latest version of Python on a Macbook. Here's an example of the kind of problem I run into: The source code is: from Tkinter import * root = Tk() myContainer1 = Frame(root) myContainer.pack() button1 = Button(myContainer1) button1["text"} = "Hello, World!" button1[background"] = "green" button1.pack root.mainloop() I can execute this, but the button isn't green (or any other color I try) although it turns blue when I click the mouse on it. . Similarly, I've tried to write a bit of code to create a canvas object and put a rectangle in it, but I can't dimension the canvas, change its color, or get the rectangle to appear. Any advice or suggestion where to look for documentation would be greatly appreciated. Thanks Arden ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter problem
"Arden Hall" <[EMAIL PROTECTED]> wrote The source code is: I don't know if you cut n paste this but there are several errors: from Tkinter import * root = Tk() myContainer1 = Frame(root) myContainer.pack() mycontainer1 button1 = Button(myContainer1) button1["text"} = "Hello, World!" ] not } button1[background"] = "green" button1.pack pack() root.mainloop() I can execute this, but the button isn't green After fixing the errors, it works on my XP and Linux boxes. I haven't tried my Mac but see no reason why it shouldn't. I've tried to write a bit of code to create a canvas object and put a rectangle in it, but I can't dimension the canvas, change its color, or get the rectangle to appear. Any advice or suggestion where to look for documentation would be greatly appreciated. The online docs for tkinter are quite good. Start with the Tkinter area on the Python web site. Try posting more code here if it doesn't work. Cut n Paste by preference. Describe what you expect and what you get. -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter problem
The following worked for me. from Tkinter import * root = Tk() myContainer = Frame(root) myContainer.pack() button1 = Button(myContainer) button1['text'] = "Hello, World!" button1['background'] = "green" button1.pack() root.mainloop() Arden Hall wrote: I'm trying to learn to use Tkinter from "Thinking in Tkinter" and don't seem to be able to get the examples to work the way they are supposed to. I have the latest version of Python on a Macbook. Here's an example of the kind of problem I run into: The source code is: from Tkinter import * root = Tk() myContainer1 = Frame(root) myContainer.pack() button1 = Button(myContainer1) button1["text"} = "Hello, World!" button1[background"] = "green" button1.pack root.mainloop() I can execute this, but the button isn't green (or any other color I try) although it turns blue when I click the mouse on it. . Similarly, I've tried to write a bit of code to create a canvas object and put a rectangle in it, but I can't dimension the canvas, change its color, or get the rectangle to appear. Any advice or suggestion where to look for documentation would be greatly appreciated. Thanks Arden ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor