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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:06:24+00:00 2026-05-16T15:06:24+00:00

I got a GUI application implemented in wxpython, on the main window, there is

  • 0

I got a GUI application implemented in wxpython, on the main window, there is a listctrl used to dispaly the names of the files. it was empty at the very beginning. the user clicks the “File”, then “open”, then chooses a file to open, when this is done by clicking on the “ok” button, the names of the file is supposed to be display in the listctrl. But it seems that this does not work. I used a print clause to check, the print clause works. Here are my codes:

def OnDisplay(self):
    print "On display called"
    self.lc1.InsertStringItem(0, "level 1")
    self.lc1.InsertStringItem(1, "level 2")
    self.lc1.SetBackgroundColour(wx.RED)

    print self.lc1.GetItemText(0)
    print self.lc1.GetItemText(1)

    self.lc1.Refresh()

lc1 is the listctrl, it was initialized at the very beginning when the main window was lauched, but when the OnDisplay was triggered, the print "On display called" works, and the following two print clauses also work. but the listctrl on the main window did not change, i mean, did not show the level 1 and level 2, nor did the background of the listctrl was changed to red, what is the reason please? many thanks!

  • 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-16T15:06:25+00:00Added an answer on May 16, 2026 at 3:06 pm

    Here is a runnable example that works on Windows 7, Python 2.6, wx 2.8.

    import wx
    
    class ListTest(wx.Frame):
        def __init__(self, parent, title):
            wx.Frame.__init__(self, parent, -1, title, size=(380, 230))
    
            panel = wx.Panel(self, -1)
    
            self.list = wx.ListCtrl(panel, -1, style=wx.LC_REPORT) 
            self.list.InsertColumn(0, 'col 1', width=140)
    
            hbox = wx.BoxSizer(wx.HORIZONTAL)
            hbox.Add(self.list, 1, wx.EXPAND)
            panel.SetSizer(hbox)
            self.Centre()
            self.Show(True)
    
            self.Bind(wx.EVT_CHAR_HOOK, self.onKey)
    
        def onKey(self, evt):
            if evt.GetKeyCode() == wx.WXK_DOWN:
                self.list.InsertStringItem(0, "level 1")
                self.list.InsertStringItem(1, "level 2")
                self.list.SetBackgroundColour(wx.RED)
                self.list.Refresh()
    
                print self.list.GetItemText(0)
                print self.list.GetItemText(1)
            else:
                evt.Skip()
    
    
    app = wx.App()
    ListTest(None, 'list test')
    app.MainLoop()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a bit of an issue here where I want to modify GUI
I'm creating a piece of software (written in C#, will be a windows application)
Well, we all know test-driven development. I'd need to write a GUI-based library, but
Quick summary No items show up in my Grid in the GUI of my
In my application, I have the following class hierarchy: class Word { ... }
I'm currently writing an application that will control positioning of a measurement device. Because
I have Swing Java application manifesting an error on linux, which I need to
After messing around a little with making a GUI with the Windows API, I
I've looked all over the web for about a week now and not found
I am trying to get the 64-bit version of python up and running with

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.