Computer locks up when running valid stand alone Tkinter file.
py help, The file below will run as a stand alone file. It works fine as it is. But, when I call it from another module it locks my computer, The off switch is the only salvation. This module when run as a stand alone, it will open a jpeg image and add a vertical and horizontal scrollbar to the canvass. That's all it does. Replace the img9.jpg file with one of your own, put the image in the current working dir., and run. If you think you can help, I would appreciate it. jim-on-linux #!/usr/bin/env python """ # import Tkinter as Tk Do not do ( from Tkinter import * ) because of name space conflict with Image.open ## below imports Image and ImageTk are from Imaging-1.1.5, PIL in Python """ import Image import ImageTk import Tkinter as Tk import os vpath = os.getcwd()+os.sep+'img9.jpg' class Kshow_0 : def __init__(self ) : self.Fimgshow0() def Fimgshow0(self ) : window = Tk.Tk()# used for stamd alone # window = Tk.Toplevel() # Above Toplevel call used when running # from another file window.title(' Image Location '+vpath ) window.protocol('WM_DELETE_WINDOW', window.destroy) vcanvas = Tk.Canvas(window, width = 375, height=375, borderwidth = 1, bg= 'white') sbarY=Tk.Scrollbar() sbarX = Tk.Scrollbar( orient='horizontal') sbarY.config(command= vcanvas.yview) sbarX.config(command= vcanvas.xview) vcanvas.config(yscrollcommand=sbarY.set) vcanvas.config(xscrollcommand=sbarX.set) sbarY.pack(side='right', fill='y') sbarX.pack(side='bottom', fill='x') vcanvas.pack(expand='yes', fill='both') im= Image.open( vpath) tkim = ImageTk.PhotoImage(im) imgW = tkim.width() print imgW, '## imgW, jpg 58\n' imgH = tkim.height() print imgH, '## imgH, jpg 61\n' # Draw the image on the canvas vcanvas.create_image(0, 0, image=tkim, anchor = 'nw' ) vcanvas.config(scrollregion= (0, 0, imgW, imgH)) window.mainloop () if __name__ == '__main__' : Kshow_0() -- http://mail.python.org/mailman/listinfo/python-list
Re: Slightly OT: Is pyhelp.cgi documentation search broken?
On Thursday 26 October 2006 04:01, you wrote: > Hi! > > For a number of days I haven't been able to > search the online python docs at: > > http://starship.python.net/crew/theller/pyhelp. >cgi > Joel, Try here, [EMAIL PROTECTED] jim-on-linux http://www.inqvista.com > that is the "search the docs with" link at this > page: > > http://www.python.org/doc/ > > Instead of the search engine, I get Error 404. > This is a real bother for me, since I rely > heavily on it for my work. > > Is it broken? If so, is anybody trying to get > it back up again, and what's the time scale in > that case? Is there an alternative available > somewhere? > > Cheers! > /Joel Hedlund -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Split Chinese Character with backslash representation?
On Thursday 26 October 2006 23:43, you wrote: > Hi all, > > I was trying to split a string that > > represent chinese characters below: > >>> str = '\xc5\xeb\xc7\xd5\xbc' > >>> print str2, > > ??? > > >>> fields2 = split(r'\\',str) > >>> print fields2, > > ['\xc5\xeb\xc7\xd5\xbc'] > > But why the split function here doesn't seem > to do the job for obtaining the desired result: The character '\' is an escape character. It won't show just like '\n' at the end of a line doesn't show. To show it must be preceeded by another '\' like this '\\' figgure out a way to start with '\\' and you'll be ok. x = str.split('\\xc5\\xeb\\xc7\\xd5\\xbc', '\\') print x, '## x on line 10 == \n\n\n' ### '\n' won't show on printed line print x, '## x on line 15 == \\n' ### '\n' will show on printed line for n in x: n= '\\'+n print n jim-on-linux http://www.inqvista.com > > ['\xc5','\xeb','\xc7','\xd5','\xbc'] > > > > Regards, > -- Edward WIJAYA > SINGAPORE > > > > Institute For Infocomm Research - > Disclaimer - This email is > confidential and may be privileged. If you are > not the intended recipient, please delete it > and notify us immediately. Please do not copy > or use it for any purpose, or disclose its > contents to any other person. Thank you. > --- >- -- http://mail.python.org/mailman/listinfo/python-list
Re: Computer locks up when running valid stand alone Tkinter file.
Thanks for responding, For those who care. The solution to the problem was; First, I did not give a parent to the Yview scrollbar. Next, I used the pack geometry for this class and everything else is grid geometry. When run stand alone it ran fine because the Yview scrollbar attached itself to the default parent, but when run from another module, it locked up. The difficulty is really in the fact that scrollbar Yview without a parent tried to attach itself to the root Tk, already built and running with grid geometry. Pack and grid in the same Frame don't get along (computer lockup). Give Yview a parent, problem solved. Changed pack to grid anyway. jim-on-linux http://www.inqvista.com On Wednesday 25 October 2006 23:05, you wrote: > > But, when I call it from another module it > > locks > > methinks this "other module" has the answer. > > jim-on-linux wrote: > > py help, > > > > The file below will run as a stand alone > > file. It works fine as it is. > > > > But, when I call it from another module it > > locks my computer, The off switch is the only > > salvation. > > > > This module when run as a stand alone, it > > will open a jpeg image and add a vertical and > > horizontal scrollbar to the canvass. That's > > all it does. > > > > Replace the img9.jpg file with one of your > > own, put the image in the current working > > dir., and run. > > > > If you think you can help, I would appreciate > > it. > > > > > > jim-on-linux > > > > > > > > > > > > > > > > #!/usr/bin/env python > > > > """ > > # > > import Tkinter as Tk > > > > Do not do > > ( from Tkinter import * ) > > because of name space conflict with > > Image.open > > > > # > ># > > > > below imports Image and ImageTk are > > from Imaging-1.1.5, PIL in Python > > > > """ > > > > > > import Image > > import ImageTk > > import Tkinter as Tk > > import os > > > > vpath = os.getcwd()+os.sep+'img9.jpg' > > > > > > > > class Kshow_0 : > > > > def __init__(self ) : > > self.Fimgshow0() > > > > def Fimgshow0(self ) : > > window = Tk.Tk()# used for stamd > > alone > > > ># window = Tk.Toplevel() > > # Above Toplevel call used when > > running # from another file > > > > > > > > window.title(' Image Location '+vpath > > ) window.protocol('WM_DELETE_WINDOW', > > window.destroy) > > > > vcanvas = Tk.Canvas(window, width = > > 375, height=375, borderwidth = 1, bg= > > 'white') > > > > sbarY=Tk.Scrollbar() > > sbarX = Tk.Scrollbar( > > orient='horizontal') sbarY.config(command= > > vcanvas.yview) sbarX.config(command= > > vcanvas.xview) > > > > > > vcanvas.config(yscrollcommand=sbarY.set) > > vcanvas.config(xscrollcommand=sbarX.set) > > > > sbarY.pack(side='right', fill='y') > > sbarX.pack(side='bottom', fill='x') > > vcanvas.pack(expand='yes', > > fill='both') > > > > im= Image.open( vpath) > > tkim = ImageTk.PhotoImage(im) > > > > imgW = tkim.width() > > print imgW, '## imgW, jpg 58\n' > > > > imgH = tkim.height() > > print imgH, '## imgH, jpg 61\n' > > > > # Draw the image on the canvas > > vcanvas.create_image(0, 0, > > image=tkim, anchor = 'nw' ) > > > > vcanvas.config(scrollregion= (0, 0, > > imgW, imgH)) window.mainloop () > > > > > > if __name__ == '__main__' : > > > > Kshow_0() -- http://mail.python.org/mailman/listinfo/python-list
Re: lossless transformation of jpeg images
On Sunday 29 October 2006 15:17, Daniel Nogradi wrote: > > Hi all, > > > > Last time I checked PIL was not able to apply > > lossless transformations to jpeg images so > > I've created Python bindings (or is it a > > wrapper? I never knew the difference :)) for > > the jpegtran utility of the Independent Jpeg > > Group. Why not use Tkinter for jpeg ?? jim-on-linux http://www.inqvista.com > > > > The jpegtran utility is written in C and is > > very efficient, fast and robust. It can > > rotate, flip, transpose and transverse jpeg > > images in a lossless way, see www.ijg.org for > > more details. > > > > The bindings allow you to use all jpegtran > > features from Python. > > > > Downloads are here: > > http://ebiznisz.hu/python-jpegtran/ > > > > Any feedback is very welcome, especially if > > you are able to compile it on non-standard > > platforms. It has been tested on Linux and > > Python 2.3. > > > > Usage example: > > > > import jpegtran > > > > transformer = jpegtran.transformer( ) > > > > transformer.rotate( 90, 'pic.jpg', > > 'pic_rotated.jpg' ) transformer.flip( > > 'horizontal', 'pic.jpg', 'pic_flipped.jpg' ) > > transformer.transpose( 'pic.jpg', > > 'pic_transposed.jpg' ) > > transformer.transverse( 'pic.jpg', > > 'pic_transversed.jpg' ) transformer.gray( > > 'pic.jpg', 'pic_gray.jpg' ) > > Oh, I forgot to mention that this is a very > preliminary release, there is no support for > distutils or any other intelligent packaging > tool, it uses 'make' so probably will only work > on Unix flavours. Although it should compile on > Windows as well. -- http://mail.python.org/mailman/listinfo/python-list
Re: looping through two list simultenously
On Sunday 29 October 2006 15:28, CSUIDL PROGRAMMEr wrote: > folks > I have two lists > > i am trying to loop thorough them > simultenously. > Try something like this. for eachline in data1: print eachline for line in data:: print line You might also think about a while loop. jim-on-linux http://www.inqvista.com > Here is the code i am using > > f1 = os.popen('ls chatlog*.out') > data1=f1.readlines() > f1.close() > > data1=[x.strip() for x in data1] > f1 = os.popen('ls chatlog*.txt') > data=f1.readlines() > f1.close() > for eachline in data1 and line in data: > > filename='/root/Desktop/project/'+ eachline > print filename > outfile=open(filename,'r') > filename1='/root/Desktop/project/' + line > print filename1 > > I get the error that line is not defined. > Traceback (most recent call last): > File "list.py", line 16, in ? > for eachline in data1 and line in data: > NameError: name 'line' is not defined > > Is there any efficient doing this -- http://mail.python.org/mailman/listinfo/python-list
Re: How to Split Chinese Character with backslash representation?
On Friday 27 October 2006 17:21, jim-on-linux wrote: > On Thursday 26 October 2006 23:43, you wrote: > > Hi all, > > > > I was trying to split a string that > > > > represent chinese characters below: > > >>> str = '\xc5\xeb\xc7\xd5\xbc' > > >>> print str2, > > > > ??? > > > > >>> fields2 = split(r'\\',str) > > >>> print fields2, > > > > ['\xc5\xeb\xc7\xd5\xbc'] > > > > But why the split function here doesn't seem > > to do the job for obtaining the desired > > result: > The character '\' is an escape character. It won't show just like '\n' won't shoe at the end of a line. To show it must be preceeded by another '\' like this '\\' Try this: x ='\xc5\xeb\xc7\xd5\xbc' y = [] z = [] for n in x : y.append( '\\'+n+'\\') print y, '## y line 5\n' for bs in y: bs = str.strip(bs, '\\') z.append(bs) print z, '## z line 10\n' The results will be ['\xc5','\xeb','\xc7','\xd5','\xbc'] jim-on-linux http://www.inqvista.com > > > ['\xc5','\xeb','\xc7','\xd5','\xbc'] > > > > > > > > Regards, > > -- Edward WIJAYA > > SINGAPORE > > > > > > > > Institute For Infocomm Research > > - Disclaimer - This email is > > confidential and may be privileged. If you > > are not the intended recipient, please delete > > it and notify us immediately. Please do not > > copy or use it for any purpose, or disclose > > its contents to any other person. Thank you. > > - > >-- - -- http://mail.python.org/mailman/listinfo/python-list
Re: best way to check if a file exists?
On Tuesday 31 October 2006 16:01, John Salerno wrote: > What is the best way to check if a file already > exists in the current directory? I saw > os.path.isfile(), but I'm not sure if that does > more than what I need. > > I just want to check if a file of a certain > name exists before the user creates a new file > of that name. > > Thanks. How about something like one of these; if os.path.isfile(vfileName) not True : male file or if os.path.isfile (os.path.join(os.getcwd(), vFileName) )==True : do something jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: SE 2.3 temporarily unavailable. Cheese shop defeats upload with erratic behavior. Urgently requesting help.
Frederic, I've been trying to get back into my package in the Cheese Shop for over a year. The phone company changed my e:mail address and to make a long and frustrating story short I can't get back into the Cheese Shop to make changes to my file. Time is money. At some time you have to consider if it is worth it. At least you have the name of your program listed. I wish I could be more helpfull. I'll watch the responses you get from others. Good Luck, jim-on-linux http://www.inqvista.com On Thursday 02 November 2006 09:00, you wrote: > Some time ago I had managed to upload a small > package to the Cheese Shop using the data entry > template. Uploading is in two steps: first the > text then the package file. When I had a new > version it went like this: The new text made a > new page, but the new file went to the old > page. The old page then had both files and all > attempts at uploading the new file to the new > page failed with the error message that a file > could not be uploaded if it was already there. > So I let it go and handed out the url of the > old page, figuring that given the choice of two > versions, picking the latest one was well > within the capabilities of anyone. One > downloader just now made me aware that the new > version had misspelled extensions 'PY'. They > should be lower case. So I fixed it an tried to > exchange the file. One hour later I have three > text pages, headed V2,2beta, V2,2beta/V2.3 and > V2.3. The first (oldest) page has the old > package file. The two other pages have no > files. The new version package is gone, > because, prior to re-uploading I was asked to > delete it. The re-upload fails on all three > pages with the message: 'Error processing form, > invalid distribution file'. The file is a zip > file made exactly the way I had made and > uploaded the ones before. I am banging my real > head against the proverbial wall. This thing > definitely behaves erratically and I see no > alternative other than to stop banging and go > to the gym to take my anger out at machines and > when I come back in an hour, I wish a kind, > knowledgeable soul will have posted some good > advice on how to vanquish such stubborn > obstinacy. I have disseminated the url and the > thought that someone might show up there and > not find the promised goods make me really > unhappy. Until such time as this upload is > made, I will be happy to send SE-2.3 out off > list by request. > > Infinite thanks > > Frederic -- http://mail.python.org/mailman/listinfo/python-list
Re: SE 2.3 temporarily unavailable. Cheese shop defeats upload with erratic behavior. Urgently requesting help.
On Thursday 02 November 2006 14:59, Frederic Rentsch wrote: > jim-on-linux wrote: > > Frederic, > > > > I've been trying to get back into my package > > in the Cheese Shop for over a year. The phone > > company changed my e:mail address and to make > > a long and frustrating story short I can't > > get back into the Cheese Shop to make changes > > to my file. > > > > Time is money. At some time you have to > > consider if it is worth it. At least you > > have the name of your program listed. > > > > I wish I could be more helpfull. I'll watch > > the responses you get from others. > > > > Good Luck, > > jim-on-linux > > > > http://www.inqvista.com > > > > On Thursday 02 November 2006 09:00, you wrote: > >> Some time ago I had managed to upload a > >> small package to the Cheese Shop using the > >> data entry template. Uploading is in two > >> steps: first the text then the package file. > >> When I had a new version it went like this: > >> The new text made a new page, but the new > >> file went to the old > > > > snip > > Thanks for letting me know that I am not alone. > Do you know of an alternative to the Cheese > Shop? > > Frederic Python registering alternatives? Part of the mission of the Cheese Shop is to safeguard the name of your software. Once registered, no one else can use that name. That's been done, unless you spelled the package name wrong. I read the following, and I'm not sure if you have tried it. The quote below is from: http//:www.python.org/doc/current/dist/package-index.htm item #7 Registering with the Package Index. (11-15-2004) "By default PyPi will list all versions of a given package. To hide certain versions, the hidden property should be set to yes. This must be edited through the web interface." Sounds to me that you can hide what is on the site and submit a new version, if you set "Hidden property" to "yes". I don't know of any other place to register a python package with the python organization. Good Luck, jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: SE 2.3 temporarily unavailable. Cheese shop defeats upload with erratic behavior. Urgently requesting help.
On Friday 03 November 2006 08:21, Steve Holden wrote: > Frederic Rentsch wrote: > > jim-on-linux wrote: > >>Frederic, > >> > >>I've been trying to get back into my package > >> in the Cheese Shop for over a year. The > >> phone company changed my e:mail address and > >> to make a long and frustrating story short I > >> can't get back into the Cheese Shop to make > >> changes to my file. > >> > >>Time is money. At some time you have to > >> consider if it is worth it. At least you > >> have the name of your program listed. > >> > >>I wish I could be more helpfull. I'll watch > >> the responses you get from others. > >> > >>Good Luck, > >>jim-on-linux > >> > >>http://www.inqvista.com > >> > >>On Thursday 02 November 2006 09:00, you wrote: > >>>Some time ago I had managed to upload a > >>> small package to the Cheese Shop using the > >>> data entry template. Uploading is in two > >>> steps: first the text then the package > >>> file. When I had a new version it went like > >>> this: The new text made a new page, but the > >>> new file went to the old > >> > >>snip > > > > Thanks for letting me know that I am not > > alone. Do you know of an alternative to the > > Cheese Shop? > > Surely the correct answer to this problem is to > get the Cheese Shop fixed, not to migrate away > from it? To whom (besides this list) have you > communicated the problem, and with what > results? I emailed and emailed, I got one response but nothing changed. I suggest that the Cheese Shop also forward copies of help request to a site like this or similar. At least the sender knows that someone will read the email and help is on the way. Also, my guess is that before these postings of the last few days, 65% of the people on this site never heard of The Cheese Shop, Postings like these can only help The Cheese Shops. jim-on-linux http://www.inqvista.com > > Remember that python.org is run by volunteers, > but they are mostly highly capable volunteers. > This is probably just a change situation that > wasn't anticipated in the design (we all make > mistakes). > > A simple change of email address could probably > be achieved by tweaking the data for one or two > individuals, and an automated solution should > clearly be added as volumes build up. > > For now, how about a link that causes someone > to receive email? I'd be surprised if this > couldn't be used to handle low-volume changes > with adequate security. > > regards > Steve > -- > Steve Holden +44 150 684 7255 +1 800 494 > 3119 Holden Web LLC/Ltd > http://www.holdenweb.com Skype: holdenweb > http://holdenweb.blogspot.com Recent Ramblings >http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list
Re: disabledforeground or similar for Entry (in Tkinter)
On Saturday 04 November 2006 11:03, Dustan wrote: > Back in this post, I attempted to make a label > look like a button: > http://groups.google.com/group/comp.lang.python >/browse_thread/thread/a83195d3970a6851/2053cbaec >1bc1f19?auth=DQAAAHkMDAWnhNnzpuKlwOKZUwAGUTt >T2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgPfcu >OkiUE-CrSsKbBSX-67voDUXfbATBd0eYNMClezby4EXT2fuL >m6f0llJ_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21ODZBh >ouQ > > Alright, I've learned my lesson - don't use a > new widget; modify the old one. > > Except the Entry widget doesn't have a > disabledforeground option. Neither does the > Text widget, but IDLE seems to accomplish > making a disabled Text look the same as an > enabled Text in the IDLE Help section. > > No, foreground (fg) and background (bg) don't > make a difference; it still changes the color > of the Entry widget upon disabling. > > There must be something I'm missing here... Have you tried the state option ? state = 'disabled' It works for Text, Entry, and Button. Once disabled you won't be able to make changes until state= 'normal' jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: disabledforeground or similar for Entry (in Tkinter)
On Saturday 04 November 2006 11:03, Dustan wrote: > Back in this post, I attempted to make a label > look like a button: > http://groups.google.com/group/comp.lang.python >/browse_thread/thread/a83195d3970a6851/2053cbaec >1bc1f19?auth=DQAAAHkMDAWnhNnzpuKlwOKZUwAGUTt >T2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgPfcu >OkiUE-CrSsKbBSX-67voDUXfbATBd0eYNMClezby4EXT2fuL >m6f0llJ_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21ODZBh >ouQ > > Alright, I've learned my lesson - don't use a > new widget; modify the old one. > > Except the Entry widget doesn't have a > disabledforeground option. Neither does the > Text widget, but IDLE seems to accomplish > making a disabled Text look the same as an > enabled Text in the IDLE Help section. > > No, foreground (fg) and background (bg) don't > make a difference; it still changes the color > of the Entry widget upon disabling. > > There must be something I'm missing here... My previous post was hasty and we all know, "Haste makes waste." Try this; If you use wiget-01.pack_forget() or wiget-01.grid_forget(), you can now build wiget-02 using wiget-02.pack or grid() for the same location. You can reinstall uninstalled wigets by using pack() or grid() again for those hidden wigets. However only after uninstalling for the wigets in those locations. root = Tk() test1 = Button(root, text='Test No.1 button', bg = 'yellow', width = 15, height = 10) test1.grid(row=0, column=0) test1.grid_forget() test2 = Button(root, text='Test #2 button', bg = 'green', width = 15, height = 10) test2.grid(row=0, column=0) mainloop() jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: disabledforeground or similar for Entry (in Tkinter)
Since others want to see more, Try this, you can make the changes you want to the look of your final output with grid or pack_forget() . root = Tk() class Ktest: def __init__(self): self.Ftest1() def Ftest1(self): try: self.test2.grid_forget() except AttributeError : pass self.test1 = Button(root, text='Push #1 button', bg = 'yellow', width = 25, command = self.Ftest2, height = 25) self.test1.grid(row=0, column=0) def Ftest2(self): self.test1.grid_forget() self.test2 = Button(root, text='Push #2 button', bg = 'green', width = 25, command = self.Ftest1, height = 8) self.test2.grid(row=0, column=0) if __name__== '__main__' : Ktest() mainloop() jim-on-linux http://www.inqvista.com > On Saturday 04 November 2006 11:03, Dustan wrote: > > Back in this post, I attempted to make a > > label look like a button: > > http://groups.google.com/group/comp.lang.pyth > >on > > /browse_thread/thread/a83195d3970a6851/2053cb > >aec > > 1bc1f19?auth=DQAAAHkMDAWnhNnzpuKlwOKZUwAG > >UTt > > T2Ay-EAB7rCY6SnwfnDzZ98M37bZDW2Is0LrBVrr8XEgP > >fcu > > OkiUE-CrSsKbBSX-67voDUXfbATBd0eYNMClezby4EXT2 > >fuL > > m6f0llJ_xMO8BfkjVho_7CZvlf_9tNGnJixTbq8zr21OD > >ZBh ouQ > > > > Alright, I've learned my lesson - don't use a > > new widget; modify the old one. > > > > Except the Entry widget doesn't have a > > disabledforeground option. Neither does the > > Text widget, but IDLE seems to accomplish > > making a disabled Text look the same as an > > enabled Text in the IDLE Help section. > > > > No, foreground (fg) and background (bg) don't > > make a difference; it still changes the color > > of the Entry widget upon disabling. > > > > There must be something I'm missing here... > > My previous post was hasty and we all know, > "Haste makes waste." > > Try this; > > If you use wiget-01.pack_forget() or > wiget-01.grid_forget(), you can now build > wiget-02 using wiget-02.pack or grid() for the > same location. > > You can reinstall uninstalled wigets by using > pack() or grid() again for those hidden wigets. > However only after uninstalling for the wigets > in those locations. > > > > root = Tk() > > test1 = Button(root, text='Test No.1 button', > bg = 'yellow', width = 15, height = 10) > test1.grid(row=0, column=0) > test1.grid_forget() > > > test2 = Button(root, text='Test #2 button', bg > = 'green', width = 15, height = 10) > test2.grid(row=0, column=0) > > mainloop() > > > jim-on-linux > > http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Awesome Python Information
Thanks for the heads up. I spend enough time with the email without having to chase gosts. jim-on-linux http://www.inqvista.com On Sunday 05 November 2006 16:39, Paul McGuire wrote: > "Brandon" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] >groups.com... > > > Check out: www.ChezBrandon.com > > By which he means, "do NOT waste your time > checking out this ridiculous website with > absolutely no Python whatever anywhere." (This > is the idiot who claims he saved the Congress > from some Mossad poison gas attack, or > whatever.) > > -- Paul -- http://mail.python.org/mailman/listinfo/python-list
Re: how do I pass values between classes?
Kath, You can use this class to pass values around without concern for conflicts since it has no values of its own. class Kvariable: def setVariable(self, variable): self.output = variable def showVariable(self): print self.output x = Kvariable() y = Kvariable() x.setVariable("James_01") y.setVariable("Kath_01") x.showVariable() y.showVariable() x.setVariable('3.14159') y.setVariable("python.org") x.showVariable() y.showVariable() jim-on-linux http://www.inqvista.com On Monday 06 November 2006 02:00, kath wrote: > hi, Larry Bates thanks for the reply... > > > You might consider doing it the same way wx > > passes things around. When you instantiate > > the subclass pass the parent class' instance > > as first argument to __init__ method. > > Yes thats absolutely right.. > > > That way the subclass can > > easily pass values back to the parent by > > using that pointer. > > Could you please explain me this.. more > clearly. I think it is much close to the > solution. > > > Thank you. > regards, sudhir -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Tkinter problem
Greg, Run the following code to see how pack_forget() or grid_forget() works, it makes previous widgets disappear but not go away. If you call grid() or pack() again after using grid_forget() the widget returns. root = Tk() class Ktest: def __init__(self): self.Ftest1() def Ftest1(self): try: self.test2.grid_forget() except AttributeError : pass self.test1 = Button(root, text='Push #1 button', bg = 'yellow', width = 25, command = self.Ftest2, height = 25) self.test1.grid(row=0, column=0) def Ftest2(self): self.test1.grid_forget() self.test2 = Button(root, text='Push #2 button', bg = 'green', width = 15, command = self.Ftest1, height = 10) self.test2.grid(row=0, column=0) if __name__== '__main__' : Ktest() mainloop() Maybe someone else has an idea about not defining a variable. My question is how does a budket of wires and screws know its a bucket of wires and screws unless someone tells it that it's a bucket of wires and screws? On Tuesday 07 November 2006 09:35, [EMAIL PROTECTED] wrote: > Hi all, > > I'm trying to write a GUI that will put up > multiple widgets in succession. My problem is > that each widget also contains the previous > widgets when they pop up. How do I reinitialize > the widget each time so that it doesn't contain > earlier ones? Actually, another question I have > is, is there a way to set python so that it > will assume any undefined variable is 0 or ''? > That is, I have several statements like "If k > > 0 then so and so" and I would like it to assume > k=0 unless I tell it otherwise. I've just been > defining k=0 at the start of the program but it > seems there should be a better way. > > Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Simple Tkinter problem
On Tuesday 07 November 2006 10:38, jim-on-linux wrote: Greg, Run the following code to see how pack_forget() or grid_forget() works, it makes previous widgets disappear but not go away. If you call grid() or pack() again after using grid_forget() the widget returns. root = Tk() class Ktest: def __init__(self): self.Ftest1() def Ftest1(self): try: self.test2.grid_forget() except AttributeError : pass self.test1 = Button(root, text='Push #1 button', bg = 'yellow', width = 25, command = self.Ftest2, height = 25) self.test1.grid(row=0, column=0) def Ftest2(self): self.test1.grid_forget() self.test2 = Button(root, text='Push #2 button', bg = 'green', width = 15, command = self.Ftest1, height = 10) self.test2.grid(row=0, column=0) if __name__== '__main__' : Ktest() mainloop() Maybe someone else has an idea about not defining a variable. My question is how does a budket of wires and screws know its a bucket of wires and screws unless someone tells it that it's a bucket of wires and screws? jim-on-linux http://.www.inqvista.com > > > > > > On Tuesday 07 November 2006 09:35, > > [EMAIL PROTECTED] wrote: > > Hi all, > > > > I'm trying to write a GUI that will put up > > multiple widgets in succession. My problem is > > that each widget also contains the previous > > widgets when they pop up. How do I > > reinitialize the widget each time so that it > > doesn't contain earlier ones? Actually, > > another question I have is, is there a way to > > set python so that it will assume any > > undefined variable is 0 or ''? That is, I > > have several statements like "If k > 0 then > > so and so" and I would like it to assume k=0 > > unless I tell it otherwise. I've just been > > defining k=0 at the start of the program but > > it seems there should be a better way. > > > > Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Error:IndentationError: expected an indented block
try this def DoCsubnet1 (action, subject, target, args): pass jim-on-linux http://www.inqvista.com On Wednesday 08 November 2006 10:47, Antonios Katsikadamos wrote: > hi all. I try to run an old python code and i > get the following message > > File "/home/antonis/db/access.py", line 119 > def DoCsubnet1 (action, subject, target, > args): # DoC servers net ^ > IndentationError: expected an indented block > > 1) and I don't know what causes it. I would be > grate full if you could give me a tip. > > 2) how can i overcome it? Can i use the > keyword pass?and if how ccan i use it > > > Kind regards, > > Antonios > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Python deployment options
Rooy, If you are still having problems with py2exe, I suggest you start with the simplest program you can build and include everything in one file. Make that work like the simple examples in the py2exe samples. jim-on-linux http://www.inqvista.com On Wednesday 08 November 2006 22:04, Hieu Hoang wrote: > Hi list, > I have packaged a few pygames to one exe file > with pyinstaller ( http:/ > /pyinstaller.python-hosting.com/ ), sent them > to my friends and the executables > work. Running them shows a Fatal Error dialog > box with only "MSVCR71.DLL", but nothing > breaks, despite whether the system has python > or not. > I haven't been able to figure out py2exe setup > script yet, so I can't compare them. > > Hope this helps, > Rooy -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter check box behaviour - Windows / Linux discrepancy
Peter, You already have an answer to you question but if you want to fancy up your program you could replace; self.chkTest.bind('', self.chkTest_click) > with > self.chkTest.bind('',self.chkTest_click0) or some other acceptable key from the keyboard > def chkTest_click0(self,event): self.chkTest_click() def chkTest_click(self): # read check box state and display appropriate text if self.intTest.get()==0: self.lblTest.config(text='Check box cleared') else: self.lblTest.config(text='Check box set') jim-on-linux http://www.inqvista.com On Thursday 09 November 2006 18:28, peter wrote: > I've come across a weird difference between the > behaviour of the Tkinter checkbox in Windows > and Linux. The issue became apparent in some > code I wrote to display an image in a fixed > size canvas widget. If a checkbox was set then > the image should be shrunk as necessary to fit > the canvas while if cleared it should appear > full size with scrollbars if necessary. > > The code worked fine under Linux (where it was > developed). But under Windows, the first click > in the checkbox did nothing, then subsequent > clicks adjusted the size according to the > PREVIOUS, not the current, checkbox state. > > I've isolated the problem in the code below, > which shows a single checkbox and a label to > describe its state. It works ok under Linux, > but in Windows it is always one click behind. > > Any ideas? I am using >Linux: Fedora Core 3, Python 2.3.4 >Windows: Windows NT, Python 2.3.4 > > Peter > > === >= import Tkinter as tk > > > > class App: > > def __init__(self,frmMain): > > """ > Demonstrate difference in Windows / > Linux handling of check box > > Text in lblTest should track check box > state """ > > # Set up form > > self.intTest=tk.IntVar() > > > self.chkTest=tk.Checkbutton(frmMain,text='Click > me!',variable=self.intTest) > > > self.chkTest.grid(row=0,column=0,padx=5,pady=5, >sticky=tk.W) > > > self.chkTest.bind('',self.chkT >est_click) > > > > > self.lblTest=tk.Label(frmMain,text='Dummy') > > > self.lblTest.grid(row=1,column=0,padx=5,pady=5, >sticky=tk.W) > > > self.chkTest_click() # so as to > initialise text > > def chkTest_click(self,event=None): > # read check box state and display > appropriate text if self.intTest.get()==0: > self.lblTest.config(text='Check box > cleared') else: > self.lblTest.config(text='Check box > set') > > > > > if __name__=='__main__': > > frmMain=tk.Tk() > > app=App(frmMain) > > frmMain.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Press button to load data
Just from a glance my thoughts are to start with one file and build on it. Make a class of it so you can loop it to use it over for each record. You wrote that the info was in a file on the hd. If it is in a file on the hd, use the open() function, read from the file, only one record and write the data to a list. You can incorporate the button option, "command = CallSomeFunction", to call a function that builds a window, and loads the data into labels or entry boxes. If you are going to modify the data, entry boxes allow you to modify it and save it back to a file. Also, when using the open() function, close it after you get the data you need. otherwise you may experience unexpected problems. client = open('client', 'r') client.read() (readline()) (readlines()) client.close() jim-on-linux http//:www.inqvista.com On Wednesday 15 November 2006 23:20, [EMAIL PROTECTED] wrote: > I'm new to Python, and programming in general. > What I'm trying to do here is to load a list of > accounts from a file on my harddrive into a > string of Buttons in Tkinter, and when I press > one of the Buttons, which has one of my account > name, it will load that account into a new > window. But I don't understand how to code the > proccess that would tell the program what > account is selected. Any help with this would > be very appreciated. Thanks in advance. > > from Tkinter import * > import shelve > from tkMessageBox import showerror > > shelvename = shelve.open('class-shelve2') > cat = (' Name ', ' Account # ', ' Amount Due ', > ' Date Due ') > > def NameFields(top): > name1 = Label(None, text=cat[0], > relief=RIDGE, width=20, fg='blue', bg='white', > font=('bold',15)) > name2 = Label(None, text=cat[1], > relief=RIDGE, width=15, fg='blue', bg='white', > font=('bold',15)) > name3 = Label(None, text=cat[2], > relief=RIDGE, width=15, fg='blue', bg='white', > font=('bold',15)) > name4 = Label(None, text=cat[3], > relief=RIDGE, width=15, fg='blue', bg='white', > font=('bold',15)) > name1.grid(row=0, column=0, sticky=NSEW) > name2.grid(row=0, column=1, sticky=NSEW) > name3.grid(row=0, column=2, sticky=NSEW) > name4.grid(row=0, column=3, sticky=NSEW) > top.columnconfigure(0, weight=1) > top.columnconfigure(1, weight=1) > top.columnconfigure(2, weight=1) > top.columnconfigure(3, weight=1) > > > def DisplayBills(top): > c=0 > for bill in shelvename: > bill1 = Button(None, text= > shelvename[bill].name, font=('bold',10), > command=fetchRecord) bill2 = Label(None, text= > shelvename[bill].account, relief=RIDGE, > font=('bold',10)) > bill3 = Label(None, text= > shelvename[bill].paymentDue, relief=RIDGE, > font=('bold',10), fg='red') bill4 = Label(None, > text= shelvename[bill].dateDue, relief=RIDGE, > font=('bold',10)) > bill1.grid(row=c, column=0, > sticky=NSEW) bill2.grid(row=c,column=1, > sticky=NSEW) bill3.grid(row=c,column=2, > sticky=NSEW) bill4.grid(row=c,column=3, > sticky=NSEW) c = c + 1 > > def fetchRecord(): > > top = Tk() > > DisplayBills(top), NameFields(top) > > mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Press button to load data
Without being able to run the code my question is where is the id in the lambda defined? On Thursday 16 November 2006 22:31, jim wrote: > Thanks for your help, but now I have a another > problem so here is my code again > when I run this it prints id> > > from Tkinter import * > import shelve > from tkMessageBox import showerror > > shelvename = shelve.open('class-shelve2') > cat = (' Name ', ' Account # ', ' Amount Due ', > ' Date Due ') > > def NameFields(top): > name1 = Label(None, text=cat[0], > relief=RIDGE, width=20, fg='blue', bg='white', > font=('bold',15)) > name2 = Label(None, text=cat[1], > relief=RIDGE, width=15, fg='blue', bg='white', > font=('bold',15)) > name3 = Label(None, text=cat[2], > relief=RIDGE, width=15, fg='blue', bg='white', > font=('bold',15)) > name4 = Label(None, text=cat[3], > relief=RIDGE, width=15, fg='blue', bg='white', > font=('bold',15)) > name1.grid(row=0, column=0, sticky=NSEW) > name2.grid(row=0, column=1, sticky=NSEW) > name3.grid(row=0, column=2, sticky=NSEW) > name4.grid(row=0, column=3, sticky=NSEW) > top.columnconfigure(0, weight=1) > top.columnconfigure(1, weight=1) > top.columnconfigure(2, weight=1) > top.columnconfigure(3, weight=1) > > > def DisplayBills(top): > c=0 > x = [] > global bill > for bill in shelvename: > global funcs > bill1 = Button(None, text= > shelvename[bill].name, > font=('bold',10),command=(lambda x = id: > fetchRecord(x))) > > bill2 = Label(None, text= > shelvename[bill].account, relief=RIDGE, > font=('bold',10)) > bill3 = Label(None, text= > shelvename[bill].paymentDue, relief=RIDGE, > font=('bold',10), fg='red') bill4 = Label(None, > text= shelvename[bill].dateDue, relief=RIDGE, > font=('bold',10)) > bill1.grid(row=c, column=0, > sticky=NSEW) bill2.grid(row=c,column=1, > sticky=NSEW) bill3.grid(row=c,column=2, > sticky=NSEW) bill4.grid(row=c,column=3, > sticky=NSEW) c = c + 1 > return bill > > def fetchRecord(x): > print x > > > > top = Tk() > > DisplayBills(top), NameFields(top) > > mainloop() > > jim-on-linux wrote: > > Just from a glance my thoughts are to > > start with one file and build on it. Make > > a class of it so you can loop it to use > > it over for each record. > > > > > > You wrote that the info was in a file on > > the hd. If it is in a file on the hd, use the > > open() > > function, read from the file, only one record > > and write the data to a list. > > > > You can incorporate the > > button option, > > > > "command = CallSomeFunction", > > > > to call a function that builds a window, > > and loads the data into labels or > > entry boxes. > > If you are going to modify > > the data, entry boxes allow you to > > modify it and save it back to a > > file. > > > > Also, when using the open() function, > > close it after you get the data you need. > > otherwise you may experience > > unexpected problems. > > > > client = open('client', 'r') > > client.read() (readline()) (readlines()) > > client.close() > > > > jim-on-linux > > > > http//:www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Press button to load data
On Friday 17 November 2006 02:58, you wrote: > On Fri, 17 Nov 2006 00:25:39 -0500, > jim-on-linux <[EMAIL PROTECTED]> > > declaimed the following in comp.lang.python: > > Without being able to run the code my > > question is where is the id in the lambda > > defined? > > Please take into account that I've not > actually used lambdas, so might have some > mistakes in the syntax... > > > > for bill in shelvename: > > > global funcs > > > bill1 = Button(None, text= > > > shelvename[bill].name, > > > font=('bold',10),command=(lambda x = id: > > > fetchRecord(x))) > > "id" would be something that "identifies" the > button... In this case, maybe you can use > "bill": > Think about relating a Tkinter variable to each button then the button is related to a unique variable. ( Tkinter StingVar or IntVar or some others.) Then you will have to keep the variables in a list or dictionary for recalling. jim-on-linux http://www.inqvista.com > ... command=(lambda x = bill: fetchRecord(x)) > ... > > As I understand the lambda syntax, what this > does is create a "function" (which is the > command that gets run when the button is > pushed), and this function will call > fetchRecord passing it the value that "x" had > at the time of definition (hence the x=...) > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support > Staff:[EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Caution newbie question: python window to stay open ?
Michael, put this at the top of your code. After the window closes read the testLog.out file. It may give you a clue as to what is happening. sys.stdout = open('testLog.out', 'w') jim-on-linux http://www.inqvista.com On Tuesday 21 November 2006 22:20, mkengel wrote: > Caution: newbie question > > I am using python 2.4.3-11 on Windows XP. > Problem: Python window closes immediately after > executing a *.py file (e.g. containing a > "print..." command. What do I have to do to > keep it open to see the results ? > > "Interactive window" stays open. > > Thank you. > Michael -- http://mail.python.org/mailman/listinfo/python-list
Re: Access to variable from external imported module
GinTon, I think this is what you want. class Kdoi: def __init__(self) : self.Fdo() def Fdo(self): searchterm = 'help' print searchterm #local self.searchterm = searchterm print self.searchterm #used inside the class Kdo.searchterm = searchterm #<<<< print Kdo.searchterm #used outside the class Kdomore() class Kdomore(Kdo): def __init__(self) : self.Fdomore() def Fdomore(self): searchterm = Kdo.searchterm # <<<< print searchterm jim-on-linux http://www.inqvista.com On Thursday 23 November 2006 17:09, GinTon wrote: > Sorry, I mean access to local variable from a > method > > import module > method(value) > > I would to access to values that are created > locally in that method > > Fredrik Lundh ha escrito: > > GinTon wrote: > > > How to access to a variable (that value is > > > not returned) from a module imported? > > > And the variable is set at the > > > module-level. > > > >import module > >print module.variable > > > > (have you read the Python tutorial?) > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Access to variable from external imported module
On Friday 24 November 2006 03:30, John Machin wrote: > jim-on-linux wrote: > > GinTon, > > > > I think this is what you want. > > > > > > class Kdoi: > > Is that a typo? No, it's a style. life seems to be easier to me if one is consistent, all my classes begin with K. > > >def __init__(self) : > >self.Fdo() > > What is all this K and F stuff? > It's my style. life seems to be easier to me if one is consistent all my function begin with F. I started doing things like this when the only way to debug was to read each line of code and try to figgure out if it was the problem. They are my personal sign posts. > >def Fdo(self): > > > > searchterm = 'help' > > print searchterm #local > > > > self.searchterm = searchterm > > print self.searchterm #used inside the > > class > > > > Kdo.searchterm = searchterm #<<<< > > print Kdo.searchterm #used outside the > > class Kdomore() > > > > > > > > class Kdomore(Kdo): > > def __init__(self) : > > self.Fdomore() > > > > def Fdomore(self): > > searchterm = Kdo.searchterm # > > <<<< print searchterm > > It's not apparent what the print statements are > for -- are they part of an attempt to debug > your code? > print shows the results wherever a print statement turns up the results = 'help' . I didn't run the code, and it has it has a coding error but if removed, the results should be; searchterm = 'help' self.searchterm = 'help' Kdo.searchterm = 'help' Sound silly but many people have trouble with getting a variable from here to there in their code. This shows that it can be done > What gives you the idea that this is what the > OP wants or needs? If I remember right, he refrased his first question and asked a second one. Sometimes people don't take the time to write correctly, the questions that are really in their mind. So I guessed. If Im wrong, he will ignore it. If I'm right, he will use it. Also, I have found that other will latch on to the ideas presented in these email responses. And they will use them, even though the response was not exactly what the original emailer wanted. And, I sometimes I do use print statements to debug, I have used other ways but on linux, I prefer a print statement. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Access to variable from external imported module
On Friday 24 November 2006 13:01, jim-on-linux wrote: > On Friday 24 November 2006 03:30, John Machin > > wrote: > > jim-on-linux wrote: > > > GinTon, > > > > > > I think this is what you want. > > > > > > > > > class Kdoi: > > > > Is that a typo? > >No, it's a style. life seems to be > easier to me if one is consistent, all my > classes begin with K. Sorry, Kdoi should be Kod > > > >def __init__(self) : > > >self.Fdo() > > > > What is all this K and F stuff? > >It's my style. life seems to be easier to > me if one is consistent all my function begin > with F. > > I started doing things like this when the only > way to debug was to read each line of code and > try to figgure out if it was the problem. > They are my personal sign posts. > > > >def Fdo(self): > > > > > > > > > searchterm = 'help' > > > print searchterm #local > > > > > > self.searchterm = searchterm > > > print self.searchterm #used inside the > > > class > > > > > > Kdo.searchterm = searchterm #<<<< > > > print Kdo.searchterm #used outside the > > > class Kdomore() the line above should be Kdomore(), not class Kdomore() (For the technocrats) > > > > > > > > > > > > class Kdomore(Kdo): > > > def __init__(self) : > > > self.Fdomore() > > > > > > def Fdomore(self): > > > searchterm = Kdo.searchterm # > > > <<<< print searchterm > > > > It's not apparent what the print statements > > are for -- are they part of an attempt to > > debug your code? > > print shows the results wherever a print > statement turns up the results = 'help' . > I didn't run the code, and it has it has a > coding error but if removed, the results should > be; > >searchterm = 'help' >self.searchterm = 'help' >Kdo.searchterm = 'help' > >Sound silly but many people have trouble > with getting a variable from here to there in > their code. This shows that it can be done > > > What gives you the idea that this is what the > > OP wants or needs? > > If I remember right, he refrased his first > question and asked a second one. > Sometimes people don't take the time to write > correctly, the questions that are really in > their mind. So I guessed. If Im wrong, he will > ignore it. If I'm right, he will use it. > > Also, I have found that other will latch on to > the ideas presented in these email responses. > And they will use them, even though the > response was not exactly what the original > emailer wanted. > > And, I sometimes I do use print statements to > debug, I have used other ways but on linux, I > prefer a print statement. > jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Access to variable from external imported module
On Friday 24 November 2006 13:20, jim-on-linux wrote: > On Friday 24 November 2006 13:01, jim-on-linux > > wrote: > > On Friday 24 November 2006 03:30, John Machin > > > > wrote: > > > jim-on-linux wrote: > > > > GinTon, > > > > > > > > I think this is what you want. > > > > > > > > > > > > class Kdoi: > > > > > > Is that a typo? > > > >No, it's a style. life seems to be > > easier to me if one is consistent, all my > > classes begin with K. > > Sorry, Kdoi should be Kod Sorry again Kdoi should be Kdo (Haste makes waste.) > > > > >def __init__(self) : > > > >self.Fdo() > > > > > > What is all this K and F stuff? > > > >It's my style. life seems to be easier to > > me if one is consistent all my function begin > > with F. > > > > I started doing things like this when the > > only way to debug was to read each line of > > code and try to figgure out if it was the > > problem. They are my personal sign posts. > > > > > >def Fdo(self): > > > > > > > > > > > > searchterm = 'help' > > > > print searchterm #local > > > > > > > > self.searchterm = searchterm > > > > print self.searchterm #used inside > > > > the class > > > > > > > > Kdo.searchterm = searchterm #<<<< > > > > print Kdo.searchterm #used outside > > > > the class Kdomore() > > the line above should be Kdomore(), not class > Kdomore() (For the technocrats) > > > > > class Kdomore(Kdo): > > > > def __init__(self) : > > > > self.Fdomore() > > > > > > > > def Fdomore(self): > > > > searchterm = Kdo.searchterm # > > > > <<<< print searchterm > > > > > > It's not apparent what the print statements > > > are for -- are they part of an attempt to > > > debug your code? > > > > print shows the results wherever a print > > statement turns up the results = 'help' . > > I didn't run the code, and it has it has a > > coding error but if removed, the results > > should be; > > > >searchterm = 'help' > >self.searchterm = 'help' > >Kdo.searchterm = 'help' > > > >Sound silly but many people have trouble > > with getting a variable from here to there in > > their code. This shows that it can be done > > > > > What gives you the idea that this is what > > > the OP wants or needs? > > > > If I remember right, he refrased his first > > question and asked a second one. > > Sometimes people don't take the time to write > > correctly, the questions that are really in > > their mind. So I guessed. If Im wrong, he > > will ignore it. If I'm right, he will use > > it. > > > > Also, I have found that other will latch on > > to the ideas presented in these email > > responses. And they will use them, even > > though the response was not exactly what the > > original emailer wanted. > > > > And, I sometimes I do use print statements to > > debug, I have used other ways but on linux, I > > prefer a print statement. > jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Access to variable from external imported module
On Friday 24 November 2006 13:41, John Machin wrote: > jim-on-linux wrote: > > On Friday 24 November 2006 03:30, John Machin > > > > wrote: > > > jim-on-linux wrote: > > > > GinTon, > > > > > > > > I think this is what you want. > > > > > > > > > > > > class Kdoi: > > > > > > Is that a typo? > > > >No, it's a style. life seems to be > > easier to me if one is consistent, all my > > classes begin with K. > > and end with "i"? > > > > >def __init__(self) : > > > >self.Fdo() > > > > > > What is all this K and F stuff? > > > >It's my style. life seems to be easier to > > me if one is consistent all my function begin > > with F. > > You left out a word; the correct way of > phrasing that is: "All my function _are_ begin > with F" :-) No, for Non-Hungrian programmers it's "all-ah me" Functions gona begin witha F, not Func. anda "all-ah-me" classes gona begin witha K, not Klas. Anda only me gona Know the Fdiff cause me codea is not opena. Anda I finda that it savea me time causea I doa thisa way fora a longa time. Whena I gonna hava to changea maybe I willa. > > This appears to be a variation on "Hungarian > notation"; google that for opinions pro & con. > > In a certain vernacular, it would be called "an > effed concept" :-) > > > I started doing things like this when the > > only way to debug was to read each line of > > code and try to figgure out if it was the > > problem. > > When was that? That was when bill gates just left Harvard, basic was brand new, and 4k of memory was installed free when you bought a computer, (TRS80), my first,. Assemble was the alternative to Basic and you had to backup on tape because floppies didn't exist. And, most people on this site wern't even a gleem in their fathers eye. > Even years ago, there were > slightly better ways. For example, my first > boss' boss was an enthusiastic coder and > debugger and also a workaholic. Colleagues who > lived along the same railway line as he and > were foolish enough not to hide behind a > newspaper could have their morning or evening > reverie disturbed by a cry of "Glad you're > here! I'll hold the listing, you hold the > dump!". I get the impression that debugging > techniques have moved along a little bit since > then. :-) > > > They are my personal sign posts. > > > > > >def Fdo(self): > > > > > > > > > > > > searchterm = 'help' > > > > print searchterm #local > > > > > > > > self.searchterm = searchterm > > > > print self.searchterm #used inside > > > > the class > > > > > > > > Kdo.searchterm = searchterm #<<<< > > > > print Kdo.searchterm #used outside > > > > the class Kdomore() > > > > > > > > > > > > > > > > class Kdomore(Kdo): > > > > def __init__(self) : > > > > self.Fdomore() > > > > > > > > def Fdomore(self): > > > > searchterm = Kdo.searchterm # > > > > <<<< print searchterm > > > > > > It's not apparent what the print statements > > > are for -- are they part of an attempt to > > > debug your code? > > > > print shows the results wherever a print > > statement turns up the results = 'help' . > > I didn't run the code, and it has it has a > > coding error > > I noticed. > > > but if removed, the results should be; > > > >searchterm = 'help' > >self.searchterm = 'help' > >Kdo.searchterm = 'help' Correct but when writing one must be clear. Would it be better for me to write, your question above was Is that a typo? Or is it better if I were to write, your question above, "Is that a typo?", is a legimate question, but not clear. So, to be clear one might write is "Kdoi" correct?. A clear response would be, it is not "Kdoi", it is "Kdo". But that's not correct either, it is Kdo. If one runs the code I don't expect the user to look for "help", I think we will see help and will THINK that the results are correct. THINK is also incorrect, it should be written. think, or should it? > No, the result would be > help > help &
Re: Access to variable from external imported module
The TRS-80 I bought came with both Basic and Assembly Language teaching guides, and that was it. To make the machine work one had to program. I didn't mean to imply that Bill Gates developed it. It's well known that MS borrowed stuff when they needed to from where ever the could get it. That's business. I'm not an MS fan but Bill Gates was the one who gave away a very cheep, borrowed but improved, copy of DOS to computer sellers. These copies could also be copied to floppies (8 inch). So, DOS 3.3 was used by computer sellers, to install DOS on the buyers machine, (intel 286) free. On the other hand, IBM sold the same package for $50.00. I got the free copy of MS 3.3 with my 286. After that, Windows 3.0 cost me $25.00, Windows 3.1 cost me $30.00, DOS upgrade from3.3 to 6.22 cost me $55.00. Since then I purchased Win 95, $100.00 and Win 98. $125.00. And, all for testing software that I produced for people that use that stuff. Bill Gates probably can't program any software to write "Hello World" on any screen, but I'll bet he knows how to fill out a deposit ticket. I think Bill Gates recognize early that the money is in the marketing of the product, not the programming of it. How else can you explain the success of Windows, like it or not? jim-on-linux http://www.inqvista.com On Friday 24 November 2006 17:18, Dennis Lee Bieber wrote: > On Fri, 24 Nov 2006 16:56:58 -0500, > jim-on-linux <[EMAIL PROTECTED]> > > declaimed the following in comp.lang.python: > > That was when bill gates just left Harvard, > > basic was brand new, and 4k of memory was > > Pardon? I'd learned BASIC back around 1972, in > the 9th grade, using an ASR-33 with dial-up to > some company's Honeywell-Bull system. > > BASIC is one of the ancients in languages, > predating Pascal and C. > > Just because Gates managed to scrabble > together a BASIC interpreter for the MITS > Altair, and then had it picked up by other > makers of 8080/Z-80 based "microcomputers" > doesn't make it "brand new". (Personally, I > suspect he hasn't done any programming ever > since that day, and is probably still trying to > find some way to sue Kemeny&Kurtz (sp?s) over > their own creation) > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support > Staff:[EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Several entries on Tile and TableList at the Tkinter wiki
Thanks for posting this entry, The fact that a wiki or help site doesn't get a lot of traffic is not an necessarily an indicator of it's usfulness. It indicates to me that the product, in this case Tkinter, may be easy to use and understand, after working with it a little, A lot of help may not be necessary. A good example is the py2exe help site. At one time not to long ago there might be 8 to 12 post per day, or more. Today by my unscientific count method, I don't think there are more than 3 to 4 post per week. Yet, py2exe and Tkinter is almost as valuable as Python. If we couldn't build programs for Windows, where would a python programmes's money come from? Thanks again, jim-on-linux http://www.inqvista.com On Sunday 26 November 2006 15:50, Kevin Walzer wrote: > I'm not sure how often members of this list > visit the Tkinter wiki at > http://tkinter.unpythonic.net/wiki/FrontPage; > this wiki seems to have less traffic in general > than the Tcl/Tk wiki at http://wiki.tcl.tk. > Given that, I hope it's not out of line for me > to call attention to several pages that I've > posted about integrating Tile > (http://tktable.sourceforge.net/tile) and > TableList (http://www.nemethi.de, > http://wiki.tcl.tk/5527) into Tkinter > applications. I've noted a serious lack of > resources/documentation about these two > powerful Tk components. In addition to some > documentation, screenshots, and sample > applications, I've posted updated versions of > the original TableList and Tile wrappers by > Martin Franklin. > > I should take this moment to thank Mr. Franklin > for his work on these wrappers; whatever I > added to them was pretty minimal compared to > the heavy lifting he did. He originally posted > them on the Internet last year, but the site > that hosted them has gone dark. Anyway, Mr. > Franklin, if you are reading this, thank you > for your hard work; it has been enormously > helpful. I hope my own efforts extend your work > and make it even more useful for other Tkinter > developers. > > Here are the links: > > http://tkinter.unpythonic.net/wiki/UsingTile > http://tkinter.unpythonic.net/wiki/TileWrapper > http://tkinter.unpythonic.net/wiki/TableListWra >pper > http://tkinter.unpythonic.net/wiki/TableListTil >eWrapper > http://tkinter.unpythonic.net/wiki/PyLocateTile > http://tkinter.unpythonic.net/wiki/PyLocate > > Hope these prove useful to others, as starting > points for your own work if nothing else. > Corrections and improvements are of course > invited; it's a wiki! > > > -- > Kevin Walzer > Code by Kevin > http://www.codebykevin.com -- http://mail.python.org/mailman/listinfo/python-list
Re: odict the Ordered Diction 0.2.2
Thanks for the post, Its become a part time job keeping up with updates. jim-on-linux http://www.inqvista.com On Wednesday 29 November 2006 09:41, Fuzzyman wrote: > After a break of almost a year there has been > an update to `odict the Ordered Dictionary > <http://www.voidspace.org.uk/python/odict.html> >`_. > > The latest version is 0.2.2, with changes > implemented by Nicola Larosa. > > Despite over 700 downloads since May (plus 1300 > as part of `pythonutils > <http://www.voidspace.org.uk/python/pythonutils >.html>`_) there have been no bug reports, only > improvements [#]_. {sm;:-)} > > * `Quick Download > <http://www.voidspace.org.uk/cgi-bin/voidspace/ >downman.py?file=odict.py>`_ > > What is odict? > == > > **odict** is a pure Python implementation of an > ordered dictionary. It keeps keys in insertion > order and allows you to change the order. > Methods (including iteration) that would return > members in an arbitrary order are now ordered. > > There is also the `SequenceOrderedDict > <http://www.voidspace.org.uk/python/odict.html# >sequenceordereddict>`_ that behaves like a > sequence as well as a dictionary. It allows > slicing and the keys, values and items methods > are special sequence objects (which are also > callable and so behave as methods too). > > What's New ? > == > > Code > --- > > Removed the TODO and CHANGELOG sections in the > tail docstring (they are in the docs anyway). > > Disabled warnings during tests. > > Explicitly disabled tests execution on Python > v.2.2 . In addition to the slicing tests, other > ones are failing. > > Removed code duplication between the > ``__init__`` and the ``update`` methods. > > Misc. cleanup. > > Also, based on code from `Tim Wegener`_: > > - added the ``rename`` method; > - removed a ``has_key`` usage in the > ``__setitem__`` method. > > > Documentation > -- > > Moved the ISSUES chapter from code's tail > docstring to here. > > Moved up the `Creating an Ordered Dictionary > <http://www.voidspace.org.uk/python/odict.html# >creating-an-ordered-dictionary>`_ chapter. > > Added prompts to the code examples and removed > the superfluous print statements (sometimes > they were there, sometimes they were not). > > Misc. cleanup. > > .. [#] So either no-one is using it, or it's > really good... -- http://mail.python.org/mailman/listinfo/python-list
Re: shtoom making PC2Phone calls
On Thursday 30 November 2006 12:35, Croteam wrote: > Hello, > > Can somebody give me shtoom examples or source > code for making PC2Phone calls and pc to pc > calls. (if you give me source code,please give > me full url to that source or send me to email: >[EMAIL PROTECTED]) > >Thanks,I will really > appreciate that Try, http://pyserial.sourceforge.net/ Many examples. I've used some of the examples to connect pc to pc. And with phone attached, you can to talk with someone on the other end. Search using serial port. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: shtoom making PC2Phone calls
Forgot to include, Check out pyserial-2-2 at sourceforge.net/ by Chris Liechti On Thursday 30 November 2006 21:07, jim-on-linux wrote: > On Thursday 30 November 2006 12:35, Croteam wrote: > > Hello, > > > > Can somebody give me shtoom examples or > > source code for making PC2Phone calls and pc > > to pc calls. (if you give me source > > code,please give me full url to that source > > or send me to email: [EMAIL PROTECTED]) > > > >Thanks,I will > > really appreciate that > > Try, > http://pyserial.sourceforge.net/ > > Many examples. I've used some of the examples > to connect pc to pc. And with phone attached, > you can to talk with someone on the other end. > > Search using serial port. > > > jim-on-linux > http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Python, PostgreSQL, What next?
Before commiting to a RDBMS take a look at Gadfly. Depending on what you need a RDB for, (light duty), or (heavy duty) take a look at gadfly. Gadfly is made from all python code. Use stardard SQL statements like Select, Create and Drop Tables, etc. Newest version GadflyB5 http://gadfly.sourceforge.net/ jim-on-linux http://www.inqvista.com On Saturday 02 December 2006 11:33, Thomas Bartkus wrote: > On Fri, 01 Dec 2006 23:04:37 -0800, vbgunz wrote: > > Hello all, > > > > I've studied Python and studied PostgreSQL. > > What is the absolute next best step to take > > to merge these two finely together? I've > > heard of SQLAlchemy and some others but > > before I dive in, I would really like the > > opinion of those who tried it and other > > toolkits. > > > > My main concern is, I would like to > > completely work with a database from Python. > > What would you suggest I look into? > > Let me venture that the biggest problem most > people seem to have is that they endure great > pain just to avoid learning SQL. SQL is a > complete programming language in and of itself > with a breadth and depth that most people miss. > And it covers much terrain missed by Python. > Which is a good thing because SQL and Python > are perfect together. With this language mix > you've got darn near everything licked. > > Get SQL in your head and all you will need > would be the db-api interface with Postgres > that Frederick Lundh pointed you to. All you > want to do is throw SQL commands at Postgres > and recover result sets into Python. > > It's a cinch. > Thomas Bartkus -- http://mail.python.org/mailman/listinfo/python-list
Re: writing serial port data to the gzip file
If someone hasn't already commented, Aside from any other problems, the file you are trying to write to is (opened)?? in the "w" mode. Every time a file is opened in the 'w' mode, everything in the file is deleted. If you open a file in the 'a' mode, then everything in the file is left untouched and the new data is appended to the end of the file. Your while loop is deleting everything in the file on each loop with the 'w' mode. try, vfile = open('vfile', 'a') rather than vfile = open('vfile', 'w') jim-on-linux http:\\www.inqvista.com > while 1: > g=gzip.GzipFile("/root/foofile.gz","w") > while dataOnSerialPort(): > g.write(data) > else: g.close() On Sunday 17 December 2006 20:06, Petr Jakes wrote: > I am trying to save data it is comming from the > serial port continually for some period. > (expect reading from serial port is 100% not a > problem) Following is an example of the code I > am trying to write. It works, but it produce an > empty gz file (0kB size) even I am sure I am > getting data from the serial port. It looks > like g.close() does not close the gz file. > I was reading in the doc: > > Calling a GzipFile object's close() method does > not close fileobj, since you might wish to > append more material after the compressed > data... > > so I am completely lost now... > > thanks for your comments. > Petr Jakes > snippet of the code > def dataOnSerialPort(): > data=s.readLine() > if data: > return data > else: > return 0 > > while 1: > g=gzip.GzipFile("/root/foofile.gz","w") > while dataOnSerialPort(): > g.write(data) > else: g.close() -- http://mail.python.org/mailman/listinfo/python-list
Easiest way to print from XP/DOS.
This is the situation I'm in. I've built a single file utility using py2exe. I zip the dist directory and send it to the client. For clients that use win95, win98 machines, They unpack the zip file and run the exe. The utility creates a text file that is sent to the printer with the statement below. os.system('type ' +FileName+ ' >prn'), and the file prints. But, from an xp machine if I try to print using the same statement, I get a question on the dos screen which reads something like this; Which program authorized this operation? Since I don't have an xp machine, the statement above may not be exact, but you get the idea. The question I have is, first is there any way to work around the question asked by the xp machine using python. If not, I may have to register the package in xp, if registering the utility the only way, which package is the simplest to use. Also, if the utility is registered in xp, will the same statement send the file to the printer as it does in win98. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to print from XP/DOS.
Did you run from a file or type in from keyboard? When the client runs the utility program the output file is built but nothing prints and no messages appear. When I typed from keyboard on an xp pro at c:\, I got the message. Is it possible that virus detector or some self.defense software is interacting? On Friday 29 December 2006 17:58, Larry Bates wrote: > jim-on-linux wrote: > > This is the situation I'm in. > > > > I've built a single file utility using > > py2exe. I zip the dist directory and send it > > to the client. > > > > For clients that use win95, win98 machines, > > They unpack the zip file and run the exe. > > > > The utility creates a text file that is sent > > to the printer with the statement below. > > os.system('type ' +FileName+ ' >prn'), and > > the file prints. > > > > But, from an xp machine if I try to print > > using the same statement, I get a question > > on the dos screen which reads something like > > this; Which program authorized this > > operation? > > > > Since I don't have an xp machine, the > > statement above may not be exact, but you get > > the idea. > > > > The question I have is, first is there any > > way to work around the question asked by the > > xp machine using python. > > > > If not, I may have to register the package in > > xp, if registering the utility the only way, > > which package is the simplest to use. > > Also, if the utility is registered in xp, > > will the same statement send the file to the > > printer as it does in win98. > > > > jim-on-linux > > I don't get any such message on my XP Pro > Service Pack 2 system here using your method. > > -Larry -- http://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to print from XP/DOS.
Thanks, The client is in a one printer office. If the output file is opened with note and then sent to the printer everything is fine but it defeats the purpose of the utility. Also tried > lpt1 but the same results. I'm trying to find out if this was some change in xp from previous versions, or is there something abnormal going on. I'm trying to avoid setting up an xp machine for one client. jim-on-linux On Saturday 30 December 2006 03:05, Tim Roberts wrote: > jim-on-linux <[EMAIL PROTECTED]> wrote: > >Did you run from a file or type in from > > keyboard? > > > >When the client runs the utility program the > >output file is built but nothing prints and no > >messages appear. When I typed from keyboard on > > an xp pro at c:\, I got the message. > > > >Is it possible that virus detector or some > >self.defense software is interacting? > > It is quite possible that they simply do not > have a printer hooked up to their computer's > parallel port. If all of your printers are > from network shares, then the special file > "prn" will not go anywhere. > > Typing to "prn" is a dreadful way to do > printing on Windows. -- > Tim Roberts, [EMAIL PROTECTED] > Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list
Re: Easiest way to print from XP/DOS.
Thanks, However, using note to print is a problem. First, because note adds a header( file name etc.) to the printed output that is not acceptable. Next, the number of files is 200 to 300 per day. The idea of the utility is to eliminate the operator. But, if you have a virus detector that stops the operation then I think I may have to install the program as opposed to unzipping and running the exe file. On Saturday 30 December 2006 01:33, Tom Plunker wrote: > jim-on-linux wrote: > > When the client runs the utility program the > > output file is built but nothing prints and > > no messages appear. > > If the file has a '.txt' extension, you could > try os.system'ing "start ", which'll > make the file pop open with notepad (or > whatever happens to be associated with TXT > files), from which the user would need to press > Ctrl-P to make it print. > > > Is it possible that virus detector or some > > self.defense software is interacting? > > Quite. I run firewall software on my PC that > alerts me when a program is trying to launch > another program. The message that it gives is > not entirely unlike the one you gave me. > > To diagnose further, you could have the victim > send you a screenshot to see what's really > going on. With Outlook, it's as easy as > hitting the Print Screen button (when the > message is visible) and pasting the clipboard > into an email. Alternatively, they paste into > MS Paint, save the bitmap somewhere, and mail > that to you. > > Good luck, > -tom! > > -- -- http://mail.python.org/mailman/listinfo/python-list
Re: where is python on linux?
on linux type: whereis python You should get a list of directories where all of python lives. jim-on-linux http:\\www.inqvista.com On Sunday 07 January 2007 04:05, Frank Potter wrote: > I installed fedora core 6 and it has python > installed. But the question is, where is the > executable python file? I can't find it so I > come here for help. I want to config pydev for > eclipse and I need to know where the ececutable > python file is. > Thank you! -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter - resize tkMessageBox
On Monday 04 June 2007 16:29, [EMAIL PROTECTED] wrote: > Hi, > Is there a way to resize the width of the > "tkMessageBox.askyesno" dialog box, so that the > text does not wrap to the next line. Thanks > Rahul I don't know of any. It's a little more work but your better off using Toplevel and/or frame, you have more control over the window and its appearance. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: shelve crashing under Win ME
On Saturday 30 June 2007 04:52, [EMAIL PROTECTED] wrote: > Hi, > > I'm not a Win ME fan myself (I'm a Mac user), > but I'm here in Thailand developing software > for special-needs kids, and the test PC in my > home office is a Win ME machine (sigh). So when > I ported my Python program today to the PC, it > quickly crashed. Everything seems to work > except for shelve. Using the latest version of > Python (2.5.1), when I do the following in IDLE > on the Win ME machine here's the result: > > Python 2.5.1 (r251:54863, Apr 18 2007, > 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 > IDLE 1.2.1 > > >>> import shelve > >>> f=shelve.open("foo") > > Traceback (most recent call last): > File "", line 1, in > f=shelve.open("foo") > File "C:\PYTHON25\lib\shelve.py", line 225, > in open return DbfilenameShelf(filename, flag, > protocol, writeback) > File "C:\PYTHON25\lib\shelve.py", line 209, > in __init__ > Shelf.__init__(self, anydbm.open(filename, > flag), protocol, writeback) > File "C:\PYTHON25\lib\anydbm.py", line 83, in > open return mod.open(file, flag, mode) > File "C:\PYTHON25\lib\dbhash.py", line 16, in > open return bsddb.hashopen(file, flag, mode) > File "C:\PYTHON25\lib\bsddb\__init__.py", line > 306, in hashopen > d.open(file, db.DB_HASH, flags, mode) > DBError: (5, 'Input/output error') > > > For those who know shelve, this should actually > run fine (if the file "foo" does not exist it > should create it). Printing the value of "f" > should show an empty dictionary {}. > > It does run fine on my iBook (under Python > 2.4.4) and on my iBook's Virtual PC running Win > XP & Python 2.5.0. I do not think this is a > Python 2.5.1 problem, because my first attempt > to run my program on the Win ME machine was > with a version of the program I ported using > Py2exe on the VPC under Python 2.5.0, and it > crashed the same way when run on the Win ME > machine (I subsequently installed Python on the > Win ME PC to try to get to the root of the > problem.) > > Help! How do I get Win ME (or at least the > misbehaving Win ME machine in my office) to run > shelve? (or more specifically run bsddb's > hashopen?) > > Or should I trash shelve entirely and rewrite > all my code to use a simpler, homemade database > scheme? > > Thanks for any advice! > > Warmly, > Joel > [EMAIL PROTECTED] what version of py2exe are you using? I had a similar problem with an old version of py2exe but it it is fixed now. If my memory is correct I had to import dbhash into my setup for py2exe back then to fix it.. Your code for shelve is correct, the problem is someplace else. jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: shelve crashing under Win ME
On Saturday 30 June 2007 10:07, jim-on-linux wrote: > On Saturday 30 June 2007 04:52, > [EMAIL PROTECTED] > > wrote: > > Hi, > > > > I'm not a Win ME fan myself (I'm a Mac user), > > but I'm here in Thailand developing software > > for special-needs kids, and the test PC in my > > home office is a Win ME machine (sigh). So > > when I ported my Python program today to the > > PC, it quickly crashed. Everything seems to > > work except for shelve. Using the latest > > version of Python (2.5.1), when I do the > > following in IDLE on the Win ME machine > > here's the result: > > > > Python 2.5.1 (r251:54863, Apr 18 2007, > > 08:51:08) [MSC v.1310 32 bit (Intel)] on > > win32 IDLE 1.2.1 > > > > >>> import shelve > > >>> f=shelve.open("foo") > > > > Traceback (most recent call last): > > File "", line 1, in > > f=shelve.open("foo") > > File "C:\PYTHON25\lib\shelve.py", line 225, > > in open return DbfilenameShelf(filename, > > flag, protocol, writeback) > > File "C:\PYTHON25\lib\shelve.py", line 209, > > in __init__ > > Shelf.__init__(self, > > anydbm.open(filename, flag), protocol, > > writeback) > > File "C:\PYTHON25\lib\anydbm.py", line 83, > > in open return mod.open(file, flag, mode) > > File "C:\PYTHON25\lib\dbhash.py", line 16, in > > open return bsddb.hashopen(file, flag, mode) > > File "C:\PYTHON25\lib\bsddb\__init__.py", > > line 306, in hashopen > > d.open(file, db.DB_HASH, flags, mode) > > DBError: (5, 'Input/output error') > > > > > > For those who know shelve, this should > > actually run fine (if the file "foo" does not > > exist it should create it). Printing the > > value of "f" should show an empty dictionary > > {}. > > > > It does run fine on my iBook (under Python > > 2.4.4) and on my iBook's Virtual PC running > > Win XP & Python 2.5.0. I do not think this is > > a Python 2.5.1 problem, because my first > > attempt to run my program on the Win ME > > machine was with a version of the program I > > ported using Py2exe on the VPC under Python > > 2.5.0, and it crashed the same way when run > > on the Win ME machine (I subsequently > > installed Python on the Win ME PC to try to > > get to the root of the problem.) > > > > Help! How do I get Win ME (or at least the > > misbehaving Win ME machine in my office) to > > run shelve? (or more specifically run bsddb's > > hashopen?) > > > > Or should I trash shelve entirely and rewrite > > all my code to use a simpler, homemade > > database scheme? > > > > Thanks for any advice! > > > > Warmly, > > Joel > > [EMAIL PROTECTED] > > what version of py2exe are you using? > > I had a similar problem with an old version of > py2exe but it it is fixed now. If my memory is > correct I had to import dbhash into my setup > for py2exe back then to fix it.. > > Your code for shelve is correct, the problem is > someplace else. > > > jim-on-linux > http:\\www.inqvista.com Correction: I had to import dbhash into my program to make things work. jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
PY shutil on win xp home version
python help, A client is using win xp home. my program contains; shutil.copyfile(n, 'prn') This runs fine on win xp pro but they are getting the following traceback. File "LOP_PRT_10.pyc", line 170, in __init__ File "LOP_PRT_10.pyc", line 188, in Fprint1 File "shutil.pyc", line 47, in copyfile IOError: [Errno 2] No such file or directory: 'prn' Since this runs ok on win xp pro, does this have something to do with the home version of xp. I'm thinking of changeing 'prn' to 'lpt1' and trying again but I don't want to use the client as a testor. Or is there some other explaination for the problem. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: PY shutil on win xp home version
On Wednesday 18 April 2007 17:02, Tim Golden wrote: > jim-on-linux wrote: > > python help, > > > > A client is using win xp home. > > > > my program contains; > >shutil.copyfile(n, 'prn') > > > > This runs fine on win xp pro but they are > > getting the following traceback. > > > > File "LOP_PRT_10.pyc", line 170, in __init__ > > File "LOP_PRT_10.pyc", line 188, in Fprint1 > > File "shutil.pyc", line 47, in copyfile > > IOError: [Errno 2] No such file or directory: > > 'prn' > > > > Since this runs ok on win xp pro, does this > > have something to do with the home version of > > xp. > > > > I'm thinking of changeing 'prn' to 'lpt1' > > and trying again but I don't want to use the > > client as a testor. Or is there some other > > explaination for the problem. > > Not that this is your question, but if you're > trying to print under Windows have you looked > at: > > > http://tgolden.sc.sabren.com/python/win32_how_d >o_i/print.html > > for alternatives? > > TJG Thanks for the response, I got the following to work on windows. win32api.ShellExecute ( 0, 'print', filename, None, ".", 0 ) However it prints the name of the file at the top and adds a page number on the bottom. Is there some way of eliminating the filename and page number. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: PY shutil on win xp home version
Thanks Tim for resopnding, I appreciate the help. I convinced the client to install Linux on 4 machines rather than upgrade from xp home to XP Pro, and more machines to come if the like it. jim-on-linux On Friday 20 April 2007 03:22, you wrote: > jim-on-linux wrote: > > On Wednesday 18 April 2007 17:02, Tim Golden > > > > wrote: > >> jim-on-linux wrote: > >>> python help, > >>> > >>> A client is using win xp home. > >>> > >>> my program contains; > >>>shutil.copyfile(n, 'prn') > >>> > >>> This runs fine on win xp pro but they are > >>> getting the following traceback. > >>> > >>> File "LOP_PRT_10.pyc", line 170, in > >>> __init__ File "LOP_PRT_10.pyc", line 188, > >>> in Fprint1 File "shutil.pyc", line 47, in > >>> copyfile IOError: [Errno 2] No such file or > >>> directory: 'prn' > >>> > >>> Since this runs ok on win xp pro, does this > >>> have something to do with the home version > >>> of xp. > >>> > >>> I'm thinking of changeing 'prn' to 'lpt1' > >>> and trying again but I don't want to use > >>> the client as a testor. Or is there some > >>> other explaination for the problem. > >> > >> Not that this is your question, but if > >> you're trying to print under Windows have > >> you looked at: > >> > >> > >> http://tgolden.sc.sabren.com/python/win32_ho > >>w_d o_i/print.html > >> > >> for alternatives? > >> > >> TJG > > > > Thanks for the response, > > > > I got the following to work on windows. > > > > win32api.ShellExecute ( > > 0, 'print', > > filename, None, ".", 0 > > ) > > > > However it prints the name of the file at the > > top and adds a page number on the bottom. Is > > there some way of eliminating the filename > > and page number. > > Unfortunately, this approach is quick-and-dirty > and you're at the mercy of whatever the "print" > verb does to "filename" on your box. (Although > you can configure that if you try hard enough). > > I'm afraid if you want control, you'll have to > go the PDF route or to automate Word / > OpenOffice etc. > > TJG -- http://mail.python.org/mailman/listinfo/python-list
Re: Expanding tkinter widgets to fill the window
On Friday 20 April 2007 13:56, Anton Vredegoor wrote: > KDawg44 wrote: > > I am writing a GUI front end in Python using > > Tkinter. I have developed the GUI in a grid > > and specified the size of the window. The > > widgets are centered into the middle of the > > window. I would like them to fill the > > window. I tried using the sticky=E+W+N+S > > option on the widgets themselves and the > > window itself. > > > > How can I get this? > > If at all possible post a short, > self-contained, correct, example demonstrating > your question. > > http://homepage1.nifty.com/algafield/sscce.html > > A. try; sticky = NSEW without plus signs headFrame = Frame(win01, bg = 'light grey', bd=10) headFrame.grid(row = 0, column=0, sticky = NSEW) jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: What happened to [EMAIL PROTECTED]
On Friday 04 May 2007 22:19, Carsten Haese wrote: > Hiya, > > I just tried sending an email to > [EMAIL PROTECTED] to request a website > change, and the email bounced back with this > excerpt from the delivery failure report: > > """ > Reporting-MTA: dns; bag.python.org > [...] > Final-Recipient: rfc822; > [EMAIL PROTECTED] Original-Recipient: > rfc822; [EMAIL PROTECTED] Action: failed > Status: 5.0.0 > Diagnostic-Code: X-Postfix; unknown user: > "webmaster" """ > > Who should I contact to request the website > change? > > Thanks, > > Carsten. I'm not sure but you can try; [EMAIL PROTECTED] or http://mail.python.org/ jim-on-lnux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Circular imports
On Tuesday 29 May 2007 00:08, Carsten Haese wrote: > On Mon, 28 May 2007 23:46:00 -0400, Ron Provost > wrote > > > [...] python is not happy about my circular > > imports [...] > > A circular import is not a problem in itself. > I'm guessing you're running into a situation > like this: > > Module A imports module B and then defines an > important class. Module B imports A (which does > nothing because A is already partially > imported) and then defines a class that depends > on the class that is defined in module A. That > causes a NameError. > > The root of the problem is that all statements > are executed in the order in which they appear, > and B is imported before A had a chance to > define the class that B depends on. > > Note that import statements don't have to be at > the top of the file. I agree, waite until python complains. You might try to remove all of the import statements then add then as they are requested by the program by a traceback error. jim-on-linux > Try moving each import > statement to the latest possible point in the > code, i.e. right before the first occurence of > whatever names you're importing from the > respective modules. That way, each module gets > to define as much as it possibly can before it > gets side-tracked by importing other modules. > > If my guess doesn't help, you're going to have > to post at least the exception/traceback you're > getting, and you're probably going to have to > post some code, too. > > Good luck, > > -- > Carsten Haese > http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list
Re: python unix install, sqlite3
On Tuesday 29 May 2007 08:52, Simon wrote: > I installed the source code on unix for python > 2.5.1. The install went mainly okay, except for > some failures regarding: _ssl, _hashlib, > _curses, _curses_panel. > > No errors regarding sqlite3. > However, when I start python and do an import > sqlite3 I get: > > /ptmp/bin/> python > Python 2.5.1 (r251:54863, May 29 2007, > 05:19:30) [GCC 3.3.2] on sunos5 > Type "help", "copyright", "credits" or > "license" for more information. > > >>> import sqlite3 > I'm using python 2.5 on linux and it works fine Try; import sqlite3 in place of from sqlite3 import * jim-on-linux http://www.inqvista.com > Traceback (most recent call last): > File "", line 1, in > File > "/ptmp/Python-2.5.1/lib/python2.5/sqlite3/__ini >t__.py", line 24, in > from dbapi2 import * > File > "/ptmp/Python-2.5.1/lib/python2.5/sqlite3/dbapi >2.py", line 27, in > from _sqlite3 import * > ImportError: No module named _sqlite3 -- http://mail.python.org/mailman/listinfo/python-list
Re: Error with Tkinter and tkMessageBox
On Tuesday 31 July 2007 15:24, Fabio Z Tessitore wrote: > Il Tue, 31 Jul 2007 19:12:48 +, kyosohma ha scritto: > > I'm not sure, but I don't think you need the > > "win" variable at all. I can get it to work > > as follows: > > > > > > > > from Tkinter import * > > from tkMessageBox import showinfo > > > > def reply(): > > showinfo(title='ciao', > > message='hello') > > > > Button(text='press me', > > command=reply).pack(fill=X) mainloop() > > > > > > > > Mike > > You're right. But the problem I have is always > there. Tkinter doesn't work properly and I > don't understand why. Thanks! Try This: def reply(): showinfo('ciao','hello') jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
sqlite3 create table col width?
PY help, Using sqlite3 v3.1.3 When I create a table collumn using; newcollum VARCHAR(35), I get a default of 10 spaces. No matter what I set the size to I get 10 spqces, even using varchar(0) defaults to 10 spaces. I would appreciae the help if someone could tell me what I'm missing, I want to varry the column sizes. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: sqlite3 create table col width?
On Saturday 04 August 2007 14:05, Carsten Haese wrote: > On Sat, 2007-08-04 at 13:51 -0400, jim-on-linux wrote: > > PY help, > > > > Using sqlite3 v3.1.3 > > > > When I create a table collumn using; > > > > newcollum VARCHAR(35), > > > > I get a default of 10 spaces. > > > > No matter what I set the size to I get 10 > > spqces, even using varchar(0) defaults to 10 > > spaces. > > > > I would appreciae the help if someone could > > tell me what I'm missing, I want to varry the > > column sizes. > > What you're missing is that sqlite columns are > type-less. Column type > > and size are irrelevant: > >>> import sqlite3 > >>> conn = sqlite3.connect(":memory") > >>> cur = conn.cursor() > >>> cur.execute("create table t1 (c1 > >>> varchar(35))") > > > > >>> cur.executemany("insert into t1(c1) > >>> values(?)", > > ... [ ("X"*i*10,) for i in range(10) ] ) > > >>> cur.execute("select * from t1") > > > > >>> for row in cur: print row > > ... > (u'',) > (u'XX',) > (u'',) > (u'XX',) > (u'',) > (u' >XX',) > (u' >',) > (u' >XX',) > (u' >',) > (u' >XX', >) > > Even though the column was created to be 35 > characters wide, it'll happily accept > 100-character strings. > > HTH, > > -- > Carsten Haese > http://informixdb.sourceforge.net Right, the data is there. My question is framed wrong. Your answer pointed out the flaw in the question. Since I'm on linux, the database can be opened with Knoda. Once opened the table collumns are always 10 spaces so all the data is not readable as presented. Not quite a python problem. I can Tk a display for the data, just thought I could save time by letting the user open the table and read the data right from the table. Thanks for the help. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter pack difficulty
On Wednesday 12 September 2007 13:22, Simon Forman wrote: > Hi all, > > I realize this is more of a Tk question than a python one, but > since I'm using python and don't know Tcl/Tk I figured I'd ask here > first before bugging the Tcl folks. > > I am having a terrible time trying to get a pack() layout working. > > I have three frames stacked top to bottom and stretching across the > master window from edge to edge. > > Crude ASCII Art rendition of the frames: > > > > | header | > > > > | body | > > > > | log| > > > > > I want the header and log frames to have a fixed height (and stick > to the top and bottom, respectively, of the master frame) and the > body frame to expand to fill the rest of the space, for instance if > the window is maximized. > > Here is a simple script that /almost/ does what I want. I've been > tweaking the pack() options for three hours and I just can't seem > to get the effect I want. This /can't/ really be this hard can it? > > If you run the script, be aware that since there are only frame > widgets the window will initially be very very tiny. If you expand > or maximize the window you'll see a thin black frame at the top, > yay, a thin white frame at the bottom, yay, but the middle grey > "body" frame will NOT span the Y axis, boo. > > It's there, and stretches from side to side, but it refuses to > stretch top to bottom. Adding a widget (say, a Text) doesn't help, > the light grey non-frame rectangles remain. > > My investigations seem to indicate that the light grey bars are > part of something the Tk docs call a "parcel" that each slave > widget gets packed into. Apparently the "header" and "log" frames > don't use their entire parcels, but I don't know how to get the > parcels themselves to "shrinkwrap" to the size of the actual Frame > widgets. > > In any event, my head's sore and I'm just about ready to take out > some graph paper and use the grid() layout manager instead. But I > really want the automatic resizing that the pack() manager will do, > rather than the static layout grid() will give me. > > Any thoughts or advice? Sorry I can't help you with pack, I don't use it anymore. I am able to do everything with grid that I can do with pack. Once I learned to use grid I liked it better than pack. Spend some time to learn grid you may like it. I'm sure others will disagree, but for me it works for everything I need. jim-on-linux http://inqvista.com > > Thanks in advance, > ~Simon > > # Tkinter script > from Tkinter import * > > t = Tk() > > header = Frame(t, bg="black", height=10) > header.pack(expand=1, fill=X, side=TOP, anchor=N) > > body = Frame(t, bg="grey") > body.pack(expand=1, fill=BOTH, anchor=CENTER) > > log = Frame(t, bg="white", height=10) > log.pack(expand=1, fill=X, side=BOTTOM, anchor=S) > > t.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: pop method question
On Saturday 03 March 2007 15:56, Nicholas Parsons wrote: > On Mar 3, 2007, at 3:49 PM, Paul Rubin wrote: > > Nicholas Parsons <[EMAIL PROTECTED]> writes: > >> I was just playing around in IDLE at the > >> interactive prompt and typed in dir({}) for > >> the fun of it. I was quite surprised to see > >> a pop method defined there. I mean is that > >> a misnomer or what? From the literature, > >> pop is supposed to be an operation defined > >> for a stack data structure. A stack is > >> defined to be an "ordered" list data > >> structure. Dictionaries in Python have no > >> order but are sequences. Now, does anyone > >> know why the python core has this pop method > >> implemented for a dictionary type? aDict.pop(theKey) 'produce the value' pop removes the key:value and produces the value as results jim-on-linux http:\\www.inqvista.com > > > > Try typing: > > > > help({}.pop) > > -- > > http://mail.python.org/mailman/listinfo/pytho > >n-list > > Thanks, that gives a more details explanation > of what the behavior is but doesn't answer my > question above :( -- http://mail.python.org/mailman/listinfo/python-list
Re: askstring Window to the top under Windows
On Tuesday 06 March 2007 08:13, iwl wrote: > Hi, > > I tryed askstring to input some text in my > script, but some ugly empty Window appears with > the Input-Window behind and all together behind > my Console showing my script. So all have to > brought to the top first by the user - very > unconfortable By default tk will open a root window. so you will have to create something to put into the root window. I suggest a button to open the tkSimpleDialog box. go to; http://www.pythonware.com/library/tkinter/introduction/ jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: askstring Window to the top under Windows
On Wednesday 07 March 2007 05:05, iwl wrote: > On 7 Mrz., 02:49, jim-on-linux <[EMAIL PROTECTED]> wrote: > > On Tuesday 06 March 2007 08:13, iwl wrote: > > > Hi, > > > > > > I tryed askstring to input some text in my > > > script, but some ugly empty Window appears > > > with the Input-Window behind and all > > > together behind my Console showing my > > > script. So all have to brought to the top > > > first by the user - very unconfortable > > > > By default > > tk will open a root window. > > Is this default changeable befor askstring? Here is an example of a simple button that will open a tkSimpleDialog box == from Tkinter import * import tkSimpleDialog from tkSimpleDialog import askfloat root = Tk() ## this is the default window vlab = Button( root, text= 'Click here to Open Dialog', width = 20, height = 2, bg = 'yellow', command =(lambda: askfloat( 'Entery', 'Enter credit card number') ) ) vlab.grid() mainloop() jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: askstring Window to the top under Windows
On Wednesday 07 March 2007 05:02, Ingo Wolf wrote: > Original-Nachricht > Datum: Tue, 06 Mar 2007 20:49:42 -0500 > Von: jim-on-linux <[EMAIL PROTECTED]> > An: python-list@python.org > CC: "iwl" <[EMAIL PROTECTED]> > Betreff: Re: askstring Window to the top under > Windows > > > By default > > tk will open a root window. > > so you will have to create > > something to put into the > > root window. > > I suggest a button to open the tkSimpleDialog > > box. > > > > go to; > > > > http://www.pythonware.com/library/tkinter/int > >roduction/ > > I've allready had a short look trough this to > find an idea how to change this behavior (which > should be done by the askstring makers) but > haven't up to now. I think what I do is what > askstring was made for keeping me away from tk > internals only wanting a little string input. > > Because I have embedded python In my C-App I > make my own window now In C and extend python > by it so having more control about things > happen. Check out how to use Entry Wiget for data entry. from Tkinter import * root = Tk() ## this is the default window vlab = Label(root, width = 20, text = 'Enter data here') vlab.grid( row=0, column =0) ventry= Entry(root, width = 30) ventry.grid(row = 0, column = 1) mainloop() jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter text editor
On Friday 09 March 2007 12:04, Gigs_ wrote: > Gigs_ wrote: > > I'm writing text editor. > > > > How to enable/disable (cut, copy etc.) when > > text is selected/not selected > > Btw it is cut copy ... in edit menu state = 'diabled' ## no change allowed ## to Text Wiget state = 'normal' ## default for Text Wiget jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: writing dictionary to file
On Thursday 08 March 2007 14:40, kavitha thankaian wrote: > Hi Simon, > > iam till here: > > dorc=some['DorC'] > amount=some['amount'] > f=open("logfile.txt", "w") > if dorc =='C': >a = -(amount) > if dorc == 'D': >b = amount >sum=a + b >if sum == 0: >f.writelines("name:") >f.writelines("%s" %some['name']) >f.writelines("credit:") >f.writelines("%s" % amount) > > but i see an empty file opened,,, > > kavitha > > Simon Brunning <[EMAIL PROTECTED]> > wrote: > > On 3/8/07, kavitha thankaian wrote: > > can anyone help me??? > > I'm sure we can. How far have you got so far? try f=open("logfile.txt", "w") f.write('name') f.write('\n') f.write(('credit(') f:close() jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
SQLite3 trapping OperationalError
pyhelp, I set up a table in SQLite3. While running other modules I want to know if a table exists. SQL has a command "List Tables" but I don't think SQLlite3 has this command. I've tried cursor.execute("select * from debtor where key is not null ") The table debtor does not exist so I get "OperationalError" which I want to trap with try/except or some other way. However python 2.5, except OperationalError: responds with "OperationalError" is not defined. Ideas on how to determine if a table exists would be welcome. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite3 trapping OperationalError
On Friday 09 March 2007 13:10, Jerry Hill wrote: > On 3/9/07, jim-on-linux <[EMAIL PROTECTED]> wrote: > > However python 2.5, > > except OperationalError: > > responds with > > "OperationalError" is not defined. > > I believe that needs to be spelled > except sqlite3.OperationalError: > do_something() > > -- > Jerry Thanks, except sqlite3.OperationalError: works for me. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: Signed zeros: is this a bug?
On Sunday 11 March 2007 10:31, Mark Dickinson wrote: > I get the following behaviour on Python 2.5 (OS > X 10.4.8 on PowerPC, in case it's relevant.) > > >>> x, y = 0.0, -0.0 > >>> x, y > > (0.0, 0.0) > > >>> x, y = -0.0, 0.0 > >>> x, y > > (-0.0, -0.0) > > I would have expected y to be -0.0 in the first > case, and 0.0 in the second. Should the above > be considered a bug, or is Python not expected > to honour signs of zeros? I'm working in a > situation involving complex arithmetic where > branch cuts, and hence signed zeros, are > important, and it would be handy if the above > code could be relied upon to do the right > thing. > > Mark This works for some reason instead of x,y = -0.0, 0.0 clumpy but the results are right. x = -0.0 y= 0.0 x,y (-0.0, 0.0) jim-on-linux http:\\inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Signed zeros: is this a bug?
# > > Interesting. So on Windows there's probably no > hope of what I want to do working. > But on a platform where the C library does the > right thing with signed zeros, this > behaviour is still a little surprising. I > guess what's happening is that there's > some optimization that avoids creating two > separate float objects for a float literal > that appears twice, and that optimization > doesn't see the difference between 0. and -0. > > >>> x, y = 0., -0. > >>> id(x) == id(y) > > True > > jim-on-linux's solution works in the > interpreter, but not in a script, presumably > because we've got file-wide optimization rather > than line-by-line optimization. > > #test.py > x = -0.0 > y = 0.0 > print x, y > #end test.py > > >>> import test > > -0.0 -0.0 > > Mark This is the only way I could make this work in a script. from decimal import Decimal x = Decimal( "-0.0") y= Decimal("0.0") print x,y x = Decimal( "0.0") y= Decimal("-0.0") print x,y jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: attaching Tkinter Listbox to python list object
On Monday 12 March 2007 20:34, Steve Potter wrote: > I am trying to find some method of attaching a > Listbox object to a list object so as the > contents of the list are changed the contents > of the Listbox will be updated to match. I > have found a few references to something like > this in this old post > http://groups.google.com/group/comp.lang.python >/browse_thread/thread/3a6fe7534c812f55/43f201ab5 >3cfdbf7 as well as here > http://effbot.org/zone/wck-4.htm . > > It just seems that there should be some way of > achieving this. > > The only this I can think of is create a > subclass of list that deletes and then refills > the Listbox every time that the list changes, > but this seems very in efficient. > > > Any ideas? > > Steve Look into the StringVar(), class for Tkinter. var = stringVar() sorry I can't help more, but I think this is what you are looking for. jim-on-linux http:\\www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
SQLite3, data not found
Python help, I just started working with SQLite3 and ran into this problem. Below, the first select produces results but, after closing then re-opening the database the select produces an empty list. Anyone know the reason ?? The table seems to be empty. import sqlite3 con = sqlite3.connect('myData') cursor = con.cursor() cursor.execute ("""create table data (recordNo varchar, caseNo varchar)"""); record = ['A', 'B'] cursor.execute("insert into data values (?,?)", record ) ; cursor.execute("select * from data "); print cursor.fetchall(); con.close() con = sqlite3.connect('myData') cursor = con.cursor() cursor.execute("select * from data"); print cursor.fetchall(); jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite3, data not found
from John Clark use con.commit() Thanks John, this works jim-on-linux On Friday 16 March 2007 17:55, jim-on-linux wrote: > Python help, > > I just started working with SQLite3 and ran > into this problem. > > Below, the first select produces results but, > after closing then re-opening the database the > select produces an empty list. Anyone know the > reason ?? > > The table seems to be empty. > > > > import sqlite3 > con = sqlite3.connect('myData') > cursor = con.cursor() > > cursor.execute ("""create table data >(recordNo varchar, >caseNo varchar)"""); > > record = ['A', 'B'] > > cursor.execute("insert into data values (?,?)", > record ) ; > > cursor.execute("select * from data "); > print cursor.fetchall(); > con.close() > > con = sqlite3.connect('myData') > cursor = con.cursor() > cursor.execute("select * from data"); > print cursor.fetchall(); > > > jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite3, data not found
On Friday 16 March 2007 18:23, Jerry Hill wrote: > On 3/16/07, jim-on-linux <[EMAIL PROTECTED]> wrote: > > Below, the first select produces results but, > > after closing then re-opening the database > > the select produces an empty list. Anyone > > know the reason ?? > > When you first open a connection, you > implicitly begin a transaction. You need to > call con.commit() before you close the > connection, or your transaction will be rolled > back when you close() it. If don't want to > bother with transaction handling, you can turn > it off when you open the connection, like this: > con = sqlite3.connect('myData', > isolation_level=None) > > See the Python Database API 2.0 PEP for more > details about the behavior required of DB-API > 2.0 compliant interfaces: > http://www.python.org/dev/peps/pep-0249/ > > -- > Jerry Thanks, this saves a lot of con.commit action. And the website is valuable. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: SQLite3, data not found
On Saturday 17 March 2007 13:51, John Nagle wrote: > jim-on-linux wrote: > > On Friday 16 March 2007 18:23, Jerry Hill wrote: > >>On 3/16/07, jim-on-linux > >> <[EMAIL PROTECTED]> > > > > wrote: > >>>Below, the first select produces results > >>> but, after closing then re-opening the > >>> database the select produces an empty list. > >>> Anyone know the reason ?? > >> > >>When you first open a connection, you > >>implicitly begin a transaction. You need to > >>call con.commit() before you close the > >>connection, or your transaction will be > >> rolled back when you close() it. If don't > >> want to bother with transaction handling, > >> you can turn it off when you open the > >> connection, like this: con = > >> sqlite3.connect('myData', > >>isolation_level=None) > >> > >>See the Python Database API 2.0 PEP for more > >>details about the behavior required of DB-API > >>2.0 compliant interfaces: > >>http://www.python.org/dev/peps/pep-0249/ > >> > >>-- > >>Jerry > > > > Thanks, this saves a lot of con.commit > > action. And the website is valuable. > > > > jim-on-linux > > Don't turn off atomic transactions, use > them. Otherwise, two copies of your program > running at the same time will probably not do > what you want. Just call "commit" at the end of > each transaction. > > John Nagle Thanks I appreciate the help. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: mysterious unicode
On Tuesday 20 March 2007 18:35, Gerry wrote: > I'm using pyExcelerator and xlrd to read and > write data from and to two spreadsheets. > > I created the "read" spreadsheet by importing a > text file - and I had no unicode aspirations. > > When I read a cell, it appears to be unicode > u'Q1", say. > > I can try cleaning it, like this: > > > try: > s.encode("ascii", "replace") > except AttributeError: > pass > > > which seems to work. Here's the mysterious > part (aside from why anything was unicode in > the first place): > > print >> debug, "c=", col, > "r=", row, "v=", value, "qno=", qno > tuple = (qno, family) > try: > data[tuple].append(value) > except: > data[tuple] = [value] > print >> debug, "!!!", col, > row, qno, family, tuple, value, data[tuple] > > which produces: > > c= 1 r= 3 v= 4 qno= Q1 > !!! 1 3 Q1 O (u'Q1', 'O') 4 [1, u' ', 4] > > where qno seems to be a vanilla Q1, but a tuple > using qno is (u'Q1', ...). > > Can somebody help me out? I have been getting the same thing using SQLite3 when extracting data fron an SQLite3 database. I take the database info which is in a list and do name = str.record[0] rather than name = record[0] So far, I havn't had any problems. For some reason the unicode u is removed. I havn't wanted to spend the time to figure out why. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: mysterious unicode
On Tuesday 20 March 2007 21:17, Carsten Haese wrote: > On Tue, 2007-03-20 at 20:26 -0400, jim-on-linux wrote: > > I have been getting the same thing using > > SQLite3 when extracting data fron an SQLite3 > > database. > > Many APIs that exchange data choose to exchange > text in Unicode because that eliminates > encoding uncertainty. Whether an API uses > Unicode would probably be noted somewhere in > its documentation. > > > I take the database info which is in a list > > and do > > > > name = str.record[0] > > You probably mean str(record[0]) . Yes, > > > rather than > > name = record[0] > > > > So far, I havn't had any problems. > > For some reason the unicode u is removed. > > I havn't wanted to spend the time to figure > > out why. > > As a software engineer, I'd get worried if I > didn't know why the code I wrote works. Maybe > that's just me. I don't disagree, but sometime depending on the situation, time to investigate is a luxury. However, ( If you don't have the time to do it right the first time when will you have the time to fix it.) > > Unicode is not rocket science. I suggest you > read http://www.amk.ca/python/howto/unicode to > demystify what Unicode objects are and do. > > With str(), you're asking the Unicode object > for its byte string interpretation, which > causes the Unicode object to give you its > encoding in the system default encoding. The > default encoding is normally ascii. That can be > tweaked for your particular Python > installation, but if you need an encoding other > than ascii it's recommended that you explicitly > encode and decode from and to Unicode, lest you > risk writing non-portable code. > > Using str() coercion of Unicode objects will > work well enough until you run into a string > that contains characters that can't be > represented in the default encoding. Right, even though None or null are not strings they are common enough to cause a problem. Try to run a loop through a list with None or null in it. Example, x = str(list[2]) when list[2] = null or None, problems. Easy to fix but more work. I'll check the web site out. Thanks for the update, Jim-on-linux > Once that > happens, you're better off explicitly encoding > the Unicode object into a well-defined encoding > on input, or, even better, just work with > Unicode objects internally and only encode to > byte strings when absolutely necessary, such as > when outputting to a file or to the console. > > Hope this helps, > > Carsten. -- http://mail.python.org/mailman/listinfo/python-list
Re: the second of nested buttons using textvariable remains void!
On Wednesday 21 March 2007 20:11, Samkos wrote: > Hi there, > > I am fighting with a problem I intended to > believe trivial that I could not solve yet! > > I am trying to have a button with a variable > text, that pops up another button with a > variable text when pressed. > > I did that with the following program in > Python, but the second button remains always > void!!! is it related to the textvariable > parameters? > > If any of you had a clue, please don't > hesitate! > > in advance, many thanks > > Samuel > > #--- program 2 buttons.py > -- > > from Tkinter import * > > > def go(event): > root = Tk() > > s1=StringVar() > s1.set("s1") > label1 = Label(root, textvariable=s1) > label1.pack(side=LEFT) > > root.mainloop() > > > > root = Tk() > > s0=StringVar() > s0.set("s0") > label0 = Label(root, textvariable=s0) > label0.pack(side=LEFT) > > > root.bind("",go) > > root.mainloop() try this; def go(): root = Tk() root.config(bg= 'yellow') s1=StringVar() blabel1 = Button(root, textvariable=s1, width = 10, height = 2, command = next) blabel1.pack() root.bind("", vbind) s1.set('click_s1') def vbind(event): next() def next(): second = Toplevel() s0=StringVar() s0.set("click_s0") blabel0 = Button(second, textvariable=s0, command = second.destroy, width = 10, height = 2) blabel0.pack() if __name__ == '__main__' : go() mainloop() jim-on-linux http://inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: What is the best way to upgrade python?
On Thursday 22 March 2007 15:18, Facundo Batista wrote: > [EMAIL PROTECTED] wrote: > > i am using red hat enterprise 4. It has > > python 2.3 installed. What is the best way to > > upgrade to python 2.4? > > > > I think one way is to compile python 2.4 from > > the source, but I can't remove the old one > > since when i do 'rpm -e python', i get error > > like 'failed dependencies'. > > Install Py2.4 and actually start using it, are > two different animals. > > For example, I have installed Py2.4 and Py2.5 > in my laptop. They coexist, and there's no > problem about this. > > Telling all your installed applications to use > the newer, it's not so easy, mainly because you > don't have the power to test and change every > installed application. > > So let them be. Just install the new version, > and use it. > > Regards, > > -- > . Facundo > . > Blog: http://www.taniquetil.com.ar/plog/ > PyAr: http://www.python.org/ar/ I recently installed py 2.5 and I used the local user option. Now I build programs on 2.5 but I left the system with the original 2.4? since it worked just fine. Look in the instructions on how to build for local users and you 'll save yourself from encountering the unexpected. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: gui toolkits: the real story? (Tkinter, PyGTK, etc.)
On Monday 01 October 2007 21:04, bramble wrote: > What is the backstory to why Python includes Tk bindings, as > opposed to some other set of bindings? > > I've written a few little Tkinter-based apps, and it's nice and > simple. I like it well enough. That said though, I keep feeling the > gravitational pull toward GTK+. I've been meaning to get the whole > glade+gtk+python thing happening with my own projects, as soon as > time allows. Is there resistance in the upper Python echelons to > GTK because of its LGPL licensing? > > Reading Alex's Nutshell book, right off the bat he comments that > "The most popular Python GUI toolkit today is probably wxPython". > But then he goes on for 45 pages on Tkinter... Seems like he wanted > to write that chapter on wx instead... > > WxWidgets, the last time I looked at it, seemed awfully like MS > Window's MFC. The licensing seemed vague at the time, and it looks > like wx contains an extra layer of GUI library, so I didn't spend > any real time on it. But, regardless, it seems to get good press > among python folk (I think I remember ESR noting how it was his GUI > toolkit of choice). > > PyQt has had that issue (IIRC) about needing to pay for it for > commercial apps, so I can see how there might be resistance to it > being considered the "standard Python GUI toolkit". > > So, it would seem to me that Tkinter *might* remain in Python > proper, but that I probably wouldn't see much effort put into it. > Well, the Python standard library docs tell a different story. > There's stuff in there about Tix, ScrolledText, turtle, and then > the "other GUI packages" doc page goes on about Python megawidgets > (Tk-based) and Tkinter3000 Widget Construction Kit (WCK). Wow. > Looks like Tkinter is still having serious support -- even though > in that same doc at the bottom notes, "PyGTK, PyQt, and wxPython, > all have a modern look and feel and far more widgets and better > documentation than Tkinter." > > So, that leaves me wondering, why is Tkinter still getting so much > focus in the Python standard library? > > Maybe a better question is, how has Tk managed to keep beating up > the newer, more modern, more featureful, better documented toolkits > encroaching on his territory? What's Tk's secret weapon? Tkinter's secret weapon are pgmrs like me that would rather put pressure on the Tk people to improve what already is working. Update and improve Tk, change the look and feel of it, add features. Let me spend my time programming not trying to make existing programs compatible with the unknown. (Some change to who knows what.) On the other hand, questions like yours are exactly what keeps the pressure on the Tkinter people to upgrade. I think they got the message with the recent announcement of some long awaited changes. jim-on-linux http://inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
download win32file
Where can I download win32file / win32ui? The links below are broken. Mark Hammond should be made aware of this. URL below has two links that send you no place http://mail.python.org/pipermail/python-list/2002-October/167638.html Links: http://starship.python.net/crew/mhammond/win32/Downloads.html http://starship.python.net/crew/mhammond/downloads/win32all-148.exe Produce; The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: download win32file
On Monday 15 January 2007 10:37, hg wrote: > jim-on-linux wrote: > > Where can I download win32file / win32ui? > > > > The links below are broken. Mark Hammond > > should be made aware of this. > > > > > > URL below has two links that send you no > > place > > http://mail.python.org/pipermail/python-list/ > >2002-October/167638.html > > > > > > Links: > > http://starship.python.net/crew/mhammond/win3 > >2/Downloads.html > > > > http://starship.python.net/crew/mhammond/down > >loads/win32all-148.exe > > > > > > Produce; > > > > The requested URL was not found on this > > server. The link on the referring page seems > > to be wrong or outdated. Please inform the > > author of that page about the error. > > > > jim-on-linux > > Do you mean PyWin32 ? ?? Do I have to download pywin32 to get win32ui, or win32file, or win32api > > http://sourceforge.net/projects/pywin32/ -- http://mail.python.org/mailman/listinfo/python-list
Re: download win32file
On Monday 15 January 2007 18:02, Bill Tydeman wrote: > > ?? Do I have to download pywin32 to get > > win32ui, or win32file, or win32api > > Yes Got it. Thank you. -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
I'm using Suse Linux which has five program that will open a pdf file from a shell command line. Acrobat Reader is one of the five. A right button click on the file should give a list of programs that will open a PDF file. Im using a KDE desktop Open a shell, add the path to the directory where the PDF file lives, and on the command line type; xpdf myfile.pdf ## may also work on a Gnome ## Desktop or any of these for the KDE desktop; kpdf myfile.pdf Kghostview myfile.pdf konqueror myfile.pdf ## my browser + myfile. Acrobat Reader is also listed on my system. It open files as adobe reader using the mouse to open a pdf file but not from the command line with an arg, and I haven't spent the time to figgure out why. You will have to import os and some combination of any of the exec.. args, or the popen, spawn, or system modules. os.execvep() ## or others like execl, execle os.spawnv(), os.spawnve(), os.popen() hope this give some direction. jim-on-linux On Tuesday 13 February 2007 03:44, Jussi Salmela wrote: > Grant Edwards kirjoitti: > > On 2007-02-12, Larry Bates <[EMAIL PROTECTED]> wrote: > >> Grant Edwards wrote: > >>> On 2007-02-12, Larry Bates <[EMAIL PROTECTED]> wrote: > >>>> On 2007-02-12, Larry Bates <[EMAIL PROTECTED]> wrote: > >>>>>>> I at least need the code for useing > >>>>>>> some library for connecting to acrobat > >>>>>>> reader and giving the print command on > >>>>>>> windows and some thing similar on > >>>>>>> ubuntu linux. > >>>>>> > >>>>>> Just let the registered .PDF viewer do > >>>>>> it for you. > >>>>>> > >>>>>> os.start('myfile.pdf') > >>>>> > >>>>> Eh? I don't see os.start() it either 2.5 > >>>>> or 2.44 documentation, and it's sure not > >>>>> there in 2.4.3: > >>>> > >>>> My bad. os.system() > >>> > >>> That doesn't work either: > >>> > >>>$ ls -l user.pdf > >>>-rw--- 1 grante users 35640 > >>> 2005-11-21 14:33 user.pdf > >>> > >>>$ python > >>>Python 2.4.3 (#1, Dec 10 2006, 22:09:09) > >>>[GCC 3.4.6 (Gentoo 3.4.6-r1, > >>> ssp-3.4.5-1.0, pie-8.7.9)] on linux2 Type > >>> "help", "copyright", "credits" or "license" > >>> for more information. > >>> > >>>>>> import os > >>>>>> os.system('user.pdf') > >>> > >>>sh: user.pdf: command not found > >>>32512 > >> > >> Works fine on my system. You linux guys > >> just have it hard. The op said "windows". > > > > The posting to which you replied specified > > Linux. > > > >> I can't answer for ubuntu linux but maybe > >> you can help there? > > > > I don't see how. Pdf files just aren't > > executable. > > On Windows, this (where fileName is xyz.PDF, > for example): webbrowser.open(r'file://' + > fileName) starts Acrobat Reader with the > document read in. I have no idea why, because > Acrobat Reader sure ain't my browser;) > > Maybe someone could try this out on Linux. > > Cheers, > Jussi -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter: how; newbie
On Tuesday 13 February 2007 18:02, Gigs_ wrote: > can someone explain me this code? > > from Tkinter import * > > root = Tk() > > def callback(event): > print "clicked at", event.x, event.y > > frame = Frame(root, width=100, height=100) > frame.bind("", callback) > frame.pack() > > root.mainloop() > if you live on longititude 32, wrere is that? If you live on latitude 40 and longitiude 32 I can find that location. Your mouse is pointing to x, and y, which is simply a location on the screen. > > well, my problem is at frame.bind(",Button-1>", > callback) callback function prints event.x and > event.y. How the callback function get this two > number when it has only one argument (event) > Why its not: def callback(x, y): print x, y > > Im new to gui programming > > Sorry for bad eng! > > Thanks for replay! -- http://mail.python.org/mailman/listinfo/python-list
Re: can't find a way to display and print pdf through python.
For those who care, the file below should run on a unix/ linux style system. And "xpdf", amoung others, will run a pdf file. import os def Printpdf(): os.system( 'xpdf form.pdf' ) if __name__ == '__main__' : Printpdf() jim-on-linux > On Tue, 13 Feb 2007 08:44:18 GMT, Jussi Salmela > > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python: > > On Windows, this (where fileName is xyz.PDF, > > for example): webbrowser.open(r'file://' + > > fileName) starts Acrobat Reader with the > > document read in. I have no idea why, because > > Acrobat Reader sure ain't my browser;) > > Most likely Adobe installed the Acrobat > plug-in for the browser... The browser > identifies the file as PDF and passes it to the > plug-in for rendering. > -- > WulfraedDennis Lee Bieber KD6MOG > [EMAIL PROTECTED] [EMAIL PROTECTED] > HTTP://wlfraed.home.netcom.com/ > (Bestiaria Support > Staff:[EMAIL PROTECTED]) > HTTP://www.bestiaria.com/ -- http://mail.python.org/mailman/listinfo/python-list
window opens with os.system()
python help, I'm testing on xpPro I have a simple module that sends text files to a printer. Then, it moves the file to the 'Fprtd' directory. The module contains the following code; # for n in PrtList: os.system('type '+n+ ' > prn' os.system('move '+n+ ' Fprtd') # os.system opens and closes a window for each file it sends to the printer and again for each time it moves a file to the Fprtd directory. If there were only a few files, this wouldn't be so bad. But, when the files number 300 to 400 it becomes objectionable. Is there any way to supress the flashing window. xp no longer allows the 'ctty' command. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: window opens with os.system()
On Sunday 18 February 2007 17:27, Gabriel Genellina wrote: > En Sun, 18 Feb 2007 18:09:23 -0300, > jim-on-linux <[EMAIL PROTECTED]> > > escribió: > > I have a simple module that sends text files > > to a printer. Then, it moves the file to the > > 'Fprtd' directory. The module contains the > > following code; > > > > > > # > > > > for n in PrtList: > > os.system('type '+n+ ' > prn' > > os.system('move '+n+ ' Fprtd') > > Thanks Geneilina, It works fine. shutil.copyfile(xxx,prn) jim-on-linux > > # > > > > os.system opens and closes a window for each > > file it sends to the printer and again for > > each time it moves a file to the Fprtd > > directory. If there were only a few files, > > this wouldn't be so bad. But, when the files > > number 300 to 400 it becomes objectionable. > > Just code the above in Python itself. > type xxx > prn == copy xxx prn == > shutil.copyfile(xxx,prn) move xxx Fprtd == > shutil.move(xxx, Fprtd) > > -- > Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list
Re: Custom Tkinter scrollbar
On Wednesday 14 November 2007 18:22, [EMAIL PROTECTED] wrote: > I want to create a custom scrollbar using particular images, which > will then be placed on a canvas to control another window on the > canvas. Right now I am inheriting from scrollbar, but I do the > movement with custom functions. When I create it and put in into > the canvas with "canvas.create_window" a standard scrollbar shows > in the correct spot and my custom one is outside of the canvas. > > All I have right now is something that moves like a scrollbar but > has no effect on other objects. > > Can anyone give me some advice or point me to a guide for this? Is > it even possible? Can I create a widget that mimics a scrollbar, > or would that be more difficult? I have been unable to find > anything online and would appreciate any help. Sounds to me that you want a navigation window for a chosen image. Gimp imaging program has such a window. Check out how gimp works with multiple images. You might want to work with a toolbar that opens a navigation window for each image. For an explanation on how scrolling works check out a book by O'Reilly written by Mark Lutz, Programming Python, look up programming scrollbars. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: It works! Was: Installing Python 3000
On Tuesday 27 November 2007 07:20, André wrote: > On Nov 26, 9:59 pm, "André" <[EMAIL PROTECTED]> wrote: > > While I made some progress in trying to install Py3k from source > > (for the first time), it has failed... > > > > Here are the steps I went through (not necessarily in that order > > - except for those that matter). > > > > 1. After installing Leopard, install Xcode tools from the dvd - > > even if you had done so with a previous version (they need to be > > updated - trust me :-) > > > > 2. Download Python 3.0a1 > > > > 3. Unpack the archive. > > > > 4. Go to /usr/local and make a directory "sudo mkdir py3k" > > (This is probably not needed, but that's what I did). > > > > 5. From the directory where the Python 3.0a1 was unpacked run > > ./configure --prefix=/usr/local/py3k > > > > 6. run "make" > > > > This last step failed with the following error message: > > > > gcc -fno-strict-aliasing -Wno-long-double -no-cpp-precomp > > -mno-fused- madd -DNDEBUG -g -O3 -Wall -Wstrict-prototypes -I. > > -I./Include - DPy_BUILD_CORE -c ./Modules/posixmodule.c -o > > Modules/posixmodule.o ./Modules/posixmodule.c: In function > > 'posix_setpgrp': > > ./Modules/posixmodule.c:3769: error: too few arguments to > > function 'setpgrp' > > make: *** [Modules/posixmodule.o] Error 1 > > > > Any suggestions? > > > > André > > Following Martin v Löwis's suggestion, I looked at > > http://bugs.python.org/issue1358 > > and added the line > #define SETPGRP_HAVE_ARG > by hand to pyconfig.h (after it was created by configure). Then > 6. run "make" > 7. run "make test" (one test failed; this step likely unnecessary) > 8. sudo make altinstall > 9. sudo ln /usr/local/bin/py3k/python3.0 /usr/bin/python3.0 > > 10. type "python" > 11. print("Hello world!") > 12. Be happy! > > André, hoping this report might help some other newbie. Bug fix excluded, After unpacking the compressed version of Python, look for a file named "README". Open "README" and look for Installing. Make install and Make altinstall is explained. I don't like to read instructions but in the long run, it saves time. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: user friendly datetime features
Why not build your own module? You can use it where and when you need it. jim-on-linux http://www.inqvista.com On Tuesday 08 January 2008 20:19, Daniel Fetchinson wrote: > Many times a more user friendly date format is convenient than the > pure date and time. > For example for a date that is yesterday I would like to see > "yesterday" instead of the date itself. And for a date that was 2 > days ago I would like to see "2 days ago" but for something that > was 4 days ago I would like to see the actual date. This is often > seen in web applications, I'm sure you all know what I'm talking > about. > > I'm guessing this feature is needed so often in so many projects > that it has been implemented already by several people. Does anyone > know of such a stand alone module? -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems installing Python on server
On Tuesday 29 January 2008 01:20, Devraj wrote: > Also be careful and setup all the paths > that is required for compiling various > Python modules etc. > > On Jan 29, 8:28 am, Yansky <[EMAIL PROTECTED]> wrote: > > I asked my hosting company if they would > > upgrade Python on my server to the > > latest version. They responded with: > > > > "Sorry no. We tend to stick with what > > comes packaged with the unix > > distribution to ease maintenance issues. > > > > There is nothing stopping you from > > running your own version of python from > > within your own account. Download the > > source and compile it and install it > > into your own space. Adjust the fist > > line of your python scripts to reflect > > the location of YOUR python binary: > > > > #! /home/youraccount/yourlibs/python > > > > and you should be all set." > > Go to the ReadME file after you unpack python. Open and look for "Installing". Read the section, it explains how to install on the entire system and how to install locally. "Make altinstall" is what you are looking for. jim-on-linux http:\\www.inqvista.com > > > > The build instructions for Python are: > > To start building right away (on UNIX): > > type "./configure" in the current > > directory and when it finishes, type > > "make". This creates an executable > > "./python"; to install in usr/local, > > first do "su root" and then "make > > install". > > > > The problem is, I don't have root access > > to the server so I can't do the "make > > install". I have ubuntu on my computer, > > but from what I understand I can't > > compile it on that and upload it because > > the server runs Red Had and the > > ./configure would have made it > > incompatible right? > > > > So how can I build Python without root > > access? -- http://mail.python.org/mailman/listinfo/python-list
Fwd: Re: Problems installing Python on server
> > Also be careful and setup all the paths > > that is required for compiling various > > Python modules etc. > > > > On Jan 29, 8:28 am, Yansky > > <[EMAIL PROTECTED]> wrote: > > > I asked my hosting company if they > > > would upgrade Python on my server to > > > the latest version. They responded > > > with: > > > > > > "Sorry no. We tend to stick with what > > > comes packaged with the unix > > > distribution to ease maintenance > > > issues. > > > > > > There is nothing stopping you from > > > running your own version of python > > > from within your own account. Download > > > the source and compile it and install > > > it into your own space. Adjust the > > > fist line of your python scripts to > > > reflect the location of YOUR python > > > binary: > > > > > > #! /home/youraccount/yourlibs/python > > > > > > and you should be all set." > > Go to the ReadME file after you unpack > python. > Open and look for "Installing". > Read the section, it explains how to > install on the entire system and how to > install locally. > "Make altinstall" is what you are looking > for. > > jim-on-linux > http:\\www.inqvista.com > > > > The build instructions for Python are: > > > To start building right away (on > > > UNIX): type "./configure" in the > > > current directory and when it > > > finishes, type "make". This creates an > > > executable "./python"; to install in > > > usr/local, first do "su root" and then > > > "make install". > > > > > > The problem is, I don't have root > > > access to the server so I can't do the > > > "make install". I have ubuntu on my > > > computer, but from what I understand I > > > can't compile it on that and upload it > > > because the server runs Red Had and > > > the ./configure would have made it > > > incompatible right? > > > > > > So how can I build Python without root > > > access? Will the "make install" make my Python the default one? If I want to install some Python modules, will I need to alter their installation as well or will it see my Python version as the right one to install too? Cheers. --- -- http://mail.python.org/mailman/listinfo/python-list
Re: Fwd: Re: Problems installing Python on server
On Thursday 31 January 2008 09:46, jim-on-linux wrote: > > > Also be careful and setup all the > > > paths that is required for compiling > > > various Python modules etc. > > > > > > On Jan 29, 8:28 am, Yansky > > > > <[EMAIL PROTECTED]> wrote: > > > > I asked my hosting company if they > > > > would upgrade Python on my server to > > > > the latest version. They responded > > > > with: > > > > > > > > "Sorry no. We tend to stick with > > > > what comes packaged with the unix > > > > distribution to ease maintenance > > > > issues. > > > > > > > > There is nothing stopping you from > > > > running your own version of python > > > > from within your own account. > > > > Download the source and compile it > > > > and install it into your own space. > > > > Adjust the fist line of your python > > > > scripts to reflect the location of > > > > YOUR python binary: > > > > > > > > #! /home/youraccount/yourlibs/python > > > > > > > > and you should be all set." > > > > Go to the ReadME file after you unpack > > python. > > Open and look for "Installing". > > Read the section, it explains how to > > install on the entire system and how to > > install locally. > > "Make altinstall" is what you are > > looking for. > > > > jim-on-linux > > http:\\www.inqvista.com > > > > > > The build instructions for Python > > > > are: To start building right away > > > > (on UNIX): type "./configure" in the > > > > current directory and when it > > > > finishes, type "make". This creates > > > > an executable "./python"; to install > > > > in usr/local, first do "su root" and > > > > then "make install". > > > > > > > > The problem is, I don't have root > > > > access to the server so I can't do > > > > the "make install". I have ubuntu on > > > > my computer, but from what I > > > > understand I can't compile it on > > > > that and upload it because the > > > > server runs Red Had and the > > > > ./configure would have made it > > > > incompatible right? > > > > > > > > So how can I build Python without > > > > root access? > > Will the "make install" make my Python the > default one? If I want to install some > Python modules, will I need to alter > their installation as well or will it see > my Python version as the right one to > install too? > > Cheers. >From the Readme file enclose with Python; -- " If you have a previous installation of Python that you don't want to replace yet, use make altinstall This installs the same set of files as "make install" except it doesn't create the hard link to "python" named "python" and it doesn't install the manual page at all. " -- I installed python 2.5 using make altinstall by going to " /usr/local/lib " unpacking, then using make altinstall Folder 2.5 is created. To add modules, as I have added PIL to my system, I go to; " /usr/local/lib/python2.5/site-packages " where I installed PIL. installing a py module in the site-packages folder is where I would install any package unless otherwise directed. When upgrading you can go to the site directory and see what's in there, and what has to be added to a new upgrade. http:\\www.inqvista.com jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter fonts setting
On Tuesday 05 February 2008 15:22, Unnamed One wrote: > First question - is it possible to set > font to default OS font for window text? > It would be preferable, while on my > Windows XP system Tkinter sets small > Helvetica-style font by default. > > Secondly, can I set font globally (or > specify "default" font for widgets)? In > fact, all I want is to get default OS font > unless (rarely) I need to specify another. > > Thanks Go to: http://www.pythonware.com/library/tkinter/introduction/ Read chapter 6, Widget Styling, there is a section on Fonts which has a sub-section on System Fonts. jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: shelve.open call gives error
On Friday 08 February 2008 12:10, jim-on-linux wrote: > On Friday 08 February 2008 03:36, waltbrad > > wrote: > > Working through the Mark Lutz book > > Programming Python 3rd Edition. > > > > A couple of modules in the "Preview" > > chapter give me errors. Both on a > > shelve.open call: > > > > Pretty simple code, (2nd example): > from; jim-on-linux http://[EMAIL PROTECTED] > My guess, add this and see if it helps also try import anydbm if not on linux, or import dbhash will work on linux > > =code begin= > > import dbhash > > > import shelve > > from people import Person, Manager > > > > bob = Person('Bob Smith', 42, 3, > > 'sweng') sue = Person('Sue Jones', 45, > > 4, 'music') tom = Manager('Tom Doe', > > 50, 5) > > > > db = shelve.open('class-shelve') > > db['bob'] = bob > > db['sue'] = sue > > db['tom'] = tom > > db.close() > > code end > > > > Error message > > Traceback (most recent call last): > > File "make_db_classes.py", line 9, in > > db = > > shelve.open('class-shelve') File > > "C:\PYTHON25\lib\shelve.py", line 225, > > in open return > > DbfilenameShelf(filename, flag, > > protocol, writeback) File > > "C:\PYTHON25\lib\shelve.py", line 209, > > in __init__ Shelf.__init__(self, > > anydbm.open(filename, flag), protocol, > > writeback) > > File "C:\PYTHON25\lib\anydbm.py", line > > 83, in open return mod.open(file, flag, > > mode) File "C:\PYTHON25\lib\dbhash.py", > > line 16, in open return > > bsddb.hashopen(file, flag, mode) File > > "C:\PYTHON25\lib\bsddb\__init__.py", > > line 306, in hashopen d.open(file, > > db.DB_HASH, flags, mode) > > bsddb.db.DBError: (5, 'Input/output > > error') ++End Error message > > > > I've looked on the errata pages of his > > website and used Google to find someone > > else who ran into this problem. Found > > someone else who had a similar error but > > no explanation was given. No other > > reader of the book seems to have had the > > problem. > > > > I'm using 2.5.1 > > > > I thought maybe the file had to exist > > before it could be opened, so I created > > one with that name, but no dice. A > > different but similar set of errors. I > > also thought maybe there had to be a > > second argument like 'a', 'r' or 'w'. > > That doesn't work either. > > > > This is the first chapter of the book. > > It's an overview of the language > > features. So, this is pretty perplexing. > > Any help would be appreciated. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: shelve.open call gives error
On Friday 08 February 2008 03:36, waltbrad wrote: > Working through the Mark Lutz book > Programming Python 3rd Edition. > > A couple of modules in the "Preview" > chapter give me errors. Both on a > shelve.open call: > > Pretty simple code, (2nd example): from; jim-on-linux http://[EMAIL PROTECTED] My guess, add this and see if it helps > =code begin= import dbhash > import shelve > from people import Person, Manager > > bob = Person('Bob Smith', 42, 3, > 'sweng') sue = Person('Sue Jones', 45, > 4, 'music') tom = Manager('Tom Doe', > 50, 5) > > db = shelve.open('class-shelve') > db['bob'] = bob > db['sue'] = sue > db['tom'] = tom > db.close() > code end > > Error message > Traceback (most recent call last): > File "make_db_classes.py", line 9, in > db = shelve.open('class-shelve') > File "C:\PYTHON25\lib\shelve.py", line > 225, in open return > DbfilenameShelf(filename, flag, protocol, > writeback) File > "C:\PYTHON25\lib\shelve.py", line 209, in > __init__ Shelf.__init__(self, > anydbm.open(filename, flag), protocol, > writeback) > File "C:\PYTHON25\lib\anydbm.py", line > 83, in open return mod.open(file, flag, > mode) File "C:\PYTHON25\lib\dbhash.py", > line 16, in open return > bsddb.hashopen(file, flag, mode) File > "C:\PYTHON25\lib\bsddb\__init__.py", line > 306, in hashopen d.open(file, db.DB_HASH, > flags, mode) bsddb.db.DBError: (5, > 'Input/output error') ++End Error > message > > I've looked on the errata pages of his > website and used Google to find someone > else who ran into this problem. Found > someone else who had a similar error but > no explanation was given. No other reader > of the book seems to have had the problem. > > I'm using 2.5.1 > > I thought maybe the file had to exist > before it could be opened, so I created > one with that name, but no dice. A > different but similar set of errors. I > also thought maybe there had to be a > second argument like 'a', 'r' or 'w'. That > doesn't work either. > > This is the first chapter of the book. > It's an overview of the language features. > So, this is pretty perplexing. Any help > would be appreciated. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: shelve.open call gives error
On Friday 08 February 2008 03:36, waltbrad wrote: > Working through the Mark Lutz book > Programming Python 3rd Edition. > > A couple of modules in the "Preview" > chapter give me errors. Both on a > shelve.open call: > > Pretty simple code, (2nd example): > =code begin= > import shelve > from people import Person, Manager > > bob = Person('Bob Smith', 42, 3, > 'sweng') sue = Person('Sue Jones', 45, > 4, 'music') tom = Manager('Tom Doe', > 50, 5) > > db = shelve.open('class-shelve') > db['bob'] = bob > db['sue'] = sue > db['tom'] = tom > db.close() > code end This works for me. I converted your numbers to text, I believe shelves requires string keys and values. I had to eliminate the import Person, Manager If you still have problems you have an idea where to look. jim-on-linux http://[EMAIL PROTECTED] # import shelve ##from people import Person, Manager bob = 'Bob Smith', '42, 3', 'sweng' sue = 'Sue Jones', '45, 4', 'music' tom = 'Tom Doe', '50, 5' db = shelve.open('class-shelve') db['bob'] = bob db['sue'] = sue db['tom'] = tom db.close > > Error message > Traceback (most recent call last): > File "make_db_classes.py", line 9, in > db = shelve.open('class-shelve') > File "C:\PYTHON25\lib\shelve.py", line > 225, in open return > DbfilenameShelf(filename, flag, protocol, > writeback) File > "C:\PYTHON25\lib\shelve.py", line 209, in > __init__ Shelf.__init__(self, > anydbm.open(filename, flag), protocol, > writeback) > File "C:\PYTHON25\lib\anydbm.py", line > 83, in open return mod.open(file, flag, > mode) File "C:\PYTHON25\lib\dbhash.py", > line 16, in open return > bsddb.hashopen(file, flag, mode) File > "C:\PYTHON25\lib\bsddb\__init__.py", line > 306, in hashopen d.open(file, db.DB_HASH, > flags, mode) bsddb.db.DBError: (5, > 'Input/output error') ++End Error > message > > I've looked on the errata pages of his > website and used Google to find someone > else who ran into this problem. Found > someone else who had a similar error but > no explanation was given. No other reader > of the book seems to have had the problem. > > I'm using 2.5.1 > > I thought maybe the file had to exist > before it could be opened, so I created > one with that name, but no dice. A > different but similar set of errors. I > also thought maybe there had to be a > second argument like 'a', 'r' or 'w'. That > doesn't work either. > > This is the first chapter of the book. > It's an overview of the language features. > So, this is pretty perplexing. Any help > would be appreciated. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: class object using widget
On Wednesday 20 February 2008 13:16, you wrote: > from Tkinter import * > # get widget classes from tkMessageBox > import askokcancel # get canned > std dialog > > class Quitter(Frame): > # subclass our GUI def __init__(self, > parent=None): # constructor > method Frame.__init__(self, parent) > self.pack() > widget = Button(self, text='Quit', > command=self.quit) widget.pack(side=LEFT) > def quit(self): > ans = askokcancel('Verify exit', > "Really quit?") if ans: Frame.quit(self) > > if __name__ == '__main__': > Quitter().mainloop() > > In the above program, why the error comes > ?? This example works. I only used carriage return and spacebar for formatting. You are using '\xc2' whatever that represents, I'm not sure. But if you carriage return at the end of each line then delete until the next line comes to the cursor then use only space bar and carriage return (Enter) to format you will fix it. Or copy below and paste into your file. jim-on-linux http://www.inqvista.com from Tkinter import * from tkMessageBox import askokcancel class Quitter (Frame): # subclass our GUI def __init__(self, parent=None): # constructor method Frame.__init__(self, parent) self.pack() widget = Button(self, text='Quit', command=self.quit) widget.pack(side=LEFT) def quit(self): ans = askokcancel('Verify exit', "Really quit?") if ans: Frame.quit(self) if __name__ == '__main__': Quitter().mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Licence confusion: distributing MSVC?71.DLL
> > If someone has worked their way through > > this maze before and has an answer, I'd > > be keen to hear it. This is what someone wrote on 1-21-2007 to this help site about this pain in the a... MSVCR71 stuff. " I believe this problem doesn't exist. Licensees of Python are permitted to redistribute mscvr71.dll, as long as they redistribute it in order to support pythonxy.dll. The EULA says # You also agree not to permit further distribution of the # Redistributables by your end users except you may permit further # redistribution of the Redistributables by your distributors to your # end-user customers if your distributors only distribute the # Redistributables in conjunction with, and as part of, the Licensee # Software, you comply with all other terms of this EULA, and your # distributors comply with all restrictions of this EULA that are # applicable to you. In this text, "you" is the licensee of VS 2003 (i.e. me, redistributing msvcr71.dll as part of Python 2.5), and the "Redistributable" is msvcr71.dll. The "Licensee Software" is "a software application product developed by you that adds significant and primary functionality to the Redistributables", i.e. python25.dll. IANAL; this is not legal advise." jim-on-linux http://www.inqvista.com -- http://mail.python.org/mailman/listinfo/python-list
Re: escape string to store in a database?
> > -- > > Carsten > > Haesehttp://informixdb.sourceforge.net > > Thanks for the reply, Carsten, how would > this work with UPDATE command? I get this > error: > > cmd = "UPDATE items SET content = > ? WHERE id=%d" % id try this; ("update items set contents = (?) where id =(?)", [ x, y] ) put your data in a list or ("update items set contents = (?) where id =%d ", [ x] ) below statement "uses 1" refers to the one (?) , 0 supplied, means no list or none in list. jim-on-linux http://www.inqvista.com > > self.cursor.execute(cmd, content) > pysqlite2.dbapi2.ProgrammingError: > Incorrect number of bindings supplied. The > c > rrent statement uses 1, and there are 0 > supplied. > > Sqlite site doesn't give any details on > using parameter bindings in UPDATE > command, I'm > going to look around some more.. -ak -- http://mail.python.org/mailman/listinfo/python-list
python program deleted
py users, I developed a python program and used py2exe to create the exe. I zip the entire package and email it to my clients. Some clients get the zip file, unzip the package and everything works fine. And some clients get my email with an icon attached which has the correct filename but the size is 8k when it should be about 5 mb. I've renamed the file without the zip ext. and tried other renaming schemes without success. Has anyone had this experience? Any ideas on how to solve this problem. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Re: python program deleted
thanks for the responses. I put the files in an ftp site and all is well. jim-on-linux -- http://mail.python.org/mailman/listinfo/python-list
Problems running on hp duo Pentium R processor
Python help, In September I wrote: I have a number of clients running a program built with python 2.5. One has just purchased an HP with a duo core Pentium R processor E2200, 2.2G with .99g ram. Only on the new HP, when they try to print they get an import error; File win32ui.pyc line 12, in File win32ui.pyc, line 10, in _load ImportError: DLL load failed: The specified module could not be found. It turns out that the E2200 processor is 64 bit architecture. What are my options? I've run DependecyWalker, They are using Win XP Service Pack 2 jim=on-linux -- http://mail.python.org/mailman/listinfo/python-list