Note that there are some explanatory texts on larger screens.

plurals
  1. POtkinter widget interface interactive button
    text
    copied!<p>I am very new to interactive python programming so please bear with me. I am using PyCharm with Python 3.3. </p> <p>I am attempting to build the following:</p> <p>I want to generate an a function that pulls up interactive window with two text input fields and two buttons:</p> <p>-The first button (START) runs a small text-search function (which I already wrote and tested), while the second button (QUIT) will quit the app.</p> <p>-The first text input field takes a string to be searched (ex: "Hello Stack World"), while the other text input field takes a string to be searched within the first input string (ex: "Stack").</p> <p>The plan is that once the two text fields are filled in, pressing the 'START' button will start the text-search function, while the'QUIT' button stops the program.</p> <p>The problem is, the 'QUIT' button works the way it should, but the 'START' button does nothing. I think it actually sends my program into an infinite loop. </p> <p>Any and all help is really appreciated it. I am a novice at interface/widget programming. </p> <p>Thanks in advance!</p> <p>Here is my code as I have it now:</p> <pre><code>import tkinter from tkinter import * class Application(Frame): def text_scan(self): dataf = str(input()) '''string to be searched''' s = str(input()) ''' string to search for''' ''' ... I will leave out the rest of this function code for brevity''' def createWidgets(self): root.title("text scan") Label (text="Please enter your text:").pack(side=TOP,padx=10,pady=10) dataf = Entry(root, width=10).pack(side=TOP,padx=10,pady=10) Label (text="Please enter the text to find:").pack(side=TOP,padx=10,pady=10) s = Entry(root, width=10).pack(side=TOP,padx=10,pady=10) self.button = Button(root,text="START",command=self.text_scan) self.button.pack() self.QUIT = Button(self) self.QUIT["text"] = "QUIT" self.QUIT["fg"] = "red" self.QUIT["command"] = self.quit self.QUIT.pack({"side": "left"}) def __init__(self, master=None): Frame.__init__(self, master) self.filename = None self.pack() self.createWidgets() root = Tk() root.title("text scan") root.quit() app = Application(master=root) app.mainloop() </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload