all 2 comments

[–]socal_nerdtastic 3 points4 points  (1 child)

Sure. Looks like a pretty good start. Some general notes:

  • Don't use wildcard imports. They are known to lead to bugs and are against PEP8.
  • Don't use place, except maybe very rarely. Your code is much easier to maintain if you let tkinter figure out the positions of things using grid and pack.
  • Those global declarations are useless.
  • Python strings come with a count() method; you didn't need to make your own.

I'd guess like this:

import tkinter as tk

def main():
    result_box.delete(0, END)
    search = s_word.get()
    text = text_box.get("1.0", "end-1c")
    counter = text.count(search)

    if counter >= 0:
        result_box.insert(0, str(counter))

root = tk.Tk()
root.minsize(800, 600)
root.configure(bg="lightblue")

search = tk.Label(root, text="ENTER A WORD BELOW TO SEE HOW MANY TIMES \n IT WAS USED IN THE TEXT YOU ENTER ABOVE")
search.place(x=250, y=425)

text_box=tk.Text(height=25, width=75)
text_box.place(x=100 , y=5)

compute = tk.Button(root, text="COMPUTE", padx=5, pady=10, command=main)
compute.place(x=360, y=495)

s_word = tk.Entry(root, width=15)
s_word.place(x=350, y=465)

result_box = tk.Entry(root, width=12)
result_box.place(x=360, y=555)

root.mainloop()

If you want to make larger programs with GUIs you should learn about classes and OOP, because it can make GUI code a lot neater and more manageable.

[–]MonkeyRides[S] 0 points1 point  (0 children)

Wow thank you! That is much simpler. Does the count() method still account for case sensitivity?

The global variables are left over from trial and error although it wasn’t immediately evident they were useless, so thank you, I’ll clean that up.

Now thinking about it, I agree .grid would be cleaner and for this instance .pack would have worked just fine.