Problem with demos

Hello,

I'm trying to learn how the ListCtrl widget works, and the demos are not helping.

1) The ListCtrl.py demo is a 510-line program which has an unnecessary dependency on the "impages" module. I can't run it because I don't have the images module and I can't figure out how ListCtrl widgets work 510 lines long. This program is as much about images as it is about ListCtrl, and because I cannot separate one from the other, I can't learn ListCtrl.

2) The ListCtrl_edit.py demo is at least a more manageable 150 lines. I still can't run it because it wants to use the "run" module. Even this program seems to have a lot of needless complexity if the objective is to teach someone how to use the ListCtrl widget. I'd be nice to see a few source comments so I have a better chance of figuring out how ListCtrl is supposed to work.

Daniel.

Hello,

I'm trying to learn how the ListCtrl widget works, and the demos are not helping.

1) The ListCtrl.py demo is a 510-line program which has an unnecessary dependency on the "impages" module.

images.py is in your wxPython demo folder.

I can't run it because I don't have the images module and I can't figure out how ListCtrl widgets work 510 lines long. This program is as much about images as it is about ListCtrl, and because I cannot separate one from the other, I can't learn ListCtrl.

2) The ListCtrl_edit.py demo is at least a more manageable 150 lines. I still can't run it because it wants to use the "run" module.

"run" too is part of the demo infrastructure.

Even this program seems to have a lot of needless complexity if the objective is to teach someone how to use the ListCtrl widget. I'd be nice to see a few source comments so I have a better chance of figuring out how ListCtrl is supposed to work.

Maybe this page helps.

http://wiki.wxpython.org/Using%20wxPython%20Demo%20Code

An easy way to play with demo code is just to copy it to another folder (if making changes within the demo is going to far).

For listctrl.py I just copied:
run.py
images.py
listctrl.py

to myTestFolder and then run listctrl.py

Over a year ago I came across ObjectListView and I am slowly but surly throwing all listctrl stuff out and replace it with OLV, it is just so much easier to use. Especially if your data comes from a database, after setting things up you just "throw" the data at OLV, i.e. you don't have to loop through your rows of data to load item by item. The sorting is easier, you can do grouping, nicer look (also that is in the eye of ...) and probably some more I can't think of at the moment.

Werner

···

On 19/01/2010 11:08, Daniel Carrera wrote:

werner wrote:

images.py is in your wxPython demo folder.
...
"run" too is part of the demo infrastructure.

Thanks. It wasn't at all clear that these weren't standard Python modules that for some reason I didn't have.

I'd still advice making the demos simple. The goal is to teach people, right? We're not trying to dazzle the user with our programming skill. I think 510 lines is excessive. A 20-line example should be doable.

As it is, I have trouble with ListCtrl.py because of its length and its intertwining the image module with the ListCtrl module.

Anyways, I've just spent a while trying to figure out how to insert items and between the API reference and the example I've made some progress.

Over a year ago I came across ObjectListView and I am slowly but surly throwing all listctrl stuff out and replace it with OLV, it is just so much easier to use.

I haven't decided what to do myself. If I'm going to use wxPython I can use OLV, but if I have to do my work in C++ then I might as well tough it out and learn ListCtrl.

Especially if your data comes from a database, after setting things up you just "throw" the data at OLV, i.e. you don't have to loop through your rows of data to load item by item.

That does sound good. My data *does* come from a database.

The sorting is easier, you can do grouping, nicer look (also that is in the eye of ...) and probably some more I can't think of at the moment.

OLV is very tempting.

Daniel.

Daniel Carrera wrote:

werner wrote:

images.py is in your wxPython demo folder.
...
"run" too is part of the demo infrastructure.

Thanks. It wasn't at all clear that these weren't standard Python modules that for some reason I didn't have.

I'd still advice making the demos simple. The goal is to teach people, right? We're not trying to dazzle the user with our programming skill. I think 510 lines is excessive. A 20-line example should be doable.

I'd assume that run and images are Python modules inside the demo folder, for they are far too generally named to be a system-wide important (e.g. compared to numpy, wx, psyco)
There's only about 200 lines of *code*. The point of the demos is that they demonstrate most of the functionality offered by a class - if they didn't, then you'd be wondering questions like "how do I do x, how do I do y" and have stop reading the demo code and look elsewhere. With the code in the demo, it's all in one convenient place

As it is, I have trouble with ListCtrl.py because of its length and its intertwining the image module with the ListCtrl module.

Anyways, I've just spent a while trying to figure out how to insert items and between the API reference and the example I've made some progress.

Glad to hear. The images are needed here, because well, it's part of the demo (adding images to the list). If there was separation between each Control's functionality, then each control could have anywhere from 5-20 demos. The images module is re-used since many other demos demonstrate how to use images in a variety of ways.

OLV is very tempting.

I've yet to try it, but I'm interesting in taking a look, particularly since it simplifies dragging/dropping list items to re-arrange them.

···

--
Steven Sproat, BSc
http://www.basicrpg.com/

Steven Sproat wrote:

I'd assume that run and images are Python modules inside the demo folder, for they are far too generally named to be a system-wide important (e.g. compared to numpy, wx, psyco)

That's not what I assumed, and even in hindsight, I don't think it's a fair assumption. If you can "import math" why not "import images"? It seems reasonable enough that Python might come with an images module. Ditto for "run". Whatever it does, it sounds like something that could be part of Python itself.

EVEN IF I figure that "images" is a local module, you just added a 7,000 line module with a bunch of gibberish and decided to use it in a demo that's supposed to show me how lists work.

There's only about 200 lines of *code*. The point of the demos is that they demonstrate most of the functionality offered by a class

I think that ListCtrl is needlessly complex, EVEN IF we agree that we want to show a lot of the the features of the class.

Why do I need ListCtrlAutoWidthMixin? Why do I need a separate class for TestListCtrl and TestListCtrlPanel? What does all the code inside the platform-specific __WXMAC__ do? Why is it there?

The way the program is laid out, it is harder to figure out how to insert text than how to insert an image with your custom module. (And I'd question whether teaching me how to use your custom images module is valuable).

Look, it doesn't make sense to argue about whether the demo is easy or hard to understand. I have been studying wx for a week or two now and I couldn't figure it out. That should be evidence that it is hard. Maybe you are an expert and already know all this stuff, but if that's the case, you should listen to the newbie (who was a teacher for 8 years) who says that it's hard.

- if they didn't, then you'd be wondering questions like "how do I do x, how do I do y" and have stop reading the demo code and look elsewhere. With the code in the demo, it's all in one convenient place

Not very convenient as my experience shows. At least you could add some code comments, simplify the code, separate the features and put them in a logical order (basic features first). For example, a place to start would be:

1) FIRST create an empty list.
2) THEN add some text.
3) THEN add coloured text.
4) THEN add an image.

I should not have to parse through image-creating code before I even know how to insert text.

IF you are going to insert images, then just insert the image. Why do you need things like:

   self.idx1 = self.il.Add(images.Smiles.GetBitmap())
   self.sm_up = self.il.Add(images.SmallUpArrow.GetBitmap())
   self.sm_dn = self.il.Add(images.SmallDnArrow.GetBitmap())

   # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
   def GetSortImages(self):
      return (self.sm_dn, self.sm_up)

This is mostly gibberish to me and it doesn't teach me how to use ListCtrl.

Daniel.

Daniel,

Don’t work yourself into “frustration mode”,

Have a look at OLV

The SimpleExample1 from olv.examples, just 56 lines to look at.
This is the result:
It does sorting of any of the columns and and and and.
NOTE: I am not the author or in any way related to him - just love the
work he has done.
Werner

moz-screenshot.png

SimpleExample1.py (1.55 KB)

···

:wink:

Steven Sproat wrote:

I’d assume that run and images are Python modules inside the demo folder, for they are far too generally named to be a system-wide important (e.g. compared to numpy, wx, psyco)

That’s not what I assumed, and even in hindsight, I don’t think it’s a fair assumption. If you can “import math” why not “import images”? It seems reasonable enough that Python might come with an images module. Ditto for “run”. Whatever it does, it sounds like something that could be part of Python itself.

EVEN IF I figure that “images” is a local module, you just added a 7,000 line module with a bunch of gibberish and decided to use it in a demo that’s supposed to show me how lists work.

There’s only about 200 lines of code. The point of the demos is that they demonstrate most of the functionality offered by a class

I think that ListCtrl is needlessly complex, EVEN IF we agree that we want to show a lot of the the features of the class.

Why do I need ListCtrlAutoWidthMixin? Why do I need a separate class for TestListCtrl and TestListCtrlPanel? What does all the code inside the platform-specific WXMAC do? Why is it there?

You don’t “need” ANY of the mixins. They are for convenience so you don’t have to roll-your-own sorting or in this case, a way to make the column widths automagically size themselves to the widest text in the column.

I don’t have a Mac, but it looks like that code is loading a native version of either the list control via a checkbox event.

The way the program is laid out, it is harder to figure out how to insert text than how to insert an image with your custom module. (And I’d question whether teaching me how to use your custom images module is valuable).

Look, it doesn’t make sense to argue about whether the demo is easy or hard to understand. I have been studying wx for a week or two now and I couldn’t figure it out. That should be evidence that it is hard. Maybe you are an expert and already know all this stuff, but if that’s the case, you should listen to the newbie (who was a teacher for 8 years) who says that it’s hard.

  • if they didn’t, then you’d be wondering questions like “how do I do x, how do I do y” and have stop reading the demo code and look elsewhere. With the code in the demo, it’s all in one convenient place

Not very convenient as my experience shows. At least you could add some code comments, simplify the code, separate the features and put them in a logical order (basic features first). For example, a place to start would be:

  1. FIRST create an empty list.

  2. THEN add some text.

  3. THEN add coloured text.

  4. THEN add an image.

I should not have to parse through image-creating code before I even know how to insert text.

IF you are going to insert images, then just insert the image. Why do you need things like:

self.idx1 = self.il.Add(images.Smiles.GetBitmap())

self.sm_up = self.il.Add(images.SmallUpArrow.GetBitmap())

self.sm_dn = self.il.Add(images.SmallDnArrow.GetBitmap())

Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py

def GetSortImages(self):

 return (self.sm_dn, self.sm_up)

This is mostly gibberish to me and it doesn’t teach me how to use ListCtrl.

Daniel.

I’ve attached a simple 39 line List control demo for you to look at.

listctrl-ex.py (1.33 KB)

···

On Tue, Jan 19, 2010 at 7:51 AM, Daniel Carrera dcarrera@gmail.com wrote:


Mike Driscoll

Blog: http://blog.pythonlibrary.org

Daniel Carrera wrote:

Steven Sproat wrote:

I'd assume that run and images are Python modules inside the demo folder, for they are far too generally named to be a system-wide important (e.g. compared to numpy, wx, psyco)

That's not what I assumed, and even in hindsight, I don't think it's a fair assumption. If you can "import math" why not "import images"? It seems reasonable enough that Python might come with an images module. Ditto for "run". Whatever it does, it sounds like something that could be part of Python itself.

EVEN IF I figure that "images" is a local module, you just added a 7,000 line module with a bunch of gibberish and decided to use it in a demo that's supposed to show me how lists work.

There's only about 200 lines of *code*. The point of the demos is that they demonstrate most of the functionality offered by a class

I think that ListCtrl is needlessly complex, EVEN IF we agree that we want to show a lot of the the features of the class.

Why do I need ListCtrlAutoWidthMixin? Why do I need a separate class for TestListCtrl and TestListCtrlPanel? What does all the code inside the platform-specific __WXMAC__ do? Why is it there?

The way the program is laid out, it is harder to figure out how to insert text than how to insert an image with your custom module. (And I'd question whether teaching me how to use your custom images module is valuable).

Look, it doesn't make sense to argue about whether the demo is easy or hard to understand. I have been studying wx for a week or two now and I couldn't figure it out. That should be evidence that it is hard. Maybe you are an expert and already know all this stuff, but if that's the case, you should listen to the newbie (who was a teacher for 8 years) who says that it's hard.

- if they didn't, then you'd be wondering questions like "how do I do x, how do I do y" and have stop reading the demo code and look elsewhere. With the code in the demo, it's all in one convenient place

Not very convenient as my experience shows. At least you could add some code comments, simplify the code, separate the features and put them in a logical order (basic features first). For example, a place to start would be:

1) FIRST create an empty list.
2) THEN add some text.
3) THEN add coloured text.
4) THEN add an image.

I should not have to parse through image-creating code before I even know how to insert text.

IF you are going to insert images, then just insert the image. Why do you need things like:

  self.idx1 = self.il.Add(images.Smiles.GetBitmap())
  self.sm_up = self.il.Add(images.SmallUpArrow.GetBitmap())
  self.sm_dn = self.il.Add(images.SmallDnArrow.GetBitmap())

  # Used by the ColumnSorterMixin, see wx/lib/mixins/listctrl.py
  def GetSortImages(self):
     return (self.sm_dn, self.sm_up)

This is mostly gibberish to me and it doesn't teach me how to use ListCtrl.

Daniel.

Following your e-mails about struggling with wxPython for the last 2 weeks, it seems me that a lot of it comes from installation problems (you seem to always be missing some module) and ... as already said ... not having the book that, by the way, has a full chapter on "Building list controls and managing items". The book is not "crap" as you could fear, I think everybody agrees it's rather excellent.

Now, about OLV, I just can confirm all the good things that have been said about it. Plus, the documentation is very good, at least after my standards. See ObjectListView — ObjectListView v1.2 documentation. Just remember that this is a 3rd party piece of code with all the pros and cons that it means.

Good luck.

Raphael

Raphael Mayoraz wrote:

Following your e-mails about struggling with wxPython for the last 2 weeks, it seems me that a lot of it comes from installation problems (you seem to always be missing some module) and ... as already said ... not having the book that, by the way, has a full chapter on "Building list controls and managing items". The book is not "crap" as you could fear, I think everybody agrees it's rather excellent.

Are you confident that if I had the book I wouldn't have had trouble making a package with PyInstaller? That doesn't seem likely. I cannot think of any installation problems I've had at least in the last week.

I have already replied to the "buy the book" comment. My thoughts on the issue have not changed.

Lately I've been making progress with the C++ API. I think I might end up using that. I have been able to make a static binary that runs on my wife's computer. That's encouraging.

Now, about OLV, I just can confirm all the good things that have been said about it. Plus, the documentation is very good, at least after my standards. See ObjectListView — ObjectListView v1.2 documentation. Just remember that this is a 3rd party piece of code with all the pros and cons that it means.

If I go for wxPython I think I'll use OLV.

Daniel.