Tuesday, 15 April 2014

python - Trying to change label using entry box and button -


I am trying to create a label that will change when I enter text in the entry box and click on the button.

I have tried to do some research, but how will it be known how to do it. Tkinter import * master = Tk () master.title ("Part 3") v = StringVar () v.set ("Please replace me")

  lb = Label (master, textvariable = V, fg = "red", bg = "black"). Grid (line = 0, column = 0 grid (line = 1, column = 2) b1 = button (master, text = "click to change", fg = "red", bg = "black") ant = Entry (Master, Textual = V, Grid) (Line = 1, Column = 0)  

To do this, you first need to define a callback that changes the value (examples given below)

You can use different types of string types to store different values Of two variables Also use

tkinter import * master = Tk () master.title ("Part 3") lText = StringVar () lText.set ("Please replace me") eText = StringVar () Def ChangeLabelText (event = none): global lText global eTextLText.set (eText.get ()) <

  lb = label (master, textvariable = lteext, Fg = "red", bg = "black"), grid (line = 0, column = 0) ent = entry (master, textual = etext) .Grid (line = 1, column = 2) b1 = button (master) , Text = "click to change", fg = "red", bg = "black", command = ChangeLabelText) .grid (line = 1, column = 0)  

No comments:

Post a Comment