Re: [Tutor] Lists in List question
Hello Phil! the HTML-Formating look's better than the text-Version. on Thu, 23 Jun 2005 17:15:59 -0500 Phillip Hart <[EMAIL PROTECTED]> wrote : - Phillip Hart > Hello, Phillip Hart > I've been using lists within lists for several functions, but have been Phillip Hart > unable, in loop form, to extract data from them or, in loop for, apply data Phillip Hart > to them. Phillip Hart > Phillip Hart > Basically, when extracting data, it only runs 1 loop. Likewise, when Phillip Hart > initially assigning the data, it only runs 1 loop. Phillip Hart > Phillip Hart > In the following example, the loop works once for x, and then a full loop (8 Phillip Hart > times) for y: Phillip Hart > Phillip Hart > ### Phillip Hart > rr1=[0,0,0,0,0,0,0,0] Phillip Hart > rr2=[0,0,0,0,0,0,0,0] Phillip Hart > rr3=[0,0,0,0,0,0,0,0] Phillip Hart > rr4=[0,0,0,0,0,0,0,0] Phillip Hart > rr5=[0,0,0,0,0,0,0,0] Phillip Hart > rr6=[0,0,0,0,0,0,0,0] Phillip Hart > rr7=[0,0,0,0,0,0,0,0] Phillip Hart > rr8=[0,0,0,0,0,0,0,0] Phillip Hart > results=[rr1,rr2,rr3,rr4,rr5,rr6,rr7,rr8] Phillip Hart > Phillip Hart > Phillip Hart > x=0 Phillip Hart > y=0 Phillip Hart > while x<8: Phillip Hart > while y<8: Phillip Hart > value=x+y Phillip Hart > results[x][y]=value Phillip Hart > y=y+1 Phillip Hart > x=x+1 Phillip Hart > In the nested while-Loop's there is no reset of y during each run for an incremented x so after the first turn the second while will never be run, because y is allways set to 8. --- end -- HTH Ewald ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Changing what you've already printed
Ed Singleton wrote: > Is it possible (and easy) to change something you've already printed > rather than print again? > > Any clues or pointers to documentation gratefully recieved. You might like textui. It creates a console window in Tkinter so it is portable and it supports gotoxy(). http://py.vaults.ca/apyllo.py/808292924.247038364.15871892 Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Thanks for your response, Shuying Wang -- I was afraid no one even read the post. Now I see I wasn't clear. -- Shuying Wang: I'm not sure what you're trying to do. But I run cgi scripts and makexmlrpc requests with xmlrpclib with a connection withxmlrpclib.Server(server_uri), though I'm only doing this client side.I'm not running the server as cgi. ---I have a Python module that I am trying to expose via XMLRPC. I can get it running by assigning a port on the server using SimpleXMLRPCRequestHandler, but I would prefer to expose it through CGI if possible. This seems to be the stated purpose of the CGIXMLRPCRequestHandler, but I believe it is broken in some very serious way. The example code in the python online documentation calls a non-existant "div" function, so it was obviously a typing exercise, not actual code that anyone ever tested. In researching the module, I found several requests on various mailing lists for example code -- not a single one ever had a response. When I've seen this before, it has turned out that either: a) it is terribly difficult, or b)it is stupidly simple. Since this is a tutor list, and I have seen the members graciously answer some questions that seemed pretty simple, I thought I'd post it here. Since the only response (yours -- thanks again for responding!) was about xmlrpclib on the client side, not CGIXMLRPCRequestHandler on the server side, I can now conclude that it is terribly difficult, and slink off to publish using SOAP. Ron On 6/23/05, Ron Phillips <[EMAIL PROTECTED]> wrote:> > I believe I've tried every setting known to man, in every script in every> little scrap of documentation available. XMLRPC requests using> SimpleXMLRPCRequestHandler -- no problem. But try to run them as a CGI> script, and I get system lock ups and that's all. No error codes; no> response whatsoever. > > I am using Python 2.3, Windows XP. I have run other CGI scripts in the same> directory, so I know that works. > > Has anyone used this successfully? Can you share demo server and client> scripts -- just an echo function or something? > > Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
##Run a simple CGI server by opening a command line to the parent dir of cgi-bin and runningpython -c "import CGIHTTPServer; CGIHTTPServer.test()" ## Oh, dear -- I responded before I read your post, Kent. It turns out it was option b), after all. But I had NO idea I would need to do anything like the little clip above. Anything else I run under CGI, I just send an HTTP request and it works. I read, and read, and read, but never read anything about starting a CGIHTTPServer -- I'll look it up right away, but I can't see how I missed that. Maybe by Googling "XMLRPC", which was what I really wanted to do. Anyway, thank you -- if I can find them again, I'll respond to all those other posts with a link to yours in the archives. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Ron Phillips wrote: > ## > Run a simple CGI server by opening a command line to the parent dir of > cgi-bin and running > python -c "import CGIHTTPServer; CGIHTTPServer.test()" > > ## > > Oh, dear -- I responded before I read your post, Kent. It turns out it > was option b), after all. But I had NO idea I would need to do anything > like the little clip above. Anything else I run under CGI, I just send > an HTTP request and it works. I read, and read, and read, but never read > anything about starting a CGIHTTPServer -- I'll look it up right away, > but I can't see how I missed that. Maybe by Googling "XMLRPC", which was > what I really wanted to do. CGI requires a running HTTP server in front of it. The server receives the HTTP request, sees that it is a CGI request, starts a new process with the environment set according to the CGI protocol, and runs the CGI handler. Do you understand this relationship? (I mean that kindly, your response makes me suspect there is a fair amount of black magic in this for you.) The snippet above just starts a simple CGI-capable HTTP server. It is useful for testing, not an essential part of the recipe. If you have other CGIs working you must have a working HTTP server already, such as Apache or IIS. In your initial post you said "I have run other CGI scripts in the same directory." Were those CGIs written in Python? How did you run them? Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Hi, I managed to make it work with the following code: #! /usr/bin/python from SimpleXMLRPCServer import CGIXMLRPCRequestHandler def plus(a,b): return a + b server = CGIXMLRPCRequestHandler() server.register_function(plus) server.handle_request() Setting this to run from a cgi directory then using the following worked: >>> import xmlrpclib >>> s = xmlrpclib.ServerProxy("http://127.0.0.1/~joe/xmlrpctest.cgi";) >>> s.plus(4,5) 9 Hope this helps Joe > Thanks for your response, Shuying Wang -- I was afraid no one even read > the post. Now I see I wasn't clear. > -- > Shuying Wang: I'm not sure what you're trying to do. But I run cgi > scripts and make > xmlrpc requests with xmlrpclib with a connection with > xmlrpclib.Server(server_uri), though I'm only doing this client side. > I'm not running the server as cgi. > --- > I have a Python module that I am trying to expose via XMLRPC. I can get > it running by assigning a port on the server using > SimpleXMLRPCRequestHandler, but I would prefer to expose it through CGI > if possible. This seems to be the stated purpose of the > CGIXMLRPCRequestHandler, but I believe it is broken in some very serious > way. > > The example code in the python online documentation calls a > non-existant "div" function, so it was obviously a typing exercise, not > actual code that anyone ever tested. > > In researching the module, I found several requests on various mailing > lists for example code -- not a single one ever had a response. When > I've seen this before, it has turned out that either: a) it is terribly > difficult, or b)it is stupidly simple. Since this is a tutor list, and I > have seen the members graciously answer some questions that seemed > pretty simple, I thought I'd post it here. > > Since the only response (yours -- thanks again for responding!) was > about xmlrpclib on the client side, not CGIXMLRPCRequestHandler on the > server side, I can now conclude that it is terribly difficult, and slink > off to publish using SOAP. > > Ron > > > On 6/23/05, Ron Phillips <[EMAIL PROTECTED]> wrote: >> >> I believe I've tried every setting known to man, in every script in > every >> little scrap of documentation available. XMLRPC requests using >> SimpleXMLRPCRequestHandler -- no problem. But try to run them as a > CGI >> script, and I get system lock ups and that's all. No error codes; no >> response whatsoever. >> >> I am using Python 2.3, Windows XP. I have run other CGI scripts in > the same >> directory, so I know that works. >> >> Has anyone used this successfully? Can you share demo server and > client >> scripts -- just an echo function or something? >> >> Ron > > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with Tkinter teachers' report program?
I am a teacher and have written this little Python/Tkinter application to help me with my report writing: http://cvs.sourceforge.net/viewcvs.py/squawk/ It's released under GPL and was quite fun to write. However, currently the application only allows for 15 statements to be managed. Increasing it to 25 would be easy. But I'm not sure how I would manage the widget to present 100 or organise the statements according to subjects. Can anyone have a look at the code - perhaps run it and if possible suggest a way of implementing many more statements? Tabbed frames would be a good way forward (where each tab is a school subject) but under Tkinter they don't appear to be that easy. TIA Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Tkinter teachers' report program?
On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: I am a teacher and have written this little Python/Tkinter applicationto help me with my report writing:http://cvs.sourceforge.net/viewcvs.py/squawk/ It's released under GPL and was quite fun to write.However, currently the application only allows for 15 statements to bemanaged. Increasing it to 25 would be easy. But I'm not sure how Iwould manage the widget to present 100 or organise the statements according to subjects.Can anyone have a look at the code - perhaps run it and if possiblesuggest a way of implementing many more statements? Tabbed frameswould be a good way forward (where each tab is a school subject) but under Tkinter they don't appear to be that easy. You can do tabbed frames in Tkinter. They take a little bit of coding, but to get right, but it is certainly something to think about. You might want to look into PMW (Python MegaWidgets) which is a Tkinter library. Myself, I had always prefered to write things in Tkinter, but a lot of people like the widget set in PMW. As for scaling the statements you have, you might want to think about putting the Label/Entry/Button widgets in a Frame with a Scrollbar widget. Then you can add as many as you like and the user can scroll down to the 200th statement. (I'm assuming that the user fills out each statement one by one, ugh!) Incidently, this Frame would be the same frame used for the tabbing, I would expect. -Arcege-- There's so many different worlds,So many different suns.And we have just one world,But we live in different ones. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Tkinter teachers' report program?
On 6/24/05, Michael P. Reilly <[EMAIL PROTECTED]> wrote: > On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: > > I am a teacher and have written this little Python/Tkinter application > > to help me with my report writing: > > > > http://cvs.sourceforge.net/viewcvs.py/squawk/ > > > > It's released under GPL and was quite fun to write. > > > > However, currently the application only allows for 15 statements to be > > managed. Increasing it to 25 would be easy. But I'm not sure how I > > would manage the widget to present 100 or organise the statements > > according to subjects. > > > > Can anyone have a look at the code - perhaps run it and if possible > > suggest a way of implementing many more statements? Tabbed frames > > would be a good way forward (where each tab is a school subject) but > > under Tkinter they don't appear to be that easy. > > > > You can do tabbed frames in Tkinter. They take a little bit of coding, but > to get right, but it is certainly something to think about. You might want > to look into PMW (Python MegaWidgets) which is a Tkinter library. Myself, I > had always prefered to write things in Tkinter, but a lot of people like the > widget set in PMW. > > As for scaling the statements you have, you might want to think about > putting the Label/Entry/Button widgets in a Frame with a Scrollbar widget. > Then you can add as many as you like and the user can scroll down to the > 200th statement. (I'm assuming that the user fills out each statement one > by one, ugh!) Incidently, this Frame would be the same frame used for the > tabbing, I would expect. >-Arcege I hadn't thought about a scrollbar - that would be very useful, although doesn't add to the management side of the statement (i.e. organising them according to subjects). The user can load a text file and adapt that - so they don't have to enter them by hand if they have them in a .txt file. Typing them in by hand once is better than typing them in by hand for every child that you have in your class, which is the whole aim of the software. Thanks Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Tkinter teachers' report program?
On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: I hadn't thought about a scrollbar - that would be very useful,although doesn't add to the management side of the statement (i.e.organising them according to subjects).The user can load a text file and adapt that - so they don't have to enter them by hand if they have them in a .txt file. Typing them in byhand once is better than typing them in by hand for every child thatyou have in your class, which is the whole aim of the software. I could try to whip up an example a little later if you like. I probably wouldn't be large, but it could demonstrate tabbed frames with scrolling. -Arcege-- There's so many different worlds,So many different suns.And we have just one world,But we live in different ones. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Kent wrote: CGI requires a running HTTP server in front of it. The server receives the HTTP request, sees that it is a CGI request, starts a new process with the environment set according to the CGI protocol, and runs the CGI handler. Do you understand this relationship? (I mean that kindly, your response makes me suspect there is a fair amount of black magic in this for you.) The snippet above just starts a simple CGI-capable HTTP server. It is useful for testing, not an essential part of the recipe. If you have other CGIs working you must have a working HTTP server already, such as Apache or IIS. In your initial post you said "I have run other CGI scripts in the same directory." Were those CGIs written in Python? How did you run them? Kent- Well, I understand the words, and I can see that the HTTP server (IIS, in this case) hands off CGI stuff to a CGI handler -- but I think that IS a fair amount of black magic! So no, I really can't claim any deep understanding of the process. What I ran before were simple little test scripts of the "HelloWorld.py" variety. I would put them in the cgi-bin directory and invoke them with the browser, or with the HTTPLib in the command line, and I would get something back. When I invoke any script in the cgi-bin that has CGIXMLRPCRequestHandler in it through localhost or localhost:80, the program freezes right up. Nothing returned, nothing in the IIS error log, no reply at all. However, the little test scripts that you and Joe provided run just fine as long as I don't use IIS as the server. Maybe I should have posted "IIS and CGIXMLRPCRequestHandler doesn't work at all!!" Seriously, it looks like my IIS installation is at fault -- probably some setting I need to change. I wonder if that's the reason for all those unanswered posts -- it's not a Python problem, per se? Odd, though, that IIS is perfectly happy to run a Python script unless it has CGIXMLRPCRequestHandler in it. Ron ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Search and Replace
I ma trying to write a script to search adn replace a sizable chink of text in about 460 html pages. It is an old form that usesa search engine no linger availabe. I am wondering if anyone has any advice on the best way to go about that. There are more than one layout place ment for the form, but I would be happy to correct the last few by hand as more than 90% are the same. So my ideas have been, use regex to find .* and replace it with newform. Unfortunately there is more than just search form. So this would just clobber all of them. So I could .*knownName of SearchButton.* --> newform Or should I read each file in as a big string and break on the form tags, test the strings as necessary ad operate on them if the conditions are met. Unfortunaltely I think there are wide variances in white space and lines breaks. Even the order of the tags is inconsistent. So I think I am stuck with the first option... Unless there is some module or package I haven't found that works on html in just the way that I want. I found htmlXtract but it is for Python 1.5 and not immediately intuitive. Any help or advice on this is much appreciated. TIA ~r -- 4.6692916090 'cmVlZG9icmllbkBnbWFpbC5jb20=\n'.decode('base64') http://www.spreadfirefox.com/?q=affiliates&id=16474&t=1 -- 4.6692916090 'cmVlZG9icmllbkBnbWFpbC5jb20=\n'.decode('base64') http://www.spreadfirefox.com/?q=affiliates&id=16474&t=1 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Tkinter teachers' report program?
On 6/24/05, Michael P. Reilly <[EMAIL PROTECTED]> wrote: > On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: > > I hadn't thought about a scrollbar - that would be very useful, > > although doesn't add to the management side of the statement (i.e. > > organising them according to subjects). > > > > The user can load a text file and adapt that - so they don't have to > > enter them by hand if they have them in a .txt file. Typing them in by > > hand once is better than typing them in by hand for every child that > > you have in your class, which is the whole aim of the software. > > > > I could try to whip up an example a little later if you like. I probably > wouldn't be large, but it could demonstrate tabbed frames with scrolling. > > -Arcege > -- Michael, That would be much appreciated. Thanks Adam -- http://www.monkeez.org PGP key: 0x7111B833 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Ron Phillips wrote: > What I ran before were simple little test scripts of the "HelloWorld.py" > variety. I would put them in the cgi-bin directory and invoke them with > the browser, or with the HTTPLib in the command line, and I would get > something back. OK, that is a good test. > > When I invoke any script in the cgi-bin that has CGIXMLRPCRequestHandler > in it through localhost or localhost:80, the program freezes right up. Which program freezes up? The client, IIS, or the CGI? > Nothing returned, nothing in the IIS error log, no reply at all. > However, the little test scripts that you and Joe provided run just fine > as long as I don't use IIS as the server. Maybe I should have posted > "IIS and CGIXMLRPCRequestHandler doesn't work at all!!" Seriously, it > looks like my IIS installation is at fault -- probably some setting I > need to change. Try putting this at the top of your Python CGI: import cgitb cgitb.enable(display=0, logdir='C:/temp') where logdir points to a writable directory. Then try accessing the cgi and see if anything is written to the log dir. Hopefully it will give a clue to what is going wrong. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Search and Replace
Reed L. O'Brien wrote: > I ma trying to write a script to search adn replace a sizable chink of > text in about 460 html pages. > It is an old form that usesa search engine no linger availabe. > > I am wondering if anyone has any advice on the best way to go about that. > There are more than one layout place ment for the form, but I would be > happy to correct the last few by hand as more than 90% are the same. > > So my ideas have been, > use regex to find .* and replace it with newform. > Unfortunately there is more than just search form. So this would just > clobber all of them. So I could .*knownName of > SearchButton.* --> newform If you are sure 'knownName of SearchButton' only occurs in the form you want to replace, this seems like a good option. Only use non-greedy matching .*?knownName of SearchButton.*? Without the ? you will match from the start of the first form in the page, to the end of the last form, as long as the search form is one of them. > > Or should I read each file in as a big string and break on the form > tags, test the strings as necessary ad operate on them if the conditions > are met. Unfortunaltely I think there are wide variances in white > space and lines breaks. Even the order of the tags is inconsistent. So > I think I am stuck with the first option... > > Unless there is some module or package I haven't found that works on > html in just the way that I want. I found htmlXtract but it is for > Python 1.5 and not immediately intuitive. You might be able to find a module that will read the HTML into a structured form, work on that, and write it out again. Whether this is easy or practical depends a lot on how well-formed your HTML is, and how important it is to keep exactly the same form when you write it back out. You could take a look at ElementTidy for example. http://effbot.org/zone/element-tidylib.htm But I think the regex solution sounds good. Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
> The example code in the python online documentation calls a non-existant > "div" function, so it was obviously a typing exercise, not actual code > that anyone ever tested. Hi Ron, Ah, ok, I see. Check the bottom of: http://www.python.org/doc/lib/simple-xmlrpc-servers.html for a working example of that div function in the MyFuncs class. I believe that the example you were looking at earlier, near the bottom of: http://www.python.org/doc/lib/node556.html has is a documentation bug: the intent is clearly to compare and contrast SimpleXMLRPCServer and CGIXMLRPCRequestHandler, so the code should be using the same example. The fact that it isn't is confusing, and should be fixed. I'll send a bug report now. http://python.org/sf/1227181 Try Kent's example again; XMLRPC stuff is itself not too bad. Your two assumptions: 1. It's too easy to mention, and not worth talking about 2. It's too hard in practice, and not worth talking about are too black-and-white: XMLRPC itself is not bad at all, but CGI stuff can be maddeningly difficult at first, because it involves not only Python but also integration with an external web server. What I think you're running into is the CGI part, the part that doesn't debug as easily, just because error output doesn't automatically send to the browser --- that would be a security risk! --- but instead is shuttled off to your web server's error log file. So take a closer look at your web server's error logs; I wouldn't be surprised to see some Python error messages there that should help to isolate the issue. Best of wishes to you! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Yes, I believe you are right -- I posted a reply to the list indicating that I suspect IIS is at fault; not Python. Or perhaps I should say "my installation of IIS"; I have no confidence whatsoever in my abilities to administer IIS properly. Thanks for looking at the documentation -- I was stuck using 2.3 because of some other modules I needed, so I didn't look at the 2.4 docs. That would have made me less angry, but the script still wouldn't have run, because the problem (evidently) is in IIS, not my code. I was really hard up against it -- no response at all from IIS, just a lockup, and apparently when IIS locked up, it did so prior to writing to the error log. When I tried using the CGIHTTPServer, everything I did over the past 3 days worked without a hitch. What a relief!! Now I just need to work around IIS -- and we don't use it outside the firewall, anyway. I think I'll put Apache on my local machine and use that. Thanks, again Ron >>> Danny Yoo <[EMAIL PROTECTED]> 6/24/2005 2:44:44 PM >>> > The example code in the python online documentation calls a non-existant> "div" function, so it was obviously a typing exercise, not actual code> that anyone ever tested.Hi Ron,Ah, ok, I see. Check the bottom of: http://www.python.org/doc/lib/simple-xmlrpc-servers.htmlfor a working example of that div function in the MyFuncs class.I believe that the example you were looking at earlier, near the bottomof: http://www.python.org/doc/lib/node556.htmlhas is a documentation bug: the intent is clearly to compare and contrastSimpleXMLRPCServer and CGIXMLRPCRequestHandler, so the code should beusing the same example. The fact that it isn't is confusing, and shouldbe fixed. I'll send a bug report now. http://python.org/sf/1227181Try Kent's example again; XMLRPC stuff is itself not too bad. Your twoassumptions: 1. It's too easy to mention, and not worth talking about 2. It's too hard in practice, and not worth talking aboutare too black-and-white: XMLRPC itself is not bad at all, but CGI stuffcan be maddeningly difficult at first, because it involves not only Pythonbut also integration with an external web server.What I think you're running into is the CGI part, the part that doesn'tdebug as easily, just because error output doesn't automatically send tothe browser --- that would be a security risk! --- but instead is shuttledoff to your web server's error log file. So take a closer look at yourweb server's error logs; I wouldn't be surprised to see some Python errormessages there that should help to isolate the issue.Best of wishes to you!__This email has been scanned by the MessageLabs Email Security System.For more information please visit http://www.messagelabs.com/email __ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
Danny Yoo wrote: > I believe that the example you were looking at earlier, near the bottom > of: > > http://www.python.org/doc/lib/node556.html > > has is a documentation bug: the intent is clearly to compare and contrast > SimpleXMLRPCServer and CGIXMLRPCRequestHandler, so the code should be > using the same example. The fact that it isn't is confusing, and should > be fixed. I'll send a bug report now. http://python.org/sf/1227181 I'm way ahead of you on that one :-) I filed a bug report that fixed the example on the SimpleXMLRPCServer page and recently reopened it for the CGIXMLRPCRequestHandler page. You might want to flag yours as a duplicate...see http://sourceforge.net/tracker/index.php?func=detail&aid=1041501&group_id=5470&atid=105470 Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Tkinter teachers' report program?
> suggest a way of implementing many more statements? Tabbed frames > would be a good way forward (where each tab is a school subject) but > under Tkinter they don't appear to be that easy. Faking tabbed frames is fairly easy. Baasically its two frames one on top of the other, the top one is the tab set and the bottom the tab content selected. As you click a button simply unpack the current frame an pack the new one. Remember to change the highlighting of the selected tab by changing button appearance in some way. The principle is easy even if requiring a little bit of effort. We did this with an Oracle Forms application about 12 years ago when tabbed displays were very new and very sexy! :-) Alan G Author of the Learn to Program web tutor http://www.freenetpages.co.uk/hp/alan.gauld ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Tkinter teachers' report program?
for tabs, try the PMW library, notebook widget. its fairly easy to use I have found. Ike Adam Cripps wrote: >I am a teacher and have written this little Python/Tkinter application >to help me with my report writing: > >http://cvs.sourceforge.net/viewcvs.py/squawk/ > >It's released under GPL and was quite fun to write. > >However, currently the application only allows for 15 statements to be >managed. Increasing it to 25 would be easy. But I'm not sure how I >would manage the widget to present 100 or organise the statements >according to subjects. > >Can anyone have a look at the code - perhaps run it and if possible >suggest a way of implementing many more statements? Tabbed frames >would be a good way forward (where each tab is a school subject) but >under Tkinter they don't appear to be that easy. > >TIA >Adam > > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] CGIXMLRPCRequestHandler doesn't actually work, does it?
> > has is a documentation bug: the intent is clearly to compare and contrast > > SimpleXMLRPCServer and CGIXMLRPCRequestHandler, so the code should be > > using the same example. The fact that it isn't is confusing, and should > > be fixed. I'll send a bug report now. http://python.org/sf/1227181 > > I'm way ahead of you on that one :-) I filed a bug report that fixed the > example on the SimpleXMLRPCServer page and recently reopened it for the > CGIXMLRPCRequestHandler page. You might want to flag yours as a > duplicate...see > http://sourceforge.net/tracker/index.php?func=detail&aid=1041501&group_id=5470&atid=105470 Hi Kent, Ah! Ok, thanks for the correction. That was silly of me. *grin* Ok, will do; I'm marking my report as a duplicate now. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] strip an email
Hi nephish, I clearly remember it is very very simple and it is defined in the RFC. As far as I remember, the end of the headers are signalled by an empty line. Try looking for '\n\n', this should do the trick. I've saved a couple of emails and it looks like this should work. something like: #full_text holds the full text of the message bodypos = full_text.find('\n\n') + 2 body = full_text[bodypos:] #body now holds the message body Please let us know if this works, hope it helps. Hugo nephish wrote: > Does anyone know how to strip everything off of an email? > i have a little app that i am working on to read an email message and > write the > body of a message to a log file. > each email this address gets is only about three to five lines long. > but i cannot seem to get just the body filtered through. > i get all the headers, the path, what spam-wall it went through, etc... > > any suggestions would be greatly appreciated . > thanks > ___ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Popen4 and Paths Containing Spaces
Thanks, didn't know it before, as I have done very little Windows programming... only used the command line... > Windows doesn't care. The only place you can't use forward slashes in > path names is in a command prompt. It's been that way since DOS 2.0 in > the 80s. I prefer using the forward slashes in file name strings since > they're fairly portable. > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with Tkinter teachers' report program?
On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote: On 6/24/05, Michael P. Reilly <[EMAIL PROTECTED]> wrote:> On 6/24/05, Adam Cripps <[EMAIL PROTECTED]> wrote:> > I hadn't thought about a scrollbar - that would be very useful, > > although doesn't add to the management side of the statement (i.e.> > organising them according to subjects).> >> > The user can load a text file and adapt that - so they don't have to > > enter them by hand if they have them in a .txt file. Typing them in by> > hand once is better than typing them in by hand for every child that> > you have in your class, which is the whole aim of the software. > >>> I could try to whip up an example a little later if you like. I probably> wouldn't be large, but it could demonstrate tabbed frames with scrolling.>> -Arcege> -- Michael,That would be much appreciated.ThanksAdam Here you go, Adam. It's not full and complete, but it's working and you can customize it how you like. -Michael-- There's so many different worlds,So many different suns.And we have just one world, But we live in different ones. from Tkinter import * class TabbedFrame(Frame): """Create a frame with two areas, one is a small bar at the top where tabs will be placed, like a menu. The second area will be one container panel. When a tab is pressed, the panel will display the contents of a selected frame (created with the new() method). Each tab has a unique given name that identifies it. These are the public methods: new(tab_name) -> frame create a new tab and panel frame, return that frame remove(tab_name) destroy the tab and associated panel frame has_tab(tab_name) -> boolean does a tab exist with this name? select(tab_name) switch to selected tab """ def __init__(self, master): Frame.__init__(self, master) self.tabs = {} self.current_tab = None self._create_widgets() def _create_widgets(self): self.tabframe = Frame(self, height=25, relief=SUNKEN, bg='grey25', bd=2) self.tabframe.pack(side=TOP, fill=X, expand=YES) self.baseframe = Frame(self, bg='white', bd=2) self.baseframe.pack(side=BOTTOM, fill=BOTH, expand=YES) def _add_tab(self, name, button, frame): self.tabs[name] = (button, frame) def new(self, name): if self.has_tab(name): raise ValueError(name) button = Button(self.tabframe, relief=FLAT, text=str(name), bg='grey50', command=lambda n=name, s=self: s.select(n)) button.pack(side=LEFT, pady=1, padx=1) frame = Frame(self.baseframe) self._add_tab(name, button, frame) self.select(name) return frame def remove(self, name): try: button, frame = self.tabs[name] except: raise ValueError(name) if self.current_tag == name: frame.forget() button.forget() self.current_tag = None frame.destroy() button.destroy() del self.tabs[name] def has_tab(self, name): return self.tabs.has_key(name) def select(self, name): if self.current_tab: button, frame = self.tabs[self.current_tab] button['bg'] = 'grey50' frame.forget() button, frame = self.tabs[name] button['bg'] = 'grey75' frame.pack(fill=BOTH, expand=YES) self.current_tab = name def Adam_Report(tabbedframe): # Reproduce something like Adam's teacher report frame = tabbedframe.new('subject') topframe = Frame(frame) nameframe = Frame(topframe) firstnameframe = Frame(nameframe) Label(firstnameframe, text="First name: ").pack(side=LEFT) Entry(firstnameframe).pack(side=LEFT) firstnameframe.pack(side=TOP) lastnameframe = Frame(nameframe) Label(lastnameframe, text="Last name: ").pack(side=LEFT) Entry(lastnameframe).pack(side=LEFT) lastnameframe.pack(side=TOP) nameframe.pack(side=LEFT, fill=BOTH, expand=YES) sexframe = Frame(topframe) Label(sexframe, text="Sex: ").pack(side=LEFT) sexm_r = Radiobutton(sexframe, value="male", text="male") sexf_r = Radiobutton(sexframe, value="female", text="female") sexm_r.pack(side=LEFT) sexf_r.pack(side=LEFT) sexframe.pack(side=RIGHT, fill=BOTH, expand=YES) topframe.pack(side=TOP, fill=X, expand=YES) splitbottom = Frame(frame) NoStatements = 16 leftsplitframe = Frame(splitbottom) # has statementframe and Scrollbar sb = Scrollbar(leftsplitframe, orient=VERTICAL) canv = Canvas(leftsplitframe, yscrollcommand=sb, height=200, width=150) sb.config(command=canv.yview) statementframe = Frame(leftsplitframe) canv.create_window(75, 0, window=statementframe) for i in range(NoStatements): label = Label(statementframe, text="Statement %s" % i) label.grid(column=0, row=i) entry = Entry(statementframe)
Re: [Tutor] Search and Replace
Reed L. O'Brien wrote: >I ma trying to write a script to search adn replace a sizable chink of >text in about 460 html pages. >It is an old form that usesa search engine no linger availabe. > Well in the vein of Kents suggestion there is http://www.crummy.com/software/BeautifulSoup/ however it will change the output some. So if you have some bizarre markup I think it'll try to fix it. Which afaik most html parsers outputers will do. I don't know how to do regex's so I would just do he string manipulation method. Good Luck __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] strip an email
On Fri, Jun 24, 2005, Hugo González Monteverde wrote: >Hi nephish, > >I clearly remember it is very very simple and it is defined in the RFC. >As far as I remember, the end of the headers are signalled by an empty line. > >Try looking for '\n\n', this should do the trick. I've saved a couple of >emails and it looks like this should work. See http://docs.python.org/lib/module-email.html for easy ways to handle e-mail. The email module has utilities that make it easy to handle headers and body. >something like: > >#full_text holds the full text of the message > >bodypos = full_text.find('\n\n') + 2 > >body = full_text[bodypos:] > >#body now holds the message body > >Please let us know if this works, hope it helps. > >Hugo > >nephish wrote: >> Does anyone know how to strip everything off of an email? >> i have a little app that i am working on to read an email message and >> write the >> body of a message to a log file. >> each email this address gets is only about three to five lines long. >> but i cannot seem to get just the body filtered through. >> i get all the headers, the path, what spam-wall it went through, etc... >> >> any suggestions would be greatly appreciated . >> thanks >> ___ >> Tutor maillist - Tutor@python.org >> http://mail.python.org/mailman/listinfo/tutor >> >___ >Tutor maillist - Tutor@python.org >http://mail.python.org/mailman/listinfo/tutor > -- Bill -- INTERNET: [EMAIL PROTECTED] Bill Campbell; Celestial Software LLC UUCP: camco!bill PO Box 820; 6641 E. Mercer Way FAX:(206) 232-9186 Mercer Island, WA 98040-0820; (206) 236-1676 URL: http://www.celestial.com/ ``Good luck to all you optimists out there who think Microsoft can deliver 35 million lines of quality code on which you can operate your business.'' -- John C. Dvorak ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] fileinput problem
I'm getting unexpected behaviour from this module. My script is meant to count the number of occurences of a term in one or more files. --- import sys, string, fileinput searchterm, sys.argv[1:] = sys.argv[1], sys.argv[2:] for line in fileinput.input(): num_matches = string.count(line, searchterm) if num_matches: print "found '%s' %i times in %s on line %i." % (searchterm, num_matches, fileinput.filename(), fileinput.filelineno()) --- When I run at the command line, this error message appears: $ python ./Python/fileinput.py for ./Python/*.py Traceback (most recent call last): File "./Python/fileinput.py", line 1, in ? import sys, string, fileinput File "./Python/fileinput.py", line 6, in ? for line in fileinput.input(): AttributeError: 'module' object has no attribute 'input' --- I'm stumped. Any ideas? Kevin ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor