开发者

Accessing methods of nested widgets

Im working on optimizing my design in terms of mvc, intent on simplifying the api of the view which is quite nested even though Iv built composite widgets(with there own events and/ pubsub messages) in an attempt to simpify things.

For example I have a main top level gui class 开发者_高级运维a wxFrame which has a number of widgets including a notebook, the notebook contains a number of tabs some of which are notebooks that contain composite widgets. So to call the methods of one of these composite widgets from the controller I would have

 self.gui.nb.sub_nb.composite_widget.method()

To create a suitable abstraction for the view I have created references to these widgets (whose methods need to be called in the controller) in the view like so

 self.composite_widget = self.nb.sub_nb.composite_widget()

so that in the controller the call is now simplified to

 self.gui.composite_widget.method()

Is this an acceptable way to create an abstraction layer for the gui?


Well that's definitely one way to handle the issue. I tend to use pubsub to call methods the old fashioned way though. Some people like pyDispatcher better than pubsub. The main problem with using multi-dot method calling is that it's hard to debug if you have to change a method name.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜