Re: How, python with Tk extensions enabled to import Tkinter
Murat Gunduz wrote: > > Dear list member, > > I am using a Linux machine (Fedora Core 7, 64 bit): > Linux 2.6.21-1.3228.fc7 #1 SMP Tue Jun 12 14:56:37 EDT 2007 x86_64 > Fedora ships ready built Tk/Tcl and Tkinter RPM's so use the Package Updater (search for tkinter) or command line 'yum install tkinter' (I may have spelt the tkinter package name wrong so do search for it first) Fedora (like RedHat) has loads of Python related packages so worth checking in the package manager - Search for python- you'll be pleasantly surprised :) Cheers, Martin. -- signature file not found, must be something I ate -- http://mail.python.org/mailman/listinfo/python-list
Re: Acting like button are being pressed (BUT THEY ARE NOT) Please Help
> self.entry00.bind('', self.leftClick(self.entry00, > 0, 0)) # bind left mouse click Difficult to say for sure due to excessive code wrapping.. ;) but I would say that these bind methods are calling the left and right Click methods... rather than bind'ing them to the entry widgets. there are a few good ways around this, lambda, class with __call__ etc etc most of these can be found with a little googling (in case this is homework) Cheers, Martin. -- signature file not found, must be something I ate -- http://mail.python.org/mailman/listinfo/python-list
Re: Tix Note Book
[EMAIL PROTECTED] wrote: > hi > > am using Tix notebook and i have two frames in that. am adding some > widgets in to both of the frames. now i want to delete all of the > widgets in one of the frame. i dont want to delete the frame, but its > childres. > so how can i get the sub widgets within that frame. > > Thanks in advance > Anil > Anil, Standard Tkinter widgets have a .children so for your frame widget try printing the value of yourframe.children like so:- Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> import Tkinter >>> root=Tkinter.Tk() >>> l=Tkinter.Label(root) >>> l.pack() >>> print root.children {'10703960': } >>> HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: logging to a text widget
Alexandre Guimond wrote: > Hi. I'm using the logging package. I would like to send my log messages > to a Text widget creating using Tkinter. I was wondering if there was a > logging handler class that would do this. It seems that the standard > handlers do not support this. Has anyone tried to do this? > Alex, To be honest I haven't used the logging package (it's on my todo list ;) but I normally sub class the Text widget, give it a write method then send stdout / stderr to it normally (sys.stdout = mytextWidget) At the same time I also add scrollbars and in the write method I scroll to the latest message. Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter canvas size determination
Dean Allen Provins wrote: > Cameron: > > Cameron Laird wrote: >> In article <[EMAIL PROTECTED]>, >> Dean Allen Provins <[EMAIL PROTECTED]> wrote: >> >>> I need to determine the size of a canvas while the process is running. >>> Does anyone know of a technique that will let me do that? >> . >> . >> . >> Does >> >>> import Tkinter >> >>> c = Tkinter.Canvas() >> >>> c.create_oval(13, 51, 80, 130) >> 1 >> >>> c.pack() >> >>> print c.cget("width") >> 284 >> help? >> >> There are actually several different notions of the size of a >> canvas. The example abovve should be a good starting point, >> though. >> >> There's also a mailing list specifically for Tkinter > http://tkinter.unpythonic.net/wiki/mailing_20lists >; that >> might interest you. > > I tried the "cget" function, and it returned the width that I had used > when creating the canvas - even though the canvas was wider than that > value at display time (and also after manually resizing the window). > > To your knowledge, is there a method to determine the current dimensions? > > Thanks, > > Dean Dean, Look at the winfo_* methods of Tkinter widgets, I think the one you want is called winfo_reqheight / winfo_reqwidth or something very similar pydoc Tkinter.Canvas will sort that out Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: regular expresson for Unix and Dos Lineendings wanted
Franz Steinhaeusler wrote: > On Thu, 23 Feb 2006 14:46:20 +0100, Franz Steinhaeusler > <[EMAIL PROTECTED]> wrote: > >> Hello, I need a regularexpression, which trims trailing whitespaces. >> >> While with unix line endings, it works; >> but not with Window (Dos) CRLF's: > > Thank you all for the replies. > But I still don't have a solution. > > Of course with more lines it is possible, > but it would be fine to have a "oneliner". > Then I clearly don't understand your problem... it seems we gave you several ways of skinning your cat... but none of them 'worked'? I find that hard to believe... perhaps you can re-state you problem or show us your more than one line solution...(so that we might learn from it) Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: regular expresson for Unix and Dos Lineendings wanted
Franz Steinhaeusler wrote: > On Thu, 23 Feb 2006 13:54:50 +0000, Martin Franklin > <[EMAIL PROTECTED]> wrote: > >>>>>> r="erewr\r\nafjdskl " >>> 'erewr\r\nafjdskl' >>> >>> 2) Unix >>>>>> r="erewr\nafjdskl " >>> 'erewr\nafjdskl' >> why not use string methods strip, rstrip and lstrip >> > > because this removes only the last spaces, >>>> r > 'erewr\r\nafjdskl ' >>>> r.rstrip() > 'erewr\r\nafjdskl' > > I want: > 'erewr\r\nafjdskl' > > or for unix line endings > 'erewr\nafjdskl' > how about one of these variations print 'erewr\r\nafjdskl '.replace(" ", "") print 'erewr\r\nafjdskl '.strip(" \t") -- http://mail.python.org/mailman/listinfo/python-list
Re: regular expresson for Unix and Dos Lineendings wanted
Franz Steinhaeusler wrote: > Hello, I need a regularexpression, which trims trailing whitespaces. > > While with unix line endings, it works; > but not with Window (Dos) CRLF's: > import re retrailingwhitespace = re.compile('(?<=\S)[ \t]+$', re.MULTILINE) > > 1) Windows r="erewr\r\nafjdskl " newtext, n = retrailingwhitespace.subn('', r) n > 1 newtext > 'erewr\r\nafjdskl' > > 2) Unix r="erewr\nafjdskl " newtext, n = retrailingwhitespace.subn('', r) n > 2 newtext > 'erewr\nafjdskl' > > Who can help me (regular expression, which works for both cases). > > Thank you in advance! why not use string methods strip, rstrip and lstrip -- http://mail.python.org/mailman/listinfo/python-list
Re: Little tool - but very big size... :-(
Durumdara wrote: > Dear Martin ! > > Thanx for it: > > setup( > options = {"py2exe": {"bundle_files": 1, # < this > help me > "compressed": 1, > "optimize": 2}}, > # The lib directory contains everything except the executables and > the python dll. > # Can include a subdirectory name. > windows = [wxPyHDDirList], > ) > > Can I increase level of the optimization ? > Can I increase level of the zip packing ? Sorry, I have not used py2exe for some time, you would be better to ask this question on the py2exe list: https://lists.sourceforge.net/lists/listinfo/py2exe-users or read their documentation http://www.py2exe.org/ or Wiki http://starship.python.net/crew/theller/moin.cgi/Py2Exe in particular... http://starship.python.net/crew/theller/moin.cgi/BetterCompression HTH > > Please help me: dd > > > Martin Franklin wrote: > >> Durumdara wrote: >> >> >>> Hi ! >>> >>> I have a problem. >>> I have a little tool that can get data about filesystems and wrote it in >>> python. >>> >>> The main user asked me a GUI for this software. >>> >>> This user is needed a portable program, so I create this kind of the >>> software with Py2Exe. >>> >>> But it have very big size: 11 MB... :-( >>> >>> I need to have more compressed result. Can I compress dll-s, pyd-s with >>> Py2Exe ? >>> Can I decrease the total size with something ? >>> >>> >> >> >> you could try UPX http://upx.sourceforge.net/ I think it will handle >> the .pyd and dll files (it did the last time I tested it) >> >> >> >> >>> If not, how to I create an self-unpackager and self-starter program that >>> use an temporary directory in the disk ? With WinRar ? >>> >>> >> I may be wrong (havn't used py2exe in a while) but I think it can now >> (again) create a single exe file? Otherwise something like Inno Setup >> http://www.jrsoftware.org/isinfo.php or a simple self extracting zip >> file >> >> >> >> >> >>> Thanx for help: >>> dd >>> >>> >>> >>> >>> >> >> > -- http://mail.python.org/mailman/listinfo/python-list
Re: Little tool - but very big size... :-(
Durumdara wrote: > Hi ! > > I have a problem. > I have a little tool that can get data about filesystems and wrote it in > python. > > The main user asked me a GUI for this software. > > This user is needed a portable program, so I create this kind of the > software with Py2Exe. > > But it have very big size: 11 MB... :-( > > I need to have more compressed result. Can I compress dll-s, pyd-s with > Py2Exe ? > Can I decrease the total size with something ? you could try UPX http://upx.sourceforge.net/ I think it will handle the .pyd and dll files (it did the last time I tested it) > > If not, how to I create an self-unpackager and self-starter program that > use an temporary directory in the disk ? With WinRar ? I may be wrong (havn't used py2exe in a while) but I think it can now (again) create a single exe file? Otherwise something like Inno Setup http://www.jrsoftware.org/isinfo.php or a simple self extracting zip file > > Thanx for help: > dd > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Downloading files using urllib in a for loop?
[EMAIL PROTECTED] wrote: > Thanks - but have printed and verified they are valid paths and > filenames. One correction to the code I listed: >theurl = imagepath[:-8] > > For some reason the values aren't being passed through > urllib.urlretrieve properly but this makes no sense to me? > A working (for me!) example:- import urllib paths = ["http://www.python.org/index.html";, ] for remotepath in paths: # keep only last 10 chars (index.html) # for local file name localpath = remotepath[-10:] print remotepath, localpath urllib.urlretrieve(remotepath, localpath) -- http://mail.python.org/mailman/listinfo/python-list
Re: Downloading files using urllib in a for loop?
Martin Franklin wrote: > [EMAIL PROTECTED] wrote: >> Hi, >> I'm using Python 2.3 on Windows for the first time, and am doing >> something wrong in using urllib to retrieve images from urls embedded >> in a csv file. If I explicitly specify a url and image name it works >> fine(commented example in the code), but if I pass in variables in this >> for loop it throws errors: >> >> --- The script: >> >> import csv, urllib >> reader = csv.reader(open("source.csv")) >> for x,y,z,imagepath in reader I just noticed the code you sent will not work... notice the lack of a colon ( : ) and the end of the 'for' line please post an exact copy of your code and also the results with the included print debugging line (with or without repr ;) ) Cheers Martin >> theurl = imagepath[:55] >> theimage = imagepath[55:-8] > > "No such file or directory: ''" sounds to me like you are trying > to open a file called '' (empty string) > > try adding some debugging > > print theimage, imagepath > > > >> urllib.urlretrieve(theurl, theimage) >> #urllib.urlretrieve("http://someurl/image.gif";, "image.gif") # works! >> >> --- The errors: >> >> This throws the following errors: >> File "getimages.py", line 9, in ? >> urllib.urlretrieve(theurl,theimage) >> File "C:\Python23\lib\urllib.py", line 83, in urlretrieve >> return _urlopener.retrieve(url, filename, reporthook, data) >> File "C:\Python23\lib\urllib.py", line 213, in retrieve >> fp = self.open(url, data) >> File "C:\Python23\lib\urllib.py", line 181, in open >> return getattr(self, name)(url) >> File "C:\Python23\lib\urllib.py", line 410, in open_file >> return self.open_local_file(url) >> File "C:\Python23\lib\urllib.py", line 420, in open_local_file >> raise IOError(e.errno, e.strerror, e.filename) >> IOError: [Errno 2] No such file or directory: '' >> >> --- >> >> Would really appreciate some pointers on the right way to loop through >> and retrieve images, as I've tried various other solutions but am >> clearly missing something simple! >> >> Thanks, >> >> justin. >> > -- http://mail.python.org/mailman/listinfo/python-list
Re: Downloading files using urllib in a for loop?
[EMAIL PROTECTED] wrote: > Hi, > I'm using Python 2.3 on Windows for the first time, and am doing > something wrong in using urllib to retrieve images from urls embedded > in a csv file. If I explicitly specify a url and image name it works > fine(commented example in the code), but if I pass in variables in this > for loop it throws errors: > > --- The script: > > import csv, urllib > reader = csv.reader(open("source.csv")) > for x,y,z,imagepath in reader > theurl = imagepath[:55] > theimage = imagepath[55:-8] "No such file or directory: ''" sounds to me like you are trying to open a file called '' (empty string) try adding some debugging print theimage, imagepath > urllib.urlretrieve(theurl, theimage) > #urllib.urlretrieve("http://someurl/image.gif";, "image.gif") # works! > > --- The errors: > > This throws the following errors: > File "getimages.py", line 9, in ? > urllib.urlretrieve(theurl,theimage) > File "C:\Python23\lib\urllib.py", line 83, in urlretrieve > return _urlopener.retrieve(url, filename, reporthook, data) > File "C:\Python23\lib\urllib.py", line 213, in retrieve > fp = self.open(url, data) > File "C:\Python23\lib\urllib.py", line 181, in open > return getattr(self, name)(url) > File "C:\Python23\lib\urllib.py", line 410, in open_file > return self.open_local_file(url) > File "C:\Python23\lib\urllib.py", line 420, in open_local_file > raise IOError(e.errno, e.strerror, e.filename) > IOError: [Errno 2] No such file or directory: '' > > --- > > Would really appreciate some pointers on the right way to loop through > and retrieve images, as I've tried various other solutions but am > clearly missing something simple! > > Thanks, > > justin. > -- http://mail.python.org/mailman/listinfo/python-list
Re: HOWTO Send a string???
Sbaush wrote: > Hi all. > In my application I have to do implement a lot of networking in python > My application can create with a GUI a XML file in a string.(and now my > application can do it wow!!) > This string has to be sended to another host. i need a python application > that send this string via UDP. > The packet of this communication is |int|payload| where payload is the XML > string. > After the send my application has to wait for a response and has to receive > response. > For the heaven it should be implemented with separated thread. A thread > send/receive while another indipendent thread do same. > > Have you any ideas to do it more simply as possible? > What is the best way to di it?? > What is the best way to thread programming in python? > > Thanks all for your help with me! > -- for python & socket how to : http://www.amk.ca/python/howto/sockets/ You may also want to look at: http://pyro.sourceforge.net/ which gives you a pythonic solution HTH, Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with FTPLib and incomplete files on some downloads
Peter A.Schott wrote: > I download a lot of 4-6 KB files and regularly run into issues with files that > don't get downloaded all the way or otherwise get corrupt. > > I do something like: > > RemoteList = nlstdir() > for filename in RemoteList: > LocalFile = open(filename, "wb") > LocalFile.write( "get file code here" ) > LocalFile.close() > #ftplib call to delete the remote file > > I've tried to insert a pause into the code between the close and the remote > delete, but that doesn't seem to help. For some reason it doesn't seem like > the > buffer is completely written or read before the remote delete is called. That > leads to a file that's not 100% complete and thus can't be decrypted. > > Any ideas on what to look for? I don't have my exact code handy at the moment > or I'd post some actual snippets. It's also not consistent or it would be a > whole lot easier to troubleshoot. :-) > > Running Python 2.4.2 on Win32. > > Thanks. > > -Pete Schott Pete, Not sure but here is an example that seems to always work for me: (tested this morning before pasting here on ~20 files around 7 - 300 k) import ftplib import os os.chdir("D:/TEMP/dump") ftp = ftplib.FTP("server") print ftp.login("anonymous", "[EMAIL PROTECTED]") ftp.cwd("pub/Python_Applications") for rFile in ftp.nlst(): print "Getting : ", rFile rSize = ftp.size(rFile) lFile = open(rFile, "wb") ftp.retrbinary("RETR %s" %rFile, lFile.write) lSize = lFile.tell() lFile.close() if rSize==lSize: print "Transfer complete" else: print "BAD Transfer", rSize, lSize ftp.close() HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Can't import Tkinter module.
slomo wrote: > I'm working on linux Fedora Core 3 with Python 2.3. > I can't "from Tkinter import *" . > And see only "No modlue named Tkiner" error. > Of course I have tk/tcl 8.4. They works perfectly. > Certainly, I don't have Tkinter module for Python. > What should I do for it as I'm not a root? > as root you could do: yum install tkinter Without root, you will have to build python + tkinter yourself from the source (available from www.python.org) Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Scrollbar not working
Dustan wrote: > Martin Franklin wrote: > >>Dustan wrote: >> >>>I'm trying to get a scrollbar bound with a Frame, and I keep on getting >>>a scrollbar, but it doesn't actually scroll. Some help, please? >>> >> >>It can be tricky getting an empty frame to scroll, can you post your >>example code so that we might be more helpful. Here is an example of >>binding a scroll bar to a Text widget (not exactly the same thing) >> > > > It's not an empty frame. It has a label. I was trying to do it with > just the label, but it didn't work, and I figured it might be a better > idea to try doing it with a frame instead. > > >>## import all names from Tkinter >>## bit naughty but I don't mind >>from Tkinter import * >> >> >># root window >>root=Tk() >> >> >># text area >>text=Text() >>text.pack(side="left", expand="yes", fill="both") >> >># scrolbar for above textarea >>sb = Scrollbar(root) >>sb.pack(side="right", fill="y") >> >> >> >>## bind them both together... >> >># this line binds the yscrollcommand >># of the text area to the scrollbar set method >>text['yscrollcommand'] = sb.set >> >># this line binds the scrollbars command to >># the yview method of the text area >>sb['command'] = text.yview >> >> >> >># mainloop entry >>root.mainloop() > > > That doesn't help. I need to be able to do it either with a frame (has > content!) or a Text widget. > Perhaps I am not understanding something... can you please show me an example of what is not working. I consider the above a good recipe that can be applied to any scrollable widget in Tkinter. hmm, a single change to my example (Text to Frame) produces this traceback:- >C:/python24/python -u "quicksb.py" Traceback (most recent call last): File "quicksb.py", line 17, in ? text['yscrollcommand'] = sb.set File "C:\python24\lib\lib-tk\Tkinter.py", line 1146, in __setitem__ self.configure({key: value}) File "C:\python24\lib\lib-tk\Tkinter.py", line 1139, in configure return self._configure('configure', cnf, kw) File "C:\python24\lib\lib-tk\Tkinter.py", line 1130, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: unknown option "-yscrollcommand" >Exit code: 1 and another change (Frame to Label) produces this traceback:- >C:/python24/python -u "quicksb.py" Traceback (most recent call last): File "quicksb.py", line 17, in ? text['yscrollcommand'] = sb.set File "C:\python24\lib\lib-tk\Tkinter.py", line 1146, in __setitem__ self.configure({key: value}) File "C:\python24\lib\lib-tk\Tkinter.py", line 1139, in configure return self._configure('configure', cnf, kw) File "C:\python24\lib\lib-tk\Tkinter.py", line 1130, in _configure self.tk.call(_flatten((self._w, cmd)) + self._options(cnf)) _tkinter.TclError: unknown option "-yscrollcommand" >Exit code: 1 This would suggest that the Frame and Label widgets are not scrollable (at least not in the 'y' direction) Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Scrollbar not working
Dustan wrote: > I'm trying to get a scrollbar bound with a Frame, and I keep on getting > a scrollbar, but it doesn't actually scroll. Some help, please? > It can be tricky getting an empty frame to scroll, can you post your example code so that we might be more helpful. Here is an example of binding a scroll bar to a Text widget (not exactly the same thing) ## import all names from Tkinter ## bit naughty but I don't mind from Tkinter import * # root window root=Tk() # text area text=Text() text.pack(side="left", expand="yes", fill="both") # scrolbar for above textarea sb = Scrollbar(root) sb.pack(side="right", fill="y") ## bind them both together... # this line binds the yscrollcommand # of the text area to the scrollbar set method text['yscrollcommand'] = sb.set # this line binds the scrollbars command to # the yview method of the text area sb['command'] = text.yview # mainloop entry root.mainloop() -- http://mail.python.org/mailman/listinfo/python-list
Re: putting checkbuttons in a listbox
valen1260 wrote: > I'd like to have a multicolumn listbox, with one column being a list of > items and the other being a list of checkbuttons. The user could check > his "favorites" and then shorten the list to show only the checked items. > > I have implemented the MultiListbox at > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52266 . I then > tried attaching the checkbuttons to a listbox object. To get them to > display, I had to pack them, but in packing them, they just disregard > the scrollable listbox and take as much room as needed. > > Has anyone implemented anything like this? Is there a way to put > checkbuttons in a fixed-height, scrollable listbox or similar structure? snipped from the above recipe :- """ Discussion: The resulting widget is lightweight, fast, and very easy to use. The main limitation is that only text is supported which is a fundamental limitation of the Listbox. In this implementation, only single-selection is allowed but it could be extended to multiple selection. User-resizeable columns and auto-sorting by clicking on the column label should also be possible. Auto-scrolling while dragging Button-1 was disabled because this was breaks the synchronization between the lists. However, scrolling with Button-2 works fine. """ so you cannot put anything other than text into a standard Tk Listbox however you could try using a non-standard table widget see here for more details :- http://tkinter.unpythonic.net/wiki/Widgets Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: text manipulation
Martin Franklin wrote: > Johhny wrote: > >>Hello, >> >>I am trying to write a script in python (to replace a perl script with >>limited functionality). Now I have some issues. Currently I am using >>the perl to load the file then regex parse certain lines to remove >>characters (uncomment lines and change variables). I would like to take >>that into the python script. I have had a look at the module "string" >>and I dont think its what Im looking for. >> >>Here is an example of some text I would like to manipulate >> >>#comment here >>#user_defined_variable = no >># >> >>I would like to make that >> >>#comment here >>user_defined_variable = yes >># >> >>With perl/sed Its very easy, However Im having issues to do it in >>python. Any advice would be great. >> >>Regards, >> >>Johhny. >> > > > > forget regular expressions for this job... strings have methods in > python so for example: > > > for line in file: > if line.startswith("#user_defined_variable = no"): > line.replace("#user_defined_variable = no", > "user_defined_variable = yes") > > ... continue processing file / writing out stuff as you go > > > Cheers > Martin > whoops forgot string methods return the new string. for line in file: if line.startswith("#user_defined_variable = no"): line = line.replace("#user_defined_variable = no", "user_defined_variable = yes") -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter: drop-down widget
James Stroud wrote: > Alex Hunsley wrote: > >>Can anyone recommend some code for creating drop-down menus in tkinter? >>To be absolutely clear, here's an example of a drop-down: >> >>http://www.google.co.uk/preferences?hl=en >>(see the language selection widget) >> >>I've found the odd bit of code here and there, such as: >>http://infohost.nmt.edu/tcc/cgi/pre.cgi?file=/u/www/docs/tcc/help/lang/python/mapping/dropdown.py >> >> >> >>alex > > > Try: > > 1. Tkinter OptionMenu: > http://effbot.org/tkinterbook/optionmenu.htm > > 2. Pmw OptionMenu: > http://pmw.sourceforge.net/doc/OptionMenu.html > > I would opt for these before a roll-your-own version. try searching for a ComboBox I think you will have more hits I know Pmw has one, it is also quite easy to build your own with an Entry, Button and Listbox widget + some nifty code ;) Cheers, Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: text manipulation
Johhny wrote: > Hello, > > I am trying to write a script in python (to replace a perl script with > limited functionality). Now I have some issues. Currently I am using > the perl to load the file then regex parse certain lines to remove > characters (uncomment lines and change variables). I would like to take > that into the python script. I have had a look at the module "string" > and I dont think its what Im looking for. > > Here is an example of some text I would like to manipulate > > #comment here > #user_defined_variable = no > # > > I would like to make that > > #comment here > user_defined_variable = yes > # > > With perl/sed Its very easy, However Im having issues to do it in > python. Any advice would be great. > > Regards, > > Johhny. > forget regular expressions for this job... strings have methods in python so for example: for line in file: if line.startswith("#user_defined_variable = no"): line.replace("#user_defined_variable = no", "user_defined_variable = yes") ... continue processing file / writing out stuff as you go Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Clearing the Tkinter Window
James Stroud wrote: > Dustan wrote: > >>I'm a newbie here, especially with Tkinter. I'm writing a program that >>has 3 phases, if you will, in which I would have to clear the window >>and insert new widgets. Is this possible, and if so, how? I'm writing >>my application class based on Frame, if that helps at all. >> > > > Its not obvious what you are asking. > > But, if you populate a Frame with widgets, then you can destroy those > widgets if you destroy the Frame: > > tk = Tk() > f = Frame(tk) > > # fill frame with 10 buttons > for i in xrange(10): >Button(f, text=str(i)).pack() > > # kill the frame and buttons > f.destroy() # references to buttons gone too, so they are GC'd > > # make a new frame and put it in tk > f = Frame(tk) > > # etc. > > You will want to make sure any name assignments are re-assigned, del'd, > or go out of scope after you destroy frame, or the button objects won't > be garbage collected, even though they are destroyed when the frame is > destroyed. > > James destroy is one way to do it... but if you need to access the destroyed widgets information after they have gone it may cause problems.. another method to look at is (are) the *_forget methods (pack_forget / grid_forget) these do not destroy the widgets but rather remove them from view. If for example you are writing a 'wizard' type GUI and want to show the user the 'Next' page simply forget the current page and pack the next one in it's place. Another way is to grid each 'page' over the top of each other and simply change the 'raise' order (with tkraise method) not 100% sure if this works though, i've not used it directly myself... Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Force Focus in Tkinter
annagel wrote: > Thanks for the reply and as it turns out no I don't think I really do > want to do this. I started working with tkinter after banging my head > against the wall for a while with wxwindows so the whole thing ended up > being a last minute change so I am trying to get most at least of the > bugs out on a tighter scedule than I planned. Basically coming from wx > I had it in my head that I had to call a main loop or nothing would > work and this meant threads which meant all kinds of extra headaches. > In my desperation I dropped the whole thing and just started opening > windows and to my utter suprise it worked. > > Now I just initialize a root window in my import statement withdraw it > and let the user use a picture viewer I made with a toplevel window, a > file chooser, folder chooser, and color chooser. I am still having a > couple problems though if anyone out there can shed some light I would > be apreciative. First the ColorChooser for some reason this dialog > does not open on its own. I am running on Mac and calling it gets my > python icon bouncing but it does not appear till I go click on the > icon. Second I am getting phantom window return with the folder and > file picker. If I have used one of these before showing the picture > viewer and then pop that up when I click on the picture window I also > get the most recent file dialog (filenameopen or directoryopen) as an > unresponsive window. > > Any advice on either of those problems would be great. Sorry about the > intial post in my head I knew doing something like that would just be > evil, but you start to think crazy when your sollution is too > complicated for the problem. > > Andrew > Andrew, Glad to hear you got it working, could you post some example code that shows these other problems? Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Is Python string immutable?
Chris Mellon wrote: > On 11/30/05, could ildg <[EMAIL PROTECTED]> wrote: > >>In java and C# String is immutable, str=str+"some more" will return a new >>string and leave some gargabe. >>so in java and C# if there are some frequent string operation, >>StringBuilder/StringBuffer is recommanded. >> >>Will string operation in python also leave some garbage? I implemented a >>net-spider in python which includes many html string procession. After it >>running for sometime, the python exe eats up over 300M memory. Is this >>because the string garbages? >> >>If String in python is immutable, what class should I use to avoid too much >>garbages when processing strings frequently? > > > Python strings are immutable. The StringIO class provides a buffer > that you can manipulate like a file, and then convert to a string and > is probably most suitable for your purposes. > another recipe is to build up a list with .append then when you need to convert to a string with "".join(alist) -- http://mail.python.org/mailman/listinfo/python-list
Re: Help!!! On Tkinter Menu problem!!!
Xuening wrote: > I have a problem about menu by using Tkinter. I want to make a dynamic > menu. That is when I create a new view/window, one menuitem will be > added to the menu. and when I kill a window, the correponding menuitem > will be deleted. I write a simple code and I can add menuitem now. But > I don't know how to remove the item when I close the window. > > The following is my code: > > > == > from Tkinter import* > > class App: > def __init__(self): > root=Tk() > self.root=root > self.doMenus() > root.config(menu=self.mBar) > delete=deletewindow() > self.root.mainloop() > > def doMenus(self): > mBar=Menu(self.root) > self.mBar=mBar > self.doFileMenu() > self.doWindowMenu() > > def doFileMenu(self): > filemenu = Menu(self.mBar,tearoff=0,background='yellow') > filemenu.add_command(label='New > window',underline=0,command=self.newWindow) > filemenu.add('separator') > > filemenu.add_command(label='Quit',underline=0,command=self.root.destroy) > self.filemenu=filemenu > self.mBar.add_cascade(label="File", menu=self.filemenu) > > def doWindowMenu(self): > WinName = Menu(self.mBar, > tearoff=0,postcommand=self.windowListUpdate) > self.windowMenu=WinName > self.mBar.add_cascade(label="Window", menu=self.windowMenu) > self.windowList=[] > self.nWindows=0 > > def windowListUpdate(self): > self.windowMenu.delete(0, END) > for window in self.windowList: > self.windowMenu.add_command(label=window) > > > def newWindow(self): > self.nWindows+=1 > windowName = "Window %d"% self.nWindows > self.windowList.append(windowName) > self.windowListUpdate() > > root2=Tk() > self.root2=root2 > self.root2.title(windowName) > canvas=Canvas(self.root2, width=450,height=300,bg='green') > canvas.pack() > self.canvas=canvas > > if __name__ == '__main__': > test=App() > > > Maybe I should bind something to event. Everytime I close the > window, the name of the window should be removed from the windowList > and refresh the all the menuitems again. But I don't know how and > where to add the "destroy" event. Can anyone give me a hand > > Thanks a lot!! > The Menu Tk Widget has a delete or deletecommand method(s) the first accepts an index the second a Menu label, both will remove the menu entry for more on this... http://effbot.org/tkinterbook/menu.htm Regards Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: How to make tkFileDialog GUI larger?
John Wheez wrote: > Hi all, > > I'm using teh tkFileDialog to let teh user select a directory. We have > long names which make > it difficult to view the directories. > > For some reason the GUI windows doesn;t expand on Windows like it does > on OS X or Linux. > Is there a method to make the widths of the tkFileDialog windows larger > when using Windows XP? > > Thanks for any info. > > .JW this is due to Tk using a native Windows file dialog and I guess this is the default behavior on Windows... There may be a special Windows only hack but I'm sorry I don't know what it would be Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding Python Documentation
Josh Cronemeyer wrote: > On Thursday 24 November 2005 09:27 am, Simon Brunning wrote: > >>On 24/11/05, Josh Cronemeyer <[EMAIL PROTECTED]> wrote: >> >>>I have very little experience programming in python but considerable >>>experience with java. One thing that is frustrating me is the >>>differences in the documentation style. Javadocs, at the top level are >>>just a list of packages. Drilling down on a package reveals a list of >>>classes in that package, and drilling down on a class reveals a list of >>>methods for that class. Is there something similar for python? >>> >>>The closest thing I have found to this for python is >>>http://www.python.org/doc/2.4.2/modindex.html which really isn't the >>>same thing at all. >> >>I think it is, really. Thing is, Python's standard library is broader >>and less nested in structure than Java's, so it stands to reason that >>its documetation will be broader and less nested in structure too. >> >>-- >>Cheers, >>Simon B, >>[EMAIL PROTECTED], >>http://www.brunningonline.net/simon/blog/ > > > It is true about the nature of Python's standard library. But when dealing > with a large set of methods, for example, the OS module, it is nice to have > the javadoc API style documentation. You can see a quick summary of what is But you can :) On windows the option is called "Module docs" this starts a local http server that you can point your browser at (indeed just click the Open browser button) and you will see the python standard library API (pydoc) On linux / UNIX the pydoc command line accepts a flag (not sure what it is) but with the flag (-g I seem to remember) will do the same as a the windows thing) the added benifit of pydoc is that you can 'run' it on your own code and see the resulting API description too! Cheers Martin > available, then if you want more detail you drill down on that particular > method. Oh well. I'll get used to it :) > > Thanks! > Josh -- http://mail.python.org/mailman/listinfo/python-list
Re: Copy files to Linux server through ssh tunnel
[EMAIL PROTECTED] wrote: > Hi ! > > I have some backup files on a server farm. > I want to store these local backup files on a backup file server for > "safety's snake". > > These files are compressed zip files with 12 character length password. > But my system admin asked me, how can I improve the safety of the copy > operation, and the storing (now I use Samba share to store these files. I > map the SMB share on the client, copy these files, and unmap SMB). > > Then I thinking to ssh protocol to improve protection. > > The backup script is a py script. I see that Winscp can copy files through > ssh tunnel. Can I do it too ? > How ? How to I do it in pythonic way ? > > Please help me with some examples or urls or other infos ! > > Thanks * 1000: > dd > > > > > > > > -- > 1 Gbyte Ingyenes E-Mail Tárhely a MailPont-tól > http://www.mailpont.hu/ > See this: http://www.lag.net/paramiko/ with this library you can use sftp to transfer you files. -- http://mail.python.org/mailman/listinfo/python-list
Re: about install wxPython in Redhat Linux AS 4
Leo Jay wrote: > Dear All, > > I'd like to install wxPython in my Redhat AS 4, > I have downloaded both > wxPython-common-gtk2-unicode-2.6.1.0-fc2_py2.4.i386.rpm and > wxPython2.6-gtk2-unicode-2.6.1.0-fc2_py2.4.i386.rpm packages from > www.wxpython.org. > > After I installed these two packages successfully, what should i do now? > > i tried to import wx in python, but python just returned an error: > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named wx > > Anyone can help me, please? > > Thanks > > > -- > Best Regards, > Leo Jay Leo, I don't have AS 4 but fedora core 4 has wx in it's YUM repositories I assume RedHat has too, so perhaps you need to use the officially sanctioned version. If you want to use the latest and greatest then you will most likely need to build them from source (which means installing the -devel packages for python & GTK) Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: services on linux
Christoph Haas wrote: > On Tue, Sep 20, 2005 at 02:57:26AM -0500, pt python wrote: > >>im moving from the windows world to the linux world and i need to make >>a python script to see if a service is instaled (ex: apache), if it is >>running or stoped and to start/stop a service like apache or mysql. >>Theres an API on windows to manage services and i need to know how to >>do that on linux. Can anyone help me with the module and API to work >>with services on linux? > > > Unless you really want to do that in Python. It's just a matter of "ps" > and "grep". Simple shell stuff. > > Example: ps ax | grep apache > On RedHat based distro's (fedora in my case) /sbin/service sshd status gives me (as a normal user) the status of my ssh server not sure if other distro's have this... > >>by the way, im developing a app, maybe multi-plataform, to install and >>manage several open source packages like apache, mySQL, phpwebadmin, >>phpnuke, etc... if anyone have nice ideais i apreciate that.. > > > That's usually the Linux distribution's job to handle the installed > packages. Some distributions do that better than others > (Debian). ;) Or what did you mean when you said "install > and manage"? > yeah you really need to look at the tools you have been given with your distro, rpm, deb, etc for the best way. If it's pure python then the distutils package (in the python standard library) may help, also I noticed that PyInstaller 1.0 has just been released http://pyinstaller.hpcf.upr.edu/pyinstaller and has options to create single file installers for Linux / IRIX and Windows... -- http://mail.python.org/mailman/listinfo/python-list
Re: Printer List from CUPS
Mike Tammerman wrote: > I am using Ubuntu. pycups seems to be not existed any more. > > Mike > Yeah as I said if you're using a redhat based distro... However you could try getting the redhat / fedora rpm that provides pycups and installing it? I would ask on the Ubuntu list, I know they are a very python friendly bunch :) Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Printer List from CUPS
Mike Tammerman wrote: > Hi, > > I want to get the printer list from CUPS. I found some ways using > > lpstat -p and > http://localhost:631/printers > > but, these ways require some parsing and I am not sure, if the parsing > works all the time. A pythonic way would be very helpful. > > Thanks, > Mike > Just for fun I tried this on my Fedora core 4 box [~]$ python Python 2.4.1 (#1, May 16 2005, 15:19:29) [GCC 4.0.0 20050512 (Red Hat 4.0.0-5)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pycups >>> so I guess if you are on a redhat based distro there is hope... -- http://mail.python.org/mailman/listinfo/python-list
Re: reading the last line of a file
Martin Franklin wrote: > Martin Franklin wrote: > >>Xah Lee wrote: >> >> >>>Martin Franklin wrote: >>> >>> >>> >>>>import gzip >>>>log_file = gzip.open("access_log.4.gz") >>>>last_line = log_file.readlines()[-1] >>>>log_file.close() >>> >>> >>>does the >>>log_file.readlines()[-1] >>>actually read all the lines first? >> >> >> >>Yes I'm afraid it does. >> >> >> >> >>>i switched to system call with tail because originally i was using a >>>pure Python solution >>> >>>inF = gzip.GzipFile(ff, 'rb'); >>>s=inF.readlines() >>>inF.close() >>>last_line=s[-1] >>> >>>and since the log file is 100 megabytes it takes a long time and hogs >>>massive memory. >>> >> >> >>Ok, in that case stick to your shell based solution, although 100 >>megabytes does not sound that large to me I guess it is relative >>to the system you are running on :) (I have over a gig of memory here) >> > > > And just a few minutes after I sent that... this... > > import gzip > > logfile = gzip.open("access_log.4.BIG.gz") > > ## seek relative to the end of the file > logfile.seek(-500) > > last_line = logfile.readlines()[-1] > > logfile.close() > > print last_line > > > Works quite fast on my machine... > whoops, no it doesn't looking at wrong window :( just ignore me please :) -- http://mail.python.org/mailman/listinfo/python-list
Re: reading the last line of a file
Martin Franklin wrote: > Xah Lee wrote: > >>Martin Franklin wrote: >> >> >>>import gzip >>>log_file = gzip.open("access_log.4.gz") >>>last_line = log_file.readlines()[-1] >>>log_file.close() >> >> >>does the >>log_file.readlines()[-1] >>actually read all the lines first? > > > > Yes I'm afraid it does. > > > >>i switched to system call with tail because originally i was using a >>pure Python solution >> >> inF = gzip.GzipFile(ff, 'rb'); >> s=inF.readlines() >> inF.close() >> last_line=s[-1] >> >>and since the log file is 100 megabytes it takes a long time and hogs >>massive memory. >> > > > Ok, in that case stick to your shell based solution, although 100 > megabytes does not sound that large to me I guess it is relative > to the system you are running on :) (I have over a gig of memory here) > And just a few minutes after I sent that... this... import gzip logfile = gzip.open("access_log.4.BIG.gz") ## seek relative to the end of the file logfile.seek(-500) last_line = logfile.readlines()[-1] logfile.close() print last_line Works quite fast on my machine... Regards Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: reading the last line of a file
Xah Lee wrote: > Martin Franklin wrote: > >>import gzip >>log_file = gzip.open("access_log.4.gz") >>last_line = log_file.readlines()[-1] >>log_file.close() > > > does the > log_file.readlines()[-1] > actually read all the lines first? Yes I'm afraid it does. > > i switched to system call with tail because originally i was using a > pure Python solution > > inF = gzip.GzipFile(ff, 'rb'); > s=inF.readlines() > inF.close() > last_line=s[-1] > > and since the log file is 100 megabytes it takes a long time and hogs > massive memory. > Ok, in that case stick to your shell based solution, although 100 megabytes does not sound that large to me I guess it is relative to the system you are running on :) (I have over a gig of memory here) > Xah > [EMAIL PROTECTED] > ∑ http://xahlee.org/ > -- http://mail.python.org/mailman/listinfo/python-list
Re: determine if os.system() is done
Xah Lee wrote: > suppose i'm calling two system processes, one to unzip, and one to > “tail” to get the las t line. How can i determine when the first > process is done? > > Example: > > subprocess.Popen([r"/sw/bin/gzip","-d","access_log.4.gz"]); > > last_line=subprocess.Popen([r"/usr/bin/tail","-n 1","access_log.4"], > stdout=subprocess.PIPE).communicate()[0] > > of course, i can try workarounds something like os.system("gzip -d > thiss.gz && tail thiss"), but i wish to know if there's non-hack way to > determine when a system process is done. > > Xah > [EMAIL PROTECTED] > ∑ http://xahlee.org/ > I know you've found the answer to your question, however for the exact example you gave a much better solution comes to mind... import gzip log_file = gzip.open("access_log.4.gz") last_line = log_file.readlines()[-1] log_file.close() Regards Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: determine if os.system() is done
Xah Lee wrote: > suppose i'm calling two system processes, one to unzip, and one to > “tail” to get the last line. How can i determine when the first > process is done? > > Example: > > subprocess.Popen([r"/sw/bin/gzip","-d","access_log.4.gz"]); > > last_line=subprocess.Popen([r"/usr/bin/tail","-n 1","access_log.4"], > stdout=subprocess.PIPE).communicate()[0] > > of course, i can try workarounds something like os.system("gzip -d > thiss.gz && tail thiss"), but i wish to know if there's non-hack way to > determine when a system process is done. > > Xah > [EMAIL PROTECTED] > ∑ http://xahlee.org/ > I think the idea is you wait for the first call to subprocess.call to finish before executing the second... http://docs.python.org/lib/node231.html call( *args, **kwargs) Run command with arguments. *Wait for command to complete*, then return the returncode attribute. The arguments are the same as for the Popen constructor. Example: retcode = call(["ls", "-l"]) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python IDE's
Jon Hewer wrote: > Hi > > > > I am yet to find a Python IDE (for both Windows and Mac) that I like. > Any suggestions? > > > > Thanks > See:= http://wiki.python.org/moin/PythonEditors For more help Thanks Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: [OT] Problems with permissions etc
Hi Frank, Frank Millman wrote: > Hi all > > This is not strictly a Python question, but this newsgroup feels like a > family to me, so I hope that someone will be kind enough to respond to > this, or at least point me in the right direction. > > While developing under linux, I use my own computer, as the only user, > so it has become my habit to login as root and do all my work as a > superuser. I know that this is not desirable, but it has become a > habit, which I am now trying to get out of. > Good. Most 'problems' I have running this kind of system at home can be fixed by adding your user account to the /etc/sudoers file like so:- martin ALL=(ALL) ALL so every now and then when I need to do somthing as root I just sudo (and enter *my* password) Linux distros such as ubuntu use this scheme and I think MAC OS X does too. > Now that I am logging in as an ordinary user, I find that a number of > things that previously 'just worked' have now stopped working. I can > usually find the cause, and tweak whatever is needed to get it working > again, but I am wondering how most people work. Is it normal to > experience these kinds of problems, or am I missing a trick somewhere > and making my life more complicated than it need be? > > I will give two examples. I would like advice on the best way to fix > them, but I would prefer a more general reply that explains how > experienced unix/linux users go about handling these kinds of issues. > > 1. The application I am developing will eventually be deployed as a > multi-user accounting/business system. I want to identify the physical > workstation that generates each transaction, so I am using the mac > address. My method for extracting this is as follows - > mac = os.popen("ifconfig|grep Ether|awk {print '$5'}").read()[:-1] # > I did not come up with this myself, I cribbed it from somewhere > As root, this works fine. As non-root, ifconfig is not found. The > reason is that it is in /sbin, and this is not included in the default > path for non-root users. I could either include /sbin in my path, or I > could change the above line to /sbin/ifconfig ... Alternatively, there > may be a better way of getting the mac address or identifying the > workstation. > Since you are relying on ifconfig anyway I would just stick the fully qualified pathname (/sbin/ifconfig) into the python code > 2. I am using wxPython, which was compiled from source. It so happens > that I did this with a colleague who also has a user account on my > machine, so the compile and install of wxPython was done from his home > directory. > > When I start my app as non-root, the import of wx fails, as it cannot > find certain files. They are in the other user's home directory, but as > the top-level directory has permissions of drwx--, my user cannot > read anything in that directory. I can change the directory > permissions, or I can move the files to another area which all users > can read. If the latter, is there a 'correct' place to put them? > Re-compile and or install wxPython as root, this will install it into a default place (/usr/local or wherever) and you will not need to worry about permissions. > I think that these problems are a result of my lack of experience as a > system administrator. On the other hand, the various books and articles > I have read to try and improve my knowledge have not covered these > kinds of issues. Is it just something that one learns the hard way? > > Any advice, especially pointers to reading matter that covers this > topic, will be much appreciated. > > Thanks > > Frank Millman > Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: wxPythin installation woes
linuxfreak wrote: > Hi all, > > Was working with python 2.3 in a fedora core 3 machine. I upgraded it > to Fedora Core 4 with a clean install. So now I have python 2.4 > installed. But when I try to install wxPython for python 2.4 using an > rpm file i downloaded from the wxpython web site i get dependencies > errors. Turns out that libstdc++.so.5 is needed but I checked and i > see that libstdc++.so.6 is installed on my system. Help needed guys and > needed pronto. Thanks a ton once again :) > I have fedora core 4 and a yum list wx* produces this:- wxGTK.i386 2.4.2-12 extras wxGTK-common.i3862.4.2-12 extras wxGTK-common-devel.i386 2.4.2-12 extras wxGTK-devel.i386 2.4.2-12 extras wxGTK-gl.i3862.4.2-12 extras wxGTK-stc.i386 2.4.2-12 extras wxGTK-xrc.i386 2.4.2-12 extras wxGTK2.i386 2.4.2-12 extras wxGTK2-devel.i3862.4.2-12 extras wxGTK2-gl.i386 2.4.2-12 extras wxGTK2-stc.i386 2.4.2-12 extras wxGTK2-xrc.i386 2.4.2-12 extras wxPythonGTK2.i3862.4.2.4-7 extras So I assume a yum install wxPythonGTK2 will get you wxPython installed. *I havn't done that since I only use Tkinter* Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: difficulty connecting to networked oracle database
yahibble wrote: > Now, I am no Python expert but I have dabbled and I have spent a > couple of days with another engineer unsuccessfully installing oracle > drivers for MS ODBC on the win XP machine. > > It looked to me like ODBC was the best way to get a (free) python > module to upload data to an oracle database table. Aside from > installing oracle clients to ODBC being a pain, I would like to > consider other ways to connect. > > Has anyone had experiences with Python connecting to oracle from Win > XP? I have searched the 'net for various modules and discussions but > have no success thus far. > > Thanks, Graeme. > > not used it on Windows XP (just 2000) but cx_Oracle worked for me http://sourceforge.net/projects/cx-oracle/ Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: How to kill easygui dialog?
[EMAIL PROTECTED] wrote: > William, > > Thanks for the reply. No flames, but I am running on both Linux and > Windows, so I need a x-platform solution. I thought I had it with > easygui... > > Must try some other ideas > Can you post an example... the following works for me... >>> import easygui >>> while 1: ... rv = easygui.enterbox() ... if rv: ... print "Done" ... break ... ... Done -- http://mail.python.org/mailman/listinfo/python-list
Re: don't understand MRO
Uwe Mayer wrote: > Thursday 23 June 2005 19:22 pm Terry Reedy wrote: > > [...] > >>In the absence of other information, I would presume that none of the >>other classes have a move() method. > > > move() is implemented in the class qtcanvas.QCanvasItem > I checked the pyqt sources and it is linked via sip to the C++ object file. > In C++, QCanvasItem.move is delegated to QCanvasItem.moveBy. > > -- snip: C++ sources -- > void QCanvasItem::move( double x, double y ){ > moveBy( x-myx, y-myy ); > } > > void QCanvasItem::moveBy( double dx, double dy ){ > if ( dx || dy ) { > removeFromChunks(); > myx += dx; > myy += dy; > addToChunks(); > } > } I wonder if it is to do with the signature of these methods. they accept two doubles and perhaps the python bindings do not automatically convert from integers, therefore these methods are not called and the rules of mro kick in (thus calling the python move method) > -- snip -- > > >>Are you sure that QCanvasItem has a move method? What results from >> >print qtcanvas.QCanvasItem.move # ? >> >>If so, I would need to see its code to try to answer. > > import qtcanvas qtcanvas.QCanvasItem.move > > > > Here is a working portion which recreates the strange output: > > -- snip -- > from qtcanvas import * > > class Node(object): > def move(self, x,y): > print "Node: move(%d,%d)"%(x,y) > > class Rhomb(QCanvasPolygon, Node): > def __init__(self, parent): > QCanvasPolygon.__init__(self, parent) > Node.__init__(self) > > print Rhomb.mro() > r = Rhomb(None) > r.move(1,2) > -- snip -- > > This prints: > > [, , 'qtcanvas.QCanvasPolygonalItem'>, , 'qt.Qt'>, , , ] > Node: move(1,2) > > Ciao > Uwe > -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter Question
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > >>Thanks for all the help guys... I'm a bit confused as to the inner >>workings of the Tkinter system (I'm both a Python and a GUI n00b). I was >>hoping that by slapping the x on button python was doing some cool >>dynamic variable creation (i.e. creating 9 variables with 1 loop using >>the x as a variable to modify the identifier), but I suppose you can't >>do that in Python (or can you?) > > > that's what lists are for (see the python tutorial for details). > A short explanation using a standard python list to hold the instances of Tkinter Buttons: buttonlist = [] for a in range(10): b = Tkinter.Button(root, text=a) b.pack() buttonlist.append(b) later print buttonlist[2]["text"] > >>I'm a little confused as to why self.button.text doesn't work but >>self.button["text"] does, can someone explain this? > > > x.text and x["text"] are two different operations in Python, and > Tkinter uses the former for widget methods, and latter for widget > options. > > (w[x] is a shortcut for x.cget(x), btw) > > > > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter question
I realise I was a bit short on advice earlier... Martin Franklin wrote: > [EMAIL PROTECTED] wrote: > >>I'm sure there must be a way to do this, but I can't figure it out for >>the life of me… I'm writing a program where I would like to use a >>button's text field as part of an if statement. I set up my button like >>this: >> >> i = [ "7", "8","9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", >>".", "=", "+"] you can write this as i = "789/456*123-0.=+" as strings are sequences and can be sliced [] just like lists >> t = 0 #iterator through the sequence >> >>for x in range(4): >>for y in range(4): >>self.buttonx = Button(self, text = "%s" %i[t] , >>width=10, command = self.pressed) just a note about Tkinter Button command option. You may not know but the callback self.pressed will not get any arguments, other tool kits would send the instance of the button or perhaps an event, not Tkinter there are several ways around this, my prefered is with a callback class instance: class Command: def __init__(self, text): self.text = text def __call__(self): ## user just pressed my button ## do somthing with self.text and the creation of the button would look like: self.buttonx = Button(self, text="%s" %i[t], width=10, command=Command(i[t])) >>self.buttonx.grid( row=x+1, column = y, sticky = W+E+S) >>t+=1 >> >>What I would like to do is is check which buttons' text values are >>digits, and if the text is, I would like to append the number to a >>label. But: >> >>if(self.buttonx.title.isdigit): >> > > > To get the text of a button: > > self.buttonx["text"] > and to test if it is a digit: if self.buttonx["text"] in "0123456789": # yay I'm a number Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter question
[EMAIL PROTECTED] wrote: > I'm sure there must be a way to do this, but I can't figure it out for > the life of me… I'm writing a program where I would like to use a > button's text field as part of an if statement. I set up my button like > this: > > i = [ "7", "8","9", "/", "4", "5", "6", "*", "1", "2", "3", "-", "0", > ".", "=", "+"] > t = 0 #iterator through the sequence > > for x in range(4): > for y in range(4): > self.buttonx = Button(self, text = "%s" %i[t] , > width=10, command = self.pressed) > self.buttonx.grid( row=x+1, column = y, sticky = W+E+S) > t+=1 > > What I would like to do is is check which buttons' text values are > digits, and if the text is, I would like to append the number to a > label. But: > > if(self.buttonx.title.isdigit): > To get the text of a button: self.buttonx["text"] -- http://mail.python.org/mailman/listinfo/python-list
Re: SMTP Test Rig ( SMTPRIG.PY v1.0 )
Tim Williams wrote: > After a few posts recently, I have put together an SMTP test rig that will > receive emails and either store them to a file, write them to a console, or > both. > > Does anyone have any suggestions on where I can get it hosted as a utility > for general public use? > > TIA > > Tim > Python cookbook perhaps? http://aspn.activestate.com/ASPN/Python/Cookbook/ Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: separate IE instances?
Chris Curvey wrote: > Bummer. No change at all. (In fact, I can't even call Navigate() > without throwing an error). I'm on win2k, if that makes any difference. > I could be way off, but isn't windows one of those OS's that doesn't allow you to have two instances of IEXPORE.EXE running IOW the OS is preventing you from running two instances of this executable. Someone with a lot more knowledge of windows internals will I'm sure come along and correct me ;-) Mart -- http://mail.python.org/mailman/listinfo/python-list
Re: SMTP help please
Tim Williams wrote: > - Original Message - > From: "Tim Williams" <[EMAIL PROTECTED]> > >>try: >>s.close() >>except >>pass > > > Typo!! > > That should be s.quit() not s.close() > > :) > > > > and perhaps put into a finally: Mart -- http://mail.python.org/mailman/listinfo/python-list
Re: SMTP help please
Ivan Shevanski wrote: > I really can't figure out anything about the SMTP module. . .I think I'm > in over my head( Im pretty new to python). Can someone show me a > really(and I mean REALLY) basic tutorial for smtp or explain it? > > program: > I want to make my program have a feedback form attached to it at the end > which sends me the form when they're done. I don't especially want them > to have to input all the needed details though. . .Just thought I'd put > this in so you'd know what its for. > > > > -Ivan > > _ > Don’t just search. Find. Check out the new MSN Search! > http://search.msn.click-url.com/go/onm00200636ave/direct/01/ > Ivan, import smtplib server = smtplib.SMTP("mailserver.somewhere.com") server.set_debuglevel(3) fromaddr = "[EMAIL PROTECTED]" toaddrs = ["[EMAIL PROTECTED]", "[EMAIL PROTECTED]"] msg = """Subject: Hi I'm great Thats right I really am """ server.sendmail(fromaddr, toaddrs, msg) server.quit() HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: SFTP
Kornfeld Rick (sys1rak) wrote: > Good Morning > > I have scoured the internet looking for an Python SFTP API. So far, I > have been unable to find a suitable answer. Our needs are pretty basic. > FTP & TELNET are being removed from our environment and I need to > utilize SFTP for file transfers. > > As is probably said often, I am new to Python (love it) and need a > solution that provides adequate examples and documentation. I am hoping > for an open source answer, however, I am not ruling out having to > purchase something. > > Can anyone shed some light on this for me ? > Strange the second hit on a google for python sftp was this:- http://www.lag.net/paramiko/ I also implemented (using pexpect) a very basic 'interface' to command line sftp) http://pexpect.sourceforge.net/ pexpect is *nix only (as far as I know) both of these come with simple to follow examples... Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: running tkinter
Jim Anderson wrote: > I have just installed Fedora Core 3 on my pc. Python runs > fine, but when I try to run tkinter the tkinter library is > not found. I tried installing python 2.4.1 and could not get > tkinter to run there either. > > When I look through the build directories for 2.4.1, I find > a lib-tk, but I do not find anything for tcl. In past releases, > my recollection is that tcl/tk were part of the release and > that if TCL_LIBRARY and TK_LIBRARY environment variables were > set right, then tkinter would work. > > Are tcl/tk still supposed to be an intergrated part of the > python release? > > Do I have to download, configure, make, install tcl and tk > packages to get tkinter running? > > Thanks for any suggestions in advance. > > Jim Anderson On fedora tkinter is a separate package. just do this (as root) and all will be well:- yum install tkinter Cheers, Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Has ComboBox ctrl in Tkinter?
Cameron Laird wrote: > In article <[EMAIL PROTECTED]>, > Fredrik Lundh <[EMAIL PROTECTED]> wrote: > >>"ÒÊÃÉɽÈË" <[EMAIL PROTECTED]> wrote: >> >> >>>i have not find the ComboBox in Tkinter,has it? where to get the doc about >>>how to use combobox ctrl? >> >>the Tix add-on contains a combobox: >> >> http://docs.python.org/lib/node727.html >> >>see >> >> http://docs.python.org/lib/node725.html >> >>for some information on how to check for a working Tix install. >> >>if you cannot get Tix to work (or don't want to use it), there's a combobox in >>the bwidgets package as well: >> >> http://tkinter.unpythonic.net/bwidget/ >> >> >> >> >> > > > There are also several pure-Tk implementations http://wiki.tcl.tk/combobox >, including Bryan Oakley's > popular one, all of which can be used directly from > Tkinter. > not to mention pure python implementations :-) http://pmw.sourceforge.net/ Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Cascading menus with Tk
michelle wrote: > Hi all, > > I am new to Tk, or Python GUI programming and I seem to be stuck. I > have looked about for help with Tk GUIs, but everything seems so terse > or incomplete?? I have been mostly using the "Introduction to Tkinter" > by Fredrik Lundh > (http://www.pythonware.com/library/tkinter/introduction/index.htm) > > What I am trying to do is add cascading menus to a Tk menu widget like: > > File > New... > ---> Router > ---> Firewall > Open > > Exit > > This seems simple enough, but I can't get it to work...the two > "add_cascade" methods (shown below), if used, run an endless loop that > is difficult to break: > > mainWindow = Tk() > mainWindow.title("myApp") > > # create a menu > menubar = Menu(mainWindow) > mainWindow.config(menu=menubar) > > filemenu = Menu(menubar) > menubar.add_cascade(label="File", menu=filemenu) > filemenu.add_command(label="New...") I think you want these two options to be in a cascading menu like so: newmenu = Menu(filemenu) filemenu.add_cascade(label="New...", menu=newmenu) newmenu.add_command(label="Router") newmenu.add_command(label="Firewall") > filemenu.add_cascade(label="Router") > filemenu.add_cascade(label="Firewall") > filemenu.add_command(label="Open...", command = openFileDialog) > filemenu.add_separator() > filemenu.add_command(label="Exit", command = mainWindow.destroy) > > helpmenu = Menu(menubar) > menubar.add_cascade(label="Help", menu=helpmenu) > helpmenu.add_command(label="Online Help") > helpmenu.add_command(label="Help on the web") > helpmenu.add_separator() > helpmenu.add_command(label="About...", command = openAboutBox) > > Any ideas?? > > Miki Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter puzzler
Paul Rubin wrote: > I have a gui with a bunch of buttons, labels, the usual stuff. It > uses the grid manager: > >gui = Frame() >gui.grid() >gui.Label().grid() # put some widgets into the gui >...# more widgets > > Now at the the very bottom of the gui, I want to add two more buttons, > let's say "stop" and "go". I want "stop" to appear in the gui's lower > left corner and "go" to appear in the gui's lower right corner. > Suppose that up to now, row 16 is the last row in the gui. Then this > works: > > Button(gui, text="stop").grid(sticky=W) # starts row 17 > Button(gui, text="go").grid(row=17, column=1, sticky=E) > > But I don't really want that hardwired row number and I don't want to > keep counting rows and adjusting stuff if I stick new rows in the gui. > So I try the obvious, make one Frame widget containing both new buttons: > stopgo = Frame(gui) > Button(stopgo, "stop").grid(sticky=W) > Button(stopgo, "go").grid(sticky=E) > > and try to stretch it across the bottom row of the gui: > > stopgo.grid(sticky=E+W) > > However, the buttons keep coming out centered in the gui's bottom row > pretty much no matter what I do (I've tried all sorts of combinations). > > Am I missing something? I'm not a tkinter whiz and this stuff is > pretty confusing. I did come up with an ugly workaround that I'll > spare you the agony of seeing, but there should be a natural way to do > this. > > Thanks for any advice. Sorry to say Paul but you may have to show us that ugly code! I'm no whiz with the grid manager (I prefer pack!) but seeing your code will help us help you I suspect you need to look at the columnconfigure / rowconfigure methods of the container (toplevel or frame) Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: TAKE_FOCUS
phil wrote: > WM_TAKE_FOCUS does not work on WinXP ?? > I was sure I had used that on win before. > Works on Linux. > > I have a function I need to run when the window > gets the focus. How do you do that in Tkinter > on Win32? > Thanks > Take a look at the module docs for Tkinter you will need the one of the focus_* methods $pydoc Tkinter | focus_set(self) | Direct input focus to this widget. | | If the application currently does not have the focus | this widget will get the focus if the application gets Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Does TKinter Have A Grid ?
Peter Moscatt wrote: > Does TKinter have a Grid widget ? > If not (as I assume), what is the alternative ? > > Pete > Pete, If by grid you mean Table widget or Spreadsheet type widget then no Tk does not have one (therefore nor does Tkinter) However as luck would have it there are a couple of extensions to Tk that provide a Table widget both Tk 'c' based and Tcl based. for more about this (and lots of other useful stuff!) http://tkinter.unpythonic.net/wiki/Widgets It mentions two Table widgets, Tktable and tablelist both have python (tkinter) wrappers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter weirdness item count
phil wrote: > Using Tkinter Canvas to teach High School Geometry > with A LOT of success. > > My drawing gets very slow after a lot of actions. > > For instance I have created code to rotate a set of objects > about a rotation point. > rotate 360 degrees starts to get slow > after 720 degrees its crawling. > > I checked the item list with with find_all: IT GROWS! > > OK, I create 3 lines using a line Class I created. > When I rotate these 3 lines thru 360 degrees it creates > 360 lines times 3. But each new instance of line REPLACES > the old instance. The line class has a destructor to delete > the drawn object. > > class line: > count = 0 > def __init__(s,glob,argl,color=''): > line.count = line.count + 1 > ## > ## buncha code here > ## > s.obj = glob.can.create_line(x0,y0,x1,y1, > width=glob.width,fill=s.color) > def __del__(s): > line.count = line.count - 1 > > ## delete the line object if the > ## class instance is deleted > s.glob.can.delete(s.obj) > > > After the rotation I check line.count and it is 3 > But find_all returns a tuple ofover 1000 items. > The drawn objects are not being deleted. > Which is kinda weird because the rotation works. > That is they appear to be deleted. > > Is find_all() fooling me? > Is this the reason drawing slows down? Is it refreshing > invisible objects? > > This slowing down also occurs when I draw a lot of objects. > Lets say I draw a sine wave, say 1000 individual points. > If I draw 4 or 5 sine waves it gets really slow. > > I should mention I call update() after each drawing action. > This is necessary for the students to watch the progress. > I might be drawing objects in a lengthy loop and without > update() they only appear at the end of the loop. > > Thanks for any help. > > -- Confused > > Phil, I seem to remember a thread a while ago about a 'bug' with the Tk Canvas widget keeping a reference to objects that had been deleted... Have you thought about using the 'move' method to move your lines? I think this will result in less supprises... pydoc Tkinter.Canvas | move(self, *args) | Move an item TAGORID given in ARGS. | You could even make it a method of your line class Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter text width
James Stroud wrote: Hello All, I would like for a tkinter text widget to be aware of how big the frame that contains it is, then I would like for it to reset its width to the appropriate number of characters when this frame changes size. I can get a cget("width") for the text, but this does not dynamically reflect the visible width. One way I can think of is getting the size of the font used in the widget then getting the width of the frame with cget then doing the appropriate math and configuring the text widget upon resize events. I'm thinking that there must be a more straightforward way. Any ideas? James James, Not sure I understand, do you want the text within the text widget to wrap or change font so it fits? In any case to get a widgets width you will need to look at the winfo_* methods for that widget pydoc Tkinter.Frame | winfo_height(self) | Return height of this widget. | | winfo_reqheight(self) | Return requested height of this widget. | | winfo_reqwidth(self) | Return requested width of this widget. | winfo_width(self) | Return the width of this widget. | If you do want the text to wrap there is the option to do this when you create the instance of the text widget:- text = Text(root, wrap = "word") # word, char or none text.pack() Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: How to prevent Tkinter frame resize?
[EMAIL PROTECTED] wrote: I am trying to prevent a user from resizing a frame beyond its "natural" size as given by winfo_reqwidth and winfo_reqheight, without any success. Can anyone make any suggestions, based on my code below? Thanks! from Tkinter import * class Table(Frame): def __init__(self, master, rows=['row 1'], cols=['col 1'], row_labels=True, col_labels=True, row_buttons=True, col_buttons=True): Frame.__init__(self, master) self.rows = rows self.cols = cols self.row_labels = row_labels self.col_labels = col_labels self.row_buttons = row_buttons self.col_buttons = col_buttons self.col_width = 6 self.draw() self.bind('', self.changed) def changed(self, ev): w, h = self.winfo_reqwidth(), self.winfo_reqheight() cfg = {} if ev.height > h: cfg['height'] = h if ev.width > w: cfg['width'] = w if cfg: self.config(**cfg) this has no effect I'm not sure I follow your code but this method is bound to the event *but* needs to return the string "break" so that it does not pass that event on to the default event handler. def changed(self, ev): w, h = self.winfo_reqwidth(), self.winfo_reqheight() cfg = {} if ev.height > h: cfg['height'] = h if ev.width > w: cfg['width'] = w if cfg: self.config(**cfg) this has no effect return "break" This may do what you want. Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: A smallish Tkinter question
[EMAIL PROTECTED] wrote: """ What I want: A little window to open with a 0 in it. Every second, the 0 should increment by 1. What I get: A one second delay, see the window with a 1 in it, and then nothing appears to happen. Never see the 0, never see a 2. Any quick clues? Thanks. Nick. (Python 2.4, Win98). """ from Tkinter import * from time import sleep class Clock: def __init__(self, parent): self.time = 0 self.display = Label(parent) self.display["font"] = "Arial 16" self.display["text"] = str(self.time) self.display.pack() def run(self): #also tried self,parent sleep(1.0) self.time = self.time + 1 self.display["text"] = str(self.time) win = Tk() app = Clock(win) app.run() #also tried run(win) with self,parent above win.mainloop() Nick, Look at the after method of the Tk widget also google for Tkinter clock examples should get results Cheers, Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: The value of the entry widget doesn't get updated
Clara wrote: Hi, can somebody help me,..I have an assignment due next week but now I'm stuck with this problem I tried to get values from entry widget using the widgetcontrolvariable.get(),..but it seems that it won't work I can't print the value I input in the entry widget...However when I first set the value to something I can get the value just fine... This is my code Help please... msg='*~*Please Login to use the system*~*' class LoginMenu(Frame): def createWidgets(self, msg): import tkFont self.x = StringVar() self.y = StringVar() self.x.set("Type here") self.messageLabel= Label(self, text=msg, pady=15, font=tkFont.Font(weight='bold' ,size=10)) self.messageLabel.grid(row=0, columnspan=6) self.nameLabel= Label(self, text='UserName :', padx=12, justify=LEFT) self.nameLabel.grid(row=1, column=0, ipadx=9, ipady=5) self.nameEntry= Entry(self,justify=LEFT, textvariable=self.x) self.nameEntry.grid(row=1, column=3, columnspan=2) self.nameEntry.update_idletasks() self.passLabel= Label(self, text='Password :', padx=12, justify=LEFT) self.passLabel.grid(row=2, column=0,ipadx=9, ipady=5) self.passEntry= Entry(self,justify=LEFT, show='*', textvariable=self.y) self.passEntry.grid(row=2, column=3, columnspan=2) self.passEntry.update_idletasks() self.loginButton = Button(self, text='Login', command = VerifyProcessor(self.x.get(), self.y.get()) ) Here is the problem, the values of the two entries have been got'on before the button is pressed and the command is called. I would replace the above with:- VerifyProcessor(self.x, self.y)) ) and see below for the changes to the command callback class self.loginButton.grid(row=4, column=3, ipadx=15, ipady=3, pady=20) self.quitButton = Button(self, text='Exit', command = self.quit) self.quitButton.grid(row=4, column=4, ipadx=20, ipady=3, pady=20, padx=10) def __init__(self, msg, master=None): Frame.__init__(self, master) self.grid(column=4, row=4) self.createWidgets(msg) class VerifyProcessor: def __init__(self, thename, thepass): self.username = thename self.password = thepass def __call__(self): print self.username print self.password print self.username.get() print self.password.get() app = LoginMenu(msg) app.master.title("Login Menu") app.master.maxsize(280,200) app.mainloop() HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tk Listbox - Selected Item ?
Peter Moscatt wrote: Martin Franklin wrote: Peter Moscatt wrote: I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the text of the selected item ? Pete Pete, pydoc Tkinter.Listbox | curselection(self) | Return list of indices of currently selected item. | | delete(self, first, last=None) | Delete items from FIRST to LAST (not included). | | get(self, first, last=None) | Get list of items from FIRST to LAST (not included). So to get the value of the selected item: lb.get(lb.curselection()[0]) provided the listbox is in single selection mode or only one item is selected Martin Thanks Martin, I used the: lb.get(lb.curselection()[0]) ant this works to a point. When I select the item in the listbox the system generates an error: Exception in Tkinter callback Traceback (most recent call last): File "/usr/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__ return self.func(*args) File "/home/linux/programming/dxcluster/servers.py", line 37, in sel items = self.listbox.get(self.listbox.curselection()[0]) IndexError: tuple index out of range Then if I select a second time directly after the error message I get my desired result. Pete, Sounds like you are using the wrong kind of bind event. That is the first time you select an item the callback for the bind command is called *before* the selection is made. Can you post the code you have showing the bind method and callback? This code shows three different bind methods, the first produces the same exception that you got... from Tkinter import * root = Tk() lb = Listbox(root) lb.insert(0, "one") lb.insert(0, "two") lb.insert(0, "three") lb.pack() def callback(*event): print lb.get(lb.curselection()[0]) ## BAD #~ lb.bind("<1>", callback) ## OK #~ lb.bind("", callback) ## Best lb.bind("<>", callback) root.mainloop() The <> is a virtual event I think quick google would tell you more and the Tk man pages (online) have a complete explanation... http://www.tcl.tk/man/tcl8.4/TkCmd/listbox.htm http://www.tcl.tk/man/tcl8.4/TkCmd/listbox.htm#M60 Cheers, Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tk Listbox - Selected Item ?
Peter Moscatt wrote: I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the text of the selected item ? Pete Pete, pydoc Tkinter.Listbox | curselection(self) | Return list of indices of currently selected item. | | delete(self, first, last=None) | Delete items from FIRST to LAST (not included). | | get(self, first, last=None) | Get list of items from FIRST to LAST (not included). So to get the value of the selected item: lb.get(lb.curselection()[0]) provided the listbox is in single selection mode or only one item is selected Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Northampton, UK
Fuzzyman wrote: Just on the off chance I thought I'd ask if there were any Pythoneers out there local to Northampton UK ? Best Regards, Fuzzy http://www.voidspace.org.uk/python I'm just over the border (Bedfordshire) but like a lot of people commute :-( -- http://mail.python.org/mailman/listinfo/python-list
Re: logging as root using python script
Luis Bruno wrote: Raghul wrote: What I need is when I execute a script it should login as root and execute my command and logout from root to my existing account. I'm not sure of what you need, so I'll assume your *whole* .py script needs root priviledges. In this case, you can configure sudo(8) or use su(1). For example, the script below does nothing special: | #!/usr/bin/env python | | print "Hello world!" You can run it with higher priviledges if you use sudo(8): $ chmod 755 hello.py $ sudo ./hello.py Or you can use su(1): $ su - root -c ./hello.py You can configure sudo(8) to not prompt for any password, BTW. Cheers! another alternative would be setuid for more on this (and why it could be a bad idea) google... Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: check interpreter version before running script
F. Petitjean wrote: Le Tue, 05 Apr 2005 08:57:12 -0400, rbt a écrit : Is there a recommended or 'Best Practices' way of checking the version of python before running scripts? I have scripts that use the os.walk() feature (introduced in 2.3) and users running 2.2 who get errors. Instead of telling them, 'Upgrade you Python Install, I'd like to use sys.version or some other way of checking before running. I thought of sys.version... but getting info out of it seems awkward to me. First 5 chars are '2.4.1' in string format have to split it up and convert it to ints to do proper checking, etc. It doesn't seem that sys.version was built with this type of usage in mind. So, what is the *best* most correct way to go about this? try: from os import walk as os_walk except ImportError: os_walk = None # raise some exception or implement a fallback solution # use os_walk instead of os.walk Thanks, rbt You may be interested in this... http://www.jorendorff.com/articles/python/path/ as an alternative to the os.path functions... Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, Python and low level networking
Peter Hansen wrote: [EMAIL PROTECTED] wrote: Is it possible to have low level netwoking with python under Windows? Like raw sockets? Is it possible to send a single packet using python under windows? Google is your friend: Try searching with "python sockets", for example... (You *have* heard of Google, haven't you? It's been in the news a bit lately...) The OP may get 302'd though! ;-) -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows, Python and low level networking
[EMAIL PROTECTED] wrote: Is it possible to have low level netwoking with python under Windows? Like raw sockets? Is it possible to send a single packet using python under windows? Thank you Yes http://www.python.org/doc/2.4/lib/module-socket.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Text-to-speech
Charles Hartman wrote: Maybe you can bind Festival (http://www.cstr.ed.ac.uk/projects/festival/download.html) with SWIG. Presumably somebody could; at this point it's well beyond me. But thank you for the suggestion. Charles Hartman http://cherry.conncoll.edu/cohar There is tkfestival http://ludios.org/programs/tkfestival that uses expect to control festival, I assume it has a very easy to use CLI and would be simple to make use of pexpect to control festival from python in the same way. Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter wrappers for TkTreeCtrl and Tile
Harlin Seritt wrote: (snip) That said I have got a Tile Button example working (and I can change it's style) so perhaps not that much work Do you happen to have a sampling of this that I can get my hands on?? I've cc'd the tkinter mailing list to see if there is any more interest over there... Thanks for doing so! Harlin Harlin, Sure here is all 90 lines of it:- ## import Tkinter from Tkconstants import * class Style: def default(self, style, **kw): """Sets the default value of the specified option(s) in style""" pass def map_style(self, **kw): """Sets dynamic values of the specified option(s) in style. See "STATE MAPS", below.""" pass def layout(self, style, layoutSpec): """Define the widget layout for style style. See "LAYOUTS" below for the format of layoutSpec. If layoutSpec is omitted, return the layout specification for style style. """ pass def element_create(self, name, type, *args): """Creates a new element in the current theme of type type. The only built-in element type is image (see image(n)), although themes may define other element types (see Ttk_RegisterElementFactory). """ pass def element_names(self): """Returns a list of all elements defined in the current theme. """ pass def theme_create(self, name, parent=None, basedon=None): """Creates a new theme. It is an error if themeName already exists. If -parent is specified, the new theme will inherit styles, elements, and layouts from the parent theme basedon. If -settings is present, script is evaluated in the context of the new theme as per style theme settings. """ pass def theme_settings(self, name, script): """Temporarily sets the current theme to themeName, evaluate script, then restore the previous theme. Typically script simply defines styles and elements, though arbitrary Tcl code may appear. """ pass def theme_names(self): """Returns a list of the available themes. """ return self.tk.call("style", "theme", "names") def theme_use(self, theme): """Sets the current theme to themeName, and refreshes all widgets.""" return self.tk.call("style", "theme", "use", theme) class Button(Tkinter.Widget, Style): def __init__(self, master=None, cnf={}, **kw): master.tk.call("package", "require", "tile") Tkinter.Widget.__init__(self, master, 'ttk::button', cnf, kw) class Treeview(Tkinter.Widget): def __init__(self, master=None, cnf={}, **kw): master.tk.call("package", "require", "tile") Tkinter.Widget.__init__(self, master, 'ttk::treeview', cnf, kw) def callback(): print "Hello" root = Tkinter.Tk() b = Button(root, text="Tile Button", command=callback) b.pack() print b.theme_names() b.theme_use("step") b1 = Tkinter.Button(root, text="Tk Button", command=callback) b1.pack() tree = Treeview(root) tree.pack() root.mainloop() ## -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter wrappers for TkTreeCtrl and Tile
Harlin Seritt wrote: Martin, If I may ask, who actually works on the Tkinter module? Is there a certain group that does this? I'm just curious as I've never been able to find this information. I know there are, of course, someone who develops Tk but just not sure who does this on the Python side. Thanks, Harlin Harlin, There is no Tkinter group of core developers, if somthing needs doing then it is done by those who need it (AFAIK) I have made a few small patches to Tkinter.py in the past and will do so again should I need to I have been looking some more at Tile - it's come a long way in the last few months (since the last time I looked at it), I have even started writting a *test* wrapper for it (I first had to build tcl, tk, tile and python from source!) I have created a Style class (as a mixin like the Pack and Grid classes in Tkinter.py I have also wrapped the Tile.Button but right now it extends Tkinter.Widget class (as it is starting to look like a large chunk of work wrapping Tile from scratch;-) That said I have got a Tile Button example working (and I can change it's style) so perhaps not that much work I've cc'd the tkinter mailing list to see if there is any more interest over there... Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter wrappers for TkTreeCtrl and Tile
Harlin Seritt wrote: Martin, Take a look here: http://mail.python.org/pipermail/tkinter-discuss/2004-March/10.html It is a well-known post from what I understand. You may have already seen it before. Actually, (as I'm looking at a 8.4 demo set from ActiveTcl distribution), it seems the Tree widget has been added to the 8.4 set. I don't think the Tiles has been added just yet though. Harlin Thanks, I must have missed it first time round... after more googling I did find a reference to Tile going into Tk 8.5 but it was not on the tcltk wiki recent changes for 8.5: http://wiki.tcl.tk/10630 Which made me think it will not go in. Cheers, Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Tkinter wrappers for TkTreeCtrl and Tile
Harlin Seritt wrote: I was looking at the Tcl/Tk sourceforge page and found that there were a couple of new widgets being produced for Tcl 8.5. Does anyone know if there are any Tkinter wrappers somewhere? thanks, Harlin Harlin, I can't see the web page saying these will be included in Tk 8.5 can you give me the URL? As far as wrappers go, if they don't exist (and I don't think they do) it is fairly easy to create them provided they are written in a very similar style to 'standard' Tk widgets. Somone usually steps up and patches Tkinter.py to include changes in the Tk core, but usually only when a new _final_ version is released... Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python becoming less Lisp-like
Tim Daneliuk wrote: In-Reply-To: <[EMAIL PROTECTED]> X-Enigmail-Version: 0.90.0.0 X-Enigmail-Supports: pgp-inline, pgp-mime Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Nick Craig-Wood wrote: Torsten Bronger <[EMAIL PROTECTED]> wrote: The current snapshot is a transitional Python and thus with some double features. The numerical types and two kinds of classes are examples. I'm very surprised about this, because Python is a production language, but I'm happy, too. As long as python 2.x -> 3.x/3000 isn't like perl 5.x -> perl 6.x I'll be perfectly happy too. "Less is more" is a much better philosophy for a language and having the courage to take things out differentiates python from the crowd. Of course we users will complain about removals, but we'll knuckle down and take our medicine eventually ;-) Except that in this case, removal will also complicate code in some cases. Consider this fragment of Tkinter logic: UI.CmdBtn.menu.add_command(label="MyLabel", command=lambda cmd=cmdkey: CommandMenuSelection(cmd)) In this case you perhaps should try using a class like so:- UI.CmdBtn.menu.add_command(label="MyLabel", command=CommandMenuSelectionCallback(cmdkey)) Where CommandMenuSelectionCallback is a class like so: class CommandMenuSelectionCallback: def __init__(self, key): self.key = key def __call__(self): print self.key Would it not be the case that, without lambda, we will need to pollute the name space with a bunch of specialized little functions for each and every construct like this? -- http://mail.python.org/mailman/listinfo/python-list
Re: Bitmaps On Buttons ?
PGMoscatt wrote: I am slowly progressing with my python app. I have got to the point where I would like to place images onto my buttons. I use Tkinter as my GUI libary. The following is how I understand I place an image onto a button - but I am not having much success with it all. Any ideas ? Pete b=Button(ToolBar,padx=1,pady=1,width=2,height=1,command=callquit,) b.bitmap="@button_cancel.xbm" b.place(x=0,y=0) put the bitmap= inside the construction of the button widget like so: b = Button(ToolBar, padx=1, pady=1, width=2, height=1, command=callquit, bitmap="@button_cancel.xbm") BTW You shouldn't need to set the height and width - the button will take it's size from the bitmap BTW2 I notice you are using place geometry manager you may get a 'better' behaved GUI with the pack or grid geometry manager, it will resize much better as widgets are pack'ed or grid'ed relative to each other for more help you could try: http://www.pythonware.com/library/tkinter/introduction/ or the Wiki that has links to other sources of help (including the Tkinter mailing list http://tkinter.unpythonic.net/wiki/FrontPage Cheers Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Listbox fill=BOTH expand=YES (Tkinter)
Harlin Seritt wrote: I am trying the following: Listbox(parent).pack(fill=BOTH, expand=YES) I notice that the listbox will fill on the X axis but will not on the Y axis unlike other widgets. Is there any way to force this? thanks, Harlin Harlin, It should expand (and fill ) in both directions have you checked it's parents packing options? Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Huge performance gain compared to perl while loading a text file in a list ...!?
Paul Rubin wrote: "Marc H." <[EMAIL PROTECTED]> writes: I'm fairly new to python, and don't know much of its inner working so I wonder if someone could explain to me why it is so much faster in python to open a file and load it in a list/array ? My guess is readlines() in Python is separating on newlines while Perl is doing a regexp scan for the RS string (I forget what it's called in Perl). I remember when it was the other way round ;-) http://groups-beta.google.com/group/comp.lang.python/browse_thread/thread/fe217ae9723f7a38/23477243324bebc6?q=python+file+IO+speed#23477243324bebc6 -- http://mail.python.org/mailman/listinfo/python-list
Re: Searching for a ComboBox for Tkinter?
Martin Franklin wrote: Harlin Seritt wrote: I've created a ghetto-ized ComboBox that should work nicely for Tkinter (unfortunately no dropdown capabilities yet). I've found why it's such a pain in the @ss to create one. You have to re-create common methods and make sure they're mapped to the right component (inside this widget are frame, entry, listbox, and scrollbar widgets). I tried to look for ways I could inherit some methods from other widgets but couldn't think of how to do it in an efficient way. If anyone has suggestions to improve it, please respond... Remember... I'm a traditional c/c++ turned python programmer who forgets that there usually is a better, faster more graceful way to do things with Python than with C/C++/Java. Cheers, Harlin ## # Seritt Extensions: # Date: 02262005 # Class ComboBox # Add this section to your Tkinter.py file in 'PYTHONPATH/Lib/lib-tk/' # Options: width, border, background, foreground, fg, bg, font #, relief, cursor, exportselection, selectbackgroun, selectforeground, height # # Methods: activate(int index) => int, curselection() => int, delete(item=["ALL" or int], start=int, end=["END" or # int], # focus_set()/focus(), get()=>selected string in box, pack(padx=int, pady=int, fill(X, Y, BOTH), expand=bool, # side=LEFT, # RIGHT, TOP, BOTTOM, CENTER # class ComboBox: Why not extend an existing Tkinter widget? This way you get at least the geometry (pack, grid etc) methods thown in for free! class ComboBox(Frame): def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args, **kw) You could extend Entry above is just an example... Also worth pointing out are a couple of ComboBox's out there already Pmw includes one as does Tix (IIRC) Cheers, Martin. I forgot to say good work! and you may be interested in the Tkinter mailing list and Wiki (where you could post your 'mega' widget as an example http://mail.python.org/mailman/listinfo/tkinter-discuss gmane.comp.python.tkinter http://tkinter.unpythonic.net/wiki/ (There seems to be a lot of Tkinter related posts recently) Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Bind Escape to Exit
Kent Johnson wrote: Binny V A wrote: Hello Everyone, I am new to python and I am trying to get a program to close a application when the Escape Key is pressed. Here is a version that works. The changes from yours: - Bind , not These amount to the same thing AFAIK - Bind the key to the root, not the frame This is the 'fix' Tkinter's Tk (and Toplevel) widgets will allow key bindings, Frames do not. - Define a quit() method that takes an event parameter Yep the bind'ing will pass an event object to the callback. just FYI, you may be interested in the Tkinter mailing list:- http://mail.python.org/mailman/listinfo/tkinter-discuss also available from gmane:- gmane.comp.python.tkinter Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Searching for a ComboBox for Tkinter?
Harlin Seritt wrote: I've created a ghetto-ized ComboBox that should work nicely for Tkinter (unfortunately no dropdown capabilities yet). I've found why it's such a pain in the @ss to create one. You have to re-create common methods and make sure they're mapped to the right component (inside this widget are frame, entry, listbox, and scrollbar widgets). I tried to look for ways I could inherit some methods from other widgets but couldn't think of how to do it in an efficient way. If anyone has suggestions to improve it, please respond... Remember... I'm a traditional c/c++ turned python programmer who forgets that there usually is a better, faster more graceful way to do things with Python than with C/C++/Java. Cheers, Harlin ## # Seritt Extensions: # Date: 02262005 # Class ComboBox # Add this section to your Tkinter.py file in 'PYTHONPATH/Lib/lib-tk/' # Options: width, border, background, foreground, fg, bg, font # , relief, cursor, exportselection, selectbackgroun, selectforeground, height # # Methods: activate(int index) => int, curselection() => int, delete(item=["ALL" or int], start=int, end=["END" or # int], # focus_set()/focus(), get()=>selected string in box, pack(padx=int, pady=int, fill(X, Y, BOTH), expand=bool, # side=LEFT, # RIGHT, TOP, BOTTOM, CENTER # class ComboBox: Why not extend an existing Tkinter widget? This way you get at least the geometry (pack, grid etc) methods thown in for free! class ComboBox(Frame): def __init__(self, parent, *args, **kw): Frame.__init__(self, parent, *args, **kw) You could extend Entry above is just an example... Also worth pointing out are a couple of ComboBox's out there already Pmw includes one as does Tix (IIRC) Cheers, Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter: always scroll to show last line of text
Benjamin Rutt wrote: I have a tkinter 'Text' and 'Scrollbar' connected and working normally. When a new line of text is inserted (because I'm monitoring an output stream), I'd like the text and scrollbar to be scrolled to the bottom, so the latest line of text is always shown. How to do this? Thanks, text.yview_pickplace("end") -- http://mail.python.org/mailman/listinfo/python-list
Re: basic tkinter/Windows question
Paul Rubin wrote: I find myself having to write some code on Windows :-(. To alleviate the pain, at least I get to use Python for some of it. I'm trying to write a simple application, say "eggs.py". It pops a tkinter gui and lets the user do some stuff. The system has Python installed so I don't care about wrapping it in a .exe file or anything like that. But I'd like to make a desktop icon for eggs.py and let the user double-click it and run the app without also getting a DOS box on the screen. Is there a simple way to do that? I didn't see anything in the Python docs about it. I suspect that this is really a dumb Windows question, but I avoid Windows whenever I can, so most anything I can ask about it is probably dumb. Thanks much. renaming the eggs.py to eggs.pyw will tell windows to use pythonw.exe to start this python file (and will not open a console) You can then create a shortcut in the normal way Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: python connect to server using SSH protocol
Simon Anders wrote: Hi Laszlo Zsolt Nagy wrote: [EMAIL PROTECTED] wrote: How can python connect to server which use SSH protocol? There should be a better way. Simon There is : pexpect! http://pexpect.sourceforge.net/ -- http://mail.python.org/mailman/listinfo/python-list
Re: convert ftp.retrbinary to file object? - Python language lacks expression?
Martin Franklin wrote: Martin Franklin wrote: Robert wrote: I just tried to convert a (hugh size) ftp.retrbinary run into a pseudo-file object with .read(bytes) method in order to not consume 500MB on a copy operation. [snip] H this is nearly there I think...: whoops... spoke too soon.. Trigger happy this morning... import ftplib class TransferAbort(Exception): pass class FTPFile: def __init__(self, server, filename): self.server = server self.filename = filename self.offset = 0 def callback(self, data): self.offset = self.offset + len(data) self.data = data ## now quit the RETR command? raise TransferAbort("stop right now") def read(self, amount): self.ftp = ftplib.FTP(self.server) self.ftp.login() I needed to insert a time.sleep(0.1) here as the connections were falling over themselves - I guess testing with a blocksize of 24 is a little silly. try: self.ftp.retrbinary("RETR %s" %self.filename, self.callback, blocksize=amount, rest=self.offset) except TransferAbort: also need to close the ftp connection here! self.ftp.close() return self.data f = FTPFile("HOSTNAME", "FILENAME") print f.read(24) print f.read(24) ## new test... f = FTPFile("HOSTNAME", "FILENAME") while 1: data = f.read(24) if not data: break print data, I open the ftp connection inside the read method as it caused an error (on the second call to read) when I opened it in __init__ ??? HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: convert ftp.retrbinary to file object? - Python language lacks expression?
Martin Franklin wrote: Robert wrote: I just tried to convert a (hugh size) ftp.retrbinary run into a pseudo-file object with .read(bytes) method in order to not consume 500MB on a copy operation. [snip] H this is nearly there I think...: whoops... spoke too soon.. import ftplib class TransferAbort(Exception): pass class FTPFile: def __init__(self, server, filename): self.server = server self.filename = filename self.offset = 0 def callback(self, data): self.offset = self.offset + len(data) self.data = data ## now quit the RETR command? raise TransferAbort("stop right now") def read(self, amount): self.ftp = ftplib.FTP(self.server) self.ftp.login() I needed to insert a time.sleep(0.1) here as the connections were falling over themselves - I guess testing with a blocksize of 24 is a little silly. try: self.ftp.retrbinary("RETR %s" %self.filename, self.callback, blocksize=amount, rest=self.offset) except TransferAbort: return self.data f = FTPFile("HOSTNAME", "FILENAME") print f.read(24) print f.read(24) ## new test... f = FTPFile("HOSTNAME", "FILENAME") while 1: data = f.read(24) if not data: break print data, I open the ftp connection inside the read method as it caused an error (on the second call to read) when I opened it in __init__ ??? HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: convert ftp.retrbinary to file object? - Python language lacks expression?
Robert wrote: I just tried to convert a (hugh size) ftp.retrbinary run into a pseudo-file object with .read(bytes) method in order to not consume 500MB on a copy operation. First I thought, its easy as usual with python using something like 'yield' or so. Yet I didn't manage to do (without using threads or rewriting 'retrbinary')? Any ideas? I tried a pattern like: def open(self,ftppath,mode='rb'): class FTPFile: #TODO ... def iter_retr() ... def callback(blk): how-to-yield-from-here-to-iter_retr blk??? ftp.retrbinary("RETR %s" % relpath,callback) def read(self, bytes=-1): ... self.buf+=self.iter.next() ... H this is nearly there I think...: import ftplib class TransferAbort(Exception): pass class FTPFile: def __init__(self, server, filename): self.server = server self.filename = filename self.offset = 0 def callback(self, data): self.offset = self.offset + len(data) self.data = data ## now quit the RETR command? raise TransferAbort("stop right now") def read(self, amount): self.ftp = ftplib.FTP(self.server) self.ftp.login() try: self.ftp.retrbinary("RETR %s" %self.filename, self.callback, blocksize=amount, rest=self.offset) except TransferAbort: return self.data f = FTPFile("HOSTNAME", "FILENAME") print f.read(24) print f.read(24) I open the ftp connection inside the read method as it caused an error (on the second call to read) when I opened it in __init__ ??? HTH Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: debugging os.spawn*() calls
Skip Montanaro wrote: I have an os.spawnv call that's failing: pid = os.spawnv(os.P_NOWAIT, "ssh", ["ssh", remote, "PATH=%(path)s nice -20 make -C %(pwd)s" % locals()]) When I wait for it the status returned is 32512, indicating an exit status of 127. Unfortunately, I see no way to collect stdout or stderr from the spawned process, so I can't tell what's going wrong. The "ssh remotehost PATH=$PATH nice -20 make ..." command works fine from a similar shell script. Thx, Skip Skip, While not a 'real' answer - I use pexpect to automate my ssh scripts these days as I had a few problems using ssh with the os.* family perhaps you may find pexpect a wee bit easier... Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: tkinter socket client ?
Tonino wrote: Hi, thanks for this info - I had to abandon the createfilehandler() method as it is not supported in windows and the GUI "might" be used there at some time ... So - I went the threading route - works well - for now - so I will stick to it ... BUT - the next question: In the Text() widget - why - when the text scrolls off the screen - does the window not follow it ? I have added a scrollbar to it : self.center_frame = Frame(self.top_frame, background="tan", relief=RIDGE) self.text=Text(self.center_frame,background='white') scroll=Scrollbar(self.center_frame) self.text.configure(yscrollcommand=scroll.set) self.text.pack(side=LEFT, fill=BOTH, expand=YES) scroll.pack(side=RIGHT,fill=Y) self.center_frame.pack(side=RIGHT, expand=YES, fill=BOTH) but the window does not scroll to follow the text ? Any ideas ? This is the default behavior of the Text widget. You have two options (as I see it) one, put the new text at the top of the Text widget textwidget.insert(0, "your new text") or two, use the yview_pickplace method to move the view down every time you insert text textwidget.yview_pickplace('end') I wrote a sub-class of the ScrolledText widget to do just this I gave it a write method - so I could re-direct stdout to it - and also called yview_pickplace in that method. HTH Martin. -- http://mail.python.org/mailman/listinfo/python-list
Re: samba/windows shares
On Thu, 9 Dec 2004 20:03:55 +0530 (IST), I.V. Aprameya Rao <[EMAIL PROTECTED]> wrote: hi does anybody know how to access samba/windows shares on a network? is there any module that does this? i am running linux and i thought of using the mount command to mount that remote share and then access it, but i was wondering whether that is the right way? Aprameya Hi, I was looking for this just yesterday... I 'found' a pure python samba client package here:- http://miketeo.net/projects/pysmb/ It seems to work too! I also found, but did not look into further, python bindings in the samba source code tree http://www.samba.org/ Regards Martin -- http://mail.python.org/mailman/listinfo/python-list