Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8080327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:22:49+00:00 2026-06-05T16:22:49+00:00

Say I have a dictionary full of parameters: {speed = 1, intelligence = 3,

  • 0

Say I have a dictionary full of parameters:

{speed = 1, intelligence = 3, dexterity = 2}

I want to call a loop that creates a Label and a SpinBox for each item in this list procedurally, in case I want to add more attributes later. I can create the window and return the updated values just fine. My only issue is that I want all the widgets to be created as necessary, whether I have 7 or 20 attributes to edit.

So the label object could be called speed_Label and the intelligence label object intelligence_Label, and the spinbox containing the value of speed would be speed_SpinBox and so on, which then I could pass back easily. However, this

a) seems like poor naming practice

b) seems difficult seeing as I can’t find out how to give objects names procedurally, say

for KEY in dict.keys(): # say the KEY is "Speed"
    # this would produce a Label object called Speed_Label
    # which displays the text "Speed"
    "KEY" + "_Label" = QLabel("KEY")
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T16:22:50+00:00Added an answer on June 5, 2026 at 4:22 pm

    Why not simply use a list or dict?

    Something like this should work:

    widgets = {}
    form = QFormLayout()
    for key, value in your_dict.iteritems():
        widgets[key] = widget = {}
        widget['spinbox'] = spinbox = QSpinBox()
        spinbox.setValue(value)
        form.addRow(key, spinbox)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a dictionary full of objects for keys that may or
Say that i have a generic dictionary with data like this (I hope the
If I have, say, 100 items that'll be stored in a dictionary, should I
Let's say I have a dictionary of names (a huge CSV file). I want
Let's say that I have a dictionary of controls and strings. If I run
Say I have a very large dictionary / associative array and I want to
Let's say I have a list: a = ['apple', 'carrot'] and a dictionary: d
say i have a nvarchar field in my database that looks like this 1,
Say I have real, dimension(0:100) :: realResults and I want to iterate over realResults
I have a Dictionary<int, string> cached (for 20 minutes) that has ~120 ID/Name pairs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.