Yes -- standard Tkinter <variable>-s mechanics does that:
There is a Tkinter StringVar() ( and similarly IntVar(), DoubleVar(), BoolVar() ) object constructor, that prepares a smart object that is ready to be later used for this very purpose in Tkinter Widgets.
You may use .set() / .get() methods for manipulating with such object's value(s).
name = StringVar() # this creates a Tkinter object
name.set( "bob" ) # .set() assigns / .get() retrieves
L = Label( root, textvariable = name ) # makes the <name> used in Label Widget
Label text gets changed right by a new value gets assigned in <variable>
name.set( "alice" ) # .set() assigns a new value -> promoted
print L['text'] # show, a value has been promoted in L
FYI: Advanced <variable>-s' Tools
You may also want to know about a more advanced tools for Tkinter variables. There are also more powerful tools associated with Tkinter variables -- called trace-er(s) -- which set the Tkinter system to "watch" any change to a "traced" variable and this can associate further automated responsive activities, automatically launched upon a traced-event-type.
aWriteTraceID = name.trace_variable( "w", f2CallOnWriteAccessToTracedVariable )
aRead_TraceID = name.trace_variable( "r", f2CallOnRead_AccessToTracedVariable )
aDel__TraceID = name.trace_variable( "u", f2CallOnDel__AccessToTracedVariable )
name.trace_vinfo() # show all associated <<Tracers>>
>>> name.trace_vinfo()
[('u', '12945528f2CallOnDel__AccessToTracedVariable'),
('r', '12251384f2CallOnRead_AccessToTracedVariable'),
('w', '12760924f2CallOnWriteAccessToTracedVariable')
]
name.trace_vdelete( aRead_TraceID ) # delete an identified <<Tracer>>
name.trace_vdelete( aWriteTraceID ) # delete an identified <<Tracer>>
del( name ) # del() makes name undefined
# so this will "auto-launch" the last, still active <<Tracer>>
# you assigned above -- the function f2CallOnDel__AccessToTracedVariable()
This instrumentation helps you create your GUI toolbox strategies very powerful for an efficient, event-driven, fully self-reflecting layered [Model-Visual-Controller], supervised under the hood of the Tkinter.mainloop() scheduler
How to put it together?
As abarnert has proposed, the automated version may look in principle like this
name = StringVar() # a pure name holder
show = StringVar() # a post-processed text
L = Label( root, textvariable = show ) # L will display a post-processed string
L.pack() # L goes into GUI framework's geometry manager
# # prepare the <<Handler>> function
def autoProcessAndPropagateOnNameVarCHANGE( p1, p2, p3, p4 = name, p5 = show ):
# # this function will get called
# # upon WRITE-ACCESS <<Tracer>>
#
# .set( a post-processed value ) into [show], that is connected to GUI[Label]
p5.set( "Hello, " + p4.get() )
# # Always be carefull not to fire
# # an unstoppable chain-reaction ;)
# # of <<Tracer>>-related events
# # as more <<Tracer>>-s get used
# # create <<Tracer>> / <<Handler>> pair
aWriteTraceID = name.trace_variable( "w", autoProcessAndPropagateOnNameVarCHANGE )
# -------------------------------------------------------------------------------
# test <<Tracer>>:
name.set( "Craig" ) # <<Tracer>>-watched WRITE-ACCESS
# test <<Tracer>> result: GUI Label L shall show "Hello, Craig" -----------------
# -------------------------------------------------------------------------------
# erase all <<Tracer>>-s assigned:
name.trace_vinfo() # initial state of <<Tracer>>-s
for aTracerRECORD in name.trace_vinfo():
name.trace_vdelete( aTracerRECORD[0], aTracerRECORD[1] )
# erase [[[DONE]]] --------------------------------------------------------------
name.trace_vinfo() # final state of <<Tracer>>-s