Re: [Tutor] Tkinter Icon Suse 10
I tried that but still the same error. Any other idea?Rgds,Alberto2006/8/25, Alberto Troiano [EMAIL PROTECTED] :Hi everyoneIt's been a long time since I left Python for .NET 2003, but then again I need it to make an app under Linux Suse 10 and I have a question I'm trying to put an icon to my window...Here is the code so far: ###Start Code###import Tkinterfrom Tkinter import *root = Tk()root.iconbitmap(Change.ico)root.mainloop()###End Code###It works great under Windows but on an Suse 10 Machine it complains about the file. Is this because the icon files are not the same as in Windows or should I be using another sentence to make it work? I know it's a dumb question but I'm out of practice and I couldn't find docs on Google (maybe I didn't look where I supposed to)Ups..I forgot, I'm using Python 2.4.1Regards-- Alberto -- Alberto Troiano ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tkinter Icon Suse 10
Hey..thanks for the replyI found some XBM on the PC (Suse) but still no luckThe error says that the bitmap is not definedWas the code OK or I have to change it?Thanks 2006/8/25, Alberto Troiano [EMAIL PROTECTED]: Hi everyoneIt's been a long time since I left Python for .NET 2003, but then again I need it to make an app under Linux Suse 10 and I have a questionI'm trying to put an icon to my window...Here is the code so far: ###Start Code###import Tkinterfrom Tkinter import *root = Tk()root.iconbitmap(Change.ico)root.mainloop()###End Code###It works great under Windows but on an Suse 10 Machine it complains about the file. Is this because the icon files are not the same as in Windows or should I be using another sentence to make it work? I know it's a dumb question but I'm out of practice and I couldn't find docs on Google (maybe I didn't look where I supposed to)Ups..I forgot, I'm using Python 2.4.1Regards-- Alberto -- Alberto Troiano ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tkinter Icon Suse 10
Hi everyoneIt's been a long time since I left Python for .NET 2003, but then again I need it to make an app under Linux Suse 10 and I have a questionI'm trying to put an icon to my window...Here is the code so far: ###Start Code###import Tkinterfrom Tkinter import *root = Tk()root.iconbitmap(Change.ico)root.mainloop()###End Code###It works great under Windows but on an Suse 10 Machine it complains about the file. Is this because the icon files are not the same as in Windows or should I be using another sentence to make it work? I know it's a dumb question but I'm out of practice and I couldn't find docs on Google (maybe I didn't look where I supposed to)Ups..I forgot, I'm using Python 2.4.1Regards-- Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Convert integer number to binary representation
Hey all I want to know how can I convert an integer number to a binary number. Like this example: +10 (decimal representationinteger) = 1010 (binary representation) Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Do I have to initialize TKInter before I can use it?
Hey Nathan I think this is what you are looking for Code Below from Tkinter import * import tkMessageBox tkMessageBox._show(Windows Title,This is the description,icon=tkMessageBox.INFO,type=tkMessageBox.OK) ###End of Code Regards Alberto -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre de Nathan Pinno Enviado el: Martes, 15 de Noviembre de 2005 00:43 Para: 'Alan Gauld'; 'Tutor Mailing List' Asunto: Re: [Tutor] Do I have to initialize TKInter before I can use it? Alan and all, I imported it, but its not there. I tried using the Message one found in it, but I got an error message: import Tkinter tk = Tkinter.Tk() Tkinter.Message(Help,Help!) Traceback (most recent call last): File pyshell#6, line 1, in -toplevel- Tkinter.Message(Help,Help!) File D:\Python24\lib\lib-tk\Tkinter.py, line 2640, in __init__ Widget.__init__(self, master, 'message', cnf, kw) File D:\Python24\lib\lib-tk\Tkinter.py, line 1862, in __init__ BaseWidget._setup(self, master, cnf) File D:\Python24\lib\lib-tk\Tkinter.py, line 1840, in _setup self.tk = master.tk AttributeError: 'str' object has no attribute 'tk' What does this mean, and how can I get it working? Nathan -Original Message- From: Alan Gauld [mailto:[EMAIL PROTECTED] Sent: November 14, 2005 9:35 PM To: Nathan Pinno; Tutor Mailing List Subject: Re: [Tutor] Do I have to initialize TKInter before I can use it? Nathan, I am having problems. The latest error message I got was: tkMessageBox.showinfo(Hockey, NameError: name 'tkMessageBox' is not defined A NameError means Python doesn't recognise the name. Usually that's because either you didn't declare the variable or you forgot to import the module or you spelled it wrong. In this case I'd guess you forgot the import? Python error messages are really quite helpful if you just stop and think about what they are saying for a few minutes. 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 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Config Parser question
Hey tutors Im trying to make a configuration file I know how to read the sections and options (using ConfigParser module from Python 2.3.4 on Win XP) What I wanted to know is that eventually I will need to add sections and options or change values or erase options or , etc Is there any way that I can do this changes to the config.ini file? Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Config Parser question
Hey Kent Thank you for the reply Let me get this straight.. In order to store the new configuration I would have to make something like this? import ConfigParser f=open(config.ini,w+) c=ConfigParser.ConfigParser() c.add_section(foo) c.write(f) Please let me know if this is correct Thank you Alberto -Mensaje original- De: Kent Johnson [mailto:[EMAIL PROTECTED] Enviado el: Viernes, 07 de Octubre de 2005 18:36 Para: Alberto Troiano CC: tutor@python.org Asunto: Re: [Tutor] Config Parser question Alberto Troiano wrote: I'm trying to make a configuration file I know how to read the sections and options (using ConfigParser module from Python 2.3.4 on Win XP) What I wanted to know is that eventually I will need to add sections and options or change values or erase options or , etc Is there any way that I can do this changes to the config.ini file? Sure. See the docs for RawConfigParser add_section(), set() and write(). ConfigParser is a subclass of RawConfigParser so you can use any of these methods. http://docs.python.org/lib/RawConfigParser-objects.html Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] FW: Re: USB Capture Image WebCAM
Hey all If you noticed I also admitted that I don't want to crack it but I needed for testing In fact if I wanted to crack 200 licenses I wouldn't be asking you guys for help on this program By the way I bought 10 licenses from them so crime...I really don't think so Let's see: 200 *10 $us = 2000 $us My own prog = Free (well maybe a little of time) I don't mean to crack the software and give it, I mean to make my own. That's why I posted. And also I don't use cracked softwares..They always have some error when you crack it. Sorry if I cause the wrong impression here. :) Then again, I still can't make the code works...it keeps crashing with the same error I sent I tried to contact Markus (the creator of VideoCapture) but without luck Anyone who has tried it out or want to try it out? Best Regards Alberto From: Poor Yorick [EMAIL PROTECTED] To: tutor@python.org Subject: Re: [Tutor] FW: Re: USB Capture Image WebCAM Date: Thu, 22 Sep 2005 20:52:50 -0400 Alberto Troiano wrote: But it doesn't works so fine, I think its because I cracked and didn't buy it *grin* But I need like 200 licenses so it would be a little expensive. That's why I'm trying to make my own Python Gengis Cam *grin* You just admitted on a public forum to committing a crime. Not wise, friend. -- Poor Yorick ___ 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] FW: Re: USB Capture Image WebCAM
Hey Hugo Yes...I have PIL 1.1.5 installed. The weird thing about this is that the program gets one image and then show the error I sent After that it doesn't load any more images and I have to unplug tha web cam and plug it again so I can get the software to work only one more time and so on I will try it out in the computer I have at home...I'm thiking that maybe it is something on the machine...that's why I would like that somebody who had tried this app tell if this worked ok or maybe had the same problem I have Thanks anyway Hugo Alberto From: Hugo González Monteverde [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] FW: Re: USB Capture Image WebCAM Date: Fri, 23 Sep 2005 11:32:06 -0500 Hi Alberto, Sorry if I point out something obvious... from the page: # # The high-level module needs PIL to produce actual images from the pixel-data. PIL can be downloaded from PythonWare. Do you have PIL installed? The fact that the image cannot be created just bit me... Hugo Alberto Troiano wrote: Hey Danny I have downloaded videoCapture but I can't make it run. This is the error I get when I try run the example Traceback (most recent call last): File C:\Documents and Settings\Daron Malakian\Desktop\VideoCapture-0.9\Tools\webcam-uploader\webcam-uploader.py, line 130, in ? cam = VideoCapture.Device(devnum=devnum) File C:\Python23\lib\VideoCapture.py, line 49, in __init__ self.dev = vidcap.new_Dev(devnum, showVideoWindow) Error: Capture Graph could not be created. I want to be able to see the reproduction of the WebCAM inside a GUI of Python I didn't find docs for this on the WEB. If somebody have some pointers I would appreciate a lot Thanks in advanced Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] USB Capture Image WebCAM Date: Thu, 22 Sep 2005 11:38:16 -0700 (PDT) On Thu, 22 Sep 2005, Alberto Troiano wrote: For those who doesn't know what is it its a program that captures images from your USB WebCAM and saves them to send via FTP. Anyway, getting to the point I don't know how to get the video from the camara to watch it inside a GUI made in Python. You might be in luck; there's a project that provides USB Webcam access for Windows: http://videocapture.sourceforge.net/ Good luck! ___ 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 maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] USB Capture Image WebCAM
Hey Tutors I want to make a program that looks like Conquer Cam For those who doesn't know what is it its a program that captures images from your USB WebCAM and saves them to send via FTP. Anyway, getting to the point I don't know how to get the video from the camara to watch it inside a GUI made in Python. Is this possible? How? One step at the time..First I want to accomplish the online viewer of the camera and then talk about capturing the image I'm using Python 2.3.4 over Windows XP Professional Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] USB Capture Image WebCAM
Hey Danny I have downloaded videoCapture but I can't make it run. This is the error I get when I try run the example on the Web Page I want to be able to see the reproduction of the WebCAM inside a GUI of Python I didn't find docs for this on the WEB. If somebody have some pointers I would appreciate a lot Thanks in advanced Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] USB Capture Image WebCAM Date: Thu, 22 Sep 2005 11:38:16 -0700 (PDT) On Thu, 22 Sep 2005, Alberto Troiano wrote: For those who doesn't know what is it its a program that captures images from your USB WebCAM and saves them to send via FTP. Anyway, getting to the point I don't know how to get the video from the camara to watch it inside a GUI made in Python. You might be in luck; there's a project that provides USB Webcam access for Windows: http://videocapture.sourceforge.net/ Good luck! ___ 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] FW: Re: USB Capture Image WebCAM
Hey Danny I have downloaded videoCapture but I can't make it run. This is the error I get when I try run the example Traceback (most recent call last): File C:\Documents and Settings\Daron Malakian\Desktop\VideoCapture-0.9\Tools\webcam-uploader\webcam-uploader.py, line 130, in ? cam = VideoCapture.Device(devnum=devnum) File C:\Python23\lib\VideoCapture.py, line 49, in __init__ self.dev = vidcap.new_Dev(devnum, showVideoWindow) Error: Capture Graph could not be created. I want to be able to see the reproduction of the WebCAM inside a GUI of Python I didn't find docs for this on the WEB. If somebody have some pointers I would appreciate a lot Thanks in advanced Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] USB Capture Image WebCAM Date: Thu, 22 Sep 2005 11:38:16 -0700 (PDT) On Thu, 22 Sep 2005, Alberto Troiano wrote: For those who doesn't know what is it its a program that captures images from your USB WebCAM and saves them to send via FTP. Anyway, getting to the point I don't know how to get the video from the camara to watch it inside a GUI made in Python. You might be in luck; there's a project that provides USB Webcam access for Windows: http://videocapture.sourceforge.net/ Good luck! ___ 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 maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] FW: Re: USB Capture Image WebCAM
Hey Danny Thanks for the reply and the tip...I will try to reach him/her. In answer to your question, Conquer Cam is a buyable software. What it does is to show the WebCAM an captures Images every x time and sends it via FTP to any server. But it doesn't works so fine, I think its because I cracked and didn't buy it *grin* But I need like 200 licenses so it would be a little expensive. That's why I'm trying to make my own Python Gengis Cam *grin* Thanks again Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: Tutor tutor@python.org Subject: Re: [Tutor] FW: Re: USB Capture Image WebCAM Date: Thu, 22 Sep 2005 15:29:07 -0700 (PDT) I have downloaded videoCapture but I can't make it run. This is the error I get when I try run the example Traceback (most recent call last): File C:\Documents and Settings\Daron Malakian\Desktop\VideoCapture-0.9\Tools\webcam-uploader\webcam-uploader.py, line 130, in ? cam = VideoCapture.Device(devnum=devnum) File C:\Python23\lib\VideoCapture.py, line 49, in __init__ self.dev = vidcap.new_Dev(devnum, showVideoWindow) Error: Capture Graph could not be created. Hi Alberto, You may want to talk with the developer of the VideoCapture module software. I don't know what's going on here. Testing this is also complicated because I don't have a webcam or Windows. Wait, let's back up a moment. You mentioned earlier that: For those who doesn't know what is it its a program that captures images from your USB WebCAM and saves them to send via FTP. Does this mean then that you already have a program that saves webcam images to disk? If so, then if we know what graphical format they are, then perhaps we might be able to use PIL to convert them into a format that your favorite GUI toolkit can display. PIL can talk with different graphical formats: http://www.pythonware.com/products/pil/ Tkinter integrates with this: http://effbot.org/zone/tkinter-plot.htm And wxpython + PIL also appears to work: http://wiki.wxpython.org/index.cgi/WorkingWithImages ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tail -f problem
Hey I'm still working with this RADIUS system over Red Hat 9.0, mysql 3.23 and python 2.2.2 I ran to another problem.I have a file that is written by the RADIUS server (for those who don't know RADIUS is an authentication Service). The file contains the detail of the RADIUS, the server writes the STOP and START signals to this filebelow is the detail of the file. What I need to do is a program that check when the file gets an input and analyze only the text that has entered...I thought about tail-f /var/log/radacct/max/detail but this thing opens a console and I won't end but how can I get the output of the command to python.. This is one of two solutionsthe other would be Upgrade the MySQL Server to version 4.1.11 which I don't have idea how to file desc --- Date User-Name NAS-IP-ADDRESS and a long list of variables --- end of file desc I know the second option has nothing to do with this forum but if anyone knows of any manual to upgrade MySQL over Linux Red HAt I would appreciate Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Tail -f problem
Hey Nick About the mysql upgrade (by the way thanks for the reply) I have downloaded the rpm fron mysql.com along with the installation manual..I will give it a try The code you sent in the hyperlink looks neat...I will try it out since the page hasn't much documentation about this example in particular Thanks a lot Alberto From: Nick Lunt [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED], tutor@python.org Subject: Re: [Tutor] Tail -f problem Date: Wed, 31 Aug 2005 22:38:42 +0100 Hi Alberto, -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Alberto Troiano Sent: 31 August 2005 22:01 To: tutor@python.org Subject: [Tutor] Tail -f problem Hey I thought about tail-f /var/log/radacct/max/detail but this thing opens a console and I won't end but how can I get the output of the command to python.. Have a look here for a possible solution to your tail -f problem http://twistedmatrix.com/projects/core/documentation/examples/filewatch.py I know the second option has nothing to do with this forum but if anyone knows of any manual to upgrade MySQL over Linux Red HAt I would appreciate If your using a recent Redhat then try this as root (im on a windows box at the moment so this is untested) $ yum upgrade mysql mysql-server Naturally this will only work if your current mysql install is an RPM. Cheers Nick . ___ 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] Generate 8 digit random number
Hi Kent Nope... Not workingI'm still getting 7 even 6 digits number Any other idea? Thanks Alberto From: Kent Johnson [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Generate 8 digit random number Date: Fri, 26 Aug 2005 10:00:50 -0400 Alberto Troiano wrote: Hi everyone I need to generate a password..It has to be an 8 digit number and it has to be random The code I've been trying is the following: import random random.randrange(,) The code works but sometimes it picks a number with 7 digits. Is there any way that I can tell him to select always a random number with 8 digits? random.randrange(1000,) ?? Kent ___ 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] Generate 8 digit random number
Hey ALL The code Kent sent might work ok but I didn't see it because of what Pierre said about the left 0's I think I will go with Pietro's approach. I think is neater and shorter than the randrange approach Thanks to all that helped Best Regards Alberto From: Kent Johnson [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Generate 8 digit random number Date: Fri, 26 Aug 2005 10:16:37 -0400 Alberto Troiano wrote: Hi Kent Nope... Not workingI'm still getting 7 even 6 digits number Are you sure? It works for me: import random random.randrange(1000,) 42247129 for i in range(1000): ... x = random.randrange(1000,) ... if len(str(x)) 8: ... print x ... (prints nothing - they are all 8 digits) Kent Any other idea? Thanks Alberto From: Kent Johnson [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Generate 8 digit random number Date: Fri, 26 Aug 2005 10:00:50 -0400 Alberto Troiano wrote: Hi everyone I need to generate a password..It has to be an 8 digit number and it has to be random The code I've been trying is the following: import random random.randrange(,) The code works but sometimes it picks a number with 7 digits. Is there any way that I can tell him to select always a random number with 8 digits? random.randrange(1000,) ?? Kent ___ 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 maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Linux app question
Hey Alan From: Alan G [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED], tutor@python.org Subject: Re: [Tutor] Linux app question Date: Thu, 18 Aug 2005 08:25:51 +0100 1.- Is there any way that the script can be started when he mounts the CDROM with the command mount /mnt/cdrom? I don't know of any way to autostart a CD program on mount in Linux. Now we are two 2.- Is there any way that the script could be started by typing directly ./installer instead of python installer.py? THe usual unix shebang trick will work just fine. call your install script 'install' and put #! /bin/env/python as the first line. It should then run directly with no problems. Assuming of course that Python is already installed on the web server! This I didn't know, so in order to work I would have to rename installer.py to only installer and in the shell I would only type installer and it would run right?? If this work I'm done..It's godd enough to give them a CD and tell them to type installer to run it Thanks Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Linux app question
Hey tutorslong time don't see...*grin* I have a question, I've made a web page in PHP and its going to run under Linux Red Hat 9.0 The page has scripts that has to be on a certain path off the system...I have to make a CD to give the web page to my client and I made a script using Python 2.2.2 so when he runs it, the data in the CD will be copied automatically to the path where every script has to be My question is: Obviously I will have the cdrom in /mnt/cdrom and in order to run the installer the user will have to type python /mnt/cdrom/installer.py 1.- Is there any way that the script can be started when he mounts the CDROM with the command mount /mnt/cdrom? 2.- Is there any way that the script could be started by typing directly ./installer instead of python installer.py? Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Minesweeper the return
I think I got it..finally...*grin* I will try to put this in practice right away and let you know if I have so more problems or if I didn't understand what I think I did. jeje Thank you Jhon and Danny Best Regards, Alberto From: [EMAIL PROTECTED] To: tutor@python.org tutor@python.org Subject: Re: [Tutor] Minesweeper the return Date: Wed, 20 Jul 2005 11:18:09 +1200 (NZST) Quoting Alberto Troiano [EMAIL PROTECTED]: Please let's talk about this more! *grin* I'm not sure if I'm following you, what I see here is a function inside other function and the first function returns its inside function, but how does it work? In Python, as in other modern languages, functions are first-class objects. In particular, you can pass functions as arguments to other functions, or return functions from other functions. I like examples: def add(x, y): ... return x + y ... f = add # Notice the lack of brackets after 'add' f(3, 5) 8 f(9, 12) 21 In this case, all I've done is assigned to f the function 'add'. This means that f is now a function, and I can call it, even though I never did 'def f(x, y)' anywhere. def square(x): ... return x*x ... range(10) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] map(square, range(10)) [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] The 'map' builtin function takes two arguments: a function and a list. It makes a new list by applying the function to each element of the old list. ie: This is an example of passing a functino as an argument. Finally: def makeAdder(x): ... def add(y): ... return x + y ... return add ... f = makeAdder(5) f(3) 8 f(8) 13 'def add(y)' defines a function of one argument, which adds that argument to x, and returns the result. What is x? Well, x is a variable in the scope of makeAdder(); it gets bound to the argument you pass. In my example, x was bound to 5. So, effectively, we have created a new function by: 'def add(y): return 5 + y', and then returned that function to f. We can now call f and see the result. HTH! -- John. [ps: sorry for the troll.. I couldn't resist :-) ] ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Scrolling multilistbox help
Hey Michael It worked like a charm Thank GOD you understood what I wanted, you see speaking Spanish made me so hard to explain what the problem were but...I guess you just figured out To my code was this: self.see(int(self.curselection()[0])) Thank you very much Best Regards Alberto From: Michael Lange [EMAIL PROTECTED] To: tutor@python.org Subject: Re: [Tutor] Scrolling multilistbox help Date: Tue, 19 Jul 2005 11:06:43 +0200 On Mon, 18 Jul 2005 13:54:45 + Alberto Troiano [EMAIL PROTECTED] wrote: Hey tutors I'm using the Multilistbox class and I noticed that it only handles the mouse scroll and the scrollbar to go down or up.I succesfully implemented the sort function that came with the class I also added code to handle the up and down arrow keys and it goes down all right but only select the item and it doesn't scroll down or up How can make it go up or down? I'm sendind the class here: Hi Alberto, I haven't tested your code, but if I understand you correctly, the problem is that the list is not automatically scrolled when you select a new item with the Up and Down keys (right?). Maybe it's the easiest to add a line like this to your _select1() and _select2() methods: l.see(int(l.curselection()[0])) where l is the first of the listboxes; this should make sure the selected item is visible (at least if you use selectmode=SINGLE). If keeping all lists in sync works, this should be enough to scroll all other lists, too (like I said, untested though). I hope this helps Michael class MultiListbox(Frame): fila=0 sortedBy=-1 def __init__(self, master, lists): Frame.__init__(self, master) self.lists = [] for l,w,a in lists: frame = Frame(self,background=red); frame.pack(side=LEFT, expand=YES, fill=BOTH) Button(frame,background=red,foreground=white,font=Verdana 8 bold,text=l, borderwidth=1, relief=RAISED,command=lambda a=a: self._sortBy(a)).pack(fill=X) lb = Listbox(frame, width=w, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE) lb.pack(expand=YES, fill=BOTH) self.lists.append(lb) lb.bind('B1-Motion', lambda e, s=self: s._select(e.y)) lb.bind('Double-Button-3', lambda e, s=self: s._devolverfila(e.y)) lb.bind('Return', lambda e, s=self: s._devolverfila(e.y)) lb.bind('Button-1', lambda e, s=self: s._select(e.y)) lb.bind('Down', lambda s: _select1()) lb.bind('Up', lambda s: _select2()) lb.bind('Leave', lambda e: 'break') lb.bind('B2-Motion', lambda e, s=self: s._b2motion(e.x, e.y)) lb.bind('Button-2', lambda e, s=self: s._button2(e.x, e.y)) frame = Frame(self,background=red); frame.pack(side=LEFT, fill=Y) Label(frame,background=red,foreground=white,font=Verdana 8 bold, borderwidth=1, relief=RAISED).pack(fill=X) sb = Scrollbar(frame,background=red, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand']=sb.set def _sortBy(self, column): Sort by a given column. if column == self.sortedBy: direction = -1 * self.direction else: direction = 1 elements = self.get(0, END) self.delete(0, END) elements.sort(lambda x, y: self._sortAssist(column, direction, x, y)) self.insert(END, *elements) self.sortedBy = column self.direction = direction def _sortAssist(self, column, direction, x, y): if column!=0: c = cmp(x[column], y[column]) if c: return direction * c else: return direction * cmp(x, y) else: c = cmp(int(x[column]), int(y[column])) if c: return direction * c else: return direction * cmp(x, y) def _select(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.fila=row return 'break' def _devolverfila(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.fila=row def _select1(self): if self.fila==self.size()-1: pass else: self.selection_clear(0, END) self.selection_set(self.fila+1) self.fila+=1 self._scroll() return 'break' def _select2(self): if self.fila==0: pass else: self.selection_clear(0, END) self.selection_set(self.fila-1) self.fila-=1 return 'break' def _button2(self, x, y): for l in self.lists: l.scan_mark(x, y) return 'break' def _b2motion(self, x, y
Re: [Tutor] Hy, I'm a n00b to Python, have some questions
Hey Alex First of all welcome I've been programming in Python for almost 1 year now and I think I can answer two of your questions 1. Is there any decent forum were people are talking in python ? You found one of them, here you have people willing to help each others at no cost. Send an email with your problem and someone here will answer 2. what about speed ? (any beginners question I suppose). Is it something to be concerned about ? Does anyone know how it compares to PHP ? (for Java I allready know) I have no experience in web Python but I do have experience with PHP, JavaScript and ASP.NET and I have to tell you: you can't compare PHP with JavaScript, PHP is server-side and JavaScript is Client-side so the speed is irrelevant because they are two different things. You can compare PHP with ASP. About Python I'm not sure if this is a server or client-side. This is the first thing I would ask. 3. I want any usefull resources you can provide me with You may want to invest in some books. Try searching in Amazon. I have one very practical called Python: Developing Applicattions In fact this is a database book, but the aim is Python on web pages with databases The autor is Sonu Mangla Best Regards Alberto From: Alex Nedelcu [EMAIL PROTECTED] Reply-To: Alex Nedelcu [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] Hy, I'm a n00b to Python, have some questions Date: Mon, 18 Jul 2005 16:17:11 +0300 Hy all, I am a Java/PHP programmer. I read the tutorial and I like the language. I am more interested in the web capabilities of the platform (CPython). I have some questions I'd like to ask you guys: 3. I want any usefull resources you can provide me with 4. What's the hottest web framework right now that does not require an application server (meaning that it runs on fastcgi) Also, why is www.python.org http://www.python.org so ugly :) ? If I'd like to point others to learn Python I would need a site that markets Python through eye-candy case studies, not some boring old site :). Just joking. I don't want to give examples of others. I am sure you guys know what I mean. Thank you, ___ 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] Scrolling multilistbox help
Hey tutors I'm using the Multilistbox class and I noticed that it only handles the mouse scroll and the scrollbar to go down or up.I succesfully implemented the sort function that came with the class I also added code to handle the up and down arrow keys and it goes down all right but only select the item and it doesn't scroll down or up How can make it go up or down? I'm sendind the class here: class MultiListbox(Frame): fila=0 sortedBy=-1 def __init__(self, master, lists): Frame.__init__(self, master) self.lists = [] for l,w,a in lists: frame = Frame(self,background=red); frame.pack(side=LEFT, expand=YES, fill=BOTH) Button(frame,background=red,foreground=white,font=Verdana 8 bold,text=l, borderwidth=1, relief=RAISED,command=lambda a=a: self._sortBy(a)).pack(fill=X) lb = Listbox(frame, width=w, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE) lb.pack(expand=YES, fill=BOTH) self.lists.append(lb) lb.bind('B1-Motion', lambda e, s=self: s._select(e.y)) lb.bind('Double-Button-3', lambda e, s=self: s._devolverfila(e.y)) lb.bind('Return', lambda e, s=self: s._devolverfila(e.y)) lb.bind('Button-1', lambda e, s=self: s._select(e.y)) lb.bind('Down', lambda s: _select1()) lb.bind('Up', lambda s: _select2()) lb.bind('Leave', lambda e: 'break') lb.bind('B2-Motion', lambda e, s=self: s._b2motion(e.x, e.y)) lb.bind('Button-2', lambda e, s=self: s._button2(e.x, e.y)) frame = Frame(self,background=red); frame.pack(side=LEFT, fill=Y) Label(frame,background=red,foreground=white,font=Verdana 8 bold, borderwidth=1, relief=RAISED).pack(fill=X) sb = Scrollbar(frame,background=red, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand']=sb.set def _sortBy(self, column): Sort by a given column. if column == self.sortedBy: direction = -1 * self.direction else: direction = 1 elements = self.get(0, END) self.delete(0, END) elements.sort(lambda x, y: self._sortAssist(column, direction, x, y)) self.insert(END, *elements) self.sortedBy = column self.direction = direction def _sortAssist(self, column, direction, x, y): if column!=0: c = cmp(x[column], y[column]) if c: return direction * c else: return direction * cmp(x, y) else: c = cmp(int(x[column]), int(y[column])) if c: return direction * c else: return direction * cmp(x, y) def _select(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.fila=row return 'break' def _devolverfila(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.fila=row def _select1(self): if self.fila==self.size()-1: pass else: self.selection_clear(0, END) self.selection_set(self.fila+1) self.fila+=1 self._scroll() return 'break' def _select2(self): if self.fila==0: pass else: self.selection_clear(0, END) self.selection_set(self.fila-1) self.fila-=1 return 'break' def _button2(self, x, y): for l in self.lists: l.scan_mark(x, y) return 'break' def _b2motion(self, x, y): for l in self.lists: l.scan_dragto(x, y) return 'break' def _scroll(self, *args): for l in self.lists: apply(l.yview, args) def curselection(self): return self.lists[0].curselection() def delete(self, first, last=None): for l in self.lists: l.delete(first, last) def get(self, first, last=None): result = [] for l in self.lists: result.append(l.get(first,last)) if last: return apply(map, [None] + result) return result def index(self, index): self.lists[0].index(index) def insert(self, index, *elements): for e in elements: i = 0 for l in self.lists: l.insert(index, e[i]) i = i + 1 def size(self): return self.lists[0].size() def see(self, index): for l in self.lists: l.see(index) def selection_anchor(self, index): for l in self.lists: l.selection_anchor(index) def selection_clear(self, first, last=None): for l in self.lists: l.selection_clear(first, last) def selection_includes(self,
[Tutor] Scrolling multilistbox help
Hey tutors I'm using the Multilistbox class and I noticed that it only handles the mouse scroll and the scrollbar to go down or up.I succesfully implemented the sort function that came with the class I also added code to handle the up and down arrow keys and it goes down all right but only select the item and it doesn't scroll down or up How can make it go up or down? I'm sendind the class here: class MultiListbox(Frame): fila=0 sortedBy=-1 def __init__(self, master, lists): Frame.__init__(self, master) self.lists = [] for l,w,a in lists: frame = Frame(self,background=red); frame.pack(side=LEFT, expand=YES, fill=BOTH) Button(frame,background=red,foreground=white,font=Verdana 8 bold,text=l, borderwidth=1, relief=RAISED,command=lambda a=a: self._sortBy(a)).pack(fill=X) lb = Listbox(frame, width=w, borderwidth=0, selectborderwidth=0, relief=FLAT, exportselection=FALSE) lb.pack(expand=YES, fill=BOTH) self.lists.append(lb) lb.bind('B1-Motion', lambda e, s=self: s._select(e.y)) lb.bind('Double-Button-3', lambda e, s=self: s._devolverfila(e.y)) lb.bind('Return', lambda e, s=self: s._devolverfila(e.y)) lb.bind('Button-1', lambda e, s=self: s._select(e.y)) lb.bind('Down', lambda s: _select1()) lb.bind('Up', lambda s: _select2()) lb.bind('Leave', lambda e: 'break') lb.bind('B2-Motion', lambda e, s=self: s._b2motion(e.x, e.y)) lb.bind('Button-2', lambda e, s=self: s._button2(e.x, e.y)) frame = Frame(self,background=red); frame.pack(side=LEFT, fill=Y) Label(frame,background=red,foreground=white,font=Verdana 8 bold, borderwidth=1, relief=RAISED).pack(fill=X) sb = Scrollbar(frame,background=red, orient=VERTICAL, command=self._scroll) sb.pack(expand=YES, fill=Y) self.lists[0]['yscrollcommand']=sb.set def _sortBy(self, column): Sort by a given column. if column == self.sortedBy: direction = -1 * self.direction else: direction = 1 elements = self.get(0, END) self.delete(0, END) elements.sort(lambda x, y: self._sortAssist(column, direction, x, y)) self.insert(END, *elements) self.sortedBy = column self.direction = direction def _sortAssist(self, column, direction, x, y): if column!=0: c = cmp(x[column], y[column]) if c: return direction * c else: return direction * cmp(x, y) else: c = cmp(int(x[column]), int(y[column])) if c: return direction * c else: return direction * cmp(x, y) def _select(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.fila=row return 'break' def _devolverfila(self, y): row = self.lists[0].nearest(y) self.selection_clear(0, END) self.selection_set(row) self.fila=row def _select1(self): if self.fila==self.size()-1: pass else: self.selection_clear(0, END) self.selection_set(self.fila+1) self.fila+=1 self._scroll() return 'break' def _select2(self): if self.fila==0: pass else: self.selection_clear(0, END) self.selection_set(self.fila-1) self.fila-=1 return 'break' def _button2(self, x, y): for l in self.lists: l.scan_mark(x, y) return 'break' def _b2motion(self, x, y): for l in self.lists: l.scan_dragto(x, y) return 'break' def _scroll(self, *args): for l in self.lists: apply(l.yview, args) def curselection(self): return self.lists[0].curselection() def delete(self, first, last=None): for l in self.lists: l.delete(first, last) def get(self, first, last=None): result = [] for l in self.lists: result.append(l.get(first,last)) if last: return apply(map, [None] + result) return result def index(self, index): self.lists[0].index(index) def insert(self, index, *elements): for e in elements: i = 0 for l in self.lists: l.insert(index, e[i]) i = i + 1 def size(self): return self.lists[0].size() def see(self, index): for l in self.lists: l.see(index) def selection_anchor(self, index): for l in self.lists: l.selection_anchor(index) def selection_clear(self, first, last=None): for l in self.lists:
[Tutor] Minesweeper the return
Hi I now get stucked in the arguments of the buttons Here's what I've got: def crearbutton(self): for i in range(self.fil): for j in range(self.col): self.buttonmatrix[i][j]=Button(root,width=1,height=0,command=lambda: self.hello(i,j)) self.buttonmatrix[i][j].grid(row=i,column=j,sticky=N+S+W+E) def hello(self,f,c): self.buttonmatrix[f][c].configure(text=d) I'm trying to create the buttons dinamically (that's not a problem) the problem is wherever I click the hello function returns the last button I created. I know that the problem is in the lambda part and that the variable i (the one I change the value within the for) but I don't how to fix it Any hints? Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] This should be easy
I think it would be better for us if you send us the entire line that's giving you problems along with the error its givin you so we can start somewhere Right now I don't know where to look at Best Regards Alberto From: nephish [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] This should be easy Date: Mon, 18 Jul 2005 20:02:38 + ok here is the error i am getting. You have an error in your SQL syntax. Check the manual that corrosponds to your MySQL version for the right syntax near Name ) values ('one', 'two') thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] This should be easy
Hey Your problem is in the database I'm surprised how MySQL let you put a space in a field In MySQL you can't have spaces, as far as I know Try renaming the field by enteriig to the console and making the alter table sentence and put Site_Name instead of Site Name. Then make the query again and see what happens mysql create table d(autoinc int(4) primary key,Site Name varchar(30)); ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name varchar(30))' This is the error I get from MySQL Server when I try to create a field with a space and check the solution: mysql create table d(autoinc int(4) primary key,Site_Name varchar(30)); Query OK, 0 rows affected (0.14 sec) This should fix your problem. Best Regards to you Alberto From: nephish [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] This should be easy Date: Mon, 18 Jul 2005 20:32:55 + ok here is what i have, cursor.execute(INSERT INTO History (autoinc, Site Name) VALUES (12, 'Test');) gives me this ''' _mysql_exceptions.ProgrammingError : (1064, You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'Name) VALUES (12, 'Test')' at line 1) ''' the autoinc field isn't really an auto-increment field, its an int. That is left over from the migration from Access. there are other fields in the table but all can be null. this line works fine though cursor.execute(INSERT INTO History (autoinc) VALUES (12);) this line does not cursor.execute(INSERT INTO History (Site Name) VALUES ('test');) can you not have spaces in a field name ? is the quotes gone awry? dont know what to do next. please help ! thanks On 07/18/2005 03:06:34 PM, Alberto Troiano wrote: I think it would be better for us if you send us the entire line that's giving you problems along with the error its givin you so we can start somewhere Right now I don't know where to look at Best Regards Alberto From: nephish [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] This should be easy Date: Mon, 18 Jul 2005 20:02:38 + ok here is the error i am getting. You have an error in your SQL syntax. Check the manual that corrosponds to your MySQL version for the right syntax near Name ) values ('one', 'two') thanks ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] HTML links from Tkinter
Thanks for the links I will try both, the tktable and multilistbox About the HTML llinks I will have to make some functions using webbrowser. I want to show some reports (tktable or multilistbox) but I want she to be able to check the same query on the web So I think that with the GET method I can send paramaters to the page I want her to open Best Regards Alberto From: Michael Lange [EMAIL PROTECTED] To: tutor@python.org Subject: Re: [Tutor] HTML links from Tkinter Date: Fri, 15 Jul 2005 10:45:29 +0200 On Fri, 15 Jul 2005 10:55:37 +1200 (NZST) [EMAIL PROTECTED] wrote: There's no table widget in standard Tkinter. Search in the Python Cookbook (on ActiveState) for a MultiListbox; it might do what you need. -- On the Tkinter wiki there are some links to Tkinter table widgets (I have not tried any of these though): http://tkinter.unpythonic.net/wiki/Widgets Regards Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Minesweeper implementing 20%, weird problem with matrixes
Hey I didn't notice that :P Thanks to Alan, I learn something new with the use of List Comprehension and thanks to Danny for the docs, they really helped a lot to understand the figure here I think I can say that Minesweeper implementing 23% with this problem solved Thanks a lot Alberto From: Alan G [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED], tutor@python.org Subject: Re: [Tutor] Minesweeper implementing 20%,weird problem with matrixes Date: Thu, 14 Jul 2005 01:12:18 +0100 I initialize them by putting None along all the fields Actually you don't. def initialize(self): self.buttonmatrix=[] self.statematrix=[] self.bombmatrix=[] 3 empty lists, so far so good. for i in range(self.fil): aux=[] for j in range(self.col): aux.append(None) a new list filled with None self.buttonmatrix.append(aux) self.bombmatrix.append(aux) self.statematrix.append(aux) THat same list inserted into all three lists, so they all point at the same internal list of Nones. So when you change one, you change all. Try using aux[:] instead to take a copy of aux... You could also use list comprehension instead of the loop/append: aux = [None for i in range(self.col)] HTH, Alan G. ___ 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] Minesweeper implementing 20%, weird problem with matrixes
Hey tutors I think I got this a little, but I have a very weird problem This is the code I'm using: ## class buscaminas(object): def __init__(self): self.col=0 self.marcas=Tkinter.BooleanVar() self.color=Tkinter.BooleanVar() self.sonido=Tkinter.BooleanVar() self.fil=0 self.byob=0 menubar= Menu(root) archivo=Menu(menubar,tearoff=0) archivo.add_command(label=Nuevo,underline=0,command=self.initialize) archivo.add_radiobutton(label=Fácil,underline=0,command=lambda: self.nivel(9,9,10)) archivo.add_radiobutton(label=Medio,underline=0,command=lambda: self.nivel(16,16,40)) archivo.add_radiobutton(label=Dificil,underline=0,command=lambda: self.nivel(16,30,99)) archivo.add_radiobutton(label=Personalizado,underline=0,command=self.hello) archivo.add_separator() archivo.add_checkbutton(label=Marcas (?),variable=self.marcas,underline=0,command=self.hello) archivo.add_checkbutton(label=Color,underline=0,command=self.hello) archivo.add_checkbutton(label=Sonido,underline=1,command=self.hello) archivo.add_separator() archivo.add_command(label=Mejores Tiempos,underline=8,command=self.hello) archivo.add_separator() archivo.add_command(label=Salir,underline=0,command=root.destroy) menubar.add_cascade(label=Juego,underline=0,menu=archivo) help = Menu(menubar, tearoff=0) help.add_command(label=Contenido, command=self.hello) help.add_command(label=Indice de ayuda, command=self.hello) help.add_command(label=Como usar la ayuda, command=self.hello) help.add_separator() help.add_command(label=Acerca de..., command=self.hello) menubar.add_cascade(label=Ayuda,underline=1, menu=help) root.config(menu=menubar) root.bind_all(F1,lambda d: self.hello()) root.bind_all(F2,lambda s: self.initialize()) root.bind_all(Control-x,lambda x: root.destroy()) def hello(self): print funca def initialize(self): self.buttonmatrix=[] self.statematrix=[] self.bombmatrix=[] for i in range(self.fil): aux=[] for j in range(self.col): aux.append(None) self.buttonmatrix.append(aux) self.bombmatrix.append(aux) self.statematrix.append(aux) self.bombs() def nivel(self,f,c,b): self.col=c self.fil=f self.byob=b self.initialize() def bombs(self): c=0 while not c==self.byob: fi=random.randrange(self.fil) co=random.randrange(self.col) if self.bombmatrix[fi][co]==None: self.bombmatrix[fi][co]=9 c+=1 self.numbers() def putnumber(self,row,column): c=0 fi=row-1 ci=column-1 ff=row+2 cf=column+2 for i in range(fi,ff): for j in range(ci,cf): if (i0) or (i=self.fil) or (j0) or (j=self.col): pass elif self.bombmatrix[i][j]==9: c+=1 else: pass return c def numbers(self): for i in range(self.fil): for j in range(self.col): if self.bombmatrix[i][j]==9: pass else: self.bombmatrix[i][j]=self.putnumber(i,j) self.nuevo() def nuevo(self): for el in self.buttonmatrix: print el for l in self.statematrix: print l for e in self.bombmatrix: print e def main(): global root root=Tk() root.title(Buscaminas) root.iconbitmap(images\mina.ico) a=buscaminas() root.mainloop() main() ## The following variables are the one with the problem: self.bombmatrix, self.buttonmatrix, self.statematrix I initialize them by putting None along all the fields (this is to allow the user to have any size of matrix) then I charge with numbers the self.bombmatrix but weirdly the others variables are filled with the same values, which is very strange to me since I'm not assigning them each others Any hint? Thanks in advanced and sorry for the long piece of code Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] py2exe
Hey all I had some problems with this module too but I aas able with your help to make a script that works Here it is: from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') ##setup( ##windows = [{'script': NovusExtension.pyw}], ##) setup( console = [{'script': front-end.py}], ) The commented part is for GUI scripts (Graphic User Interface) The uncommented part is for CLI scripts (Command Line Interface) This works 100% sure. I use this piece in all my scripts to make them executable over Windows. Never tried with pygame though but I think it is the same. The script doesn't need to be run from command line, but if you want to see if there is some error, you'll have to (not mandatory I think you could add a try statement to the code) If you have Pmw, then you have to freeze Pmw first. IIf this is the case reply to me, there is a case opened for that and I'll be glad to forward the answer Best Regards to all Alberto From: [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: Re: [Tutor] py2exe Date: Sat, 09 Jul 2005 22:15:44 +1200 (NZST) Quoting D. Hartley [EMAIL PROTECTED]: I modified the setup.py file to match the details of my game (as best I can imagine: I don't know what optimize = 2 #0, 1, or 2; like -O and -OO means, so I just left it as his sample had it, From python -h: -O : optimize generated bytecode (a tad; also PYTHONOPTIMIZE=x) -OO: remove doc-strings in addition to the -O optimizations optimize=2 means py2exe will optimize the bytecode and remove doc strings; this is probably OK since you're not going to be running the debugger on your finished executable. and I'm not sure if I put in all of the module names it will need specified, but it looks as if its supposed to give me an error if it can't find them). py2exe will search for all the modules it thinks it needs, but sometimes it will miss some. Generally, the best way to find out if it missed anything is to run your executable and see if it crashes :-) But then the tutorial says simply run this script and it will do all the work. You need to run it from the command line: python setup.py py2exe HTH. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] MineSweeper
Hey Tutors I have a question I want to make a minesweeper (just for practice) but I don't what can I use to make the GUI I was thinking about buttons (click event you know) and change the background image on change Maybe there's another widget to use My doubt is that I want to be able to allow the user to put how many bombs they want and how any spaces (how big is the board) so I will have to create buttons dinamically, but in doing this the reference to the buttons will be lost How do I know which button did I click when all buttons have the same name? Does this make sense? I recall in VB.6.0 the control matrix but I never knew how to use it Any help? Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Built-in modules
Hey tutors I have some classes I want to make available as built-in modules in Python 2.3.4 over Windows To make myself clear in case you don't understand I have the file List.py (a nested list C# like) and I want to be able to call the class List (which is inside the List.py) without having to copy it in every folder where I have a script that needs this module Can I do that? You see I googled about it but it seems I'm not using the right words. Best Regards Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Process problem
Thanks for the reply That was one of the problems Now the other problem is that when the script finishes all processes (runing in the background or not) finishes with him. levantamuertos.py is supoosed to be a process manager for cotascamon.py I need levantamuertos.py run, start the cotascamons.py that are dead, let them running and then die letting the others alive How can I do this? Best Regards Alberto From: Michael Lange [EMAIL PROTECTED] To: tutor@python.org Subject: Re: [Tutor] Process problem Date: Thu, 16 Jun 2005 12:19:12 +0200 On Wed, 15 Jun 2005 22:04:48 + Alberto Troiano [EMAIL PROTECTED] wrote: Hi Alberto, Hey Let me make you understand I need that levantamuertos.py run cotascamon.py (every script with it differents arguments that are passed) and then die letting the cotascamon.py scripts running independently Now, I don't know if my code is right, and thinking now you're right, levantamuertos.py waits until cotascamon.py finish. What can I do since cotascamon will never die (and it doesn't have to die)? Maybe a different approach will be the solution but I can't find a way to do it Best Regards Alberto I didn't follow the thread completely, so maybe I missed something, but if the problem is that python waits until the os.system() calls are finished, I think adding a to the command to make it run in the background should do the trick. Best regards Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Process problem
Hey You weren't pedantic at all I needed the explanation 'cause I don't like to make things I don't understand so now I will add the code to mine Thanks Alberto htmldivIMG height=12 src=http://graphics.hotmail.com/emvamp.gif; width=12nbsp;Gaucho/div/html From: Michael P. Reilly [EMAIL PROTECTED] Reply-To: Michael P. Reilly [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] Process problem Date: Thu, 16 Jun 2005 10:40:09 -0400 On 6/16/05, Alberto Troiano [EMAIL PROTECTED] wrote: Hey What its that for? can you explain me what it does? and the way to implementing it here: os.system(python2.2 /root/levantamuertos.py ) and what headaches are you talking about? Hi, The 'nohup' command is to make sure that the child process sticks around after the parent (and grandparents) have died. When a process creates a child, the child is tied to the parent and when the parent exits, all the child processes get sent a specific signal (with os.kill()) telling them that the parent has died. The default procedure when they receive this signal is to exit. A little history: back in the days of only modems, you would dial into a UNIX mainframe from a terminal and if the modem disconnected, the system (or you) would not want all your processes hanging around afterward. For this reason, the UNIX system would send a hangup signal (SIGHUP) to the login shell and all its child processes. Shells added a nohup (no hangup) command so certain processes could survive if the user wanted. When you say nohup it tells the process to ignore the default procedure and to ignore the SIGHUP (hangup signal). It does not put the process in the background so you still need the and it does not change stdout and stderr (that is why I put those in my e-mail too). In python, you would just say: os.system(nohup python2.2 /root/levantamuertos.py /dev/null 21 ) This should handle most headaches. The headaches that I mentioned are going to be very subtle. 1. One is that sometimes developers have changed shells without telling users. It has happened in the past that has had an implicit nohup in one version of a shell and in the next release, the implict nohup is no longer there. It is better to be explicit and clear... it also helps readability. 2. A second headache comes from the output streams (stdout and stderr). You want to be running a number of these levantamuertos.pyprocess at the same time. Did you know that the output of your cron job is captured and e-mailed to you? And by default, the output of child processes (levantamuertos.py) would be the same as cron job, usually only on error? So you might get a lot of mixed output from the different levantamuertos.py processes running at the same time. If you send all the output to /dev/null. Or to specific log files (based on PID), then you may not have this headache. I hope this helps and wasn't too pedantic. I get that way sometimes. -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
[Tutor] Process problem
Hey all I have a problem with a program You see, I have a python script made in Python 2.2 that runs every 15 minutes on Linux Red Hat 9.0 This program (which code is attached below) named levantamuertos.py (spanish for death weakener) has to check in a database if the pids stored are running (note that it will be more than one pid) and if they are not it has to start again the process and it will store the new pid on the database The problem is that when I call it it runs and weaks all dead process but when it dies, he takes all his sons with him. How can I make that the cotascamon.py keep running although levantamuertos.py die? Thanks in advanced and here is the code Alberto ## ### levantamuertos.py ### ## import os import sys import MySQLdb import time class conexion(object): def __init__(self): self.db = MySQLdb.connect(host=localhost, user=administrador, passwd=123456,db=seguridad) def consulta(self,query,args=None): try: self.cursor=self.db.cursor() self.sql=self.cursor.execute(query,args) except: self.cerrar() else: self.cerrar() def cerrar(self): self.db.close() query=SELECT PID,user,cam,ruta from proceso where user='DMALAKIAN' cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)0: for elem in res: pi=elem[0] ps_command = 'ps -p %s' % pi pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count 1: print Encontre el proceso else: query=update proceso set PID=%s where user='DMALAKIAN' p=os.getpid() args=(p) cur=conexion() cur.consulta(query,args) query=SELECT PID,user,cam,ruta from proceso where user 'DMALAKIAN' cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)0: for elem in res: pid=elem[0] user=elem[1] cam=elem[2] ruta=str(elem[3]) ps_command = 'ps -p %s' % pid pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count 1: pass else: os.system(python2.2 /root/cotascamon.py +str(ruta[19:len(ruta)])+ +user+ +str(cam)) else: pass else: query=insert into proceso values('DMALAKIAN',0,%s,'NO HAY RUTA PARA ESTE USUARIO') p=os.getpid() args=(p) cur=conexion() cur.consulta(query,args) query=SELECT PID,user,cam,ruta from proceso where user 'DMALAKIAN' cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)0: for elem in res: pid=elem[0] user=elem[1] cam=elem[2] ruta=str(elem[3]) ps_command = 'ps -p %s' % pid pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count 1: pass else: os.system(python2.2 /root/cotascamon.py +str(ruta[19:len(ruta)])+ +user+ +str(cam)) else: pass ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Process problem
Hey Let me make you understand I need that levantamuertos.py run cotascamon.py (every script with it differents arguments that are passed) and then die letting the cotascamon.py scripts running independently Now, I don't know if my code is right, and thinking now you're right, levantamuertos.py waits until cotascamon.py finish. What can I do since cotascamon will never die (and it doesn't have to die)? Maybe a different approach will be the solution but I can't find a way to do it Best Regards Alberto From: Hugo González Monteverde [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Process problem Date: Wed, 15 Jun 2005 13:30:30 -0500 Hi Alberto, Mmm I'm not sure if I get this all right. Why do you want to keep cotascamon running after levantamuertos dies?? If you're using system(), levantamuertos is waiting for cotascamon to finish completion before it continues running, there should be no point where levantamuertos *runs* while cotascamon also does (levantamuertos is sleeping) One advice though: it is easier and more elegant if you, instead of parsing the output of ps for a single process, you send it signal 0. This will do nothing to the process itself, but will complain with a traceback (OSError) if the pid does not exist. Like this: from os import kill from signals import SIG_DFL pid = 16 try: kill(pid, SIG_DFL) except OSError: print Process does not exist... Please note this is untested as I'm os a Windows machine right now =/ Hope it helps, Hugo Alberto Troiano wrote: Hey all I have a problem with a program You see, I have a python script made in Python 2.2 that runs every 15 minutes on Linux Red Hat 9.0 This program (which code is attached below) named levantamuertos.py (spanish for death weakener) has to check in a database if the pids stored are running (note that it will be more than one pid) and if they are not it has to start again the process and it will store the new pid on the database The problem is that when I call it it runs and weaks all dead process but when it dies, he takes all his sons with him. How can I make that the cotascamon.py keep running although levantamuertos.py die? Thanks in advanced and here is the code Alberto ## ### levantamuertos.py ### ## import os import sys import MySQLdb import time class conexion(object): def __init__(self): self.db = MySQLdb.connect(host=localhost, user=administrador, passwd=123456,db=seguridad) def consulta(self,query,args=None): try: self.cursor=self.db.cursor() self.sql=self.cursor.execute(query,args) except: self.cerrar() else: self.cerrar() def cerrar(self): self.db.close() query=SELECT PID,user,cam,ruta from proceso where user='DMALAKIAN' cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)0: for elem in res: pi=elem[0] ps_command = 'ps -p %s' % pi pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count 1: print Encontre el proceso else: query=update proceso set PID=%s where user='DMALAKIAN' p=os.getpid() args=(p) cur=conexion() cur.consulta(query,args) query=SELECT PID,user,cam,ruta from proceso where user 'DMALAKIAN' cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)0: for elem in res: pid=elem[0] user=elem[1] cam=elem[2] ruta=str(elem[3]) ps_command = 'ps -p %s' % pid pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count 1: pass else: os.system(python2.2 /root/cotascamon.py +str(ruta[19:len(ruta)])+ +user+ +str(cam)) else: pass else: query=insert into proceso values('DMALAKIAN',0,%s,'NO HAY RUTA PARA ESTE USUARIO') p=os.getpid() args=(p) cur=conexion() cur.consulta(query,args) query=SELECT PID,user,cam,ruta from proceso where user 'DMALAKIAN' cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)0: for elem in res: pid=elem[0] user=elem[1] cam=elem[2] ruta=str(elem[3]) ps_command = 'ps -p %s' % pid pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count 1: pass else: os.system(python2.2 /root/cotascamon.py +str(ruta[19:len(ruta)])+ +user+ +str(cam)) else
Re: [Tutor] Just a Python formatting question
Kristiano Don't worry about it. I'm sure everyone passed over this before. The identation errors are errors in the tabulation of a line Let's take your code in example number=78 guess=0 while guess != number: guess=input (Guess a number:) if guess number: print Too High elif guess number: print Too low The last line has to belong to the elif clause, right? so if you are working with a single tab or 4 spaces (default identation in Python) that means that for every loop statement, try , functions, classes or any line that ends with :, the next line has to be 4 spaces forward. And all the lines that belong to the statement also. It does not matter if is a nested sequence. Let me lighten you: for i in somelist: do_something do_something_else if x==y: inside the if clause all statements go with 4 spaces after the if line elif xy: the same here You ended an identation when you went back the spaces and typed elif so you don't acumulate the identations, you just keep using 4 spaces after the line with the : so Python knows what's inside and what's outside I hope to be clear, and if you don't understand it (probably because of my English) you can always read in the tutorial or in the Python help Best Regards Alberto print Just right I just can't get it to run and I get some indentation error. I'm pretty new to this so I'm sorry if this question(s) sound(s) amateurish. Do help. Thanks. -Kristiano Ang ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Py2exe Problem
Hey Thanks for the docs I finally was able to make a good compilation After I freezed Pmw into pmw.py I had to restart Python (Ctrl-Alt-Del and terminate all python process that were running, by the way why they still stay there and how can I terminate them?) and only then the compilation didn't include the Pmw library inside the dist folder that py2exe creates. But I made a compilation a few months before (I didn't remember how to compile with Pmw) and I remembered that I had to copy inside the dist folder all the images I was using and of course de pmw.py and pmwblt.py and pmwcolor.py also This is in case you want to make a compilation and you have the same problems I had Best Regards to all Alberto From: [EMAIL PROTECTED] To: tutor@python.org tutor@python.org Subject: Re: [Tutor] Py2exe Problem Date: Fri, 03 Jun 2005 10:06:18 +1200 (NZST) Quoting Alberto Troiano [EMAIL PROTECTED]: I'm having a problem with Py2exe. I created the executable but when I try to execute it it gives the following error: Traceback (most recent call last): File NovusExtension.pyw, line 8, in ? File Pmw\__init__.pyc, line 28, in ? WindowsError: [Errno 3] El sistema no puede hallar la ruta especificada: 'C:\\Documents and Settings\\percy.IMPOR-FERNANDO\\Escritorio\\NovExt\\dist\\library.zip\ \Pmw/*.*' It might help if you translated that error message :-) But, I will make one guess, since I see the problem is to do with Pmw: From this page: http://pmw.sourceforge.net/doc/dynamicloader.html When Pmw is first imported, an instance of PmwLoader is created and placed into sys.modules['Pmw']. From that point on, any reference to attributes of the Pmw 'module' is handled by the loader. The real Pmw package is stored in sys.modules['_Pmw']. ... Freezing Pmw Since the dynamic loader requires that Pmw be installed at run time, it can not be used when freezing Pmw. In this case, a single module containing all Pmw code is required, which can then be frozen with the rest of the application's modules. The bundlepmw.py script in the Pmw bin directory can be used to create such a file. This script concatenates (almost) all Pmw megawidget files into a single file, Pmw.py, which it writes to the current directory. The script is called like this: bundlepmw.py [-noblt] [-nocolor] /path/to/Pmw/Pmw_X_X_X/lib The last argument should be the path to the lib directory of the required version of Pmw. By default, the Pmw.py file imports the PmwBlt and PmwColor modules and so, to freeze an application using Pmw, you will need to copy the files PmwBlt.py and PmwColor.py to the application directory before freezing. If you are sure that your application does not use any of the Pmw.Blt or Pmw.Color functions, you can use the -noblt or -nocolor options. In this case Pmw.py will be modified so that it does not import these module(s) and so will not need to be included when freezing the application. If your application only uses a few Pmw megawidgets, you can remove the references to the usused ones in the files list in the bundlepmw.py code. To make the change, take a copy of the script and modify it. This will make the Pmw.py file smaller. However, be sure that you do not delete megawidgets that are components or base classes of megawidgets that you use. If you haven't done this, you will need to, otherwise Pmw won't work with py2exe. -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Py2exe Problem
Hey I'm having a problem with Py2exe. I created the executable but when I try to execute it it gives the following error: Traceback (most recent call last): File NovusExtension.pyw, line 8, in ? File Pmw\__init__.pyc, line 28, in ? WindowsError: [Errno 3] El sistema no puede hallar la ruta especificada: 'C:\\Documents and Settings\\percy.IMPOR-FERNANDO\\Escritorio\\NovExt\\dist\\library.zip\\Pmw/*.*' The thing is when I run the .pyw, runs smoothly Here is the code for the setup creation: from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') ##setup( ##windows = [{'script': NovusExtension.pyw,'icon_resources': [(1, icono.ico)]}], ##) setup( windows = [{'script': NovusExtension.pyw}], ) Am I doing something wrong? Another thing. I have a MySQL Server in my PC and the app I've made has to be used by others PC and have to connect to my machine. How can I accomplish that? If you need the code I can send it as an attachment Please Help ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Python Date picker
Hey everyone I've been searching (with no luck by the way) for a date picker combo or something like it What I need to do is validate a date field (better if it's already done) and I want to know if anyone knows about a code to do that (a made code, don't mean you to do my work). I was hoping to find a calendar combo box as in Visual Basic DropDown Calendar Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Disable menubar
Thank you very much for your help Now it's all clear Thanks again and best regards Alberto From: Michael P. Reilly [EMAIL PROTECTED] Reply-To: Michael P. Reilly [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] Disable menubar Date: Thu, 19 May 2005 19:00:11 -0400 On 5/19/05, Alberto Troiano [EMAIL PROTECTED] wrote: Hey everyone I've read about menubars and I decided to use the MenuBar from PMW instead of Tkinter's The reason is that I couldn't find an example to make a menu with cascade submenus and another cascade submenu inside the submenu and so on. Now I want to ask if somebody knows how to accomplish these with Menu from TKinter? On the other hand, every button on the menu opens a Toplevel, but I want to restrict the Toplevels to one of each kind. I was thinking in disable the menubutton but PMW only has disable_all and I only want to disable the opened Toplevel. Is there another way to accomplish this using Menu from TKinter or MenuBar from PMW or any other option? I'm sending a copy of the code of the menu (If you think you'll need all the code tell me because is kind of long and has many things that I haven't tried yet) Thanks in advanced Alberto Hi Alberto, I believe I recreated what you are trying to do (except the tip balloons that come with PMW but those can be added with bind events). I've added some example code that, I hope, does everything your code was doing. I also made the Implantes menu disabled to show you how that is handled. It can be done on the fly as well. -Arcege -- There's so many different worlds, So many different suns. And we have just one world, But we live in different ones. alberto.py Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] RPG game.
Hey You must set dmg to a value before using it The error is that the variable dmg hasn't been asigned yet wp = raw_input(\n\nSelect between warrior and Archer ) mob = 300 hit = 0 hp = 100 run = while True: while (mob 0): hit += 1 mob = mob - dmg#HERE before doing this and before the while you should type dmg=0 or the value you like Best Regards Alberto From: Kooser, Ara S [EMAIL PROTECTED] To: . , [EMAIL PROTECTED], tutor@python.org Subject: Re: [Tutor] RPG game. Date: Fri, 20 May 2005 08:32:42 -0600 Could you post the error message? Ara Fatti non foste per viver come bruti, ma per seguir virtute e canoscenza - Dante Alighieri You were not made to live like brutes, but to pursue virtue and knowledge -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of . , Sent: Friday, May 20, 2005 5:56 AM To: tutor@python.org Subject: [Tutor] RPG game. I'm trying to make an RPG game which is only consisted of texts. But, it doesn't work! thanks. --- import random print \ Warrior - damage: 10~60 Archer - damage: 0~100 HP of Player: 100 HP of the monster: 300 wp = raw_input(\n\nSelect between warrior and Archer ) mob = 300 hit = 0 hp = 100 run = while True: while (mob 0): hit += 1 mob = mob - dmg hp = hp - atk if (hp 0): print \nYour, wp, has died by the monster(, mob, hp) break elif wp == warrior: dmg = random.randrange(50) + 10 atk = random.randrange(10) elif wp == archer: dmg = random.randrange(100) atk - random.randrage(5) print \n, hit, hits print HP of, wp,:, hp,/100 print HP of the monster:, mob,/300 print \nYou defeated the monster by, hit,hits,, dmg,damage run = raw_input(\n\nrun or exit ) if run == exit: break elif run == run: continue else: raw_input(\nError) break --- _ Don't just search. Find. Check out the new MSN Search! http://search.msn.click-url.com/go/onm00200636ave/direct/01/ ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Crossfire problem
Hey everyone I have a very big problem with two versions of Python (2.2.2 and 2.3.4) over Linux Red Hat 9.0 I'll try to be as explicit as I can In the version 2.2.2 I have the module MySQLdb running but not the datetime module. In the version 2.3.4 I have the module datetime running but not the MySQLdb module. I need both modules running in the same version. I have tried to install MySQLdb for Python 2.3.4 but no luck and I read several documents telling me the steps to follow (in fact I posted yesterday the errors I got) and still no luck. These are the commands I need from datetime module. Is there another way to get this info hoy=datetime.datetime.now() # Today's date and time as a tuple dia=days[hoy.isoweekday()] # Today's dayweek as integer from 0 to 6 grupo=datetime.datetime.today().strftime(%Y%m%d%H%M%S) # string today's date and time I was looking for the datetime module so I can copy it to the libraries of Python 2.3.4. About this first I couldn't find the datetime.py in the version I'm using over Windows and second where should be located the libraries in Linux? Thank you very much in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Troubles with Python modules
Hey Is there any work around to accomplish what I want? I'm asking because I'm still with the same problem Regards Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Troubles with Python modules Date: Tue, 17 May 2005 14:56:52 -0700 (PDT) On Tue, 17 May 2005, Alberto Troiano wrote: Sorry about the question marks (MSN addiction :)) Didn't work and as I suspected it was already installed. Hi Alberto, I'm still thinking that the MySQL development packages are either damaged or mixed up, since the error message says that it can't find MySQL's headers. Let's double check something. Can you do the following from your Unix shell? ## $ rpm -qil mysql-devel $ ls -l /usr/include/mysql ## Show us what comes out. ___ 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] Disable menubar
Hey everyone I've read about menubars and I decided to use the MenuBar from PMW instead of Tkinter's The reason is that I couldn't find an example to make a menu with cascade submenus and another cascade submenu inside the submenu and so on. Now I want to ask if somebody knows how to accomplish these with Menu from TKinter? On the other hand, every button on the menu opens a Toplevel, but I want to restrict the Toplevels to one of each kind. I was thinking in disable the menubutton but PMW only has disable_all and I only want to disable the opened Toplevel. Is there another way to accomplish this using Menu from TKinter or MenuBar from PMW or any other option? I'm sending a copy of the code of the menu (If you think you'll need all the code tell me because is kind of long and has many things that I haven't tried yet) Thanks in advanced Alberto def menuc(): balloon = Pmw.Balloon(root) menuBar = Pmw.MenuBar(root,hull_relief = 'raised',hull_borderwidth = 1,balloon = balloon) menuBar.pack(fill = 'x') menuBar.addmenu('Archivo', 'Salir') menuBar.addmenuitem('Archivo', 'command', 'Salir de la aplicacion',command = root.destroy,label = 'Salir') menuBar.addmenu('Parametros', 'Define ciudades y otros paramtros') menuBar.addmenuitem('Parametros', 'command', 'Agregar, modificar o eliminar ciudades',command=city,label='Ciudades') menuBar.addmenuitem('Parametros', 'separator') menuBar.addmenuitem('Parametros', 'command', 'Agregar, modificar o eliminar hospitales',command=hello,label='Hospitales') menuBar.addmenuitem('Parametros', 'command', 'Agregar, modificar o eliminar pacientes',command=hello,label='Pacientes') menuBar.addmenuitem('Parametros', 'separator') menuBar.addmenuitem('Parametros', 'command', 'Agregar, modificar o eliminar especialidades',command=hello,label='Especialidades') menuBar.addmenuitem('Parametros', 'command', 'Agregar, modificar o eliminar medicos',command=hello,label='Medicos') menuBar.addmenuitem('Parametros', 'separator') menuBar.addmenuitem('Parametros', 'command', 'Agregar, modificar o eliminar tecnicos',command=hello,label='Tecnicos') menuBar.addmenuitem('Parametros', 'separator') menuBar.addcascademenu('Parametros', 'Marcapasos','Marcas y modelos', traverseSpec = 'z', tearoff = 0) menuBar.addmenuitem('Marcapasos', 'command', 'Agregar, modificar o eliminar marcas',command=hello,label='Marcas') menuBar.addmenuitem('Marcapasos', 'command', 'Agregar, modificar o eliminar modelos',command=hello,label='Modelos') menuBar.addcascademenu('Parametros', 'Electrodos','Marcas y modelos', traverseSpec = 'z', tearoff = 0) menuBar.addmenuitem('Electrodos', 'command', 'Agregar, modificar o eliminar marcas',command=hello,label='Marcas') menuBar.addmenuitem('Electrodos', 'command', 'Agregar, modificar o eliminar modelos',command=hello,label='Modelos') menuBar.addmenu('Implantes', 'Programacion de implantes') menuBar.addmenuitem('Implantes', 'command', 'Agregar, modificar o eliminar implantes',command=hello,label='Nuevo') menuBar.addmenuitem('Implantes', 'command', 'Generar reportes',command=hello,label='Reporte') menuBar.addmenu('Reprogramaciones', 'Programacion de reprogramaciones') menuBar.addmenuitem('Reprogramaciones', 'command', 'Agregar, modificar o eliminar reprogramaciones',command=hello,label='Nuevo') menuBar.addmenuitem('Reprogramaciones', 'command', 'Generar reportes',command=hello,label='Reporte') ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Disable menubar
YES That's what I was looking for and I will replace it. I don't like to much the MenuBar from Pmw its different and it does not have all the menu attributes that windows menu have (or maybe I don't know how to use it well :D) About disabling the button it would be nice to know if that can be done , although I made some work around and I managed to restrict the Toplevels. If anybody wants to know how I can post the code Thanks in advanced Alberto From: [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] Disable menubar Date: Fri, 20 May 2005 10:15:49 +1200 (NZST) Quoting Alberto Troiano [EMAIL PROTECTED]: The reason is that I couldn't find an example to make a menu with cascade submenus and another cascade submenu inside the submenu and so on. Now I want to ask if somebody knows how to accomplish these with Menu from TKinter? Here is some code: from Tkinter import * tk = Tk() m = Menu(tk) m2 = Menu(m, tearoff=False) m.add_cascade(label='foo', menu=m2) m3 = Menu(m2, tearoff=False) m2.add_cascade(label='bar', menu=m3) m3.add_command(label='One') m3.add_command(label='Two') tk.config(menu=m) Is this what you are after? Check the attachment for what it produces. You could add more menus, eg: m4 = Menu(m3, tearoff=False) m3.add_cascade(label='baz', menu=m4) m4.add_command(label='Three') m4.add_command(label='Four') I think using Tkinter.Menu is better than Pmw, because Tkinter.Menu will use native menu widgets (which means your menu will look the same as other menus in other apps), whereas I think Pmw may do its own thing. -- John. menu.jpg Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Password
Hey I think that is a good built-in way to protect your passwords, but then I don't know if a text file is the best way to store them. I think (in my opinion) I consider using a database to store tha info. There is a way to make the entry appears as *. txtPass=Entry(root,width=25,show=*) The show attribute accomplish what you want Regards Alberto From: Øyvind [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] Password Date: Wed, 18 May 2005 14:46:43 +0200 (CEST) Hello. I am trying to make a loginbox for a program, and need to make a somewhat safe passwordroutine. Will this work? import md5 h = md5.new() h.update(password) h.hexdigest() The user enters a password first. These lines will create a string: '12c0faae657b3d068c0f19b71f5b43bc' This string will be stored in the file settings.txt Then, I will do the same where the password is entered in a GUI-box. Then I will do the same, and compare. If file.readline == h.hexdigest() the user will be accepted. Is this a good way to do this? And a second question. I have made a tkinter box with two entry-fields. Is there a way to make the letters in the second entrybox appear as as the user types his password? Is there some built in function in the Tkinter Entry that does this? Thanks in advance -- This email has been scanned for viruses spam by Decna as - www.decna.no Denne e-posten er sjekket for virus spam av Decna as - www.decna.no ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Troubles with Python modules
I'm sending the commands you asked I'm still can't make it work and I don't know what else should I do I'll aprecciate any help Best Regards Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Troubles with Python modules Date: Tue, 17 May 2005 14:56:52 -0700 (PDT) On Tue, 17 May 2005, Alberto Troiano wrote: Sorry about the question marks (MSN addiction :)) Didn't work and as I suspected it was already installed. Hi Alberto, I'm still thinking that the MySQL development packages are either damaged or mixed up, since the error message says that it can't find MySQL's headers. Let's double check something. Can you do the following from your Unix shell? ## $ rpm -qil mysql-devel $ ls -l /usr/include/mysql ## Show us what comes out. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho total 204 -rw-r--r--1 root root 3445 Feb 18 2003 dbug.h -rw-r--r--1 root root 2082 Feb 18 2003 errmsg.h -rw-r--r--1 root root 5864 Feb 18 2003 m_ctype.h -rw-r--r--1 root root 7594 Feb 18 2003 m_string.h -rw-r--r--1 root root22431 Feb 18 2003 my_config.h -rw-r--r--1 root root32038 Feb 18 2003 my_global.h -rw-r--r--1 root root 1579 Feb 18 2003 my_list.h -rw-r--r--1 root root 2696 Feb 18 2003 my_net.h -rw-r--r--1 root root 1205 Feb 18 2003 my_no_pthread.h -rw-r--r--1 root root22737 Feb 18 2003 my_pthread.h -rw-r--r--1 root root 8677 Feb 18 2003 mysql_com.h -rw-r--r--1 root root 8188 Feb 18 2003 mysqld_error.h -rw-r--r--1 root root10787 Feb 18 2003 mysql.h -rw-r--r--1 root root 590 Feb 18 2003 mysql_version.h -rw-r--r--1 root root25751 Feb 18 2003 my_sys.h -rw-r--r--1 root root 5869 Feb 18 2003 raid.h -rw-r--r--1 root root 1605 Feb 18 2003 sslopt-case.h -rw-r--r--1 root root 1296 Feb 18 2003 sslopt-longopts.h -rw-r--r--1 root root 1239 Feb 18 2003 sslopt-usage.h -rw-r--r--1 root root 1013 Feb 18 2003 sslopt-vars.h Name: mysql-devel Relocations: (not relocateable) Version : 3.23.54a Vendor: Red Hat, Inc. Release : 11 Build Date: Tue 18 Feb 2003 03:48:26 PM BOT Install Date: Wed 20 Apr 2005 03:07:32 PM BOT Build Host: porky.devel.redhat.com Group : Applications/Databases Source RPM: mysql-3.23.54a-11.src.rpm Size: 1520790 License: LGPL Signature : DSA/SHA1, Mon 24 Feb 2003 02:38:50 AM BOT, Key ID 219180cddb42a60e Packager: Red Hat, Inc. http://bugzilla.redhat.com/bugzilla URL : http://www.mysql.com Summary : Files for development of MySQL applications. Description : MySQL is a true multi-user, multi-threaded SQL database server. This package contains the libraries and header files that are needed for developing MySQL applications. /usr/include/mysql /usr/include/mysql/dbug.h /usr/include/mysql/errmsg.h /usr/include/mysql/m_ctype.h /usr/include/mysql/m_string.h /usr/include/mysql/my_config.h /usr/include/mysql/my_global.h /usr/include/mysql/my_list.h /usr/include/mysql/my_net.h /usr/include/mysql/my_no_pthread.h /usr/include/mysql/my_pthread.h /usr/include/mysql/my_sys.h /usr/include/mysql/mysql.h /usr/include/mysql/mysql_com.h /usr/include/mysql/mysql_version.h /usr/include/mysql/mysqld_error.h /usr/include/mysql/raid.h /usr/include/mysql/sslopt-case.h /usr/include/mysql/sslopt-longopts.h /usr/include/mysql/sslopt-usage.h /usr/include/mysql/sslopt-vars.h /usr/lib/mysql /usr/lib/mysql/libdbug.a /usr/lib/mysql/libheap.a /usr/lib/mysql/libmerge.a /usr/lib/mysql/libmyisam.a /usr/lib/mysql/libmyisammrg.a /usr/lib/mysql/libmysqlclient.a /usr/lib/mysql/libmysqlclient.so /usr/lib/mysql/libmysqlclient_r.a /usr/lib/mysql/libmysqlclient_r.so /usr/lib/mysql/libmystrings.a /usr/lib/mysql/libmysys.a /usr/lib/mysql/libnisam.a ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Troubles with Python modules
Hey I'm working on Python 2.2 over Linux REd Hat 9.0 and here is the code I have import os import sys import MySQLdb import datetime import time class conexion(object): def __init__(self): self.db = MySQLdb.connect(host=localhost, user=administrador, passwd=123456,db=seguridad) def consulta(self,query,args=None): try: self.cursor=self.db.cursor() self.sql=self.cursor.execute(query,args) except: self.cerrar() else: self.cerrar() def cerrar(self): self.db.close() def getpath(): global ruta global user global cam try: i=0 for arg in sys.argv: if i==1: ruta+=arg elif i==2: user=arg elif i==3: cam=arg else: pass i+=1 except: f=open(cotascamonerrors.log,a+) f.write(ERROR -- No se pudo encontrar el path +ruta+. Contacte al administrador.) f.close() def getHoursMinutes(ts=None): if ts: t = time.strptime(ts, '%H:%M') else: t = time.localtime() return (t.tm_hour, t.tm_min) global ruta global user global cam ruta=/var/www/html/home/ getpath() os.chdir(ruta) os.system(mkdir grabacion) days={1:Lunes,2:Martes,3:Miercoles,4:Jueves,5:Viernes,6:Sabado,7:Domingo} while 1: hoy=datetime.datetime.now() dia=days[hoy.isoweekday()] query=SELECT %s, Limite from camara where CodigoCamara=%s args=(dia,cam) cur=conexion() cur.consulta(query,args) res=cur.cursor.fetchall() for i in res: horag=i[0] limite=i[1] horai1=horag[0:5] horaf1=horag[6:11] horai2=horag[12:17] horaf2=horag[18:23] if getHoursMinutes(horai1) = getHoursMinutes() = getHoursMinutes(horaf1): cur=conexion() query=SELECT count(*) from imagen where CodigoCamara=%s and Usuario=%s args(cam,user) cur.consulta(query,args) j=cur.cursor.fetchall() for k in j: actual=k[0] if actual limite: cur=conexion() grupo=datetime.datetime.today().strftime(%Y%m%d%H%M%S) try: os.system(cp webcam.jpg grabacion/cam+grupo+.jpg) query=INSERT INTO imagen values (%s,%s,%s,NOW(),NOW(),%s) where CodigoCamara=%s and Usuario=%s grupo1=datetime.datetime.today().strftime(%Y%m%d%H%M) ruta1=ruta+/grabacion/cam+grupo+.jpg args(user,cam,ruta1,grupo1) cur.consulta(query,args) except: pass else: f=open(cotascamonerrors.log,a+) f.write(ERROR -- El usuario +user+ agoto su espacio de almacenamiento.) f.close() elif getHoursMinutes(horai2) = getHoursMinutes() = getHoursMinutes(horaf2): cur=conexion() query=SELECT count(*) from imagen where CodigoCamara=%s and Usuario=%s args(cam,user) cur.consulta(query,args) j=cur.cursor.fetchall() for k in j: actual=k[0] if actual limite: cur=conexion() grupo=datetime.datetime.today().strftime(%Y%m%d%H%M%S) try: os.system(cp webcam.jpg grabacion/cam+grupo+.jpg) query=INSERT INTO imagen values (%s,%s,%s,NOW(),NOW(),%s)where CodigoCamara=%s and Usuario=%s grupo1=datetime.datetime.today().strftime(%Y%m%d%H%M) ruta1=ruta+/grabacion/cam+grupo+.jpg args(user,cam,ruta1,grupo1) cur.consulta(query,args) except: pass else: f=open(cotascamonerrors.log,a+) f.write(ERROR -- El usuario +user+ agoto su espacio de almacenamiento.) f.close() else: pass First I'd like to know if this code can be shorter or more efficient (if you have the time) Second the error is the following: Traceback (most recent call last): File /root/cotascamon.py, line 4, in ? import datetime ImportError: No module named datetime I think this module is in Python 2.3. What can I do?? Then I have installed Python 2.3.4 in the same Linux but I can't use it because it doesn't recognze the module MySQLdb Here is the error Traceback (most recent call last): File /root/cotascamon.py, line 3, in ? import MySQLdb File /usr/local/lib/python2.3/site-packages/MySQLdb/__init__.py, line 27, in ? import _mysql ImportError: No module named _mysql I have cross modules Modules Python 2.2 - Python 2.3.4 MySQLdb YES NO datetimeNO YES Heelp Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Troubles with Python modules
First of all, thanks for the corrections I'm assuming that Python 2.2 doesn't have datetime module then??? Is there any way to install it??? My version of Python 2.3.4 is an alternative installation so I know that when I type python with my root account its going to Python 2.2.2 (I'm using the root account) I changed the link though so when I say Python I enter Python 2.3.4 (works and checked) I'm sending the errors MySQLdb gives me when I try to install it. It's hola.txt file I'm doing python setup.py build and inside hola.txt you can see what it says I have installed Linux Red Hat with ALL packages Can I add datetime module to Python 2.2.2 ?? If so how??? Regards Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: Tutor tutor@python.org Subject: Re: [Tutor] Troubles with Python modules Date: Tue, 17 May 2005 09:58:10 -0700 (PDT) On Tue, 17 May 2005, Alberto Troiano wrote: I'm working on Python 2.2 over Linux REd Hat 9.0 and here is the code I have [code cut] First I'd like to know if this code can be shorter or more efficient (if you have the time) Yes. But let's look at the errors first. Second the error is the following: Traceback (most recent call last): File /root/cotascamon.py, line 4, in ? import datetime ImportError: No module named datetime I think this module is in Python 2.3. What can I do?? I'll assume for the moment that you are using your root account. Are you sure that your root account is using Python 2.3? It may be possible that the root account has a slightly more restricive PATH than normal user accounts, and that you might be picking up '/usr/bin/python'. Then I have installed Python 2.3.4 in the same Linux but I can't use it because it doesn't recognze the module MySQLdb Here is the error Traceback (most recent call last): File /root/cotascamon.py, line 3, in ? import MySQLdb File /usr/local/lib/python2.3/site-packages/MySQLdb/__init__.py, line 27, in ? import _mysql ImportError: No module named _mysql Different releases of Python will not automatically migrate the old third-party modules. You'll need to reinstall MySQLdb for Python 2.3. MySQLdb can be found here: http://sourceforge.net/projects/mysql-python Let's look at some of the code. def consulta(self,query,args=None): try: self.cursor=self.db.cursor() self.sql=self.cursor.execute(query,args) except: self.cerrar() else: self.cerrar() The consulta() function tries to make sure that the cerrar() method is called, no matter what. In this case, try/finally may do what you want: ## try: ... finally: self.cerrar() ## def getpath(): global ruta global user global cam try: i=0 for arg in sys.argv: if i==1: ruta+=arg elif i==2: user=arg elif i==3: cam=arg else: pass i+=1 except: f=open(cotascamonerrors.log,a+) f.write(ERROR -- No se pudo encontrar el path +ruta+. Contacte al administrador.) f.close() This looks like it's trying to do argument parsing, storing state in global variables. You may want to see if you can avoid the globals, and instead just return those three values back to the caller. My nervousness with the globals comes from the requirement that getpath() has to assume that 'ruta' already has some sort of value already. So there's already a dependency that can be more clearly documented by making getpath() take in an initial base path argument: ## def getpath(base_path): ... return (ruta, user, cam) ## But the block above also feels a little awkward because it assumes that any exception that occurs has to be a path problem. That might not necessarily be the case. I'd strongly recommend letting the exception speak for itself. traceback.print_exc() can help: http://www.python.org/doc/lib/module-traceback.html ## try: except: f = open(cotascamonerrors.log, a+) traceback.print_exc(file=f) f.close() ## Up to this point, though, things are pretty ok, with the nice helper functions with clear roles. The large block near the bottom, though, needs work. I'd recommend applying the same helper-function breakup to make the code's intent clearer. For example, here's SQL code that's repeated, a. It should be broken out: try: os.system(cp webcam.jpg grabacion/cam+grupo+.jpg) query=INSERT INTO imagen values (%s,%s,%s,NOW(),NOW(),%s) where CodigoCamara=%s and Usuario=%s grupo1=datetime.datetime.today().strftime(%Y%m%d%H%M) ruta1=ruta+/grabacion/cam+grupo+.jpg args(user,cam,ruta1,grupo1) cur.consulta(query,args) except
Re: [Tutor] Troubles with Python modules
Hey Danny Sorry about the question marks (MSN addiction :)) Didn't work and as I suspected it was already installed. What else can I do? Is there another built-in module that resemble datetime module? I had to use Python 2.2.2 because of MySQLdb but now I can't use datetime. As you see I'm in the middle of the wall and the sword thanks for any help you can give me Best Regards Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: Tutor tutor@python.org Subject: Re: [Tutor] Troubles with Python modules Date: Tue, 17 May 2005 13:26:09 -0700 (PDT) On Tue, 17 May 2005, Alberto Troiano wrote: I'm sending the errors MySQLdb gives me when I try to install it. It's hola.txt file I'm doing python setup.py build and inside hola.txt you can see what it says I have installed Linux Red Hat with ALL packages Hi Alberto, [Side note: please avoid using the plaintive '??' in your questions. it just reads in a way that feels like begging; you don't need to do that.] Red Hat's Install All Packages might not actually install all the packages you need --- I suspect that it might not include developer packages. According to the error messages: ## gcc -pthread -fno-strict-aliasing -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include/python2.3 -c _mysql.c -o build/temp.linux-i686-2.3/_mysql.o -I'/usr/include/mysql' _mysql.c:41:19: mysql.h: No such file or directory ## the necessary MySQL header files can't be found in '/usr/include/mysql'. You mentioned Red Hat 9, so you probably need to install something like the 'mysql-devel-3.23.54a-11.i386.rpm' file. Here is a link to a mirror with that file: ftp://ftp.linux.ncsu.edu/pub/redhat/linux/9/en/os/i386/RedHat/RPMS/mysql-devel-3.23.54a-11.i386.rpm Can I add datetime module to Python 2.2.2? You may find: http://www.egenix.com/files/python/mxDateTime.html useful, although I can't confirm that it has the exact same API as the one in the Standard Library. Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Menu help
Hey I know I posted so many things but it's because I have so much to do I used to program in VB 6 but I want to learn a programming so I can I master it. I want to make a menu (Tkinter) like the one of the image attached to this email I can do the menu and submenu but I can't do the third submenu Help me! Regards Alberto attachment: Menu_example.JPG___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Troubles with Python modules
Here you go Each filenaem corresponds to the command Thanks in advanced Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Troubles with Python modules Date: Tue, 17 May 2005 14:56:52 -0700 (PDT) On Tue, 17 May 2005, Alberto Troiano wrote: Sorry about the question marks (MSN addiction :)) Didn't work and as I suspected it was already installed. Hi Alberto, I'm still thinking that the MySQL development packages are either damaged or mixed up, since the error message says that it can't find MySQL's headers. Let's double check something. Can you do the following from your Unix shell? ## $ rpm -qil mysql-devel $ ls -l /usr/include/mysql ## Show us what comes out. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho Name: mysql-devel Relocations: (not relocateable) Version : 3.23.54a Vendor: Red Hat, Inc. Release : 11 Build Date: Tue 18 Feb 2003 03:48:26 PM BOT Install Date: Wed 20 Apr 2005 03:07:32 PM BOT Build Host: porky.devel.redhat.com Group : Applications/Databases Source RPM: mysql-3.23.54a-11.src.rpm Size: 1520790 License: LGPL Signature : DSA/SHA1, Mon 24 Feb 2003 02:38:50 AM BOT, Key ID 219180cddb42a60e Packager: Red Hat, Inc. http://bugzilla.redhat.com/bugzilla URL : http://www.mysql.com Summary : Files for development of MySQL applications. Description : MySQL is a true multi-user, multi-threaded SQL database server. This package contains the libraries and header files that are needed for developing MySQL applications. /usr/include/mysql /usr/include/mysql/dbug.h /usr/include/mysql/errmsg.h /usr/include/mysql/m_ctype.h /usr/include/mysql/m_string.h /usr/include/mysql/my_config.h /usr/include/mysql/my_global.h /usr/include/mysql/my_list.h /usr/include/mysql/my_net.h /usr/include/mysql/my_no_pthread.h /usr/include/mysql/my_pthread.h /usr/include/mysql/my_sys.h /usr/include/mysql/mysql.h /usr/include/mysql/mysql_com.h /usr/include/mysql/mysql_version.h /usr/include/mysql/mysqld_error.h /usr/include/mysql/raid.h /usr/include/mysql/sslopt-case.h /usr/include/mysql/sslopt-longopts.h /usr/include/mysql/sslopt-usage.h /usr/include/mysql/sslopt-vars.h /usr/lib/mysql /usr/lib/mysql/libdbug.a /usr/lib/mysql/libheap.a /usr/lib/mysql/libmerge.a /usr/lib/mysql/libmyisam.a /usr/lib/mysql/libmyisammrg.a /usr/lib/mysql/libmysqlclient.a /usr/lib/mysql/libmysqlclient.so /usr/lib/mysql/libmysqlclient_r.a /usr/lib/mysql/libmysqlclient_r.so /usr/lib/mysql/libmystrings.a /usr/lib/mysql/libmysys.a /usr/lib/mysql/libnisam.a total 204 -rw-r--r--1 root root 3445 Feb 18 2003 dbug.h -rw-r--r--1 root root 2082 Feb 18 2003 errmsg.h -rw-r--r--1 root root 5864 Feb 18 2003 m_ctype.h -rw-r--r--1 root root 7594 Feb 18 2003 m_string.h -rw-r--r--1 root root22431 Feb 18 2003 my_config.h -rw-r--r--1 root root32038 Feb 18 2003 my_global.h -rw-r--r--1 root root 1579 Feb 18 2003 my_list.h -rw-r--r--1 root root 2696 Feb 18 2003 my_net.h -rw-r--r--1 root root 1205 Feb 18 2003 my_no_pthread.h -rw-r--r--1 root root22737 Feb 18 2003 my_pthread.h -rw-r--r--1 root root 8677 Feb 18 2003 mysql_com.h -rw-r--r--1 root root 8188 Feb 18 2003 mysqld_error.h -rw-r--r--1 root root10787 Feb 18 2003 mysql.h -rw-r--r--1 root root 590 Feb 18 2003 mysql_version.h -rw-r--r--1 root root25751 Feb 18 2003 my_sys.h -rw-r--r--1 root root 5869 Feb 18 2003 raid.h -rw-r--r--1 root root 1605 Feb 18 2003 sslopt-case.h -rw-r--r--1 root root 1296 Feb 18 2003 sslopt-longopts.h -rw-r--r--1 root root 1239 Feb 18 2003 sslopt-usage.h -rw-r--r--1 root root 1013 Feb 18 2003 sslopt-vars.h ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Tkinter questions
Hey Tkinter question How can I change the background color of a label?? How can I change the font-size and make it BOLD?? Regards Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with time module
Hey everyone I have two strings like this hour1=14:30 hour2=15:30 I want to compare them like this: if local_time between hour1 and hour2: print True else print False Can anyone tell me how to make that comparison to work??? (I don't know how to take only the time in this format(Hour:Minutes)) Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with time module
Thank you so much Kent That's exactly what I was lookin for Regards Alberto htmldivIMG height=12 src=http://graphics.hotmail.com/emvamp.gif; width=12nbsp;Gaucho/div/html From: Kent Johnson [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Help with time module Date: Fri, 13 May 2005 09:56:17 -0400 Alberto Troiano wrote: I have two strings like this hour1=14:30 hour2=15:30 I want to compare them like this: if local_time between hour1 and hour2: print True else print False Can anyone tell me how to make that comparison to work??? (I don't know how to take only the time in this format(Hour:Minutes)) time.strptime() can parse the time string to a time tuple, then you can pull out a tuple of (hours, minutes) and compare. import time time.strptime('10:23', '%H:%M') (1900, 1, 1, 10, 23, 0, 0, 1, -1) Here is a helper function that extracts (hours, minutes) from a provided string, or from the clock time if no string is given: def getHoursMinutes(ts=None): ... if ts: ... t = time.strptime(ts, '%H:%M') ... else: ... t = time.localtime() ... return (t.tm_hour, t.tm_min) ... getHoursMinutes() (9, 52) getHoursMinutes('8:34') (8, 34) hour1=14:30 hour2=15:30 getHoursMinutes(hour1) (14, 30) The values returned from getHoursMinutes() can be compared directly: getHoursMinutes(hour1) = getHoursMinutes() = getHoursMinutes(hour2) False hour1='8:56' getHoursMinutes(hour1) = getHoursMinutes() = getHoursMinutes(hour2) True Kent ___ 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] Linux variable to Python
Hey Another problem Here is an example of what I want to do: I run over Linux shell the following command: [EMAIL PROTECTED] root]# fec=cam`date +%Y%m%d%H%M%S`.jpg [EMAIL PROTECTED] root]# echo $fec cam2005051255702.jpg [EMAIL PROTECTED] root]# mv hola.txt grabacion/$fec To explain for those who doesn't know: The first line creates a variable named fec with the value cam(a Linux function returning year month day hour minute second).jpg The second show the value of fec The third moves hola.txt to the directory grabacion and puts the fec value as the new name for the file I need to do this from Python but I'm having problems with the Linux variable I don't get any errors when I execute the commands Here is what I'm doing import os os.system(fec=cam`date +%Y%m%d%H%M%S`.jpg) 0 os.system(echo $fec) 0 os.system(mv hola.txt grabacion/$fec) 0 Then I check for the file and turns out that it moved hola.txt to grabacion with the same name I think that for some extrange way it is not accepting the linux variable I'm using Python 2.2.2 over Red Hat 9.0 Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Linux variable to Python
And again I'm gonna say BINGO! It's like you were doing the same app as I am Thanks Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Linux variable to Python Date: Fri, 13 May 2005 14:00:50 -0700 (PDT) On Fri, 13 May 2005, Alberto Troiano wrote: Here is an example of what I want to do: I run over Linux shell the following command: [EMAIL PROTECTED] root]# fec=cam`date +%Y%m%d%H%M%S`.jpg [EMAIL PROTECTED] root]# echo $fec cam2005051255702.jpg [EMAIL PROTECTED] root]# mv hola.txt grabacion/$fec I need to do this from Python but I'm having problems with the Linux variable Hi Alberto, [Tangent: are you running things using the Unix 'root' account? If so, you may want to consider using a regular user account unless you really know what you're doing. Running things as root should never be taken lightly.] You may want to consider using the 'datetime' module for this one. There are portability and security issues that you may not be considering whenever you shell out. If you use Python's Standard Libraries, you can avoid these issues. I think you can avoid using 'date' by taking advantage of datetime.datetime.strftime(): ## import datetime datetime.datetime.today().strftime(%Y%m%d%H%M%S) '20050513135531' ## This is portable on any system that supports the Python Standard Library. The problems you are running into with os.system() are related to those that other people have been asking about this week. It's sorta funny how these questions come in streaks. *grin* For more information on driving external processes with Python, you may want to look at the messages on Pipe variable to external command that Jeffrey was asking about yesterday: http://mail.python.org/pipermail/tutor/2005-May/038341.html http://mail.python.org/pipermail/tutor/2005-May/038343.html I hope this helps! ___ 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] Compare hours
Hey everyone I have a question. I need to compare two dates and times but it has to be quick. (With quick I mean that the algorythm has to be simple in efficient Here is the deal: day=thursday hour1=15:30 hour2=16:30 all of the above are strings I have to get the system date and time and check if they are between the strings and check that days are the same Can anyone send me an explained code cause I don't know how to work with dates and times in Python (Never needed it until now) Thanks Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Riddle 8
Nevermind It was easy and I figured out But now I'm having serious problems with number 9 Do I really have to connect the dots And how can I do that using the obviuos module? Thanks Alberto From: Alberto Troiano [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] Riddle 8 Date: Wed, 11 May 2005 22:27:34 + Hey I know it is supposed to be one of the easyiest and I know what I have to find(two nouns) and I know from where (two strings on the page)(it's very difficult to avoid spoilers) but I don't know how. And I see the hint when you try to get to 9 but I don't know what it means Any hints? Thanks Alberto ___ 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] zip question
The problem is that you have to get the content before you can get the filename or comment of the files. You have to do something like this import zipfile file=zipfile.ZipFile(yourfile.zip) f=file.getinfo(name_of_the_file_inside_yourfile.zip) And then you can take the comments and filenames you want with f.comment f.filename Copy and paste without parenthesis. The getinfo part, You have to get the name of the files inside. I did a program to put the name of the files inside the zip in a list and then I looped inisde the list with the commands I'm sending you Regards Alberto From: [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: Re: [Tutor] zip question Date: Tue, 10 May 2005 13:19:52 +1200 (NZST) Quoting D. Hartley [EMAIL PROTECTED]: Instances have the following attributes: filename, comment, etc. I've tried about ten things to get filename to work: myzip.filename(99905.txt) (str not callable) Check out the error message: str not callable. You are trying to call something whose type is str --- ie: a string. In python, there is no distinction between callable and noncallable attributes. try: print myzip.filename It should print the filename that this ZipInfo object refers to. Likewise, myzip.comment is a string which is the comment attached to the file in the zip. If you have any background in other languges, it might help you to think of these as member variables (or whatever they call them). And a ZipInfo object appears to be similar to a struct in C/C++. I hope this helps. (and if it doesn't, the fault is probably in the explanation, so keep asking, and I (or someone else) will try again :-) ) -- John. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] zip question
Great!!!Keep it up!! Now you can help with number 7...I hope jejeje Hi everyone I need some pointers to solve number 7. For what I can see on that picture the only hint is the gray line inside the .png drawing, but what can I do with it? Just tell me where to start and I will try to get from there Thanks Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] zip question Date: Tue, 10 May 2005 10:46:26 -0700 Don't worry, I got it :) Thanks, though! On 5/10/05, Alberto Troiano [EMAIL PROTECTED] wrote: The problem is that you have to get the content before you can get the filename or comment of the files. You have to do something like this import zipfile file=zipfile.ZipFile(yourfile.zip) f=file.getinfo(name_of_the_file_inside_yourfile.zip) And then you can take the comments and filenames you want with f.comment f.filename Copy and paste without parenthesis. The getinfo part, You have to get the name of the files inside. I did a program to put the name of the files inside the zip in a list and then I looped inisde the list with the commands I'm sending you Regards Alberto From: [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: Re: [Tutor] zip question Date: Tue, 10 May 2005 13:19:52 +1200 (NZST) Quoting D. Hartley [EMAIL PROTECTED]: Instances have the following attributes: filename, comment, etc. I've tried about ten things to get filename to work: myzip.filename(99905.txt) (str not callable) Check out the error message: str not callable. You are trying to call something whose type is str --- ie: a string. In python, there is no distinction between callable and noncallable attributes. try: print myzip.filename It should print the filename that this ZipInfo object refers to. Likewise, myzip.comment is a string which is the comment attached to the file in the zip. If you have any background in other languges, it might help you to think of these as member variables (or whatever they call them). And a ZipInfo object appears to be similar to a struct in C/C++. I hope this helps. (and if it doesn't, the fault is probably in the explanation, so keep asking, and I (or someone else) will try again :-) ) -- John. ___ 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] RGB, images
Hey Can you be a little more specific on how to get certain part of the image to analyze? I managed to split it in all its bands (though I don't know what is that) How can I work only with the gray part?? Thanks Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: [Tutor] RGB, images Date: Tue, 10 May 2005 14:08:32 -0700 A shade of gray is made by having r == g == b. ... so this has nothing to do with masks and transparency? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Fwd: Fwd: Python riddles
Thanks I got itfinally Now I'm stucked in the riddle 6 As I understand I have to find a secret file (which I have but inside there is like 900 files) and do something with it Can someone give a hint?? Is it like number 4?the one with urllib??? thanks Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] Fwd: Fwd: Python riddles Date: Sat, 7 May 2005 17:45:32 -0700 Alberto, banner is not a method or a function or anything, it's a unix trick. also look at run-length encoding for a hint. hope this helps! i finally got it :) On 5/7/05, D. Hartley [EMAIL PROTECTED] wrote: the only thing i found with banner in it was this: http://www.python.org/doc/2.2.3/lib/module-code.html and i dont know what those are or if it would help. it'd be nice if they just had a definition or something! this puzzle has been so hard and has frustrated me a million times. i want to solve it! On 5/7/05, D. Hartley [EMAIL PROTECTED] wrote: i dont know what the banner program is. it didnt say anything about it in the python documentation? On 5/7/05, Alberto Troiano [EMAIL PROTECTED] wrote: What's a 'banner'? Can you explain me how a banner works I think we can focus on that Max suggested me that I take a look to the banner program (which I couldn't find anywhere) I'm stucked too in this riddle. Regards Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] Fwd: Fwd: Python riddles Date: Fri, 6 May 2005 23:57:47 -0700 I got the file... and see several patterns... but i'm not sure what to do about it now. something about if it were in one big flat list like a ... 'banner' but the .p isnt any kind of a meaningful hint to me and i'm still stuck :P On 5/6/05, Alberto Troiano [EMAIL PROTECTED] wrote: I'm in 5 But I don't understand it thou.:D Good luck Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] Fwd: Fwd: Python riddles Date: Fri, 6 May 2005 11:43:02 -0700 right. the trick is it can be ONLY three cap letters on either side. the first solution you come up with will probably return a lot more letters because it will return things like aAAA too. ;) i'm trying to figure out what puzzle 4 is asking right now On 5/6/05, Alberto Troiano [EMAIL PROTECTED] wrote: Hey I'm on riddle 3 right now. I figured out just after I sent you the email :D On riddle 3 let me know if I'm wrong but I suppose there is a lowercase letter between three uppercase letters on eachside wright Thanks again Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] Fwd: Fwd: Python riddles Date: Fri, 6 May 2005 11:30:06 -0700 Alberto, Right now the url ends in 0.html. eventually when you figure out the riddle, you'll get something to replace the 0 with. try 1.html for a hint (it's not the solution but it will give you a hint as to what they're asking - i wasnt sure at first either). The 0 on the screen is the number of the riddle you're on, it's unrelated to the riddle itself. Lemme know if you need another hint! ~Denise On 5/6/05, Alberto Troiano [EMAIL PROTECTED] wrote: Hey I have recently entered to the riddle but I don't understand what I have to do with those numbers I see 238 and a 0 but what does it have to do with the URL?? HELPP Thanks Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: [Tutor] Fwd: Fwd: Python riddles Date: Thu, 5 May 2005 12:28:32 -0700 ha ha. ok. I figured out the riddle (the computational part), i just had calculated it myself and wondered where python came in. if I had remembered to bring my brain with me this morning, I suppose I would have thought that I could write a python script to do the math problem for me instead of a normal calculator. Thanks! ~Sheepish Denise -- Forwarded
Re: [Tutor] Problem with threading
Hi I took a look at the code and now I'm confused I'll use CRON and I will make a python script that take parameters (username) and work only for that user but the script will never finish ÇThe FTP connection that starts the camera never ends unless I shutdown my server. Now I'm thinking that CRON will start my script only once and I will make a script that check for the record time of the user and insert all the photos that are in the record time but is there a quick to insert the filename with path to the database I'll have all the photos in one directory and I want to check all directory quickly cause after it finish it will start again and again and again and again and again and again.i think you get the picture Imagine 40 users running all at the same time. I have to ask, does the machine will overhead with this process???Does CRON make my script run as a daemon or should I insert the daemon code you gave me: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 What is the difference in running with CRON without the daemon code with running with the daemon code?? Regards Alberto - Alberto -- The one who stands beside me, does not share my pythonistic way to do things -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre de Danny Yoo Enviado el: Martes, 03 de Mayo de 2005 03:58 a.m. Para: Alberto Troiano CC: Tutor; [EMAIL PROTECTED] Asunto: Re: [Tutor] Problem with threading On Tue, 3 May 2005, Alberto Troiano wrote: In answer to Matt the cameras push the photos via ftp at my server at 1 photo every 3 seconds Hi Alberto, Just as another note: the folks here have no idea who you mean by Matt. I do know that you mean Matt from [EMAIL PROTECTED], but the folks on Tutor now have no clue what we're talking about. *grin* That's sorta why it's not such a good idea to crosspost to both lists, because now we have a conversation where not everyone can see each other. I'll put Matt in CC, but let's try to avoid this situation next time. What can I do I believe that cron has a resolution of a minute, so now it doesn't sound that cron is so viable. But how about writing a program that just continues to run as a daemon service in the background? A simple example is something like: ## import time while True: ## do something time.sleep(delay) ## This isn't a true daemon, since it's not detached from the terminal. But the Python Cookbook mentions something a little more polished here: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 and this should be a basis for writing a ftp-polling daemon. Best of wishes to you! ___ 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] Problem with threading
Hey all This is the program I need to do and I haven't been able to figure out From a web page (PHP), I'm creating users and an IP Camera that sends me photos all the time. The user configure his recording time and then a daemon has to check for the photos that does not belong to the recording time. Now I need to start a process for each user because I think is the only way to accomplish this. Someone suggested the use of CRON (I'm working over Linux) but how can I built a program to which I can pass an argument??? I mean in CRON I will have to put one task for each user and each script has to check only one user, so I think I have to make something like this in cron: at 5 o clock run python2.2 application_I_build(username) I don't know if I make myself clear about what I want Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Problem with threading
Hey I have the users config in a database so the use of a text file is double work In answer to Matt the cameras push the photos via ftp at my server at 1 photo every 3 seconds What can I do Regards Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: Tutor tutor@python.org Subject: Re: [Tutor] Problem with threading Date: Mon, 2 May 2005 15:26:12 -0700 (PDT) [Side note: try to just send messages to either tutor@python.org, or [EMAIL PROTECTED], but not both.] Someone suggested the use of CRON (I'm working over Linux) but how can I built a program to which I can pass an argument??? I mean in CRON I will have to put one task for each user and each script has to check only one user, so I think I have to make something like this in cron: at 5 o clock run python2.2 application_I_build(username) Hi Alberto, Would things work for you if the list of usernames was defined externally, in some sort of text file? It really sounds like each user has some set of configuration state, so perhaps it might be useful to do something like: at 5 o clock, run python2.2 application_wrapper configuration_file.txt where configuration_file.txt holds a list of users and other miscellaneous server-specific variables. Here, 'application_wrapper' is a simple wrapper that itself calls the real 'application_I-build' program with the right command line arguments, for each user in the configuration_file.txt. Best of wishes! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: Issue with Entry/GUI/PIL
Hey It's a matter of fancyness (Sorry, I think I invented an English word, :D) you are asking in the same Entry you want them to answer, so in order to answer your question, I'll have to delete the question. Secondly, how can you analyze if you don't give the chance to the user to type an answer You can ask and answer on the same Entry(although is no pretty nice but...), but in order to do that you'll have to give the user the oportunity to type and a way to tell Python I finish please correct me!!! so that's why I think you'll have to add a Button like Submit and in the command you can put a function that erase the answer and put the message Regards Alberto From: Brian Wurtzel [EMAIL PROTECTED] Reply-To: Brian Wurtzel [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: Issue with Entry/GUI/PIL Date: Fri, 29 Apr 2005 15:22:56 -0700 So, I cannot use the original entry box? I have to add a second one? How come python cannot figure it out in the first entry box, it seems so obvious... = = = Original message = = = Replace the 0.0 for only 0 But you have a problem. You are inserting the question and that's what the if clause analyze so it will be always wrong you have to add another Entry and a submit button so it will analyze the result of the second Entry Regards Alberto From: Brian Wurtzel [EMAIL PROTECTED] Reply-To: Brian Wurtzel [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] Issue with Entry/GUI/PIL Date: Fri, 29 Apr 2005 09:48:01 -0500 [Quoted text hidden] AL.gif ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Help with daemon
Hi I will make it with CRON. Thanks Max for the idea Now I have another problem How can I kill a process??? I know that if I run ps --user username it returns all the process started by username even the PIDs and with kill -9 PID I destroy the process but I don't know how to execute it from Python I tried: import os os.system(ps --user root) and I get 0 as a return How can I get the PID and bind the command above with a variable?? I mean varusername=root os.system(ps --user varusername) works??? thanks in advanced Alberto From: Max Noel [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Help with daemon Date: Wed, 27 Apr 2005 23:38:00 +0100 On Apr 27, 2005, at 22:35, Alberto Troiano wrote: I'm gonna give you an example: The program will check for new users and to check record time every 10 seconds. But first the program will have to finish the checking process that started before so it won't be 10 seconds right? Unless I have one process for each user to check the database at the same time is checking other users This sounds like it'd be better done as a cron job (man cron for more info). -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Help with daemon
Hi everyone Again disturbing the peace of the TUTOR :D I'm making an application to check every few seconds for photos uploaded via ftp The users will program their upload time via web page (made in php). The time is saved in a MySQL database so I will check for all the created users if they are in record time. I'm applying a security politic that when the users are in record time then the ftp will let them write and erase, but when they aren't the ftp only will let them read. Here is my problem. Imagine 100 users and lets say that User A connects at 9:00 and User B will connect at 9:10. When I first check at 9:00 User A is in record time so he can send photos but User B does not. The program will have to check for all 100 users and will hardly reach for another check at 9:10 and it will loss transfer time. The OS is linux and the version of Python is 2.2.3. The question is, how can I make the application to manage a process for each user the database find, so only one process will attend one user and I think it will be fast enough to cover the record time. I don't know if my approach is right, I'm new with multithreading and I will appreciate the help. I'm gonna give you an example: The program will check for new users and to check record time every 10 seconds. But first the program will have to finish the checking process that started before so it won't be 10 seconds right? Unless I have one process for each user to check the database at the same time is checking other users Thanks for the help and I hope this is clear (and not long) enough for you to help me Regards Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] TKinter and things over Linux
Hey Didn't work I try the python2.3 setup.py build I couldn't print the exact error because it's a lot of pages that says mostly the same the final error says error: mysql ended exit with status 1 I run the other command python2.3 setup.py install and the same error What can I do I'm desperate Just in case I'm using MySQL 3.23 (Default MySQL Red Hat 9.0, but I don't see how that can affect the module) Thanks in advanced Alberto From: Alberto Troiano [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Tue, 19 Apr 2005 19:07:16 + GOTCHA! I let you know guys how it went Bye for now Alberto From: Max Noel [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org, [EMAIL PROTECTED] Subject: Re: [Tutor] TKinter and things over Linux Date: Tue, 19 Apr 2005 20:01:31 +0100 On Apr 19, 2005, at 19:57, Alberto Troiano wrote: Thanks Danny I will try to do that and let you know how it went But one question thou, does it matter the location where I gunzip the distutil If so where should I put it??? NOTE: It's just to be sure that I'm understanding right the language (ENGLISH) of the link you attached Wherever you want, it doesn't matter. When you run python setup.py install, the module is installed in the Python standard library, so once you've done it, you can delete the files. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] TKinter and things over Linux
Could it be a problem wth gcc library and if so, gcc library is the C compiler or am I wrong in that? The exact error is the following: error: compiled 'gcc' failed with exit status 1 I'm reinstalling Red Hat 9.0 with the EVERYTHING option so there can be no problem Thanks again Alberto From: Max Noel [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Wed, 20 Apr 2005 17:15:49 +0100 On Apr 20, 2005, at 16:52, Alberto Troiano wrote: Hey Didn't work I try the python2.3 setup.py build I couldn't print the exact error because it's a lot of pages that says mostly the same the final error says error: mysql ended exit with status 1 I run the other command python2.3 setup.py install and the same error What can I do I'm desperate Just in case I'm using MySQL 3.23 (Default MySQL Red Hat 9.0, but I don't see how that can affect the module) Did you install the software development packages with your distro? If you didn't, install them. In order to install modules that aren't entirely written in Python (such as this one, I wager), you need a working C compiler and standard library. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] crash - switching between text window and graphics/gamewindow (high score)
Hey I'm curious What extension are you using on your game??? is it .py??? And what OS are you running the game??? Another thing. I made a space ship game to learn Python. Is there a possibility that we exchange the games so we can know differents points of view I'll wait your reply Regards Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: [Tutor] crash - switching between text window and graphics/gamewindow (high score) Date: Tue, 19 Apr 2005 15:29:42 -0700 Ok. I got in the working code to have a high score list, and it even saves/loads one now (!!). The only problem is, clicking back from the text window to the game window (only after you entered in your name to go onto the high score list), closes the program. you dont get to say y/n to another game, it just shuts down. i cant run a debugger on it, because the error doesnt happen when I F5-run the game from the python IDLE script, only when i have ran it by doubleclicking on it (which is how you're supposed to run it. otherwise it doesnt shut down properly). i really really REALLY want to keep the high score part of my program, because i worked really hard to get this to work. but i have to have this program running with NO crashes in like a week (it's a birthday present, and the birthday is approaching fast!) Here's the end of game code: #game over.. if lives == 0: ### trying addscore def add_score(): # high_scores = [(1000,Denise), (945,Denise), # (883,Denise),(823,Grant), #(779,Aaron), (702,Pete), # (555,Tom), (443,Tom), # (442,Robin), (4,Pete)] high_scores = pickle.load(file(scores.pik)) score = total_enemy_hits if score high_scores[-1][0]: print Ta da! You got, total_enemy_hits, Ranch Delivery Devices! name = read_string(You made the high score list! What's your name? ) user_score = (score,name) high_scores.append(user_score) high_scores.sort(reverse=True) del high_scores[-1] pickle.dump(high_scores, file(scores.pik, w)) for score, name in high_scores: slip = 30 - len(name) slip_amt = slip* prefix = 5* print prefix,name,slip_amt,score else: print Sorry, you only got, total_enemy_hits, Ranch Delivery Devices. print You didn't quite make the high score list! for score, name in high_scores: slip = 30 - len(name) slip_amt = slip* prefix = 5* print prefix,name,slip_amt,score print Better luck next time! # pdb.set_trace() add_score() end.play() showGameOver(screen, background_image) pygame.display.flip() answer = while not answer in (y,n): for event in pygame.event.get(): if event.type == KEYDOWN: if event.key == K_n: answer = n elif event.key == K_y: answer = y if answer == n: running = 0 else: return 1 #refresh the display pygame.event.pump() pygame.display.flip() #well, nice playing with you... screen = pygame.display.set_mode((640, 480)) return 0 Can anyone tell me why it crashes? you click to the text window when there's the congrats, you made the high score list, enter your name prompt, enter your name and hit enter, and it displays the high scores, with your name in it, just as it should. but then when you click back to the game screen, poof! it all closes. Of course if you dont make the high score list, you can click to the text window and click back to the game window and it operates like it should. Any suggestions would be appreciated!! Again, I'd like to have it do all this score stuff in the game/graphics window, and then it wouldnt have that crash at all. But I dont know how to do that. Please help! Thanks again :) ~Denise ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org
Re: [Tutor] TKinter and things over Linux
You're so right and I apologize for my mistake Do you or anybody knows where the error.log for this kind o things is? or how can I capture the output in a file???Cause is so damn long that I barely see the 10% of all the things its print out I'll look up for the log and send it to you Again, sorry for my ignorance and lack of info Regards Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: Tutor tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Wed, 20 Apr 2005 13:33:15 -0700 (PDT) I couldn't print the exact error because it's a lot of pages that says mostly the same Hi Alberto, No, that's precisely the kind of wrong kind of attitude toward error messages that's making this debugging much harder than it should be. You may think that those error messages are mostly the same, but we REALLY wanted to see that for ourselves. Please don't interpret error messages for us: please let us make that judgement for ourselves. Again, I have to stress that we really like seeing good error messages. This may sound weird to you, but the error message that comes out is usually much more descriptive than you might realize. the final error says error: mysql ended exit with status 1 Right, but now we can't tell if it was a problem during compilation, or linking, or any other kind of possibility. In your next email, you mentioned: The exact error is the following: Error: compiled 'gcc' failed with exit status 1 which is equally uninformative. All errors will eventually end up with saying something like something bad happened. But what we need is first cause: at what point do things start to go horribly wrong? And that's what the error log tells us. If you had shown us the whole transcript of the error log, we'd have a much better chance to give you exact answers on, at what stage, the problem starts to emerge. With what you're giving us now, we have no clue. If the error log is really that long, then zip it up, and put it as an attachment. But don't just omit it altogether. Please also read: http://www.catb.org/~esr/faqs/smart-questions.html Good luck to you. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] crash - switching between text window andgraphics/gamewindow (high score)
Hey Denise That was fast Try changing the extension to .pyw and tell me if this fix it By the way you didn't say nothing about the game :D Regards Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: [Tutor] crash - switching between text window andgraphics/gamewindow (high score) Date: Wed, 20 Apr 2005 14:15:13 -0700 The play file does end in .py. I am running it on Windows. You can double-click the play file, and run it straight that way, which is when the crash occurs. If you right click the file, go to edit in IDLE, and hit F5 to run it, the crash does NOT happen. I'm not sure why (but this is also why my debugging program won't tell me what's wrong). In fact, I wish the debugger *would* give me something, because then I'd have a specific error, which would make researching the program on google or in forum archives much easier! At the moment, I'm getting nothing (or too much information about unrelated problems). Thanks for any suggestions! -- Forwarded message -- From: Alberto Troiano [EMAIL PROTECTED] Date: Apr 20, 2005 2:07 PM Subject: RE: [Tutor] crash - switching between text window and graphics/gamewindow (high score) To: [EMAIL PROTECTED] Cc: tutor@python.org Hey I'm curious What extension are you using on your game??? is it .py??? And what OS are you running the game??? Another thing. I made a space ship game to learn Python. Is there a possibility that we exchange the games so we can know differents points of view I'll wait your reply Regards Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: [Tutor] crash - switching between text window and graphics/gamewindow (high score) Date: Tue, 19 Apr 2005 15:29:42 -0700 Ok. I got in the working code to have a high score list, and it even saves/loads one now (!!). The only problem is, clicking back from the text window to the game window (only after you entered in your name to go onto the high score list), closes the program. you dont get to say y/n to another game, it just shuts down. i cant run a debugger on it, because the error doesnt happen when I F5-run the game from the python IDLE script, only when i have ran it by doubleclicking on it (which is how you're supposed to run it. otherwise it doesnt shut down properly). i really really REALLY want to keep the high score part of my program, because i worked really hard to get this to work. but i have to have this program running with NO crashes in like a week (it's a birthday present, and the birthday is approaching fast!) Here's the end of game code: #game over.. if lives == 0: ### trying addscore def add_score(): # high_scores = [(1000,Denise), (945,Denise), # (883,Denise),(823,Grant), #(779,Aaron), (702,Pete), # (555,Tom), (443,Tom), # (442,Robin), (4,Pete)] high_scores = pickle.load(file(scores.pik)) score = total_enemy_hits if score high_scores[-1][0]: print Ta da! You got, total_enemy_hits, Ranch Delivery Devices! name = read_string(You made the high score list! What's your name? ) user_score = (score,name) high_scores.append(user_score) high_scores.sort(reverse=True) del high_scores[-1] pickle.dump(high_scores, file(scores.pik, w)) for score, name in high_scores: slip = 30 - len(name) slip_amt = slip* prefix = 5* print prefix,name,slip_amt,score else: print Sorry, you only got, total_enemy_hits, Ranch Delivery Devices. print You didn't quite make the high score list! for score, name in high_scores: slip = 30 - len(name) slip_amt = slip* prefix = 5* print prefix,name,slip_amt,score print Better luck next time! # pdb.set_trace() add_score() end.play() showGameOver(screen, background_image) pygame.display.flip() answer = while not answer in (y,n): for event in pygame.event.get(): if event.type == KEYDOWN: if event.key == K_n: answer = n
Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score)
Hi The thing is this I get an error that says sort() has no arguments Th error is in the sentence high_score.sort(reverse=TRUE) If you put just sort() it will work but the list will show from low to high and we don't want that 'cause if you make a high score it won't be able to know so you have to figure out another way to reverse the list Regards Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] crash - switching between text window and graphics/gamewindow (high score) Date: Wed, 20 Apr 2005 14:22:24 -0700 Alberto, Thank you for replying! I sent answers to the general questions to the tutor list, so that hopefully the extra clarification might help someone else answer (I havent had much luck with this thread, unfortunately). But I wanted to reply to you personally to send a copy of the game. It's a mod of a game from pygame, but I've added a lot of stuff to it. I'll send it as a zip file with two different play files - run the one simply called play to test out the game without the crash (oh, a side-note: the enemy ships will change graphics on levels 2 and 3, but they're not pretty - i just put those graphics in there as a place holder until i make their prettier replacements). Anyway, the play file called copy of play wscorelist2 is the copy with the scorelist that is crashing. If you just want to see the *code* you can look at either of those two files, but I thought you might want to play the actual game so I'm sending it all. Have fun :) Any comments/ideas/suggestions are very welcomed!! I'm having a couple friends test it out. But since I'm new I might not be able to take ALL of the suggestions before I have to have the game done next week, ha ha. Anyway thanks so much for replying, and for any help or suggestions you might have about the crash. ~Denise P.S. if you dont have them, you'll need pygame and the livewires module, available at http://www.livewires.org.uk/python/lwpackage.html . Thanks again! On 4/20/05, Alberto Troiano [EMAIL PROTECTED] wrote: Hey I'm curious What extension are you using on your game??? is it .py??? And what OS are you running the game??? Another thing. I made a space ship game to learn Python. Is there a possibility that we exchange the games so we can know differents points of view I'll wait your reply Regards Alberto From: D. Hartley [EMAIL PROTECTED] Reply-To: D. Hartley [EMAIL PROTECTED] To: Python tutor tutor@python.org Subject: [Tutor] crash - switching between text window and graphics/gamewindow (high score) Date: Tue, 19 Apr 2005 15:29:42 -0700 Ok. I got in the working code to have a high score list, and it even saves/loads one now (!!). The only problem is, clicking back from the text window to the game window (only after you entered in your name to go onto the high score list), closes the program. you dont get to say y/n to another game, it just shuts down. i cant run a debugger on it, because the error doesnt happen when I F5-run the game from the python IDLE script, only when i have ran it by doubleclicking on it (which is how you're supposed to run it. otherwise it doesnt shut down properly). i really really REALLY want to keep the high score part of my program, because i worked really hard to get this to work. but i have to have this program running with NO crashes in like a week (it's a birthday present, and the birthday is approaching fast!) Here's the end of game code: #game over.. if lives == 0: ### trying addscore def add_score(): # high_scores = [(1000,Denise), (945,Denise), # (883,Denise),(823,Grant), #(779,Aaron), (702,Pete), # (555,Tom), (443,Tom), # (442,Robin), (4,Pete)] high_scores = pickle.load(file(scores.pik)) score = total_enemy_hits if score high_scores[-1][0]: print Ta da! You got, total_enemy_hits, Ranch Delivery Devices! name = read_string(You made the high score list! What's your name? ) user_score = (score,name) high_scores.append(user_score) high_scores.sort(reverse=True) del high_scores[-1] pickle.dump(high_scores, file(scores.pik, w)) for score, name in high_scores: slip = 30 - len(name) slip_amt = slip* prefix = 5* print prefix,name,slip_amt,score else: print Sorry, you only got
Re: [Tutor] TKinter and things over Linux
Hi I have another problem. It seems that I manage to solve a problem and run into another The problem is that now I can't install MySQLdb (MySQL database module for Python 2.3.4) I try to ./configure and it prints a lot of crap and then says mysql ended on exit 1 What can I do?? Please help me I'm about to throw my machine over the windows (and I live on the 6th) Thanks in advanced Alberto htmldivIMG height=12 src=http://graphics.hotmail.com/emvamp.gif; width=12nbsp;Gaucho/div/html From: Alberto Troiano [EMAIL PROTECTED] To: [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Mon, 18 Apr 2005 19:03:08 + Hi everyone I have been able to install Python 2.3.4 with Tkinter. I don't know if there is some kind of knowledge base but if somebody has this problem this is what I did: I have downloaded the tcl/tk rpm from http://www.interlink.com.au/anthony/tech/rh9-tcltk/ (They are 8.3.5-185 and fix the bug that Linux Red Hat 9.0 tcl/tk 8.3.5-xx has) I've installed first the tcl package and then the tk package. Then I've installed Python2.3.4 with the following commands: ./configure --enable-unicode=ucs4 make make install That's all Thanks to all who tried to help me (Now I have a problem with the MySQL database but that doesn't fit in this forum ;) Regards Alberto From: Michael Lange [EMAIL PROTECTED] To: tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Mon, 18 Apr 2005 17:09:28 +0200 On Mon, 18 Apr 2005 13:24:03 + Alberto Troiano [EMAIL PROTECTED] wrote: Hi Alberto, Hey Let me know if this format is better (I use Hotmail in the web so...) Looks pretty much ok to me :-) Sadly I'm not in the linux machine so I can't run the command you sent me but I shall explain the version just so you know The fullname version is Red Hat Advanced Server 3.0. This is a commercial version of Linux But it has so many problems and so few documentation that I switched to Red Hat 9.0 (I think that you're familiar with this version) I have installed tcl and tk support and I will download and install the anthony's RPMs What can I do to make Tkinter work on Linux Red Hat 9.0?? First you should make sure that all necessary RPMs are installed; the basic python RPM will be installed by default on RedHat 9 but probably not Tkinter ( I'm not sure how the RPM is called on RedHat, maybe python-tkinter or python-tk or tkinter or... ). Best regards Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ 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] TKinter and things over Linux
Sorry I have Mysql-python 1.20 that's the one I can not install I said MySQLdb because I'm still using it for windows I can't install mysql-python it gives me the error i described With mysql-python does the sintax change???What should I import if not MySQLdb Thanks in advanced Alberto htmldivIMG height=12 src=http://graphics.hotmail.com/emvamp.gif; width=12nbsp;Gaucho/div/html From: Max Noel [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: [EMAIL PROTECTED], tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Tue, 19 Apr 2005 13:56:02 +0100 On Apr 19, 2005, at 13:49, Alberto Troiano wrote: Hi I have another problem. It seems that I manage to solve a problem and run into another The problem is that now I can't install MySQLdb (MySQL database module for Python 2.3.4) I try to ./configure and it prints a lot of crap and then says mysql ended on exit 1 What can I do?? A little Googling informs me that MySQLdb is obsolete and hasn't been updated since some time in 2000 (at that time, Python hadn't even reached 2.0, had it?). You should use MySQL-Python instead, which can be found here: http://sourceforge.net/projects/mysql-python . Chances are it's a standard distutils module, i.e. you install it with sudo python setup.py install. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ 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] TKinter and things over Linux
Thanks Danny I will try to do that and let you know how it went But one question thou, does it matter the location where I gunzip the distutil If so where should I put it??? NOTE: It's just to be sure that I'm understanding right the language (ENGLISH) of the link you attached thanks again regards Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: Tutor tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Tue, 19 Apr 2005 10:18:11 -0700 (PDT) On Tue, 19 Apr 2005, Alberto Troiano wrote: Sorry I have Mysql-python 1.20 that's the one I can not install I said MySQLdb because I'm still using it for windows I can't install mysql-python it gives me the error i described With mysql-python does the sintax change???What should I import if not MySQLdb hi Alberto Same syntax, same author. And same version number. I think you guys are talking about the same module. *grin* I hope we are both talking about the MySQL-Python module from SourceForge, here: http://sourceforge.net/project/showfiles.php?group_id=22307package_id=15775 Alberto, why are you using ./configure? Are you trying to execute Python's configure script? If so, don't: third-party modules use a different method of installation. See: http://docs.python.org/inst/inst.html Ideally, all you need to do is untar the source to MySQL-Python, and do something like: ## [EMAIL PROTECTED] dyoo]$ cd MySQL-python-1.2.0 [EMAIL PROTECTED] MySQL-python-1.2.0]$ python setup.py build ## The step 'python setup.py build' tells Python to try to build the third party extension. If you see problems here, please copy and paste exactly what you see. Otherwise, the last step: ## [EMAIL PROTECTED] MySQL-python-1.2.0]$ python setup.py install ## should finish the job --- you may need to have administrative privileges on your machine to do this, as it tries to write files into the same place as the Standard Library. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] TKinter and things over Linux
GOTCHA! I let you know guys how it went Bye for now Alberto From: Max Noel [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org, [EMAIL PROTECTED] Subject: Re: [Tutor] TKinter and things over Linux Date: Tue, 19 Apr 2005 20:01:31 +0100 On Apr 19, 2005, at 19:57, Alberto Troiano wrote: Thanks Danny I will try to do that and let you know how it went But one question thou, does it matter the location where I gunzip the distutil If so where should I put it??? NOTE: It's just to be sure that I'm understanding right the language (ENGLISH) of the link you attached Wherever you want, it doesn't matter. When you run python setup.py install, the module is installed in the Python standard library, so once you've done it, you can delete the files. -- Max maxnoel_fr at yahoo dot fr -- ICQ #85274019 Look at you hacker... A pathetic creature of meat and bone, panting and sweating as you run through my corridors... How can you challenge a perfect, immortal machine? ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] TKinter and things over Linux
Hey Let me know if this format is better (I use Hotmail in the web so...) Sadly I'm not in the linux machine so I can't run the command you sent me but I shall explain the version just so you know The fullname version is Red Hat Advanced Server 3.0. This is a commercial version of Linux But it has so many problems and so few documentation that I switched to Red Hat 9.0 (I think that you're familiar with this version) I have installed tcl and tk support and I will download and install the anthony's RPMs What can I do to make Tkinter work on Linux Red Hat 9.0?? Thanks in advanced Alberto Gaucho From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: Tutor tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Mon, 18 Apr 2005 00:04:03 -0700 (PDT)On Sun, 17 Apr 2005, Alberto Troiano wrote: [emvamp.gif] Gaucho Hey everyone I have Python 2.3 installed and when I try to import Tkinter I get the following error import Tkinter Traceback (most recent call last): File , line 1, in ? File /usr/local/lib/python2.3/lib-tk/Tkinter.py, line 38, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter I have downloaded the Python2.3.tar.bz2 and made this steps to install it ./configure --enable-unicode=ucs4 make make install The Linux AS 3.0 has Python 2.2 and even this last one doesn-t load Tkinter what can I do/ Thanks in advanced Alberto Hi Alberto, Your email client is doing hideous things to your message. *grin* Try seeing if you can switch to plain text, because it's really darn hard to see what's happening. For information on how to do send plain text emails, see: http://www.expita.com/nomime.html My best guess so far is that the Tcl/Tk development support on your system is spotty: depending on your Linux distribution, you may need to install additional packages so that Python can find the Tcl/Tk stuff. Unfortunately, this is distribution specific, so there's not set way for us to show how to fix this. I'm guessing that you have some sort of Linux distribution. Unfortunately, I'm not familiar with Release 3 of any distribution, so we'll need more information. Do you mind doing this for us? Try executing: ### import sys print sys.plaform print sys.version ### Here's what shows up on one of my systems: ### import sys print sys.platform darwin print sys.version 2.3 (#1, Sep 13 2003, 00:49:11) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] ### Show us what happens when you execute those commands, and that'll give us a better idea what Linux distribution you're running. Best of wishes to you. ___ 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] TKinter and things over Linux
Hi everyone I have been able to install Python 2.3.4 with Tkinter. I don't know if there is some kind of knowledge base but if somebody has this problem this is what I did: I have downloaded the tcl/tk rpm from http://www.interlink.com.au/anthony/tech/rh9-tcltk/ (They are 8.3.5-185 and fix the bug that Linux Red Hat 9.0 tcl/tk 8.3.5-xx has) I've installed first the tcl package and then the tk package. Then I've installed Python2.3.4 with the following commands: ./configure --enable-unicode=ucs4 make make install That's all Thanks to all who tried to help me (Now I have a problem with the MySQL database but that doesn't fit in this forum ;) Regards Alberto From: Michael Lange [EMAIL PROTECTED] To: tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Mon, 18 Apr 2005 17:09:28 +0200 On Mon, 18 Apr 2005 13:24:03 + Alberto Troiano [EMAIL PROTECTED] wrote: Hi Alberto, Hey Let me know if this format is better (I use Hotmail in the web so...) Looks pretty much ok to me :-) Sadly I'm not in the linux machine so I can't run the command you sent me but I shall explain the version just so you know The fullname version is Red Hat Advanced Server 3.0. This is a commercial version of Linux But it has so many problems and so few documentation that I switched to Red Hat 9.0 (I think that you're familiar with this version) I have installed tcl and tk support and I will download and install the anthony's RPMs What can I do to make Tkinter work on Linux Red Hat 9.0?? First you should make sure that all necessary RPMs are installed; the basic python RPM will be installed by default on RedHat 9 but probably not Tkinter ( I'm not sure how the RPM is called on RedHat, maybe python-tkinter or python-tk or tkinter or... ). Best regards Michael ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] Installation Routines (Joseph Quigley)
What exactly do you want to do If you want to make a windows installer then you should look for Create Install It's a very simple software that can copy files to a folder and deploy an executable Please post further info about what you want to achieve so I can assist you a bit more Regards Alberto From: Joseph Quigley [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] Installation Routines (Joseph Quigley) Date: Mon, 18 Apr 2005 14:55:54 -0600 Here I go, hogging the Tutor list again :) I have a friend who recently got a hush-hush contract. He told me that it was for writing an installation program for Windows and that he considered python and Tkinter as an option. I know there are installers written in python for Linux. I suppose they are easier to write, than one for Windows? Now, I'm still new, and can't do GUI yet, but I was wondering how hard would it be to write a simple installer for windows? None of that fancy INI and registry crapp, just a very simple file copier to, oh lets say, My Documents? This isn't a waste of your or my time is it? Joe ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor Gaucho ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] TKinter and things over Linux
Gaucho Hey everyone I have Python 2.3 installed and when I try to import Tkinter I get the following error> >>>import Tkinter Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 38, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: No module named _tkinter I have downloaded the Python2.3.tar.bz2 and made this steps to install it ./configure --enable-unicode=ucs4 make make install The Linux AS 3.0 has Python 2.2 and even this last one doesn-t load Tkinter what can I do/ Thanks in advanced Alberto From: Bill Campbell [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: tutor@python.org Subject: Re: [Tutor] TKinter and things over Linux Date: Sat, 16 Apr 2005 15:50:56 -0700 On Sat, Apr 16, 2005, joe_schmoe wrote: Alberto Troiano wrote: Hi everyone Sorry to bother you again but I don't know where else to go I recently switch to Linux Red Hat AS 3.0 because I have to make a daemon to run in this OS and I'm having a few problems I've struggle to replace Python 2.2(machine default) to 2.3.4 (tough but could) Now I want to program a GUI with Tkinter but when I put the sentence from TKinter import *, it tells me that it doesn't find the module Tkinter. I have downloaded Python 2.3.4 from python.org and follow the steps. The build process for python will pick up installed libraries for various components (e.g. Berkeley database, Tk, etc.), so if you don't have Tkinter on your system, and you built python yourself, it probably means that you don't have the necessary Tk/TCL development libraries installed on the system. Careful perusal of the output of the build is necessary to see what libraries have been built, and which were skipped. I normally build using ``make 21 | tee makelist'' which puts all the output in the file makelist which I can then examine when the make is complete. Secondly I want to know how to run the .py programs and which is the extension of a GUI in Linux (I know that for Windows is .pyw but it doesn't know what are these in Linux) Python scripts should Just Run(tm) whether they have a .py extension or not on a Linux box. Linux, and most *nix flavours don't depend on the file suffix to determine what type of file it is, but generally look at the first few bytes of the file (if a text file starts with ``#!'' the rest of the line is taken to be the command to run the script. ... 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/ When you have an efficient government, you have a dictatorship. -- Harry Truman ___ 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] TKinter and things over Linux
Hi everyone I recently switch to Linux Red Hat AS 3.0 because I have to make a daemon to run in this OS and I'm having a few problems I've struggle to replace Python 2.2(machine default) to 2.3.4 (tough but could) Now I want to program a GUI with Tkinter but when I put the sentence from TKinter import *, it tells me that it doesn't find the module Tkinter. I have downloaded Python 2.3.4 from python.org and follow the steps. Secondly I want to know how to run the .py programs and which is the extension of a GUI in Linux (I know that for Windows is .pyw butit doesn't know what are these in Linux) Then is there an IDLE for Linux so I can run the program without having to go to the shell Thanks a lot Regards Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] TKinter and things over Linux
Hi everyone Sorry to bother you again but I don't know where else to go I recently switch to Linux Red Hat AS 3.0 because I have to make a daemon to run in this OS and I'm having a few problems I've struggle to replace Python 2.2(machine default) to 2.3.4 (tough but could) Now I want to program a GUI with Tkinter but when I put the sentence from TKinter import *, it tells me that it doesn't find the module Tkinter. I have downloaded Python 2.3.4 from python.org and follow the steps. Secondly I want to know how to run the .py programs and which is the extension of a GUI in Linux (I know that for Windows is .pyw butit doesn't know what are these in Linux) Then is there an IDLE for Linux so I can run the program without having to go to the shell Thanks a lot Regards Alberto Hi everyone I recently switch to Linux Red Hat AS 3.0 because I have to make a daemon to run in this OS and I'm having a few problems I've struggle to replace Python 2.2(machine default) to 2.3.4 (tough but could) Now I want to program a GUI with Tkinter but when I put the sentence from TKinter import *, it tells me that it doesn't find the module Tkinter. I have downloaded Python 2.3.4 from python.org and follow the steps. Secondly I want to know how to run the .py programs and which is the extension of a GUI in Linux (I know that for Windows is .pyw butit doesn't know what are these in Linux) Then is there an IDLE for Linux so I can run the program without having to go to the shell Thanks a lot Regards Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] Question regarding the len function of a list while using aloop
Hey Ben The problem is quite simple. You're trying to get the lenght of an INTEGER. That's why it gives you the error. In the position 1 of your list you have an integer and unless you call str(int) you won't be able to get the lenght. Moving on, there is another way to accomplish the loop using this sentence: for element in foo: print len(element) Regards AlbertoFrom: Ben Markwell [EMAIL PROTECTED] Reply-To: Ben Markwell [EMAIL PROTECTED] To: Python Tutor tutor@python.org Subject: [Tutor] Question regarding the len function of a list while using aloop Date: Thu, 14 Apr 2005 08:14:12 -0400 Could somebody explain to me why the code I used to complete this exercise doesn't work. And how do you send an integer to len? Thanks Ben == *As an exercise, write a loop that traverses a list and prints the length of each element. What happens if you send an integer to len? * foo = ['spam!', 1, ['brie', 'cheddar', 'swiss'], [1, 2, 3]] i = 0 while i len(foo): print len(foo[i]) i = i+1 5 Traceback (most recent call last): File "pyshell#28", line 2, in -toplevel- print len(foo[i]) TypeError: len() of unsized object ___ 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] high score lists
Hi I've read somewhere that the appropiate way to make a best score list is with a dictionarie So you'll have something like this: best_score={"Peter":100,"Jhon":23} Best Regards Alberto GauchoFrom: Kent Johnson [EMAIL PROTECTED] CC: Python tutor tutor@python.org Subject: Re: [Tutor] high score lists Date: Thu, 14 Apr 2005 18:24:55 -0400 R. Alan Monroe wrote: Anyone have some good beginning ideas/references to creating a high score list and storing scores in a simple python game? (if there's something in the pygames module, or a simpler python way). I'm mod'ing a space invaders-type game and would like to add a high score list :) Quick and dirty approach: make a list of tuples [ (4, 'John Doe'), (3, 'Steve Austin') ] You can append new ones to the end of the list, sort it, reverse it, etc. And you can use the pickle module to save and restore the list. Kent ___ 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] Question about Frames and Scrollbars
The second option will do the trick. I use Pmw.Combobox but I didn't know there was a ScrolledFrame Thanks a lot Regards Alberto GauchoFrom: [EMAIL PROTECTED] To: "tutor@python.org" tutor@python.org Subject: Re: [Tutor] Question about Frames and Scrollbars Date: Wed, 13 Apr 2005 10:10:34 +1200 (NZST) A couple of options... You can pack a scrollbar on the right hand side of the containing frame and use the yscrollcommand option to associate it with the frame --- see Fredrik Lundh's Tkinter pages for an example. Or you could grab Python MegaWidgets from http://pmw.sourceforge.com/ and use a Pmw.ScrolledFrame instead, which will do the scrollbars for you automatically. (this is my recommended option) -- John. ___ 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] Python backwards program
OK. I'm assuming that you're writing a .py document and you want it to run by double-clicking it in the shell, right??? And you can't see the output of your prog(that's my problem to understand English, sorry :/) If this is your problem then add at the very bottom of your file this sentence: raw_input() Your program will wait until you press any key to finish. If you want to make it fancy then put a string to show inside the parenthesis Let me know if this solve your problem and if that's not the problem then sorry for misunderstanding you and I beg you post again a little more specific (that's only applied to me :)) Regards Alberto GauchoFrom: Feziwe Mpondo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: [EMAIL PROTECTED], tutor@python.org Subject: Re: [Tutor] Python backwards program Date: Wed, 13 Apr 2005 17:14:46 +0200 Alberto Troiano wrote: You can do this:word=raw_input("Type the word: ") Type the word: Kokiri Forest print word Kokiri Forest print word[::-1] tseroF irikoK But I saw that this gave you a hard time so this is an alternate longer way:backword="" counter=len(word)while counter!=0: backword+=word[counter-1] counter-=1 print backword tseroF irikoK So choose the one you want and feel free to ask in case of any doubt Regards AlbertoGaucho From: "Jim and Laura Ahl" [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] Python backwards program Date: Tue, 12 Apr 2005 20:05:41 -0500 I am very new to programming and I have an assignment to have a raw_input string that is inputted by the user and then is printed backwards. Can anyone help me? I can get it to print regular but backwards in not working. Thank You Jim ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor i am able to type, what i can't seem to do is seeing it print or executing the command on the shell window ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Multithreading and Daemon Program
Hey Back again I'm need to make a daemon application and to manage multithreading The program has to check every 3 seconds if is there images inside one folder (That's only for you to know what I'm doing in case you needed) My first problem is that I can imagine a way to do a daemon.How can I make it start with the OS???and How can I bind it to the task bar(where Messenger is) The second problem is that I have to start a thread for each user that connects to the app, but I don't understand how to use this. I've read the multithread's archives but I can't crack them. Suppose I have this function: def foo(): print hello*30 def foo2(): print bye*30 How can I make this functions to run simoultaneosly using threads? That'll help understand Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] Multithreading and Daemon Program
OK. Mercy Pierre for the reply(It's my french correct :) The OS will be Linux AS 3.0 and it will be good to know for Windows 2000 and newer also I don't understand about the processes (I mean I do but I don't know how to code it) This is the application: An IP Camera will send images to the server via ftp to a folder. Each user has a folder and I want to know how I can make my app to check the folders ('cause there is going to be many cameras sending files and that means that the app will have to check every folder) every x seconds? Will I have to make one process for every user or one for each user?? How do I achieve this?? Thanks Alberto GauchoFrom: Pierre Barbier de Reuille [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED], Python Tutor tutor@python.org Subject: Re: [Tutor] Multithreading and Daemon Program Date: Wed, 13 Apr 2005 15:51:19 +0200 Ok, the first question is an OS related question. What OS do you use ? For the second, this kind of deamon are usually done using processes rather than threads. This is a lot safer and easier to achieve. I suppose you know how to start a new process. On UNIX, the simplest way to achieve what you want is simply to call os.fork() : all open sockets are available on the child process and you can continue safely the communication with your client. Pierre Alberto Troiano a écrit : Hey Back again I'm need to make a daemon application and to manage multithreading The program has to check every 3 seconds if is there images inside one folder (That's only for you to know what I'm doing in case you needed) My first problem is that I can imagine a way to do a daemon.How can I make it start with the OS???and How can I bind it to the task bar(where Messenger is) The second problem is that I have to start a thread for each user that connects to the app, but I don't understand how to use this. I've read the multithread's archives but I can't crack them. Suppose I have this function: def foo(): print hello*30 def foo2(): print bye*30 How can I make this functions to run simoultaneosly using threads? That'll help understand Thanks in advanced Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor -- Pierre Barbier de Reuille INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP Botanique et Bio-informatique de l'Architecture des Plantes TA40/PSII, Boulevard de la Lironde 34398 MONTPELLIER CEDEX 5, France tel : (33) 4 67 61 65 77 fax : (33) 4 67 61 56 68 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
RE: [Tutor] i need to see a var from any where in my app - im clueless
Have you tried to call file2.class_of_file2.funcl Let me know how it went Regards Alberto GauchoFrom: pxlpluker [EMAIL PROTECTED] To: tutor@python.org Subject: [Tutor] i need to see a var from any where in my app - im clueless Date: Wed, 13 Apr 2005 16:19:05 -0400 i have read the book and searched the group too -- im not gettin it. i want to read a global (OPTIONS) from file1 from a class method (func1) in file2 but i cant see the OPTION from func1 -- #file1.py import file2 import sys OPTION = sys.argv[1:] pass a=global2.class1() a.func1() #file2.py import __main__ pass class class1: . def func1(self): . pass --- ___ 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] Cell Bio Newbie Here
Don't worry about it. No hard feelings. jeje ;-) I notice about the == and != at the end after I posted it. Sorry about it. And yes, your piece of code is more efficient and does the same so I think that's it for who asked, which I may say hasn't posted back. Thanks for the reply RegardsAlberto GauchoFrom: Brian van den Broek [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: tutor@python.org Subject: Re: [Tutor] Cell Bio Newbie Here Date: Mon, 11 Apr 2005 19:11:50 -0400 Alberto Troiano said unto the world upon 2005-04-11 17:43: Hi Brian Thanks for correcting me about the variable and reserved word differences (just for the record the problem is that my english is not so good, you see I'm from Bolivia so pardon my francôis :P) Hi Alberto, I wouldn't have known you felt you had difficulties in English had you not said so. :-) About the code I posted let me stand for it because it sure works like a charm. I tested and the Option 1 gives the message of "That has been difficult" stuff when you pass the 3 errors and still ask you for password. The option 2 loops 3 times unless you put unicorn or whatever is the password and at the third time it gives the message and then increment the current_count once more to take you out of the while loop Test it and let me know how it went, and also if I have a few problems with my writing please let me know as I will try to correct them You are absolutely right that your `Option 2' code does exit the loop. I somehow missed that the while condition had an `and' in it :-[ My apologies. Your second post said you intended the final if clause to be: if password=="unicorn": # etc I've changed it to if password != "unicorn": # etc and get what I would think is correct behaviour. So, it now reads: password = None # necessary pre-setting of names current_count = 0 count = 3 while password != "unicorn" and current_count = count: if current_count count: password=raw_input("Password:") current_count=current_count+1 else: current_count=current_count+1 print "That must have been complicated" if password!="unicorn": print "Try again Later" else: print "Welcome in" I would suggest that it be done like this, though: # pre-sets as before go here while password != "unicorn": if current_count count: password = raw_input("Password:") if password=='unicorn': print 'Welcome in' else: print "That must have been complicated" print "Try again Later" break current_count += 1 This pushes all of the actions consequent on the password into the password fetching loop and uses just a single incrementing line. Anyway, once again, sorry for misreading and mis-correcting you. Best, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Question about Frames and Scrollbars
Hi everyone I don't know if anyone posted something similar but I'll shoot. Is there anyway to Scroll over a Frame?? Let me put this under water. I made a 2D blueprint inside a frame. I'm creating labels dynamically depending on how many rows and columns I want. Suppose you have an 8x8 matriz of labels. The Frame expands to cover the entire size of labels. Now imagine you want an 20x20 matrix. That size is over the windows size. I put a static size to the Frame, how can I put a Scrollbar to the frame so I can see the labels I have at the bottom of the Frame??? Here is the piece of code. I want to scroll overpanel1 self.panel1=Frame(root,width=300,height=300) c=0 self.fil=0 i=1 for line in file: self.col=len(line) for letra in line: if letra=="c" or letra=="C": c+=1 file.close() file=open(f,"r",1) if c 0: for line in file: self.fil+=1 cadena=line.strip() j=1 for letra in cadena: if letra=="a" or letra=="A": self.matrizdecontrol[(i,j)]="T" photo=Image.open("terrain2.jpg") imagen=ImageTk.PhotoImage(photo) plano=Label(self.panel1,image=imagen,width=55,height=55) plano.photo=imagen plano.grid(row=i,column=j,sticky=W) elif letra=="b" or letra=="B": self.matrizdecontrol[(i,j)]="R" photo=Image.open("asteroid_small.jpg") imagen=ImageTk.PhotoImage(photo) plano=Label(self.panel1,image=imagen,width=55,height=55) plano.photo=imagen plano.grid(row=i,column=j,sticky=W) elif letra=="c" or letra=="C": self.matrizdecontrol[(i,j)]="M" photo=Image.open("mineral.jpg") imagen=ImageTk.PhotoImage(photo) plano=Label(self.panel1,image=imagen,width=55,height=55) plano.photo=imagen plano.grid(row=i,column=j,sticky=W) else: tkMessageBox._show("Error","El plano que introdujo tiene caracteres incorrectos",icon=tkMessageBox.ERROR,type=tkMessageBox.OK) break j+=1 i+=1 self.panel1.grid(row=1,column=1) Just in case, the file is a .txt where I have something like this and I want it to show completely but inside this frame and the size it says there b baaab baaab bcaab b Regards Alberto ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: [Python-Help] Support with Image
Sorry, Copy Paste error I did that cursor.execute("insert into image values('',%s)",outfile.getvalue()) My question now is where should I have to retrieve the database value to show the image? And another question yet: I'm making this application to run as a daemon under Linux (the linux part is not a problem) How can I make my application to start when the OS start??? and How can I make my application to check every x time if it has photos to store? Is it more efficient to store the data in the database (we're talking about thousands of images) or the path and the photos in HD Thanks in advanced Alberto From: Danny Yoo [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Subject: Re: [Python-Help] Support with Image Date: Sat, 9 Apr 2005 14:37:03 -0700 (PDT)Hey Danny it worked Hi Alberto, Good, I'm glad that it's working now. but now I don't know how to retrieve the image This is what I'm doing: import MySQLdb import Image from StringIO import StringIO im = Image.open("auto.jpg") outFile = StringIO() im.save(outFile, "JPEG") Ok, looks good so far. At the end of this, outFile is a file-like object whose content should be that JPEG image. db=MySQLdb.connect(connection string) cursor=db.cursor() cursor.execute("insert into image values('',%s)",outfile) This last statement is problematic. Remember: outFile is a StringIO object, not a string. A StringIO object responds to a str() call with the following: ## from StringIO import StringIO s = StringIO("hello world") s StringIO.StringIO instance at 0x41d00 str(s) 'StringIO.StringIO instance at 0x41d00' ##So we can't use the default. We have to be more specific and use getvalue() to get at the content: ## cursor.execute("insert into image values('',%s)",outfile.getvalue()) ## Hope this helps! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] Re: [Python-Help] Support with Image
Thanks for the reply I read first the one Danny sent me. I'll try the code and let you know how it went About the overwhelming of the machine, is a Dedicated Server so I don't think that would happen. The person in charge of the project told me that he needed a daemon to run under Linux to store in the database so he could take out the binary string into php and show it in a web site, so I think that's why he wants to store it in a database. Sorry I didn't comment this before it's just that I foundout this yesterday :P Thanks in advanced Alberto From: Matthew Dixon Cowles [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Subject: Re: [Python-Help] Support with Image Date: Sat, 9 Apr 2005 13:52:52 -0500 (CDT) Dear Alberto,but now I don't know how to retrieve the imageoutFile = StringIO() im.save(outFile, "JPEG")cursor.execute("insert into image values('',%s)",outfile) It would surprise me very much if that worked correctly. Have you checked to see what's stored in your database after you've done that? What Danny said was: Here, we use StringIO to use an in-memory file-like object: http://www.python.org/doc/lib/module-StringIO.html and we can use getvalue() to get at the binary bytes that you'll probably want to store into your database. Depending on just how you're getting the data for your images, you may want to go through a StringIO object or you may be able to just work with the bytes that are in the file. But it's pretty common that it's not a very good idea to store image data in a database. If your images are pretty small and your database has a "BLOB" (binary large object) type, you may have some luck. If either of those isn't the case, the overhead of getting your images into and out of the database may overwhelm your machine. You might want to consider storing your image files semi-randomly in a directory hierarchy and recording in your database only the path to the file. If you have only a few hundred or a few thousand images, a single directory may be sufficient. If you have many more of them than that, you may want to split them up according to some rule that results in approximately equal numbers going in different directories.cursor.execute("select * from image") res=cursor.fetchall() Now I have the binary string in res[1] but when I try to open it it gives me an error Here's where you may want a StringIO object. If whatever you're giving the image to expects it in a file rather than a string, you could do somwthing like:s=StringIO.StringIO() s.write(res[1]) s.seek(0) and then give the variable s to whatever wants to read the file. Regards, Matt ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] str.split and quotes
Thanks Kent but now I need you to explain me the code :( To give you a graphic example how can make this function to run every 5 seconds def foo(): print "Hello world!" Thanks in advanced AlbertoFrom: Kent Johnson [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] Subject: Re: [Tutor] str.split and quotes Date: Sat, 09 Apr 2005 11:37:56 -0400 Alberto Troiano wrote: Where and How can I see the post you make?? In the list archives http://mail.python.org/pipermail/tutor/2005-April/037362.html Kent ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] str.split and quotes
Hey Kristian, thanks for the reply The problem to use sleep is that all widgets gets locked up and they doesn't refresh themselves I just made that example so anyone can explain the code Kent posted earlier In my real application is a Tkinter GUI so I should not use sleep Thanks anyway Regards AlbertoFrom: Kristian Zoerhoff [EMAIL PROTECTED] Reply-To: Kristian Zoerhoff [EMAIL PROTECTED] To: Alberto Troiano [EMAIL PROTECTED] CC: [EMAIL PROTECTED], tutor@python.org Subject: Re: [Tutor] str.split and quotes Date: Mon, 11 Apr 2005 11:03:13 -0500 On Apr 11, 2005 11:00 AM, Alberto Troiano [EMAIL PROTECTED] wrote: To give you a graphic example how can make this function to run every 5 seconds def foo(): print "Hello world!"I'm not Kent, but I play him on TV ;-) import time def foo(): print "Hello world!" while true: foo() time.sleep(5) -- Kristian kristian.zoerhoff(AT)gmail.com zoerhoff(AT)freeshell.org ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor