Keyword wxpywf

post #17 dated 2007-01-11 20:05:22 - filetagger - wxpython - wxpywf - appaweek

At long last, I managed to finish development on a first cut of the filetagger application. It took far longer than I really wanted it to, because I spent an inordinate amount of time whipping the wxpywf framework into shape (about a month) and so the whole "app a week" thing is more like "an app per five weeks" or so. Ha.

But you know what? I did it! I actually brought a major new module of the wftk, one I'd been thinking about for three years, to the point where it can be used. Wow.

So I'm glad I took the time to do it the way I wanted to do it.

Here are some of the features of wxpywf I created and used for this app:

  • XML definition of the entire UI of an application, using frames and dialogs. In comparison with the traditional call-by-call technique for setting up a wxPython UI, this is incredibly convenient.
  • Application-specific code grouped into simple commands.
  • Each frame and each dialog automatically binds to an XML record which can be addressed on a field-by-field basis.
  • HTML can be used for more textual interfaces; links generate commands which can have arbitrary effects on the UI (in this case, clicking on a link in the tag cloud switches the tabbed frame to the file list and displays the files with the tag selected.)
  • So far, the UI can include tabsets, list controls, HTML windows, rich text controls, checkboxes, radio button groups and listboxes, command buttons, and static text.

There's a lot of ground still to cover. But in my experience, that kind of ground can be covered in small, manageable steps after initial usability is there. And initial usability is definitely there. I feel really happy about this.

post #18 dated 2007-01-20 21:31:20 - wxpython - wxpywf - wftk - appaweek

I posted the second appaweek project last week, based on the wxpywf framework from the wftk, as you know. And this week I've started mulling over app #3, and since I'd upgraded from Python 2.1 to 2.4, my old (ancient) copy of the McMillan installer was way outdated. Turns out that McMillan disappeared from the Net in about 2004, but some enterprising souls (headed by a guy in Puerto Rico, no less, at UPR!) have taken up the gauntlet and are continuing development under the name PyInstaller.

So that was good, but when I got down to business compiling the little filemonitor work-in-progress, I found that the wx libraries have now grown in size, with the result that the (already somewhat heavy) 2MB size of a simple compiled wx app has now become 5MB! Wow! (Of course, that includes the runtime and everything, but still...)

I don't want that kind of stuff bogging down my server, and already there has been respectable traffic around the appaweek projects. But there is an awful lot of specialized code involved in this venture: wx itself, of course, and the wftk's xmlapi and repmgr libraries, their Python wrappers, and the wftk and wxpywf OO wrappers around those. That's a lot of stuff to make people install, especially on Windows when they may simply have to install Python to start with! Which is why I wanted to do the compilation thing in the first place, of course.

So here's what I thought to do -- and this is what wxpywf was always intended to do: I brought the PyPop app up to date so that it displays the XML-defined UI just fine. And it would then be possible to do dynamic importation of a module to complete the application; PyPop already contains Python and all the libraries necessary to run things, so that would work fine. And yes, the UI for the filetagger app (app #2) displayed fine, although it naturally didn't do anything except display.

But then it occurred to me: Wouldn't it be nice if wxpywf could look at the XML definition of the UI and go ahead and build the CLI definition? And then I realized that if PyPop could (1) interpret the command line and put the results into the context, (2) load the data file and do the necessary Python indexing of it, and (3) build a Python CLI on the fly and link it to the frame, then, then...

Then the entire app would be in one XML file!

And a little bitty one, too, a whole app in about 20KB. That's a quick download! And then:

If the download of the app were managed through PyPop then we'd really have a Swiss Army Knife for software! And of course, more serious Python requirements could always import a Python file for better clarity, leaving the main application to define the CLI glue holding it all together.

Then envision this: imagine an application repository, and imagine the PyPop tool as a custom-thick-client "browser" of sorts. The local PyPop installation would manage common dialogs and applications in a versioned repository, and could check for updates every time you ran an app (or on a schedule). You could design your own UIs and submit them as project requests, and have a programmer fill in the hard parts. Every app built on this framework already knows about data management from the repmgr and about workflow from the wftk, it has logging and macro capabilities built in, and it runs Python. It could run Perl if you wanted to install it -- Perl's easy to embed in Python.

You'd know where all your little apps were, and you could trade them through the central repository or you could set them up for download yourself.

That would be pretty neat. Pretty neat indeed!

post #19 dated 2007-01-22 00:48:00 - wxpython - wxpywf - wftk - appaweek

Wow. This wasn't something I'd budgeted time for, but it works. I have reimplemented the filetagger app as a single-file definition, including action tags using a very convenient abbreviated notation for wxpywf-relevant Python. For instance, the code to execute a command against the frame is

self.frame.do(context, 'update_list')

in undecorated Python. In the action, it can be just

: update_list

The wxpywf then scans the entire UI definition for action tags; for each, it builds the Python code, wraps the whole thing up as a Python class inheriting from wftk.cli, and returns it to the caller, which can then exec it to define the class.

The error handling leaves much to be desired; in case of a syntax error, it's almost understandable where the error is, but in case of a runtime error, Python's stack trace is essentially useless (file <string> line 90 doesn't help much with invisibly generated code.)

But it is cool, and on-the-fly code generation is always something I wanted to find a legitimate use for. And now I have!

At any rate, I obviously need to get a lot of code uploaded at some point and documentation caught up, but now is not the time. Work beckons, frantically.

post #20 dated 2007-01-28 00:32:18 - filetagger - wxpywf - appaweek

I posted v1.0 of the filetagger in the new PyPop format. The XML definition of the app is 310 lines and about 12K. I think this could end up being quite useful.

The code is here -- I don't have the actual running PyPop up to run it, though. I still want to get registration of file extensions working -- oh, yeah, and what there is of the help system. The help text is included but there's no command to display it yet.

If I end up defining a basic XSLT processor on top of the XMLAPI, this could start to get really interesting...

post #21 dated 2007-02-02 01:08:01 - wxpywf - pypop - appaweek - code_generators

Finally! I've been pretty busy with the paying work this last week, and also with biochemistry due to my son's kidney/allergy problems, and so lowly open-source work has suffered.

But the PyPop GUI framework is ready to download in a convenient NSIS installer. Rather than host it, I've put it up onto the the SourceForge download page for your downloading pleasure.

Once it's installed, download the filetagger app definition and play around with it. It's all still pretty crude, but I'm having fun. Did I mention that this actually involves the on-the-fly generation of a Python class based on the XML application definition, which is then instantiated in the GUI to do the work? That was fun!

Anyway, more later. I'm still on week #3 of the app-a-week thing, for, um, the second or third week. Maybe I'll slowly approach an app a week as I get this stuff under control. Wish me luck!






Copyright © 1996-2008 Vivtek. All Rights Reserved. Read the disclaimer.
Read our privacy statement, too, if you are concerned.
Problems? Try webmaster@vivtek.com or our answer page.