[FAQTS] Python Knowledge Base Update -- May 19th, 2000
Fiona Czuczman
fiona at sitegnome.com
Fri May 19 09:08:07 EDT 2000
Greets!
Tonight I've entered the following into http://python.faqts.com
Have a good week-end, Fiona Czuczman
## New Entries #################################################
-------------------------------------------------------------
Where can I find information about how to manipulate Excel with Python?
http://www.faqts.com/knowledge-base/view.phtml/aid/3093
-------------------------------------------------------------
Fiona Czuczman
Robert Citek
I strongly recommend the "Python Programming on Win32" by Mark Hammond &
Andy Robinson. Visit http://www.oreilly.com/catalog/pythonwin32
Here is some sample code:
# this example starts Excel, creates a new workbook,
# puts some text in the first and second cell
# closes the workbook without saving the changes
# and closes Excel. This happens really fast, so
# you may want to comment out some lines and add them
# back in one at a time ... or do the commands interactively
from win32com.client import Dispatch
xlApp = Dispatch("Excel.Application")
xlApp.Visible = 1
xlApp.Workbooks.Add()
xlApp.ActiveSheet.Cells(1,1).Value = 'Python Rules!'
xlApp.ActiveWorkbook.ActiveSheet.Cells(1,2).Value = 'Python Rules 2!'
xlApp.Close(SaveChanges=0)
xlApp.Quit()
del xlApp
# raw_input("press Enter ...")
-------------------------------------------------------------
Is there a way to "kill" a thread that is currently asleep?
Can I stop, destroy, suspend, etc. a thread that is asleep?
http://www.faqts.com/knowledge-base/view.phtml/aid/3078
-------------------------------------------------------------
Fiona Czuczman
Jeff Blaine
From: http://www.python.org/doc/current/lib/module-threading.html
"Python's Thread class supports a subset of the behavior of Java's
Thread class; currently, there are no priorities, no thread groups, and
threads cannot be destroyed, stopped, suspended, resumed, or
interrupted...."
-------------------------------------------------------------
How can I create a "rollover" effect?
http://www.faqts.com/knowledge-base/view.phtml/aid/3086
-------------------------------------------------------------
Fiona Czuczman
John Grayson
Here is a minimal example. Choose your own images...
from Tkinter import *
class ActiveButton(Button):
def __init__(self, master, inimage=None, outimage=None,
activate=None):
self.master = master
self.inI = PhotoImage(file='icons/%s' % inimage)
self.outI = PhotoImage(file='icons/%s' % outimage)
Button.__init__(self, master, command=activate, image=self.outI)
self.bind('<Any-Enter>', lambda e, state=1, s=self:
s.change(e, state))
self.bind('<Any-Leave>', lambda e, state=0, s=self:
s.change(e, state))
def change(self, event, state):
if state:
self.configure(image=self.inI)
else:
self.configure(image=self.outI)
if __name__ == '__main__':
root = Tk()
button = ActiveButton(root, inimage='smooth.gif',
outimage='tline1.gif',
activate=root.destroy)
button.pack()
root.mainloop()
-------------------------------------------------------------
How do I force a dump of sys.last_traceback (last traceback object) to a file object, or stringio or something similar?
http://www.faqts.com/knowledge-base/view.phtml/aid/3083
-------------------------------------------------------------
Fiona Czuczman
Fredrik Lundh
Have a look here:
http://www.python.org/doc/current/lib/module-traceback.html
-------------------------------------------------------------
How do I get Python to force 'a' and 'b' into strings so that a + ":" + b concatenates instead of trying to add?
http://www.faqts.com/knowledge-base/view.phtml/aid/3082
-------------------------------------------------------------
Fiona Czuczman
Andy Lester, Remco Gerlich, Martijn Faassen, Scott
The str() function.
a = 1
b = 2
str(a) + ":" + str(b)
Or use the % operator, of course.
str = "%d:%d" % (a,b)
## Edited Entries ##############################################
-------------------------------------------------------------
How do I write a raw string (r'...') that ends with a backslash?
http://www.faqts.com/knowledge-base/view.phtml/aid/3022
-------------------------------------------------------------
Beat Bolli, Fiona Czuczman
Moshe Zadka
r'this ends with a ' '\\'
A pure raw string cannot end with an odd number of backslashes. The
above, using the fact that consecutive string literals are concatenated
at runtime, is the standard workaround.
More information about the Python-list
mailing list