April 18th, 2005, 07:07 AM
Win32com apps and Tkinter Listbox
First the Listbox question:
I have a Listbox with maybe a few 100 items in it now i do curseletion() to find the line but how do I locate what name it is because I need the name to search a file for info.
How I use Word to make a word file and then print it out.
It will be like a bill and anotherlike a list with all the people.
thanks for any help...
April 19th, 2005, 03:52 AM
To answer your Listbox question - use the listbox get() method to read the item stored at an index:
index_list = lb.curselection()
value = lb.get(index_list)
Note that index_list is actually a list of indexs of selected items. If you set up your listbox in EXTENDED mode you can select more than one item.
Here's a quick example of using a Listbox in extended mode:
from Tkinter import *
root = Tk()
choices = StringVar(root)
# A List box in extended mode allows
# you to CTRL/SHIFT click items
lb = Listbox(root, selectmode = EXTENDED)
# Somewhere to display our choice
Label(root, textvariable = choices).pack()
"""Function to read the List Box selection
and put the results in a Label"""
sel = lb.curselection()
seltext = repr([lb.get(x) for x in sel])
#Click the button to read the selection
Button(root, text = "Test", command = getlist).pack()
# Store some items in the Listbox
items = ["one", "two", "three", "four"]
for item in items:
Last edited by Grim Archon; April 19th, 2005 at 03:56 AM.
April 19th, 2005, 09:18 AM
Do u have any idea about win32com...
April 20th, 2005, 02:14 AM
Controlling Word from Python is not a small task If you are really interested - your best bet is to obtain a copy of Mark Hammond's book:
It explains the principles but you would still have to do a lot of research to achieve anything useful.
April 20th, 2005, 09:04 AM
Well I would try aleast:P
But my mom does not wanna buy me another book till my school grades are better
So thats not possible