Hi people,

I'd like to add/create labels dynamically at runtime.
Just imgaine the folowing:

I have recieved a value let's call it ' length' it has a a value already that was was calculated before. Now I want to create/add labels the amount of length.
That is my code..unfortunately it does not work:

#... final is a string initialized already
         for k in range(length):

so let's cosider length=5...so at the end there should be label0 - 4

but there is an error: 'lbl_addy' is not defined

any suggestions anyone?

thanks in advance


Recommended Answers

All 2 Replies

Well, there's two problems. First, you have to define the list lbl_addy before you start assigning to it.

Second, the name of your newly created Label in line 6 is lbl_addy[k]. So in line 7, you need to pack it like this:


Hope that helps,

thanks I fixed it now!

kindest regards

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.