Show Message Box

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Show Message Box

Post by Sem;colon » Mon Jan 11, 2016 10:17 am

Hi everyone,

There are a lot of helpful features in EventGhost, but recently I missed one:
I wanted to show a simple popup message on screen (with a button to close it).
It's not too difficult to do in python, however, a UI to customize such a Message Box would be nice, so I created one.
I integrated it in THE EventGhost plugin, as it's a very basic feature in my opinion.
messagebox.PNG
Attachments
__init__.py
1.0.4
(26.32 KiB) Downloaded 144 times

krambriw
Plugin Developer
Posts: 2570
Joined: Sat Jun 30, 2007 2:51 pm
Location: Stockholm, Sweden
Contact:

Re: Show Message Box

Post by krambriw » Mon Jan 11, 2016 11:34 am

Dear Sem;colon,

Nice feature!
Would it be OK to wish for a setting of a time-out? So that the message box could close itself in an unattended system?

Kind regards, Walter

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Show Message Box

Post by Pako » Mon Jan 11, 2016 2:20 pm

krambriw wrote:Would it be OK to wish for a setting of a time-out?
It certainly is possible.
I've used it in several plugins such as Nmap (try adding a "Named device" and press OK without filling).
Another option is a warning sound (Yes/No) when opening a MessageBox window.

Pako
You know flattr ? You can Image

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Show Message Box

Post by Sem;colon » Mon Jan 11, 2016 7:58 pm

Pako wrote:It certainly is possible.
I've used it in several plugins such as Nmap (try adding a "Named device" and press OK without filling).
Well, I used win32gui.MessageBox() which doesn't provide a native functionality for a time-out.
A possibility to set a timeout or have a proper action to close the MessageBox on an event would be cool, but I don't know how to do it.
If somebody knows and is willing to extend the MessageBox by this feature or any other feature or just wants to change some UI elements etc. please feel free to do so!
Pako wrote: Another option is a warning sound (Yes/No) when opening a MessageBox window.
Actually the OS plays the sound of the "icon" you choose, I don't even know how to disable that, but I like it that way.

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Show Message Box

Post by Pako » Tue Jan 12, 2016 7:21 am

Sem;colon wrote:Well, I used win32gui.MessageBox() which doesn't provide a native functionality for a time-out.
Sem;colon wrote:Actually the OS plays the sound of the "icon" you choose, I don't even know how to disable that, but I like it that way.
I think if we want to have an improved MessageBox, we can not use win32gui.MessageBox().
For example, we can use my class MessageBox (for example, from Nmap plugin).
There is a need to finish only a few things (especially configurable buttons).

Pako
You know flattr ? You can Image

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Show Message Box

Post by Sem;colon » Tue Jan 12, 2016 12:06 pm

Pako wrote:I think if we want to have an improved MessageBox, we can not use win32gui.MessageBox().
For example, we can use my class MessageBox (for example, from Nmap plugin).
I took a look into that plugin and I have to say that this class you wrote is pretty cool (beyond my python skills, I suck at writing GUI in Python)
But there are also some advantages with using the win32gui function, such as:
- Buttons are always in OS language
- If you select "Allways on top" the box runs in system context and is also visible on the lock screen <- I like that one very much :)

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Show Message Box

Post by Pako » Wed Jan 13, 2016 1:26 pm

Sem;colon wrote:But there are also some advantages with using the win32gui function, such as:
- Buttons are always in OS language
- If you select "Allways on top" the box runs in system context and is also visible on the lock screen
Yes, these two functions I can not do with wx.Dialog (I now do not take into account the possibilities of internationalization EventGhost).
So we can either accept the fact that some features can never have, or we can do it so, that we can have a choice of all the features
(but will not be able to select some functions simultaneously).
If you want, I can do it.

Pako
You know flattr ? You can Image

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Show Message Box

Post by Sem;colon » Wed Jan 13, 2016 7:50 pm

Pako wrote:we can do it so, that we can have a choice of all the features
(but will not be able to select some functions simultaneously).
If you want, I can do it.
yes, of course, I'd really appreciate that!
It took me hours to create the UI as it is now ^^°

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Show Message Box

Post by Pako » Thu Jan 14, 2016 8:02 am

Well, I'll start working on it.

Pako
You know flattr ? You can Image

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Show Message Box

Post by Pako » Sat Jan 16, 2016 5:30 pm

Here is the first version. You can thoroughly test it, please?

Note:
I tried it and your version of the "System modal" never really was modal.
It was only as "Always on top" (with the exception that it does not work to the lock screen). For you it worked in another way?

Pako
Attachments
__init__.py
1.0.5
(37.86 KiB) Downloaded 114 times
You know flattr ? You can Image

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Show Message Box

Post by Sem;colon » Sun Jan 17, 2016 11:57 am

Awesome!! :D
Pako wrote:I tried it and your version of the "System modal" never really was modal.
It was only as "Always on top" (with the exception that it does not work to the lock screen). For you it worked in another way?
Yes, that's the main difference I found as well, I took the name because the constant was called "MB_SYSTEMMODAL".
Pako wrote:Here is the first version. You can thoroughly test it, please?
I found one strange bug in the win32gui.MessageBox part; I noticed that you handover the EG handle if it's a "system modal" box, this seems to somehow brake something (I can't explain it).
It's all fine when I hardcode the 0 (don't know why)
Since the handle seems to have no effect anyway, I guess it's better to leave it out.

Another thing I noticed with the "Always on top" property: It's only visible on the lock screen if "Wait for the Message Box to close" is not set.
Maybe we should disable the box/Option if on or the other is selected?

On thing regarding the Tweaked MessageBox; we should consider to make the style closer to the system default, so that the Boxes look similar no matter which type is chosen. (Just an idea, i'd also be happy with as it is right now)

I attached a modified version, in this version I disabled the handle hand over for the system box and I changed the style of the Tweaked box to be like the system box.
Attachments
__init__.py
1.0.6
(37.3 KiB) Downloaded 138 times

User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: Show Message Box

Post by Pako » Sun Jan 17, 2016 1:32 pm

Sem;colon wrote:I found one strange bug in the win32gui.MessageBox part; I noticed that you handover the EG handle if it's a "system modal" box, this seems to somehow brake something (I can't explain it).
It's all fine when I hardcode the 0 (don't know why)
Since the handle seems to have no effect anyway, I guess it's better to leave it out.
I have not had that problem and I noticed a significant difference.
Now I know how to explain.
The difference is that the window actually behaves modally (relative to EventGhost).
But it has one condition: EventGhost window must be open.
If this is not, so MessageBox is not open (routine is terminated due to an unhandled error because eg.document.frame == None).
It would be possible to give the condition "if eg.document.frame is not None:"
but I think it is unnecessary. I agree with your solution.
Sem;colon wrote:Another thing I noticed with the "Always on top" property: It's only visible on the lock screen if "Wait for the Message Box to close" is not set.
Maybe we should disable the box/Option if on or the other is selected?
To me sometimes happens that it did not work even in another case.
So I do not believe a lot of this feature.
However, I certainly can do what you suggest.

Pako
Attachments
__init__.py
1.0.7
(37.63 KiB) Downloaded 137 times
You know flattr ? You can Image

Sem;colon
Experienced User
Posts: 609
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Show Message Box

Post by Sem;colon » Sun Jan 17, 2016 6:11 pm

Nice :D
No further ideas/bugs from my side.

Thank you!

Post Reply