I have Python functions that is used to set labels based on input parameters. There is a parameter called reset
which resets all labels. How can I get rid of redundant if not reset
? There should be a smarter approach...
def set_labels_text(fn, ft, t=None, a=None, i=None, reset=False):
tt = ''
at = ''
it = ''
if ft == 1
if not reset:
tt = 'bla bla 1 %s' % t
at = 'bla bla 2 %s' % a
get_component('template' + ft).get_component(fn + 'Label1').text = tt
get_component('template' + ft).get_component(fn + 'Label2').text = at
else:
if not reset:
it = 'bla bla 3 %s' % i
get_component('template' + ft).get_component(fn + 'Label3').text = it
Aucun commentaire:
Enregistrer un commentaire