G_S 38 Junior Poster in Training
def find():
    start = 1.0
    while 1:
        find = text_to_be_found.get()

It could be that you define "find" as a function and a variable. It could also be that "text_to_be_found" is not within the scope of the function. Print the result of text_to_be_found.get() and see if it is returning anything.

I did what you said and here are the results:

I changed find (variable) to f, then:

f = text_to_be_found.get()
pos = textarea.search(f, start, stopindex=END)

also, I added the following lines (outside the loop):

print(f)
print(pos)

The first print outputs whatever I'm searching for.
The second print prints nohing...

I think the problem is that there is something wrong with pos.

G_S 38 Junior Poster in Training

Hi everybody,


I am experiencing a very weird situation here:

I have a program that uses tkinter and python 3, but its search function isn't working under Windows.

from tkinter import *
import tkinter.ttk

def sort():
    pass

def find():
    start = 1.0
    while 1:
        find = text_to_be_found.get()
        pos = textarea.search(find, start, stopindex=END)
        if not pos:
            break
        beginning = pos+"linestart"
        end = pos+"lineend"
        start = pos + "+1c"
        textarea.tag_add(SEL, beginning, end)

window = tkinter.Tk()
window.title("Help with find function")

mainframe = tkinter.ttk.Frame(window, border=3, relief="sunken") 
textarea = Text(mainframe)
button = tkinter.ttk.Button(mainframe, text="Sort", command=sort)
button2 = tkinter.ttk.Button(mainframe, text="Find", command=find)
text_to_be_found_label = tkinter.ttk.Label(mainframe, text="Find the following word: ",)
text_to_be_found = tkinter.ttk.Entry(mainframe)

mainframe.grid(row=0, column=0)
textarea.grid(row=0, column=0, columnspan=2)
button.grid(row=2, column=0)
button2.grid(row=2, column=1)
text_to_be_found_label.grid(row=3, column=0, pady=5)
text_to_be_found.grid(row=3, column=1, pady=5)

window.mainloop()

Write something in the text area and then try to use the little entry field to find one of the words you wrote in the text area. You'll see that it just doesn't work, whereas it does work right away under Linux.

Can somebody tell me what the problem is, isn't python suppossed to be platform independent??


Also, if someone has a better suggestion the function itself I have already asked about it in this topic: http://www.daniweb.com/forums/thread273351.html


thank you

G_S 38 Junior Poster in Training

Hi,

I have another question: ¿is there a method that allows me to capitalize the first letter of EVERY WORD in a given string?

I know that something like:

a = "hello world"
print(a.capitalize())

would print "Hello world"

but I need it to print Hello World. It's for a program that automatically capitalizes book names, and they should be in that format. For instance: "The Book Of My Friends"

Thank you for your help.

G_S 38 Junior Poster in Training

Hi people!


I need your help with a find function for a glossary program that I'm writing for my own use. I'm using python 3.x and have already made a find function, but I don't like how it came out. Let me explain with an example:

First, let me show you the code:

from tkinter import *
import tkinter.ttk

def sort():
    pass

def find():
    start = 1.0
    while 1:
        find = text_to_be_found.get()
        pos = textarea.search(find, start, stopindex=END)
        if not pos:
            break
        beginning = pos+"linestart"
        end = pos+"lineend"
        start = pos + "+1c"
        textarea.tag_add(SEL, beginning, end)

window = tkinter.Tk()
window.title("Help with find function")

mainframe = tkinter.ttk.Frame(window, border=3, relief="sunken") 
textarea = Text(mainframe)
button = tkinter.ttk.Button(mainframe, text="Sort", command=sort)
button2 = tkinter.ttk.Button(mainframe, text="Find", command=find)
text_to_be_found_label = tkinter.ttk.Label(mainframe, text="Find the following word: ",)
text_to_be_found = tkinter.ttk.Entry(mainframe)

mainframe.grid(row=0, column=0)
textarea.grid(row=0, column=0, columnspan=2)
button.grid(row=2, column=0)
button2.grid(row=2, column=1)
text_to_be_found_label.grid(row=3, column=0, pady=5)
text_to_be_found.grid(row=3, column=1, pady=5)

window.mainloop()

now pay attention:

1. run the program
2. write the following:

race
track
racetrack
racetrack creation
horse
shoe
horseshoe
the shoes of the horse

3. now write shoe in the entry box.
4. press find.

See what happens? Now I have two problems with this code:

Firstly, it finds all the lines containing the word, I'm ok with it highlighting the whole line and not the word itself, but the problem is that it finds all the lines AT ONCE. I want it to …

G_S 38 Junior Poster in Training

I managed to do it. I installed tcl/tk 8.5 from source and in the default directories (/usr/local/lib), then I moved all these files to /usr/lib so that they ended up sitting next to their tcl/tk8.6 counterparts.

I then compiled python 3 normally with the make altinstall option to avoid overwriting the older python, and that did it.

I supposse that this is due to the mandriva devel packages, I suspect they somehow do not install everything that python needs to successfully build the tkinter modules, an this is why you go crazy trying to compile it and getting errors despite the fact that the required packages are there.

Hope this helps someone.

Gribouillis commented: Nice info for Mandrivers like me ! +3
G_S 38 Junior Poster in Training

OK, I'll keep trying then.

Thanks for your help.

G_S 38 Junior Poster in Training

Well, that's a possibility then. I'll try it in my virtual mandriva.


However, I still wanna find out how to do it from source in Mandriva AND what the problem here is. As I said before, it is not a problem in other distributions, but in Mandriva this is always the case. Last time (Mandriva 2009.1) I had to copy some folders from another system into the /usr/lib directory (if i remember correctly) to get it to work, but I don't have those files anymore.


Any ideas?
Maybe you can tell me what's installed in your system?

G_S 38 Junior Poster in Training

That's weird, I updated everything in sight and my python is still 2.64. I do see, however, a python3 package, which is not installed.

G_S 38 Junior Poster in Training

I'm interested in Romance of the Three Kingdoms and Hakuouki, but these are not show...

seems like it's gonna be a horrible season...

G_S 38 Junior Poster in Training

Hello every body. I've been lurking these forums for quite a long time, but I finally decided to join as I see it's pretty well organized and useful.

I'm a language professional curently considering either a career switch or a 'career fusion' (i.e complementing my exiting career with another one). And guess what? I want programming to be that career, I see so much future in it.

I started with Python and Java, and I've been learning by myself. I'm currently more advanced in Python than Java, and I want to be able to build simple applications before I jump completely into formal training.

I like Linux, computers/technology, science and language learning. I like learning by myself, but don't mind a helping hand. I also like videogames (RPG's) and bird breeding.

Ok. That's it, nice to meet you all.

G_S 38 Junior Poster in Training

Oh, hi and thanks for replying.

Because installing from source allows me to be more up-to-date. RPM's are not updated that often, and that python version will eventually become outdated.


Besides I wanna learn what the problem with Mandriva is, I have done this several times with several distributions, and it's easy, just install the devel packages and that's it, but Mandriva always gives me trouble...

G_S 38 Junior Poster in Training

Hi everybody,

I'm trying to install python 3 from source in my new Mandriva 2010. I have read a lot of posts in this website, but none of the instructions has worked for me.

The code compiles and all, but it doesn't install tkinter. I know that tcl/tk are installed because python 2.6 (which comes with Mandriva) can import Tkinter.

I am trying to run this code, and it does work with python 2.x:

from Tkinter import *


root = Tk()
root.geometry("100x100+300+200")
l1 = Label(root, text="Hello World!")
b1 = Button(root, text="close", command=quit)

l1.pack()
b1.pack()

root.mainloop()

I installed the following packages using the package manager:

libtk-devel
libtcl-devel
libtk8.6
libtcl8.6

Still the configure script will not find tcl/tk in my system.

Any help would be appreciated.

Thanks

PS. I know I have to change Tkinter to tkinter, the problem is that python3.1 will not even import tkinter. Instead it gives me the "no module named tkinter" error.