There's an important tool that I've got in Python that you don't have in XML: "def". :-)

There's a lot of duplicated block definitions in detail's parcel.xml, and it'd be just as big (item for item, attribute for attribute) in your proposal. I could get rid of most of the duplication with a function whose interface might start out looking like this:
  def MakeDetailViewRow(parcel, namePrefix, label, areaClass=ContentItemDetail, position=None, presentationStyle=None):
     ...

and would build the area block, the label, spacers, and AEBlock; it'd encapsulate detail-view-specific defaults like 'borders' that would be different from the raw attribute defaults).

I'm sure this function's parameter list would grow, but at least I could see at a glance what the possibilities are (another problem with XML is that I need to look at the schema, in several places because of inheritance, to see what attributes defaults are; using a function definition for common cases shortens my learning curve.

You call this a "specialized use", but I'd suggest that your definitions of menuitems could use exactly the same sort of specialization.

...Bryan

Alec Flett wrote:
Bryan Stearns wrote:
I'm looking forward to declaring UI elements in Python because Python is much more flexible and concise  than XML. For instance, if you look at the detail view's parcel.xml today, you see a lot of the same structures (like "an area containing a label and an attribute editor") and constants (like the borders around various blocks).
The thing I hate most about parcel.xml is that there's no way for me to represent or encapsulate this repetiton; the new proposal suffers from the same problem.
Fair enough. It sounds like you have a specialized use and this particular proposal may not suit the detail view. However, I wonder how much effort is going into parameterizing the creation of these detail-specific blocks, when the CPIA xml might be fairly simple. I hate redundancy as well, but maybe its enough better than parcel.xml that it might be worth looking at? Let's try.

<CalendarAllDayBlock id="CalendarAllDayArea">
  <StaticText id="CalDetailsAllDayLabel" border="4,0,0,0" title="all-day".../>
  <StaticText minimumSize="8,-1"/>
  <AEBlock id="EditAllDay" viewAttribute="allDay" border="2,2,2,2"/>
</DetailRow>

  So the "Cal" or "Calendar" appears 3 times here.. plus I imagine the text/spacer/AEBlock is part of the repetition you're talking about. So I'd be curious what the parameterized python might be like. This is obviously a very simplistic version of what you're trying to do as well, so I'm sure it only gets more complicated, not less :)

So you're probably right, this might not be appropriate for complex stuff in the detail view... worth the exercise, anyway!

But as the UI gets more complex (dashboard, toolbar, menus, etc) I can still see value in being able to declare a large part of it in XML.

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

Open Source Applications Foundation "Dev" mailing list
http://lists.osafoundation.org/mailman/listinfo/dev

Reply via email to