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

  • Home
  • SEARCH
  • 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 9163323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:25:11+00:00 2026-06-17T14:25:11+00:00

I used the code below to create several spinners with a for loop. Now,

  • 0

I used the code below to create several spinners with a for loop.

Now, I can’t figure out how to bind an event so that I know which spinner is being modified so that I can put the spinner value into the right variable.

If I can figure out which spinner is calling the handler I could map it to the correct variable.

Any thoughts? Is this even possible?

Thanks in advance!


    import wx

class spinnerFrame(wx.Frame):
    def __init__(self, parent, id):
        wx.Frame.__init__(self, parent,id, "Spinner Frame", size = (300,200))

        #constants
        spnr_sz = (50,-1)
        names = ('name1','name2','name3','name4','name5','name6')


        sizer = wx.GridBagSizer(5, 5)
        # TEXT FONT EXAMPLE
        # m_text = wx.StaticText(panel, -1, "Hello World!")
        # m_text.SetFont(wx.Font(14, wx.SWISS, wx.NORMAL, wx.BOLD))
        # m_text.SetSize(m_text.GetBestSize())

        #temp
        sizer = wx.GridBagSizer(5, 5)
        row = 0
        for n in names:
            row += 1
            my_label = wx.StaticText(self, -1, n)
            spinner = wx.SpinCtrl(self, -1, size = spnr_sz, min = 0, initial = 10 )
            self.Bind(wx.EVT_SPINCTRL, self.OnCompute, spinner)
            sizer.Add(my_label, (row,0))
            sizer.Add(spinner, (row,1))

        sizer.AddGrowableRow(7)
        sizer.AddGrowableCol(4)

        self.SetSizerAndFit(sizer)
        self.Centre()

    def OnCompute(self,event):
        # a = spinner.GetValue()
        # ????

if __name__=='__main__':
    app = wx.App(True) # was False
    frame = wx.Frame(None)
    frame = spinnerFrame (parent=None, id = -1)
    frame.Show()
    app.MainLoop()
  • 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-17T14:25:12+00:00Added an answer on June 17, 2026 at 2:25 pm

    Yes, this is possible. The easiest way I know is to associate your unique name with each call to Bind, either by giving the spinner a name or using partial functions (or lambdas, but lambdas can end up being messy), and then check for the name in the handler. Examples of how to use the name are given in this previous SO question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have used the code below to create a button on the nav bar
I have used the code below to create a row of image holders which
I used the code below to dynamically create a group of radio buttons: self.wPaymantType.qgbSomeSelectionGroup
Code below is used to create post data from jqGrid colmondel and post it.
I used the code below to create a graphic using dot (graphviz). digraph {
I have used the code below to read rfid tag values. try { if
I want to load wordpress in a smarty template. I used the code below
I have used below code to attach quckboook events // Subscribe to UI events...
Code below is used to save PostgreSql database backup from browser in Apache Mono
I had used the below code to get the row index of the UIPickerView

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.