| | |
Problem with find
![]() |
•
•
Join Date: Mar 2006
Posts: 56
Reputation:
Solved Threads: 1
Hi!I have a problem and i think you can help me!(Sorry my english.I learn just one year)
Thats part of my program...
i need add to definiction find correcet function.I need something like "find" in python GUI.If you press button find,you will see new window.In the window must be an Entry and Button.If you write sometzhing in entry and then press button will be called function:if is entry.get in text,selcet it and set cursor on them.if there is moore, they will by show by oressing button.I have tryied program from code snipet find, but i didnt solved it.
Thanks.
Thats part of my program...
Python Syntax (Toggle Plain Text)
okno=Tk() text=Text() text.pack() def find(): print "I need help here" menubar = Menu(okno) editmenu = Menu(menubar, tearoff=0,bd=4) editmenu.add_command(label="Find", command=find) menubar.add_cascade(label="Edit", menu=editmenu) okno.config(menu=menubar)
Thanks.
hi,
The following code is the find function part of your code but with part of the solution
it now prints the index (location) of the begining of a string or letter but i havn't a clue how to highlight text.
the text widget uses index's, 1.0 would mean the first row (1) and the first column (0)
just picture the text widget as a grid, with one character in each square
so when you enter a string to search, it returns either nothing (if nothing was found) or the index for the first character in the string.
at the end of the while loop, the "+1c" means +1 column.
www.pythonware.com has documentation for all of Tkinter
The following code is the find function part of your code but with part of the solution
it now prints the index (location) of the begining of a string or letter but i havn't a clue how to highlight text.
Python Syntax (Toggle Plain Text)
def find(): findStr = tkSimpleDialog.askstring("Find", "Find:") # Prompts user to enter a string, if nothing is entered, function returns None if findStr: # Test to see if the function returned a string or None print findStr start = 1.0 while 1: position = text.search(findStr, start, stopindex=END) if not position: break print "string was found at ", position start = position + "+1c" else: print 'nothing was entered'
the text widget uses index's, 1.0 would mean the first row (1) and the first column (0)
just picture the text widget as a grid, with one character in each square
so when you enter a string to search, it returns either nothing (if nothing was found) or the index for the first character in the string.
at the end of the while loop, the "+1c" means +1 column.
www.pythonware.com has documentation for all of Tkinter
![]() |
Similar Threads
- Problem registering F12 as a hotkey in Windows XP (Windows NT / 2000 / XP)
- Big Problem (Viruses, Spyware and other Nasties)
- Big Problem (Windows NT / 2000 / XP)
- Problem with Listbox (Visual Basic 4 / 5 / 6)
- Startup Problem EMERGENCY! (Windows NT / 2000 / XP)
- loop problem (C)
- Problem accessing various site (Viruses, Spyware and other Nasties)
- Windows Explorer Problem Encounters (Viruses, Spyware and other Nasties)
- Cannot Find Server or DNS Error - Secure Sites Pls Review HiJacks Log (Viruses, Spyware and other Nasties)
- Cannot Find Server. (Web Browsers)
Other Threads in the Python Forum
- Previous Thread: Avoid space in print
- Next Thread: Lisp i know its pythlon but please help
| Thread Tools | Search this Thread |
advanced aliased argv bash beginner bits calling casino changecolor clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically enter event events examples external file float format frange function google gui hints homework i/o iframe import input jaunty java keyboard line linux list lists loop matching mouse multiple newb number numbers obexftp output parsing path port prime programming projects py py2exe pygame pygtk python random rational raw_input recursion return scrolledtext signal singleton skinning string strings tails terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython





