2014-11-13 03:41:29 +01:00
|
|
|
import wx
|
|
|
|
|
2015-01-21 05:07:13 +01:00
|
|
|
toolkit = "wx"
|
2014-11-13 03:41:29 +01:00
|
|
|
# Code responses for WX dialogs.
|
2014-11-17 04:37:29 +01:00
|
|
|
# this is when an user presses OK on a dialogue.
|
2014-11-13 03:41:29 +01:00
|
|
|
OK = wx.ID_OK
|
2014-11-17 04:37:29 +01:00
|
|
|
# This is when an user presses cancel on a dialogue.
|
2014-11-13 03:41:29 +01:00
|
|
|
CANCEL = wx.ID_CANCEL
|
2014-11-17 04:37:29 +01:00
|
|
|
# This is when an user closes the dialogue or an id to create the close button.
|
2014-11-13 03:41:29 +01:00
|
|
|
CLOSE = wx.ID_CLOSE
|
2014-11-17 04:37:29 +01:00
|
|
|
# The response for a "yes" Button pressed on a dialogue.
|
2014-11-13 03:41:29 +01:00
|
|
|
YES = wx.ID_YES
|
2014-11-17 04:37:29 +01:00
|
|
|
# This is when the user presses No on a default dialogue.
|
2014-11-13 03:41:29 +01:00
|
|
|
NO = wx.ID_NO
|
|
|
|
|
|
|
|
#events
|
2014-11-17 04:37:29 +01:00
|
|
|
# This is raised when the application must be closed.
|
2014-11-13 03:41:29 +01:00
|
|
|
CLOSE_EVENT = wx.EVT_CLOSE
|
2014-11-17 04:37:29 +01:00
|
|
|
# This is activated when a button is pressed.
|
2014-11-13 05:37:52 +01:00
|
|
|
BUTTON_PRESSED = wx.EVT_BUTTON
|
2015-02-26 22:21:26 +01:00
|
|
|
CHECKBOX = wx.EVT_CHECKBOX
|
2014-11-17 04:37:29 +01:00
|
|
|
# This is activated when an user enter text on an edit box.
|
2014-11-16 02:40:19 +01:00
|
|
|
ENTERED_TEXT = wx.EVT_TEXT
|
2014-12-29 21:35:08 +01:00
|
|
|
MENU = wx.EVT_MENU
|
|
|
|
KEYPRESS = wx.EVT_CHAR_HOOK
|
|
|
|
KEYUP = wx.EVT_KEY_UP
|
2015-01-19 19:15:57 +01:00
|
|
|
NOTEBOOK_PAGE_CHANGED = wx.EVT_TREEBOOK_PAGE_CHANGED
|
2015-02-02 04:13:18 +01:00
|
|
|
RADIOBUTTON = wx.EVT_RADIOBUTTON
|
2014-11-13 03:41:29 +01:00
|
|
|
def exit_application():
|
2014-11-17 04:37:29 +01:00
|
|
|
""" Closes the current window cleanly. """
|
2014-11-13 03:41:29 +01:00
|
|
|
wx.GetApp().ExitMainLoop()
|
|
|
|
|
2014-12-29 21:35:08 +01:00
|
|
|
def connect_event(parent, event, func, menuitem=None, *args, **kwargs):
|
2014-11-17 04:37:29 +01:00
|
|
|
""" Connects an event to a function.
|
|
|
|
parent wx.window: The widget that will listen for the event.
|
|
|
|
event widgetUtils.event: The event that will be listened for the parent. The event should be one of the widgetUtils events.
|
|
|
|
function func: The function that will be connected to the event."""
|
2014-12-29 21:35:08 +01:00
|
|
|
if menuitem == None:
|
|
|
|
return getattr(parent, "Bind")(event, func, *args, **kwargs)
|
|
|
|
else:
|
|
|
|
return getattr(parent, "Bind")(event, func, menuitem, *args, **kwargs)
|
2015-01-21 05:07:13 +01:00
|
|
|
|
|
|
|
def connectExitFunction(exitFunction):
|
2015-01-25 09:38:17 +01:00
|
|
|
wx.GetApp().Bind(wx.EVT_QUERY_END_SESSION, exitFunction)
|
|
|
|
wx.GetApp().Bind(wx.EVT_END_SESSION, exitFunction)
|