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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:16:09+00:00 2026-06-03T02:16:09+00:00

I have a small program that batch handles files. These files use a map

  • 0

I have a small program that batch handles files. These files use a map file to load certain settings. The map file has a line at the top that specifies for what directory it is for.

Currently I am able to read the line and assign it to the source path variable (sPath). I want to update the TextCtrl for the Source Directory, however it is in the MainFrame class and I load the map file in a different class.

class Process(wx.Panel):

    def loadMap(self, event):
    MainFrame.sPath = str(mapFile.readline()).strip("\n")
    MainFrame.loadSource(MainFrame())

class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, title="DICOM Toolkit", size=(800,705))
        self.srcTc = wx.TextCtrl(self.panel, 131, '', size=(600,25), style=wx.TE_READONLY)

    def loadSource(self):
        self.srcTc.SetValue(MainFrame.sPath)

I eliminated most of the code and what’s above is where it is giving me trouble. How do I change self.srcTc in the MainFrame class from either the Process class or a function in the MainFrame class? I am having trouble actually pointing to self.srcTc without a handler that stems from the MainFrame class.

  • 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-03T02:16:11+00:00Added an answer on June 3, 2026 at 2:16 am

    I think what you want has to look like something like that (without a working example):

    class Process(wx.Panel):
        def loadMap(self, event):
            frame = MainFrame()
            frame.sPath = str(mapFile.readline()).strip("\n")
            frame.loadSource()
    

    when using MainFrame.sPath = ... you’re not actually changing sPath to a MainFrame you created, but to the class itself, then you create it, in MainFrame() without storing a reference to it (assign it to a variable for example). So, you can’t access it from somewhere other than “inside” the class itself as self.

    The solution is to create an instance of a MainFrame and operate on it. Once you create it and assign it to a variable, you can manipulate the .sPath attribute and call loadSource().

    UPDATE: From you code snippet, it seems you create the MainFrame instance in the end of the file: MainFrame().Show(), and then in the loadMap method, you create a new one.

    What you should do is this, in the end of your file:

    app = wx.App(0)
    #MainFrame().Show()
    mainFrame = MainFrame() # or, insteadof making it a global variable, pass it as an argument to the objects you create, or store a reference to it anywhere else.
    mainFrame.Show()
    app.MainLoop()
    

    and in the loadMap method:

    def loadMap(self, event):
        global mainFrame # or wherever you stored the reference to it
        # ...
        # remove this:
        # mainFrame = MainFrame()
        # set the sPath to the OBJECT mainFrame not the CLASS MainFrame
        mainFrame.sPath = str(mapFile.readline()).strip("\n")
        mainFrame.srcTc.SetValue(MainFrame.sPath)
    

    Now this way, it should work.
    The problem was that you are creating another frame, changing its path and updating its text, but you are not showing it. The correction is to store the actual window that is being shown, and update this one.

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

Sidebar

Related Questions

I have a small program that has several checkedboxlists in VS2010. I wanted to
I have a small program that reads in a file and processes the data
I have a small java program that reads a file in, in eclipse i
I'm experimenting with file I/O. I have a small practice program that creates a
I have a program that creates a small file in the Bin directory for
Background I have a Spring batch program that reads a file (example file I
i have a small program that uses 32bit object file, and i wish to
I have a small java program that searches the contents of all *.txt files
I have a small test program that creates millions of files (for testing purposes)
I have a small C++ program that parses a file given as a command

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.