I have a particular date time format I use for making entries in various logs I maintain, and ideally what I'd like is for my operating system (Windows or Linux) to recognize that every time I type, say, <Ctrl>-'C' '1', a Python script I wrote will execute and out will pop the current date time in my desired format. I want this to happen not just in my Xemacs text editor buffer, but inside a textfield for, say, the Gmail application in Mozilla, in Python IDLE, in the Google desktop search bar and at the command line. At LinuxWorld I asked three of the people from the San Francisco Linux users group about doing this in Ubuntu, and here is what I could ascertain: *) the Apple OS is ideally suited to doing what you want, and necessitates learning AppleScript. In Windows or Linux it's a lot more complicated to bind a sequence of keys to call a Python program that generates output in any graphical window and, in fact, it may be impossible or more trouble than it's worth *) at the prompt you can execute the Python program to output the date time in your desired format, but to do this in Gnome or KDE is a different story *) within the browser environment you can write a Mozilla Firefox extension that may allow you to call Python scripts, but this necessitates learning XUL
Have any of you ever successfully engineered an operating system key-binding that calls a Python script and directs the output where the cursor is in any graphical window in Windows and Linux ? In Ubuntu I followed the advice in this article: http://ekith.com/index.php?option=com_content&task=view&id=10181 but found that System/Preferences/Keyboard Shortcuts does not allow you to define your own action. I created launchers for my Python scripts but clicking on them seemed to have no effect. I guess my expectation should be the answer is no, in which case I'd be happy just to find out if it's possible to create key-bindings in Xemacs to call a Python program. I have a feeling the answer to this query is no as well, in which case my next step is to port the following to elisp: def output_current_datetime_in_my_desired_format(): import datetime print datetime.datetime.now().strftime("%d%b%Y%a %I:%M%p").upper() def output_current_time_in_my_desired_format(): import datetime print datetime.datetime.now().strftime("%I:%M%p").upper().rjust(20)<http://ekith.com/index.php?option=com_content&task=view&id=10181>
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor