OT - Gui code architecture question

Hello everyone,

I have a GUI that has no real main frame, it is composed of a TaskBarIcon, a login dialog, and a border-less frame that is activated when the use left clicks on the TaskBarIcon (the right click brings up a menu). Up until now, I had it setup like this :

I created a ghost frame (one that was never shown), I created the TaskBarIcon and handed it the ghost frame as it's parent, and then the TaskBarIcon held the login dialog and the left-click frame. Then another part of the app would send events to the TaskBarIcon which would then dispatch them either to the login dialog or to the left-click frame. This causes several problems, like the focus being out of whack, the dialogs showing up sometimes in the center and others on the top left side, and some of my signals get lost and I can't catch them anywhere, or I may just not know how to catch them (like I had tried to know when the user clicks outside the frame using CaptureMouse() & ReleaseMouse()).

I thought that maybe I should use the left-click frame as the main frame since it is the frame that will be used the most, have the app create it, the TaskBarIcon and the login dialog and have the app serve as the "event router". I wanted to get other people's opinion/comments/etc first.

Thank you,
Gabriel

Hi Gabriel,

Hello everyone,

I have a GUI that has no real main frame, it is composed of a
TaskBarIcon, a login dialog, and a border-less frame that is activated
when the use left clicks on the TaskBarIcon (the right click brings up a
menu). Up until now, I had it setup like this :

I created a ghost frame (one that was never shown), I created the
TaskBarIcon and handed it the ghost frame as it's parent, and then the
TaskBarIcon held the login dialog and the left-click frame. Then another
part of the app would send events to the TaskBarIcon which would then
dispatch them either to the login dialog or to the left-click frame.
This causes several problems, like the focus being out of whack, the
dialogs showing up sometimes in the center and others on the top left
side, and some of my signals get lost and I can't catch them anywhere,
or I may just not know how to catch them (like I had tried to know when
the user clicks outside the frame using CaptureMouse() & ReleaseMouse()).

I thought that maybe I should use the left-click frame as the main frame
since it is the frame that will be used the most, have the app create
it, the TaskBarIcon and the login dialog and have the app serve as the
"event router". I wanted to get other people's opinion/comments/etc first.

Thank you,
Gabriel

I have a similar application I use to monitor when I receive business
email. It's main frame only appears when one of my appointments is
about to happen. I use it as the parent of the TaskBarIcon and any
other frame or dialog that requires a parent (most of the time they
don't). I just Show() and Hide() the frame. It's hidden at startup
unless I have an appointment and I can show it by left-clicking the
taskbar icon.

I'm not sure what's going on with your application. You should be able
to use self.Center or SetPosition() to force your dialog/frame where
you want it. Calling Raise() or SetFocus() will probably help with the
focus issues.

You lose control when the user leaves your program unless you use low-
level hooks. There are events that can tell you when the mouse leaves
or enters your application's frame though. You might look at that or
explain why you need that functionality. Knowing what wxPython /
Python versions and OS would be helpful too.

- Mike

···

On Aug 24, 9:33 pm, Gabriel Rossetti <gabriel.rosse...@arimaz.com> wrote:

Mike Driscoll wrote:

Hi Gabriel,

Hello everyone,

I have a GUI that has no real main frame, it is composed of a
TaskBarIcon, a login dialog, and a border-less frame that is activated
when the use left clicks on the TaskBarIcon (the right click brings up a
menu). Up until now, I had it setup like this :

I created a ghost frame (one that was never shown), I created the
TaskBarIcon and handed it the ghost frame as it's parent, and then the
TaskBarIcon held the login dialog and the left-click frame. Then another
part of the app would send events to the TaskBarIcon which would then
dispatch them either to the login dialog or to the left-click frame.
This causes several problems, like the focus being out of whack, the
dialogs showing up sometimes in the center and others on the top left
side, and some of my signals get lost and I can't catch them anywhere,
or I may just not know how to catch them (like I had tried to know when
the user clicks outside the frame using CaptureMouse() & ReleaseMouse()).

I thought that maybe I should use the left-click frame as the main frame
since it is the frame that will be used the most, have the app create
it, the TaskBarIcon and the login dialog and have the app serve as the
"event router". I wanted to get other people's opinion/comments/etc first.

Thank you,
Gabriel
    
I have a similar application I use to monitor when I receive business
email. It's main frame only appears when one of my appointments is
about to happen. I use it as the parent of the TaskBarIcon and any
other frame or dialog that requires a parent (most of the time they
don't). I just Show() and Hide() the frame. It's hidden at startup
unless I have an appointment and I can show it by left-clicking the
taskbar icon.

I'm not sure what's going on with your application. You should be able
to use self.Center or SetPosition() to force your dialog/frame where
you want it. Calling Raise() or SetFocus() will probably help with the
focus issues.

You lose control when the user leaves your program unless you use low-
level hooks. There are events that can tell you when the mouse leaves
or enters your application's frame though. You might look at that or
explain why you need that functionality. Knowing what wxPython /
Python versions and OS would be helpful too.

- Mike

Thank you Mike, I'll have a look. I may do as you did, in my case use that left-click frame as the main frame and parent to all.
Just a question though, if I set the message dialogs parents' to that frame, when they pop-up (e.g. shutdown confirmation), won't
that frame also show (with the dialog on top)? If I remember correctly this I a problem I had before. How can this be solved?

Gabriel

···

On Aug 24, 9:33 pm, Gabriel Rossetti <gabriel.rosse...@arimaz.com> > wrote:

Hi,

> - Mike

Thank you Mike, I'll have a look. I may do as you did, in my case use
that left-click frame as the main frame and parent to all.
Just a question though, if I set the message dialogs parents' to that
frame, when they pop-up (e.g. shutdown confirmation), won't
that frame also show (with the dialog on top)? If I remember correctly
this I a problem I had before. How can this be solved?

Gabriel

I don't know...I usually don't give dialogs a parent. I just pass None
instead. As I mentioned, most dialogs and frames do not require a
parent, so don't give one to them unless you need to.

- Mike

Mike Driscoll wrote:

Hi,

- Mike
      

Thank you Mike, I'll have a look. I may do as you did, in my case use
that left-click frame as the main frame and parent to all.
Just a question though, if I set the message dialogs parents' to that
frame, when they pop-up (e.g. shutdown confirmation), won't
that frame also show (with the dialog on top)? If I remember correctly
this I a problem I had before. How can this be solved?

Gabriel
    
I don't know...I usually don't give dialogs a parent. I just pass None
instead. As I mentioned, most dialogs and frames do not require a
parent, so don't give one to them unless you need to.

Interesting, you guys solved a long lasting problem.
I have general purpose dialogs, and just as Mike I don't give them a parent.
But when the dialog is called from a subwindow (thus not the main window),
the mainwindow comes to the front.
By specifying the active window, from which the dialog is started, as the parent,
everything works as expected.

Thanks.

cheers,
Stef