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 543959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:36:16+00:00 2026-05-13T10:36:16+00:00

I am trying to get either the strings checked or the integers from a

  • 0

I am trying to get either the strings checked or the integers from a check list. I cannot seem to get it anywhere. In the code below, you’ll see a bunch of un-commented code, those are just different ways I’ve tried. I thought I would leave them in case any one’s suggestions have to do with it. I am very new to GUI-programming and wx. Thanks for your help.

import  wx


class Panel1(wx.Panel):
def __init__(self, parent, log):
    wx.Panel.__init__(self, parent, -1)

    allLoc = ['One', 'Two', 'Three', 'Four']

    wx.StaticText(self, -1, "Choose:", (45, 15))

    citList = wx.CheckListBox(self, -1, (60, 50), wx.DefaultSize, allLoc)

    #self.Bind(wx.EVT_CHECKLISTBOX, self.GetChecks, citList)

    #h = citList.GetChecked()

    #cities = ()

    #v = cities.append(h)
    #print h
    pos = citList.GetPosition().x + citList.GetSize().width + 25
    nextBtn = wx.Button(self, -1, "Next", (pos, 50))
    self.Bind(wx.EVT_BUTTON, wx.EvyRadBox2, nextBtn)

#def GetChecks(self, event):
    #r = citList.GetId()
    #print r

#def printChecks(self, event):
    #l = event.CetCheckStrings()
    #print l

def EvyRadBox2(self, event):
    filepath2 = "c:\\logger2.txt"
    file1 = open(filepath2, 'w')
    file1.write('%d \n' % event.GetChecked())
    file1.close()





app = wx.PySimpleApp()
frame = wx.Frame(None, -1, "Charlie")
Panel1(frame,-1)
frame.Show(1)
app.MainLoop()

**************************EDIT********************************

So I changed my code to look like this

import wx

checkedItems = []


class citPanel(wx.Panel):
def __init__(self, parent, id):
    wx.Panel.__init__(self, parent, id)
    allLoc = ['One', 'Two', 'Three', 'Four']

    wx.StaticText(self, -1, "Choose:", (45, 15))

    citList = wx.CheckListBox(self, -1, (60, 50), wx.DefaultSize, allLoc)

    checkedItems = [i for i in range(citList.GetCount()) if citList.IsChecked(i)]


class nextButton(wx.Button):
def __init__(self, parent, id, label, pos):
    wx.Button.__init__(self, parent, id, label, pos)




class checkList(wx.Frame):
def __init__(self, parent, id, title):
    wx.Frame.__init__(self, parent, id, title, size=(400, 400))

    panel = citPanel(self, -1)

    nextButton(panel, -1, 'Ok', (275, 50))

    self.Bind(wx.EVT_BUTTON, self.Clicked)

    self.Centre()
    self.Show(True)

def Clicked(self, event):
    print checkedItems
    event.Skip()


app = wx.App()
checkList(None, -1, 'Charlie')
app.MainLoop()

When I did this at first, when I clicked the button, It threw a global name not defined into wxstdout. I add the checkedlist at the top, and it at first showed none, now it shows an empty list., Any help, as always, thanks in advance

  • 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-05-13T10:36:16+00:00Added an answer on May 13, 2026 at 10:36 am
    checkedItems = [i for i in range(citList.GetCount()) if citList.IsChecked(i)]
    

    citList.GetChecked() should have also completed the task for you. May the problem be that you are trying to get selected items in __init__?

    Upd.: You do not want to get checked items during __init__ – they cannot be checked by the user at that moment. You’d better check them in any event handler, e.g. wx.EVT_BUTTON.

    Try writing self more often, e.g.:

    self.citList = wx.CheckListBox(self, -1, (60, 50), wx.DefaultSize, allLoc)
    # some code
    self.panel = citPanel(self, -1)
    

    and change Clicked to:

    def Clicked(self, event):
        checkedItems = [i for i in range(self.panel.citList.GetCount()) if self.panel.citList.IsChecked(i)]
        print checkedItems
        event.Skip()
    

    Hope this helps.

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

Sidebar

Related Questions

i am trying to get a value from a key stored on a string
I'm trying to add tags to some given query strings, and the tags should
So I have two possible strings here for example. /user/name and /user/name?redirect=1 I'm trying
I'm trying to use PHP to process JSON and am having trouble parsing it
I'm trying to run Fortify on a Visual Studio 2008 project. The project builds
I trying to parse a string in an XML node by using an XPath
I'm fighting the spaces bug in Java's Runtime exec method. Here's what's unique about
I have a working android app using TextView, some formatting (line breaks, rows of
I know that using Regular expressions to parse or manipulate HTML/XML is a bad
I have trouble gripping to monads and monad transformers. I have the following contrived

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.