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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:22:05+00:00 2026-05-29T07:22:05+00:00

I create a panel in wxpython, plus i have a database(MySQLdb), then i select

  • 0

I create a panel in wxpython, plus i have a database(MySQLdb), then i select some data from my database and i want to insert them in a wx.Combobox(dropdown), after that if the choice is A choice or B choice i want to insert some other data from database in a listbox.The code is below:

import MySQLdb
import sys
import wx

APP_SIZE_X = 661
APP_SIZE_Y = 319

class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, 
        size=(APP_SIZE_X, APP_SIZE_Y))

        panel = wx.Panel(self, -1,style=wx.SUNKEN_BORDER)

        sel="Make your choice"
        wx.StaticText(panel, -1,sel,(15,10))

            db=MySQLdb.connect(host="localhost",use_unicode="True",
                    charset="utf-8",
        user="youruser",passwd="somepwd",db="choicedb")

        cursor=db.cursor()
        sql="""SELECT name from choicetb"""

        cursor.execute(sql)

        rows = cursor.fetchall()

        for row in rows:

                  print row[1]



            sampleList = ["A choice", "B choice", "C choice"]#The data from db
            wx.ComboBox(panel, -1, "A choice", (15, 30), 
            wx.DefaultSize,sampleList, wx.CB_DROPDOWN)

        math="Selected items"
        wx.StaticText(panel, -1,math,(10,100))

        listBox = wx.ListBox(panel, -1, (10, 130), (230, 120),
        ' ', wx.LB_SINGLE)


        exitbutton =wx.Button(panel,-1, label="Quit", pos=(300, 230))
        exitbutton.Bind(wx.EVT_BUTTON, self.OnQuit)
        self.Centre()

    def OnQuit(self, e):

        self.Close()

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, 'form1.py')
        frame.Show(True)
        self.SetTopWindow(frame)
        return True

app = MyApp(0)
app.MainLoop()

How i insert what choice i take from row in combobox, i try something but it gives me the last choice of course. I know is something inside for loop but what? Thanks for your answers and for your help.

  • 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-29T07:22:06+00:00Added an answer on May 29, 2026 at 7:22 am

    Put the new data into a Python list and then use the ListBox’s / ComboBox’s AppendItems(your_list) method. That’s probably the easiest way. If you already have a list for the combobox, you could do something like this:

    self.myComboList = ["some", "list"]
    for row in rows:
       self.myComboList.Append(row[1])
    self.ComboList.sort()
    self.myComboBoxWidget.AppendItems(self.ComboList)
    

    Something like that should work.

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

Sidebar

Related Questions

I have been trying to create a menu panel with jQuery that can be
I want to create a new Menu in the admin panel of Wordpress for
I have created a custom control (based on a panel) in wxPython that provides
I'm used from windows forms, that I create a panel, place controls inside it
I need to create a panel where I can put some rectangles and it
I want to create settings panel for application. The application will store the settings
I am trying to create a panel that can dynamically insert components based on
I want to create a panel (or any other component) inside a component that
I have a panel Person and inside of this panel I create another panel
I want to create panel object (working as a kind of navigation bar) shared

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.