Using Python to add thumbnails to Explorer
Greetings All, In Widows Explorer there is a thumbnail view, where you see images as thumbnails. Applications such as MS Office and OpenOffice, when installed, cause their respective filetypes to be previewed as thumbnails as well. Thumbnails are stored in the Thumbs.db hidden file. There my knowledge ends. I'm asuming that aplications install registry keys somewhere that register an invocation that returns a thumbnail for a given file bit this is just a guess. What I'd like to do is write some Python script that can be invoked to add thumbnails for certian file types (my own custom types and things like the .FITS array format.) Googling isn't going anywhere so I am hoping there are some wizards out there with poiters... Specifically any information on how the thumbnail system works would be great! Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Jpg
Tuvas ([EMAIL PROTECTED]) wrote: : I am building a GUI interface at the moment, and would like to have : support for displaying a jpg file, and a FITS file if possible. Is : there any way to do this? My interface has been written in Tkinter at : the moment, especially because of it's great portability, I wouldn't : have to install the other interface software on every computer that I : use (At the moment it is 3, and will signifigantly increase). I'd : prefer to only use built-in functions, but if it can't be done, I'm : willing to look for something else. Is there any way I can do this? : Thanks! Plenty of ways to do it, although I'm not familiar with TKInter so I'll leave that part to someone else. You might find pCFITSIO usefull reading the FITS files though. http://panoramix.stsci.edu/~npirzkal/python/pcfitsio/ You would then use some python code or the PIL module to convert the FITS data in a suitable format for TKInter. --- cds -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to add thumbnails to Explorer
Hi Roger, Thanks for the info - I was actually interested in custom per file thumbnails rather than icons, but your message sentt me pouring through seemingly relevent parts of the registry - however what I need isn't there. Turns out I need to use a .dll shell extension as per http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ shellcc/platform/shell/programmersguide/shell_int/shell_int_extending/ extensionhandlers/shell_ext.asp Not so simple, and not (directly) a job for Python. Thanks, Chris Roger Upole ([EMAIL PROTECTED]) wrote: : As you guessed, the icon locations are stored in the registry. : There's a key under HKEY_CLASSES_ROOT for each : registered file type, with a default value holding the class name. : Under the class name, there's a DefaultIcon key that gives : the path to the icon. Using python files an an example, you : have HKCR\.py with Default=Python.File, and under : HKCR\Python.File\DefaultIcon, you should have the : path to py.ico. You can use the _winreg module to create : your own entries. : hth : Roger -- http://mail.python.org/mailman/listinfo/python-list
Re: Using Python to add thumbnails to Explorer
John J. Lee ([EMAIL PROTECTED]) wrote: : "Roger Upole" <[EMAIL PROTECTED]> writes: : Or, if not, then you can do it with module ctypes. : http://starship.python.net/crew/theller/ctypes/ : There's an O'Reilly book called something like "win32 shell : programming" that covers this stuff. : John Roger & John - thanks for the info. Unless I'm wrong (a distinct posibility) this isn't an option, as all though COM is used as the interface, it is used to talk to *in process* code loaded from a DLL - so Python can only be used if the interpreter is invoked from within a custom shell extension .dll, which is probably not the best idea for various reasons. Thanks, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: When someone from Britain speaks, Americans hear a "British accent"...
Michael Hoffman ([EMAIL PROTECTED]) wrote: : muldoon wrote: : > Americans consider having a "British accent" a sign of sophistication : > and high intelligence. Many companies hire salespersons from Britain to : > represent their products,etc. Question: When the British hear an : > "American accent," does it sound unsophisticated and dumb? : > : > Be blunt. We Americans need to know. : To be blunt, I have no idea what this has to do with Python. Surely : selecting the right forum to use indicates more sophistication and high : intelligence than the way one speaks. ;-) Well you could draw a tenuous Python link on the headache inducing subject of trying to remember which spelling is which when doing something like: thirdparty_module_1.color = thirdparty_module_2.colour >>> from __future__ import sane_spelling :-) cds -- http://mail.python.org/mailman/listinfo/python-list
Re: Parallel port programming on windows XP/2000?
Novice Experl ([EMAIL PROTECTED]) wrote: : I'd like to write a simple application that interfaces with the parallel port, and changes the data on it according to keyboard input. I hope I can get it to run under windows xp and / or windows 2000. : How can I do this? What do I need to know? It doesn't look like the standard library (the one under my pillow) has that feature. In addition, I've heard that with newer versions of windows don't let you communicate with the port directly, instead requiring interfacing with some driver? I always use DLPortIO, makes life almost as simple as GWBasic and a DOS box... You can either create a custom extension around this or use ctypes. Generally speaking a custom .dll is only needed if you are your lpt transactions are bidirectional, highly interleaved and high bandwidth. DLPortIO: http://www.driverlinx.com/DownLoad/DlPortIO.htm ctypes: http://starship.python.net/crew/theller/ctypes/ Note that DLPortIO is not a Python thing, it's a generic Windows .dll with C and VB examples, and needs installing, so it can't be packaged with py2exe. I'd guess this is the same for other parallel port accesing tools - I think you need admin privilidges on a Windows NT/2K/XP box to install DLPortIO, but not to use it. If you decide this is the best route for you and find yourself stuck, drop me an email for some example code. --- cds : I came across this: : http://pyserial.sourceforge.net/pyparallel.html : but it seems to only be used for direct access (would it work with XP?), and hasn't been updated for a couple of years. In addition, it requires something called "Java Communications" (JavaComm) extension for Java/Jython, doesn't provide a link to it, and when I google it - google returns the page I came from! : To add to the confusion, I hope I can provide a py2exe executable of my script instead of forcing a complete installation. : --= Posted using GrabIt = : --= Binary Usenet downloading made easy =- : -= Get GrabIt for free from http://www.shemes.com/ =- -- http://mail.python.org/mailman/listinfo/python-list
Re: Parallel port programming on windows XP/2000?
Forgot to say - under OS' derived from Windows NT (i.e. NT 3.5, NT4, 2K, XP and future) it is not possible to directly access the parallel port, this has to be done by a kernel driver, hence the need to install something like DLPortIO, which parly exists in the kernel to access the hardware, and partly in userland to allow your programs to talk to the kernel part. I find it very annoying just how far PCs have regressed in terms of simple IO - back in the 8 bit days it was easy to hook sensors and actuators up to a computer without much knowledge and program something with them in Basic. These days it's almost impossible without special kit and lots of know how. Heck, the old BBC Mirco had raw IO capabilites as fast as an IBM parallel port, and more flexible to boot. Progress. A real pain for r&d types. --- cds c d saunter ([EMAIL PROTECTED]) wrote: : Novice Experl ([EMAIL PROTECTED]) wrote: : : I'd like to write a simple application that interfaces with the parallel port, and changes the data on it according to keyboard input. I hope I can get it to run under windows xp and / or windows 2000. : : How can I do this? What do I need to know? It doesn't look like the standard library (the one under my pillow) has that feature. In addition, I've heard that with newer versions of windows don't let you communicate with the port directly, instead requiring interfacing with some driver? : I always use DLPortIO, makes life almost as simple as GWBasic and a DOS : box... You can either create a custom extension around this or use : ctypes. Generally speaking a custom .dll is only needed if you are your : lpt transactions are bidirectional, highly interleaved and high bandwidth. : DLPortIO: http://www.driverlinx.com/DownLoad/DlPortIO.htm : ctypes: http://starship.python.net/crew/theller/ctypes/ : Note that DLPortIO is not a Python thing, it's a generic Windows .dll with : C and VB examples, and needs installing, so it can't be packaged with : py2exe. I'd guess this is the same for other parallel port accesing : tools - I think you need admin privilidges on a Windows NT/2K/XP box to : install DLPortIO, but not to use it. : If you decide this is the best route for you and find yourself stuck, drop : me an email for some example code. : --- : cds -- http://mail.python.org/mailman/listinfo/python-list
Re: Decline and fall of scripting languages ?
Kay Schluehr ([EMAIL PROTECTED]) wrote: : No good news for scripting-language fans: : http://www.phpmag.net/itr/news/psecom,id,23284,nodeid,113.html Just as well I ditched a scripting language for Python then... cds -- http://mail.python.org/mailman/listinfo/python-list
Re: Jython Phone Interview Advice
George Jempty ([EMAIL PROTECTED]) wrote: : I'm undergoing a phone interview for a Jython job today. Anybody have : practical advice for me? I haven't worked with Python in years, but I : have been working with Java in the meantime (resume at : http://scriptify.com/george_jempty_resume.pdf). I've been reading up: : my old "Quick Python" (Harris/McDonald) book, a somewhat more current : "Visual Quickstart Guide" (Fehily), as well as "Jython for Java : Programmers" (Bill) via safari.oreilly.com. : My interviewer today will be a somewhat technical manager. A key thing : I plan to ask is will this be primarily maintenance or new development. : I don't think I'm cut out for new development considering my : inexperience. Not that I'm likely to be interviewing people for a long time (lowly PhD student :-) but if I were I'd be less concerned about a persons detailed knowledge of a language (esp. one like Python with relativly few gotchas and quirks) then their general competency at writing and managing code and working as part of a product group. A good programer shouldn't have any serious problems adapting to a new language, so be ready to fo over some examples of your ability to switch / learn new languages. Also, never be afraid to ask for clarification etc. Worst thing ever in interviews can be getting the wrong end of the stick and following it, esp. if the people on the other end don't realise you're on the wrong track. Take all the above with a (large) pinch of salt! Cheers, Chris : Some things I'm noticing upon (re)reading my books. Triple quoted : strings: those provide functionality similar to Perl's "here" : documents. : Also, considering Javascript will be a substantial component of my job, : I'm noticing that Javascript's array/"hash" literal syntax is EXACTLY : the same as that for Python lists/dictionaries. This could lead to : easily sharing data between the client and server side, though I think : I should probably keep this one under my hat, at least with a manager. : Though if things go well I will probably subsequently interview with : more technical folks. : Otherwise, the only thing I can think to tell a manager in a phone : screen is that I'm willing to undergo brainbench.com's Python : certification. : Any advice would be much appreciated. Thanks in advance -- http://mail.python.org/mailman/listinfo/python-list
Re: what would you like to see in a 2nd edition Nutshell?
Alex Martelli ([EMAIL PROTECTED]) wrote: : I'm considering proposing to O'Reilly a 2nd edition of "Python in a : Nutshell", that I'd write in 2005, essentially to cover Python 2.3 and : 2.4 (the current 1st edition only covers Python up to 2.2). : So, if there's any advice or request about a 2nd edition of the : Nutshell, this is the right time for y'all to let me know. Feedback is : welcome, either privately or right here. Thanks in advance -- _and_ : apologies in advance because I know I just won't be able to accomodate : all the requests/advice, given the constraints on book size &c. Alex, Probably not a practical sugestion, but have you considered ctypes? I know it's proved invaluable to our group at university - we like to make Python work with so many bits of weird hardware with vendor supplied libraries etc ... Perhaps a more resonable sugestion would be a short section on integration with native systems, e.g. an intro/overview to (non exhaustive list): psyco scipy.blitz/weave ctypes pyrex A detailed look at these is probably outside the scope of Nutshell, but they all represent intreresting areas. Perhaps the section could end with some words on PyPy. Cheers, cds -- http://mail.python.org/mailman/listinfo/python-list
Re: Robotics and parallel ports
Isaac T Alston ([EMAIL PROTECTED]) wrote: : Heiko Wundram wrote: : > Maybe it's what you're looking for. : Thanks for that. I've never actually built a robot or anything like that : before, so I'm welcome to any advice I can get! I've heard programming via : USB is hard, so that's why I'm using the parallel port (serial ports are : said to be slow when sending a lot of data (I think)). I think I'll start : off with something very simple, for example controlling a motor and then : move up to more advance models. Greetings Isaac, Go for it! Words of advice on using the parallel port: 1 - there are different modes (SPP, EPP etc.) availible - 'Parallel Port Interfacing' on www.beyondlogic.org is an excellent starting point. The mode is set in the PC BIOS, and if it's not set to the mode you're coding for then you may spend hours being perplexed... 2 - If you're new to robotics etc. make sure you think carefully about how you connect your motors to the parallel port to prevent hardware getting blown... An old but good book that covers electronic (and computer) control of motors is "The Robot Builder's Bonanza" Seperatly: USB needn't be so hard... This little board of tricks http://www.dlpdesign.com/usb/usb245.shtml gives you a parallel interface from USB 1.1, and a C library on the PC (which can be accessed from Python with ctypes) - data rate is similar to the parallel port, although latency is much higher, which can kill performance of some applications. Enjoy! -- http://mail.python.org/mailman/listinfo/python-list
Re: Robotics and parallel ports
Isaac T Alston ([EMAIL PROTECTED]) wrote: : Thanks for everyone's tips and hints. I WILL MAKE THIS WORK! I think I'll : take your advice and use the serial port instead of the parallel port - I : won't have that much data to send (in comparison with, for example, : industrial level applications). As for on-board chips though, does this : require low level programming!? Or can I have an embedded python : interpreter for the chip? Hi Isaac, You might be interested in PyMite - http://python.fyxm.net/pycon/papers/pymite/ although I don't know much (anythin? :-) about it. For on board control there are some tiny embedded computers out there that can run Linux etc. (and hence Python) these days - e.g. see http://www.linuxdevices.com/articles/AT8498487406.html or you could use a much simpler processor such as a PIC to implement a simple serial port to dgital and analogue IO module. Either way, plent to do :-) Cheers, cds -- http://mail.python.org/mailman/listinfo/python-list
Re: Fastest Way To Loop Through Every Pixel
Chaos ([EMAIL PROTECTED]) wrote: : He is the code #Actions here : myCol = (0.3 * image.GetRed(thisX, thisY)) + (0.59 * : image.GetGreen(thisX, thisY)) + (0.11 * image.GetBlue(thisX, thisY)) : if myCol < darkestCol: :darkestCol = myCol :possX = thisX :possY = thisY You really don't want to do this in interpreted Python code. Way to slow. I don't know PIL but probably you can do it their. Another aproach is to use one of the array/maths libraries e.g. Numeric or NumPy. You'll need to move the image data between PIL and the array package with the data being a (y,x,3) array for input array and (y,x) for the output array. .tostirng() methods and fromstring() can be usefull here. Then... 1. Colour map it newImage = 0.3 * image[:,:,0] + 0.59 * image[:,:,1] + 0.11 * image[:,:,2] 2. Mask of pixels less than your threshold newImage = clip(newImage, myCol, MAX_COLOUR) 3. Find the coordinates of the last minimum colour - possX, possY (do you really need/mean to do this?) hth cds -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting rid of bitwise operators in Python 3?
: arguments and dicts, which are lot more versatile. Another major use, : talking to hardware, is not something oft done in Python either. Are you sure? I've been doing lots of exactly that for 4 years, and I'm not the only one round here... Python makes an excellent language for talking to hardware. cds -- http://mail.python.org/mailman/listinfo/python-list
Windows AVIFile problems
Hi All, I'm trying to access individual video frames of an AVI file from within Python 2.4 or 2.5 under Windows XP. I have found this example code here for that does exactly what I want, using the windows avifile.dll but I am unable to find the AVIFile.h header... http://mail.python.org/pipermail/image-sig/2002-February/001748.html An alternative is to call into avifile.dll dynamically using ctypes, however under both Python 2.4 and 2.5 the following error happens: >>> from ctypes import * >>> windll.AVIFile Traceback (most recent call last): File "", line 1, in windll.AVIFile File "C:\Python25\lib\ctypes\__init__.py", line 415, in __getattr__ dll = self._dlltype(name) File "C:\Python25\lib\ctypes\__init__.py", line 340, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 193] %1 is not a valid Win32 application or WinDLL('c:/windows/system/AVIFILE.DLL') # same for .../system32/AVI... Traceback (most recent call last): File "", line 1, in windll.AVIFile File "C:\Python25\lib\ctypes\__init__.py", line 415, in __getattr__ dll = self._dlltype(name) File "C:\Python25\lib\ctypes\__init__.py", line 340, in __init__ self._handle = _dlopen(self._name, mode) WindowsError: [Error 193] %1 is not a valid Win32 application This suggests that the dll is corrupt? However if I download and run the exe's from this example of a VB program calling the DLL, they work: http://www.shrinkwrapvb.com/avihelp/avihelp.htm I'm open to suggestions about the specific problems above or other ways of getting at the frames. I've tried pymedia but it also has issues. Regards Chris Saunter -- http://mail.python.org/mailman/listinfo/python-list
Re: Windows AVIFile problems
Thomas Heller ([EMAIL PROTECTED]) wrote: : c d saunter schrieb: : > Hi All, : > : The dll is not corrupt. It is the 16-bit dll, possibly present for legacy : 16-bit support. Thomas, Thanks, that explains a lot. Regards, Chris Saunter -- http://mail.python.org/mailman/listinfo/python-list
Re: Parallel port control with USB->Parallel converter
Soren, I don't know about the USB parallel port converters but there are variousways you can add USB connectivity yourself. A simple way are the USB devices from FTDI (http://www.ftdichip.com/FTProducts.htm) Either the FT232R or the FT245R. These are both single chip solutions that provide a USB interface on one side and an 8 bit bi-directional fifo on other. The 232 is mapped as a serial port at the system level, whilst the 245 is higher bandwidth and accessed through an API (use ctypes etc.) Windows, Linux & Mac OS X are supported. FTDI provide evaluation modules (tiny, USB powered) that you can be up and running with in no time: http://www.ftdichip.com/Products/EvaluationKits/FT245RModules.htm Good luck! regards cds Soren ([EMAIL PROTECTED]) wrote: : Hi, : I want to control some motors using the parallel port.. however, my : laptop does not have any parallel ports (very few do). What I do have : is a USB->Parallel converter... I thought about using PyParallel, but : the USB->Parallel converterdoesn't actually map to the LPT port .. : and PyParallel only looks for LPT ports? : Has anyone tried doing this? What are my options for controlling : parallel connections on a laptop with no parallel port? : I also thought about controlling the USB natively.. but since I dont : have any instructions on how to do this with my Velleman USB->Parallel : port converter... i guess I would be totally blind. : Any help would be appreciated! : Soren -- http://mail.python.org/mailman/listinfo/python-list
Re: Parallel port control with USB->Parallel converter
Doh! It's been a while since I used these. I was slightly wrong; actually both the 232 and 245 devices can be accessed either via a serial port interface (COMx on windows, /dev/??? on linux etc.) or via a direct API. The 245 provides a parallel FIFO and the 232 a serial data link, so you'd want the 245. regards cds c d saunter ([EMAIL PROTECTED]) wrote: : Soren, : I don't know about the USB parallel port converters but there are : variousways you can add USB connectivity yourself. : A simple way are the USB devices from FTDI : (http://www.ftdichip.com/FTProducts.htm) : Either the FT232R or the FT245R. These are both single chip solutions : that provide a USB interface on one side and an 8 bit bi-directional fifo : on other. The 232 is mapped as a serial port at the system level, whilst : the 245 is higher bandwidth and accessed through an API (use ctypes etc.) : Windows, Linux & Mac OS X are supported. : FTDI provide evaluation modules (tiny, USB powered) that you can be up and : running with in no time: : http://www.ftdichip.com/Products/EvaluationKits/FT245RModules.htm : Good luck! : regards : cds : Soren ([EMAIL PROTECTED]) wrote: : : Hi, : : I want to control some motors using the parallel port.. however, my : : laptop does not have any parallel ports (very few do). What I do have : : is a USB->Parallel converter... I thought about using PyParallel, but : : the USB->Parallel converterdoesn't actually map to the LPT port .. : : and PyParallel only looks for LPT ports? : : Has anyone tried doing this? What are my options for controlling : : parallel connections on a laptop with no parallel port? : : I also thought about controlling the USB natively.. but since I dont : : have any instructions on how to do this with my Velleman USB->Parallel : : port converter... i guess I would be totally blind. : : Any help would be appreciated! : : Soren -- http://mail.python.org/mailman/listinfo/python-list
Unexpected string behaviour: txt = 'this' ' works'
I did a double take when debugging an error the other day. My problem was missing out a comma when building a list of strings. Much to my surprise the offending code still executed to cause problems later on: >>> txt = 'this', 'works' >>> print txt ('this', 'works') # As expected >>> txt = 'this' 'works' >>> print txt thisworks # Eh? I have never seen this behaviour before, but it works in Python 2.2.1 and 2.5.4 so I guess it's meant to be there. I assume it is a feature of the compiler. Any thoughts? Regards Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Unexpected string behaviour: txt = 'this' ' works'
Bruno Desthuilliers (bruno.42.desthuilli...@websiteburo.invalid) wrote: : c d saunter a écrit : : > I did a double take when debugging an error the other day. My : > problem was missing out a comma when building a list of strings. : > : > Much to my surprise the offending code still executed to cause : > problems later on: : > : >>>> txt = 'this', 'works' : >>>> print txt : > ('this', 'works') : > # As expected : >>>> txt = 'this' 'works' : >>>> print txt : > thisworks : > # Eh? : > : > I have never seen this behaviour before, but it works in Python 2.2.1 : > and 2.5.4 so I guess it's meant to be there. I assume it is a feature : > of the compiler. : > : > Any thoughts? : http://docs.python.org/reference/lexical_analysis.html#string-literal-concatenation Ahh. Thanks. Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing VHDL with python, where to start.
Svenn Are Bjerkem ([EMAIL PROTECTED]) wrote: : Hi, : I am in the need to write an application for PyQt to visualise the : structure of a VHDL project I am working on. Looking for a sensible : way to parse VHDL files and putting them into a data structure that : PyQt can represent as a tree (or whatever the MVC is supporting) : through search engines does not give me many hints. From what I know, : VHDL is not a very easy language to parse. There seems to be a parser : for perl available, but I do not know if it is wise to use a perl : module as a template for writing something similar in python. Hi Sven, How much of VHDL are you looking to parse? Are you just looking at files intended for synthesis, or at simulation/testbench files as well? I wrote a basic parser a few years ago for automatically stringing modules together, but it was very limited in scope. I thought VHDL was quite simple to parse, it's very rigid. Having written a basic one I realised I'd coded myself into a dead-end as you say. Maybe not so simple after all... :-) If I started again I'd use pyparsing: http://pyparsing.wikispaces.com/ Looks like someone is already there in part: http://pyparsing.wikispaces.com/message/view/home/103973 Regards, Chris : My initial idea is to start simple and extend features in my : application, but I fear that I may start off with wrong ideas how to : parse and then code myself into a dead-end requiring myself to rewrite : the whole application in order to get any further. I would start : finding definitions of entities and the instantiations of these and : build a tree from a set of external vhdl files stored in a file : hierarchy. If somebody have a starting point where to get going with a : task like this, I would be happy to know. : -- : kind regards, : Svenn -- http://mail.python.org/mailman/listinfo/python-list