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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:14:54+00:00 2026-05-30T00:14:54+00:00

I’ve a little doubt for writing a Python application follow the MVC rules on

  • 0

I’ve a little doubt for writing a Python application follow the MVC rules on wxPython.

Example:

MainForm

PanelLst (ListCtrl + Some buttons)

PanelTree (TreeCtrl + ProgressBar)

I created 3 views (ListView, TreeView, ButtonView)
I created also 3 controllers (ListController, TreeController, ButtonControllor)
In the main app, I have an object (objManager) that manage some models.

All 3 controllers have a pointer to the App.objManager() for executing some stuff.

Eg: click on a row in ListController execute App.objManager().foo1

click on a button in ButtonController execute App.objManager().bar1, ecc…

Here the question…I’m in doubt about those “my” structure…

  1. is correct pass a pointer to objManager in each controller that use that?
  2. how View/Controllers can communicate between others, in correct way?
    Actually I use a similar way like model. Using wxPython publisher.sendMessage(EVENT, data) and publisher.subscribe(EVENT, onEvent) but I think isn’t the best way..

Next doubt:

TreeController, receive a message from a model. Must load a big list in the tree, showing progress.
I already user a thread with some wx.PostEvent, but what solution is better?

Solution 1:

ProgressBar()

# Callback via publisher.subscrive(self.onUpdateStatus, "UPDATE_STATUS")
def onUpdateStatus(self, msg)
    nValue = msg.data
    self.gauge.setValue(nValue)

TreeView()

def loadTree(self, items):
    for nItem, item in enumerate(items):
        tree.addItem(item)
        pub.sendMessage(UPDATE_STATUS, item)

TreeCTRL()

 # Callback function via publisher.subscribe(self.onLoadTree, "LOAD_TREE")
 def onLoadTree():
     items = self.objManager.getList()
     self.hTreeView.loadTree(items)

Solution 2

ProgressBar()

# Callback via publisher.subscrive(self.onUpdateStatus, "UPDATE_STATUS")
def onUpdateStatus(self, msg)
    nValue = msg.data
    self.gauge.setValue(nValue)

TreeView()

def loadTree(self, item):
    self.addTreeItem(item)

TreeCTRL()

 # Callback function via publisher.subscribe(self.onLoadTree, "LOAD_TREE")
 def onLoadTree():
     items = self.objManager.getList()
     for nItem, item in enumerate(items):
         self.hTreeView.loadTree(item)
         pub.sendMessage(UPDATE_STATUS, item)

What solution is better? In first solution, is the VIEW that send a message for updating the GUI. In second solution is the CONTROLLER that send a message..
Not sure that those 2 solution is anyway the best-practice for communicating between controller/view..

Thanks and sorry for my bad English…

  • 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-30T00:14:56+00:00Added an answer on May 30, 2026 at 12:14 am

    I think using pubsub is a perfectly legitimate way to communicate between the model and the controllers. A couple months ago, I worked with another wxPython developer to create an example application that demonstrates one way to do this. You can see our code here: https://bitbucket.org/driscollis/medialocker

    I hope that helps you organize your code. Of course, code design is a very personal and subjective topic. You need to use what you’re comfortable with and understand best.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I am writing an app with both english and french support. The app requests
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.