Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I'm writing a program in wxpython, and to make GUI parts that are built in different modules I made a module called runtime, where all the GUI parts get stored on runtime. This is how it looks:

mainFrame = anotherGUIPart = InputDialog = SomethingElse = None

For example, when I need to make a ListControl to update itself, I use

#anotherGUIPart.py
class AnotherGUIPart(wx.Panel):
    def __init__(self, *args, **kwargs):
        wx.Panel.__init__(self, *args, **kwargs)
        self.listCtrl = wx.ListCtrl(self,
                 style=wx.LC_REPORT | wx.LC_SINGLE_SEL)
        ...
    def UpdateList(self):
        self.listCtrl.DeleteAllItems()
        ...

#Somewhere where I need to update the list
import runtime
runtime.anotherGUIPart.UpdateList()

Is this a good practice?
If not, what are alternatives?

share|improve this question

1 Answer

up vote 1 down vote accepted

This is fine, as long as you're not bleeding too much across the module boundaries. Ideally you would have a structure somewhat akin to MVC, where you have all of your UI logic in one module, all your business logic in another, and a controller module which links the two together. However, if you find that this improves your ability to understand the code then that's just fine. If you post a link to more of your code it'll be easier to review the design as this is quite macro-scale.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.