From: Schollnick, B. <Ben...@xe...> - 2005-06-06 16:02:05
|
> I doubt there is an easy way, not in wxPython. Which brings=20 > up an interesting question. I have been wondering whether=20 > sufficient conditions could exist to migrate 'value-added'=20 > widgets like this from sample code to core Pythoncard. This=20 > multi-button dialog is a good example. I expect code like=20 > this would normally be distro-ed as sample code, but why not=20 > make it a core component (or, I suppose more precisely, a=20 > core dialog wrapper)? Is there a policy against incorporating=20 > freestyle components and dialogs into core PCard? Just curious. Bo There's a few ways that it could be handled.... One method that I have started to use with a Text Parsing engine is a registry system.... The registry format that I use is along these lines.... Take a dictionary.... 1) The functions that are called are the keywords... 2) The data portion of the dictionary is the function "pointer" simple demo... def test (): print test return "registry demo..." registry_data =3D {} registry_data [ "test".upper().strip() ] =3D test data_returned =3D registry_data ["TEST"]() The drawback of this simplistic model, is that you can't easily exchange data unless the registry is part of a larger class... (Which my model is...) I have thought about extending it to support overloaded variables, etc... But something like this could be used to support "plugins" to Pythoncard.... Add.... def register_plugin ( plugin_name, function_pointer): plugin_name =3D plugin_name.upper().strip() if register_data.has_key ( plugin_name ): if function_pointer =3D=3D None: del register_data[ plugin_name ] return register_data[ plugin_name ] =3D function_pointer else: register_data[ plugin_name ] =3D function_pointer I'm typing this from memory, so it looks correct.... The main aspect of the plugin idea is how is the data returned? With my parser, each plugin returns their own piece of the parsed text.... So in pythoncard, maybe ....... plugin =3D a graphical widget? plugin =3D complete window? Just a idea.... - Benjamin =09 >=20 >=20 > Alex Tweedly wrote: >=20 > > Thanks Benjamin - but I'm looking for a way that allows me an > > arbitrary number of buttons, with labels I choose. > > I want to be able to write in code something like: > > > > result =3D multiButtonDialog.multiButtonDialog(self, \ > > 'Dad, can I go to the movies tonight', \ > > ['Yes', 'No', 'Maybe', 'Ask me later', 'Ask your mum'], \ > > "Movies Dialog Title") > > > > I think it does; but I want any number of buttons - not just 3 :-) > > > > It's starting to sound like there is no existing easy way, so I'll > > clean up my code and post it somewhere useful. > > And maybe start canvassing Kevin to allow such "utility"=20 > functions to=20 > > be included in PythonCard ... > > >=20 >=20 >=20 >=20 > ------------------------------------------------------- > This SF.Net email is sponsored by: NEC IT Guy Games. How far=20 > can you shotput > a projector? How fast can you ride your desk chair down the=20 > office luge track? > If you want to score the big prize, get to know the little guy. =20 > Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=3D20 > _______________________________________________ > Pythoncard-users mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/pythoncard-users >=20 |