Python & MessageBox OnAction()

For questions about using Classic.

Post » Thu Dec 26, 2013 7:29 pm

Hi!

I'm trying to use the MessageBox object in CC and evaluate some actions in Python. I've got it to display the message, but it fails to understand what option am I picking, no distinction between Yes / No etc. Any way to better handle this?

Here's a bit of code:
[CODE]msgBox.SetButtons(2)
msgBox.SetIcon(3)
msgBox.MessageBox("Hey!", "Close this stuff?")
if msgBox.OnYes():
    System.Close()
else:
    sometext.Text = "You didn't close."[/CODE]

Please help my guys, the frustration is killing me and my project. :P Any tips much appreciated.
B
4
S
1
Posts: 28
Reputation: 435

Post » Thu Dec 26, 2013 8:22 pm

The OnYes condition is a triggered event, which is only triggered in the event sheet and not in python. You'll have to either use just events or do it the way you'd have to do it without Construct in pure python by using a python library.
B
92
S
32
G
109
Posts: 5,294
Reputation: 70,999

Post » Thu Dec 26, 2013 9:42 pm

Thank you for a fast response! Oh... so it makes me wonder why have those Message Box options in the Python script editor at all. I know it's kind of an oddity, but it managed to confuse me and made me thing that it is functional, wasting a day of my life. Anyway, thanks again!
B
4
S
1
Posts: 28
Reputation: 435


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests