Dabo app without main form

I’m rewriting the FES, Fox screen savior app, which is basically just a slide show. It maintains two tables - folders and filenames of pictures to display, and some ranking system in them so that its random picking is biased towards newer and less frequently displayed photos. So far so good, I migrated the data into postgres and that part is okay.
Now the trouble was that I couldn’t run it without the main form - and there can’t be one, as there’s one form per monitor and they are equal. It would be the same with six monitors. It kept complaining that the wx.app wasn’t created yet whenever it tried to create a timer, because I tried to launch these forms from app.afterInit() or .afterSetup() and few other places. Eventually I found (while debugging) that I can hook into the app.Activate event, which is raised when the setup finishes and there’s no main form. In Dabo, this is not app.bindEvent(), its app.uiApp.bindEvent(), which took me a while to notice, so writing it here for whomever may need it.

Now there’s a button on each of these forms which should close it, and their OnHit is bound to my app.Exit() method, which calls app.finish() (don’t know whether this is a Dabo method or wx native), which does its thing but guess what, the timers keep firing and the app doesn’t stop.

Is there some .CloseAllForms() or some such method? Before I dive into yet another search through documentation (had dozens of such fun activities while doing this).

This is a little confusing because I’m not sure what you mean by main form. Dabo offen uses a class named MainForm. But it can be named anything you want. It does not have to display anything ( I have done that several times in the past so I can use the data features of Dabo). You will see something like
app.MainFormClass = MainForm
in many of the demos.
If don’t want the MainForm class to display a form then use the following:
app = dabo.dApp(UI = None)
If you are trying to display a UI but not use the display (not sure why you would do that) just hide the primary form and the in the afterInit() add your special screens or forms (whatever they are). Actually, I would just have the primary screen/form off the screen and allow it to process all the events.
I hope this helps!

Johnf

The more I think about it more ways to skin the cat come to mind. Maybe if explained more or provided an example it might help me find ways to help.

Johnf

I meant app.MainFormClass = None, but with UI.
And binding app.uiApp and not app was what did the trick:
self.uiApp.bindEvent(dEvents.Activate, self.showForms)
that’s the event it raises if there’s no MainFormClass
And of course I got it working five minutes after writing the above :). Just when I asked about some list of all forms, I realized that I already created one, so I just went through it and closed each, and it just worked.

This was an interesting exercise, using a framework to do something it wasn’t designed for… well, not entirely. Database? Yes, need one. Bizobjects? Yes, this talks to database. UI? Yes. Which controls? One image, one label, one button… no data entry anywhere. Feels good to see it running now. This is becoming as intuitive as Fox once was, when you don’t quite know whether a thing exists in it, just type what you think it should be called, and it works…

1 Like