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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:15:15+00:00 2026-05-23T14:15:15+00:00

teaching myself Python and wxPython. Not sure what I am doing wrong here, could

  • 0

teaching myself Python and wxPython. Not sure what I am doing wrong here, could use some insight from folks much smarter than myself…

import wx
from wxPython.wx import *

class myGUI(wx.Frame):

    def __init__(self, parent, title):    
        super(myGUI, self).__init__(parent, title=title,
            size=(450, 350))
        panel = wx.Panel(self)
        sizer = wx.GridBagSizer(5, 5)

    # Main Database Text, Entry and Browse Button ------------------------------
        label_MainDatabase = wx.StaticText(panel, label="Main Database:")
        sizer.Add(label_MainDatabase, pos=(0, 0), flag=wx.LEFT|
            wx.ALIGN_CENTER_VERTICAL, border=20)

        tc_MainDatabase = wx.TextCtrl(panel)
        sizer.Add(tc_MainDatabase, pos=(0, 1), span=(1, 3), flag=wx.TOP|
            wx.EXPAND|wx.ALIGN_CENTER_VERTICAL)
        tc_MainDatabase.Value = "DBG: I am properly initialized."

        bt_MainDatabase = wx.Button(panel, label="Browse...")
        sizer.Add(bt_MainDatabase, pos=(0, 4), flag=wx.LEFT|wx.RIGHT|
        wx.ALIGN_CENTER_VERTICAL, border=0)
        bt_MainDatabase.Bind(wx.EVT_BUTTON, self.bt_MainDatabaseClick,
            bt_MainDatabase)
    # --------------------------------------------------------------------------
        sizer.AddGrowableCol(2)
        panel.SetSizer(sizer)

        self.Centre()
        self.Show()

    def bt_MainDatabaseClick(self, event):
        # Create a list of filters
        self.tc_MainDatabase.SetValue = "A"


if __name__ == '__main__':
    app = wx.App()
    myGUI(None, title="myGUI")

    app.MainLoop()

I get the following error when I click the “Browse” button:
AttributeError: ‘myGUI’ object has no attribute ‘tc_MainDatabase’

What am I doing wrong? I am trying to capture information from the Browse button and then update a text control field (tc_MainDatabase). I’ve tried rearranging the order of the def statements, etc.

And yes, I always jump in with both feet. It’s the only way I know how to learn… 🙂

Thanks.

-Chow

  • 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-23T14:15:16+00:00Added an answer on May 23, 2026 at 2:15 pm

    Maybe it’s because you’re saying:

    tc_MainDatabase = wx.TextCtrl(panel)
    

    instead of:

    self.tc_MainDatabase = wx.TextCtrl(panel)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm teaching myself Python and my most recent lesson was that Python is not
I'm teaching myself Python and I was translating some sample code into this class
I'm a Python(3.1.2)/emacs(23.2) newbie teaching myself tkinter using the pythonware tutorial found here .
I am teaching myself some Python and I have come across a problem which
I'm teaching myself Python. I saw a java permutation generator from a string, and
I am teaching myself python from this site . On Chapter 3 , when
I am self teaching myself some python OOP, and I have created a simple
So I'm teaching myself Python, and I'm having an issue with lists. I want
I was recently teaching myself Python and discovered the LBYL/EAFP idioms with regards to
I am teaching myself python. I was thinking of small programs, and came up

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.