I have seen there are Tkinter widgets to create Combo and List boxes, but is there one that can create a similar object to the HTML Select/Option:

<select id="vehicleTypes">
<option value="1">Cars</option>
<option value="2">Trains</option>
<option value="3">Human RealLife space vehicles</option>
<option value="4">SuperStarDestroyers from yet another galaxy</option>

You see one thing (option innerHTML) but another value (option value) is returned. This doesn't seem possible in the documentation I have seen, you can pass a list/tuple/range only ("Cars", "Trains", "Human RealLife space vehicles", "SuperStarDestroyers from yet another galaxy").

The reason for this is that I have a (currently) JSON object/associative array with RPG spell data loaded as a javascript .js variable/JSON file:

spells = <br>
 {associative array of data},
 {associative array of data},
 {2009 entries later}

A sorted list of all entries (sorted by level then name: 'Level : Name' is the displayed format) goes into an Option object (option.innerHTML) with the value of each Option being the index (option.value) (then appendChild'd to a select) of the data so that you can reference data as spells[index][key] once an option is selected and the index returned.

As a way to learn Python, I am wanting to translate a working HTML project of mine. This looks to be my first/main hurdle at the moment (I solve problems in parts then bring it all....l together).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.