Posts: 22
Threads: 6
Joined: Nov 2018
I'm new to the concept of enforcing some kind of design pattern in the application (using wxPython) I'm trying to write according to MVP (model-view-presenter) principles. I'm having some difficulty identifying who should do what.
In the case of my dialog box, I think I've identified and isolated the code needed to setup the view (create and style controls, create and populate sizers, display buttons, etc.). I have a wx.ComboBox that is used to select which widget is displayed in the dialog for data entry. With the idea in mind that I want to keep logic out of the view, I send a command to the presenter with the value selected in the combo box. The presenter then makes a decision, and sends a widget back that should be displayed to match the combo box selection.
Should the presenter handle the code associated with switching the displayed widget and repopulating the sizer? Or is that "dumb enough" for the view to handle?
Posts: 12,038
Threads: 487
Joined: Sep 2016
you must be running the old wxpython.
I highly recommend the vastly improved phoenix version (needs python 3.6 or newer)
with it comes a most remarkable demo program which covers just about every widget (preview some of the available widgets here: https://wxpython.org/Phoenix/docs/html/gallery.html) each has example code, a working demo and full documentation arranged on a tabbed notebook window.
I have windows tutorial here: https://python-forum.io/Thread-wxPython-...ep-by-step
Posts: 22
Threads: 6
Joined: Nov 2018
(Nov-08-2018, 02:08 AM)Larz60+ Wrote: you must be running the old wxpython.
What about my post suggests I'm running old wxpython? I thought I was on the Phoenix code base, but I'll check tomorrow (I'm python 3.7)
Posts: 12,038
Threads: 487
Joined: Sep 2016
Quote: I thought I was on the Phoenix code base, but I'll check tomorrow (I'm python 3.7)
you may be, if you installed with pip using:
pip install wxpython you probably do.
if so, you can run the demo to get some ideas. I have instructions for demo here: https://python-forum.io/Thread-Generate-...0#pid56190
Posts: 8,167
Threads: 160
Joined: Sep 2016
Nov-08-2018, 10:21 AM
(This post was last modified: Nov-08-2018, 10:22 AM by buran.)
wxPython Phoenix is available on PyPI
https://pypi.org/project/wxPython/
So using
pip install wxPython should work on Windows and MacOS
for some linux distroes, there are wheels as extra files - https://extras.wxpython.org/wxPython4/extras/linux/
For detailed information
https://wxpython.org/pages/downloads/
Posts: 22
Threads: 6
Joined: Nov 2018
(Nov-08-2018, 03:56 AM)Larz60+ Wrote: Quote: I thought I was on the Phoenix code base, but I'll check tomorrow (I'm python 3.7)
you may be, if you installed with pip using:
pip install wxpython you probably do.
if so, you can run the demo to get some ideas. I have instructions for demo here: https://python-forum.io/Thread-Generate-...0#pid56190
Yes, I installed wxpython through pip, and I do recall seeing 4.0.3 as the installed version.
Perhaps this is ignorance on my part, but how do the wxPython demos fit into the MVP part of my question? I know HOW to manipulate the things I mentioned, but I'm not sure where in my code (view or presenter) it makes the most sense. This is sort of an opinion type question, but I'm looking for multiple opinions upon which to base my own development practices.
Posts: 12,038
Threads: 487
Joined: Sep 2016
Quote:how do the wxPython demos fit into the MVP part of my question
It doesn't, my confusion with Advanced User Interface (AUI) ( https://wxpython.org/Phoenix/docs/html/w...index.html ). Sorry,
you may still be interested in the demo. One of the best.
Posts: 22
Threads: 6
Joined: Nov 2018
(Nov-08-2018, 03:18 PM)Larz60+ Wrote: It doesn't, my confusion with Advanced User Interface (AUI) ( https://wxpython.org/Phoenix/docs/html/w...index.html ). Sorry,
you may still be interested in the demo. One of the best.
Lol, okay I'm not crazy :D Yes, I have run the demo numerous times to look for particular functions, they did a great service to the community with that.
Posts: 22
Threads: 6
Joined: Nov 2018
Maybe I can narrow down my question to make it a little more general.
After studying a few concrete examples, I think I noticed a pattern to the patterns. Rather than one object (model, view, or presenter) directly manipulating the attributes of another object, it seems that the right thing to do is to communicate through commands between objects. This abstracts the specific functionality of the object to a higher level protocol which is not dependent on the specific implementation of the attributes of the object.
Does this make sense?
Posts: 12,038
Threads: 487
Joined: Sep 2016
I've worked 'under the covers' all my programming life (since 1968), always avoiding the middle man, so probably not one to contribute here. Hope I haven't messed up your thread too much!. Best wishes.
|