I am creating a GUI that takes query
from a user and runs < Code> lefunction To return a list named Result
, a function (query) . When the user enters the press, I want to set the text on each label to the element of result
. My endeavor, shown below, prints the last element of the result
only on the last label ... (bear with me, I'm beginning with the tanker.)
Thanks.
Import imported importer import lefunction class simpleapp_tk (Tkinter.Tk): def __init __ (self, parent): Tkinter.Tk .__ init __ (self, parent) self. Parent = parent self initialize () def start (SIT): self. Grad () self Antivirable = takanator.strinver () self Anti = tactor.indree (self, textualial = self. Antiviewable) itself. Anti Grid (column = 0, line = 0, stick = = 'ew') self Self.entryVariable.set (u "") for J. Enry.bind ("& lt; Return & gt;", manually. Enter the Express) range (1,10): self.labelVariable = Tkinter.StringVar () Label = Tkinter.Label (self, textvariable = self.labelVariable, anchor = "w", fg = "black", bg = "white") label.bind (" aFunction
code works as expected): ManLop ()
, Lambda event, text = "sup": \ self.click_link (event, text)) label.grid (column = 0, line = j, column = 2, Stick = = 'EW') self.grid_columnconfigure (0, weight = 1) self. True, wrong) self.update () self.geometry (self.geometry ()) self.entry.focus_set () self.entry Select_range (0, Tkinter.END) def OnPressEnter (self, event): #Result is a result in the list = leFunction.aFunction (self.entryVariable.get ()) for the category (0, Lane (result)): print "Result", I, ":", Results [i] .labelVars [i] itself. Set (result [i]) self.entry.focus_set () self.entry.selection_range (0, Tkinter.END) def click_link (auto, incident, text): printed "You clicked '% s'"% text #os System ("open" + file) if __name__ == "__main__": app = simpleapp_tk (none) app.title ('my application') app.mainloop ()
Instead Setting a self.labelVariable
greater than you, you now create a self.labelVars
list, each element related to a labelVar
. Then you can set the text of the elements of this list such as:
self.labelVars [i] .set (result [i])
No comments:
Post a Comment