X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f0261a72469b57877b27a616ff790b983184df95..85bc0351f76f6d3f00460a167fc108b900e0725c:/utils/wxPython/src/msw/wx.py diff --git a/utils/wxPython/src/msw/wx.py b/utils/wxPython/src/msw/wx.py index 4bab61fc9c..4bf2ab1dbe 100644 --- a/utils/wxPython/src/msw/wx.py +++ b/utils/wxPython/src/msw/wx.py @@ -9,6 +9,8 @@ from windows import * from gdi import * +from clip_dnd import * + from events import * from mdi import * @@ -114,23 +116,6 @@ class wxPyApp(wxPyAppPtr): -class __wxPyCleanupPtr : - def __init__(self,this): - self.this = this - self.thisown = 0 - def __del__(self,wxc=wxc): - if self.thisown == 1 : - wxc.delete___wxPyCleanup(self) - def __repr__(self): - return "" % (self.this,) -class __wxPyCleanup(__wxPyCleanupPtr): - def __init__(self,*_args,**_kwargs): - self.this = apply(wxc.new___wxPyCleanup,_args,_kwargs) - self.thisown = 1 - - - - #-------------- FUNCTION WRAPPERS ------------------ @@ -153,6 +138,8 @@ _wxStart = wxc._wxStart _wxSetDictionary = wxc._wxSetDictionary +wxApp_CleanUp = wxc.wxApp_CleanUp + #-------------- VARIABLE WRAPPERS ------------------ @@ -216,11 +203,16 @@ wxTB_DOCKABLE = wxc.wxTB_DOCKABLE wxCOLOURED = wxc.wxCOLOURED wxFIXED_LENGTH = wxc.wxFIXED_LENGTH wxALIGN_LEFT = wxc.wxALIGN_LEFT -wxALIGN_CENTER = wxc.wxALIGN_CENTER -wxALIGN_CENTRE = wxc.wxALIGN_CENTRE +wxALIGN_CENTER_HORIZONTAL = wxc.wxALIGN_CENTER_HORIZONTAL +wxALIGN_CENTRE_HORIZONTAL = wxc.wxALIGN_CENTRE_HORIZONTAL wxALIGN_RIGHT = wxc.wxALIGN_RIGHT wxALIGN_BOTTOM = wxc.wxALIGN_BOTTOM +wxALIGN_CENTER_VERTICAL = wxc.wxALIGN_CENTER_VERTICAL +wxALIGN_CENTRE_VERTICAL = wxc.wxALIGN_CENTRE_VERTICAL wxALIGN_TOP = wxc.wxALIGN_TOP +wxALIGN_CENTER = wxc.wxALIGN_CENTER +wxALIGN_CENTRE = wxc.wxALIGN_CENTRE +wxSHAPED = wxc.wxSHAPED wxLB_NEEDED_SB = wxc.wxLB_NEEDED_SB wxLB_ALWAYS_SB = wxc.wxLB_ALWAYS_SB wxLB_SORT = wxc.wxLB_SORT @@ -236,6 +228,8 @@ wxTE_PASSWORD = wxc.wxTE_PASSWORD wxTE_READONLY = wxc.wxTE_READONLY wxTE_RICH = wxc.wxTE_RICH wxTE_MULTILINE = wxc.wxTE_MULTILINE +wxTE_AUTO_SCROLL = wxc.wxTE_AUTO_SCROLL +wxTE_NO_VSCROLL = wxc.wxTE_NO_VSCROLL wxCB_SIMPLE = wxc.wxCB_SIMPLE wxCB_DROPDOWN = wxc.wxCB_DROPDOWN wxCB_SORT = wxc.wxCB_SORT @@ -262,6 +256,7 @@ wxSL_SELRANGE = wxc.wxSL_SELRANGE wxSB_HORIZONTAL = wxc.wxSB_HORIZONTAL wxSB_VERTICAL = wxc.wxSB_VERTICAL wxST_SIZEGRIP = wxc.wxST_SIZEGRIP +wxST_NO_AUTORESIZE = wxc.wxST_NO_AUTORESIZE wxBU_AUTODRAW = wxc.wxBU_AUTODRAW wxBU_NOAUTODRAW = wxc.wxBU_NOAUTODRAW wxTR_HAS_BUTTONS = wxc.wxTR_HAS_BUTTONS @@ -294,6 +289,8 @@ wxSP_WRAP = wxc.wxSP_WRAP wxSP_NOBORDER = wxc.wxSP_NOBORDER wxSP_3D = wxc.wxSP_3D wxSP_BORDER = wxc.wxSP_BORDER +wxSP_LIVE_UPDATE = wxc.wxSP_LIVE_UPDATE +wxSP_PERMIT_UNSPLIT = wxc.wxSP_PERMIT_UNSPLIT wxFLOOD_SURFACE = wxc.wxFLOOD_SURFACE wxFLOOD_BORDER = wxc.wxFLOOD_BORDER wxODDEVEN_RULE = wxc.wxODDEVEN_RULE @@ -331,12 +328,6 @@ wxSIZE_AUTO_HEIGHT = wxc.wxSIZE_AUTO_HEIGHT wxSIZE_AUTO = wxc.wxSIZE_AUTO wxSIZE_USE_EXISTING = wxc.wxSIZE_USE_EXISTING wxSIZE_ALLOW_MINUS_ONE = wxc.wxSIZE_ALLOW_MINUS_ONE -wxDF_TEXT = wxc.wxDF_TEXT -wxDF_BITMAP = wxc.wxDF_BITMAP -wxDF_METAFILE = wxc.wxDF_METAFILE -wxDF_DIB = wxc.wxDF_DIB -wxDF_OEMTEXT = wxc.wxDF_OEMTEXT -wxDF_FILENAME = wxc.wxDF_FILENAME wxPORTRAIT = wxc.wxPORTRAIT wxLANDSCAPE = wxc.wxLANDSCAPE wxPRINT_QUALITY_HIGH = wxc.wxPRINT_QUALITY_HIGH @@ -400,10 +391,12 @@ wxBITMAP_TYPE_PNG_RESOURCE = wxc.wxBITMAP_TYPE_PNG_RESOURCE wxBITMAP_TYPE_ANY = wxc.wxBITMAP_TYPE_ANY wxBITMAP_TYPE_RESOURCE = wxc.wxBITMAP_TYPE_RESOURCE wxBITMAP_TYPE_JPEG = wxc.wxBITMAP_TYPE_JPEG +wxBITMAP_TYPE_PCX = wxc.wxBITMAP_TYPE_PCX wxOPEN = wxc.wxOPEN wxSAVE = wxc.wxSAVE wxHIDE_READONLY = wxc.wxHIDE_READONLY wxOVERWRITE_PROMPT = wxc.wxOVERWRITE_PROMPT +wxFILE_MUST_EXIST = wxc.wxFILE_MUST_EXIST wxACCEL_ALT = wxc.wxACCEL_ALT wxACCEL_CTRL = wxc.wxACCEL_CTRL wxACCEL_SHIFT = wxc.wxACCEL_SHIFT @@ -489,8 +482,6 @@ wxOR_INVERT = wxc.wxOR_INVERT wxNAND = wxc.wxNAND wxOR = wxc.wxOR wxSET = wxc.wxSET -wxSRC_OR = wxc.wxSRC_OR -wxSRC_AND = wxc.wxSRC_AND WXK_BACK = wxc.WXK_BACK WXK_TAB = wxc.WXK_TAB WXK_RETURN = wxc.WXK_RETURN @@ -675,6 +666,7 @@ wxEVT_COMMAND_CHOICE_SELECTED = wxc.wxEVT_COMMAND_CHOICE_SELECTED wxEVT_COMMAND_LISTBOX_SELECTED = wxc.wxEVT_COMMAND_LISTBOX_SELECTED wxEVT_COMMAND_LISTBOX_DOUBLECLICKED = wxc.wxEVT_COMMAND_LISTBOX_DOUBLECLICKED wxEVT_COMMAND_CHECKLISTBOX_TOGGLED = wxc.wxEVT_COMMAND_CHECKLISTBOX_TOGGLED +wxEVT_COMMAND_SPINCTRL_UPDATED = wxc.wxEVT_COMMAND_SPINCTRL_UPDATED wxEVT_COMMAND_TEXT_UPDATED = wxc.wxEVT_COMMAND_TEXT_UPDATED wxEVT_COMMAND_TEXT_ENTER = wxc.wxEVT_COMMAND_TEXT_ENTER wxEVT_COMMAND_MENU_SELECTED = wxc.wxEVT_COMMAND_MENU_SELECTED @@ -724,6 +716,7 @@ wxEVT_SCROLL_LINEDOWN = wxc.wxEVT_SCROLL_LINEDOWN wxEVT_SCROLL_PAGEUP = wxc.wxEVT_SCROLL_PAGEUP wxEVT_SCROLL_PAGEDOWN = wxc.wxEVT_SCROLL_PAGEDOWN wxEVT_SCROLL_THUMBTRACK = wxc.wxEVT_SCROLL_THUMBTRACK +wxEVT_SCROLL_THUMBRELEASE = wxc.wxEVT_SCROLL_THUMBRELEASE wxEVT_SCROLLWIN_TOP = wxc.wxEVT_SCROLLWIN_TOP wxEVT_SCROLLWIN_BOTTOM = wxc.wxEVT_SCROLLWIN_BOTTOM wxEVT_SCROLLWIN_LINEUP = wxc.wxEVT_SCROLLWIN_LINEUP @@ -731,6 +724,7 @@ wxEVT_SCROLLWIN_LINEDOWN = wxc.wxEVT_SCROLLWIN_LINEDOWN wxEVT_SCROLLWIN_PAGEUP = wxc.wxEVT_SCROLLWIN_PAGEUP wxEVT_SCROLLWIN_PAGEDOWN = wxc.wxEVT_SCROLLWIN_PAGEDOWN wxEVT_SCROLLWIN_THUMBTRACK = wxc.wxEVT_SCROLLWIN_THUMBTRACK +wxEVT_SCROLLWIN_THUMBRELEASE = wxc.wxEVT_SCROLLWIN_THUMBRELEASE wxEVT_SIZE = wxc.wxEVT_SIZE wxEVT_MOVE = wxc.wxEVT_MOVE wxEVT_CLOSE_WINDOW = wxc.wxEVT_CLOSE_WINDOW @@ -790,6 +784,9 @@ wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxc.wxEVT_COMMAND_TREE_ITEM_COLLAPSING wxEVT_COMMAND_TREE_SEL_CHANGED = wxc.wxEVT_COMMAND_TREE_SEL_CHANGED wxEVT_COMMAND_TREE_SEL_CHANGING = wxc.wxEVT_COMMAND_TREE_SEL_CHANGING wxEVT_COMMAND_TREE_KEY_DOWN = wxc.wxEVT_COMMAND_TREE_KEY_DOWN +wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxc.wxEVT_COMMAND_TREE_ITEM_ACTIVATED +wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK = wxc.wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK +wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK = wxc.wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK wxEVT_COMMAND_LIST_BEGIN_DRAG = wxc.wxEVT_COMMAND_LIST_BEGIN_DRAG wxEVT_COMMAND_LIST_BEGIN_RDRAG = wxc.wxEVT_COMMAND_LIST_BEGIN_RDRAG wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT = wxc.wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT @@ -854,12 +851,6 @@ def _checkForCallback(obj, name, event, theID=-1): except: pass else: obj.Connect(theID, -1, event, cb) -## def _checkClassCallback(obj, name): -## try: cb = getattr(obj, name) -## except: pass -## else: obj._addCallback(name, cb) - - def _StdWindowCallbacks(win): _checkForCallback(win, "OnChar", wxEVT_CHAR) _checkForCallback(win, "OnSize", wxEVT_SIZE) @@ -971,12 +962,29 @@ def EVT_ICONIZE(win, func): def EVT_NAVIGATION_KEY(win, func): win.Connect(-1, -1, wxEVT_NAVIGATION_KEY, func) +def EVT_PALETTE_CHANGED(win, func): + win.Connect(-1, -1, wxEVT_PALETTE_CHANGED, func) + +def EVT_QUERY_NEW_PALETTE(win, func): + win.Connect(-1, -1, wxEVT_QUERY_NEW_PALETTE, func) + +def EVT_WINDOW_CREATE(win, func): + win.Connect(-1, -1, wxEVT_CREATE, func) + +def EVT_WINDOW_DESTROY(win, func): + win.Connect(-1, -1, wxEVT_DESTROY, func) + + + def EVT_IDLE(win, func): win.Connect(-1, -1, wxEVT_IDLE, func) def EVT_UPDATE_UI(win, id, func): win.Connect(id, -1, wxEVT_UPDATE_UI, func) +def EVT_UPDATE_UI_RANGE(win, id, id2, func): + win.Connect(id, id2, wxEVT_UPDATE_UI, func) + # Mouse Events def EVT_LEFT_DOWN(win, func): @@ -1038,6 +1046,7 @@ def EVT_COMMAND(win, id, cmd, func): def EVT_COMMAND_RANGE(win, id1, id2, cmd, func): win.Connect(id1, id2, cmd, func) + # Scrolling def EVT_SCROLL(win, func): win.Connect(-1, -1, wxEVT_SCROLL_TOP, func) @@ -1047,6 +1056,7 @@ def EVT_SCROLL(win, func): win.Connect(-1, -1, wxEVT_SCROLL_PAGEUP, func) win.Connect(-1, -1, wxEVT_SCROLL_PAGEDOWN, func) win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK,func) + win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE,func) def EVT_SCROLL_TOP(win, func): win.Connect(-1, -1, wxEVT_SCROLL_TOP, func) @@ -1069,6 +1079,9 @@ def EVT_SCROLL_PAGEDOWN(win, func): def EVT_SCROLL_THUMBTRACK(win, func): win.Connect(-1, -1, wxEVT_SCROLL_THUMBTRACK, func) +def EVT_SCROLL_THUMBRELEASE(win, func): + win.Connect(-1, -1, wxEVT_SCROLL_THUMBRELEASE, func) + # Scrolling, with an id @@ -1080,6 +1093,7 @@ def EVT_COMMAND_SCROLL(win, id, func): win.Connect(id, -1, wxEVT_SCROLL_PAGEUP, func) win.Connect(id, -1, wxEVT_SCROLL_PAGEDOWN, func) win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK,func) + win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE,func) def EVT_COMMAND_SCROLL_TOP(win, id, func): win.Connect(id, -1, wxEVT_SCROLL_TOP, func) @@ -1102,15 +1116,19 @@ def EVT_COMMAND_SCROLL_PAGEDOWN(win, id, func): def EVT_COMMAND_SCROLL_THUMBTRACK(win, id, func): win.Connect(id, -1, wxEVT_SCROLL_THUMBTRACK, func) +def EVT_COMMAND_SCROLL_THUMBRELEASE(win, id, func): + win.Connect(id, -1, wxEVT_SCROLL_THUMBRELEASE, func) + #--- def EVT_SCROLLWIN(win, func): - win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func) - win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM, func) - win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP, func) - win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN, func) - win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP, func) - win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) - win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK,func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_BOTTOM, func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEUP, func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_LINEDOWN, func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEUP, func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) + win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func) def EVT_SCROLLWIN_TOP(win, func): win.Connect(-1, -1, wxEVT_SCROLLWIN_TOP, func) @@ -1133,17 +1151,21 @@ def EVT_SCROLLWIN_PAGEDOWN(win, func): def EVT_SCROLLWIN_THUMBTRACK(win, func): win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) +def EVT_SCROLLWIN_THUMBRELEASE(win, func): + win.Connect(-1, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func) + # Scrolling, with an id def EVT_COMMAND_SCROLLWIN(win, id, func): - win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func) - win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM, func) - win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP, func) - win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN, func) - win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP, func) - win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) - win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK,func) + win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func) + win.Connect(id, -1, wxEVT_SCROLLWIN_BOTTOM, func) + win.Connect(id, -1, wxEVT_SCROLLWIN_LINEUP, func) + win.Connect(id, -1, wxEVT_SCROLLWIN_LINEDOWN, func) + win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEUP, func) + win.Connect(id, -1, wxEVT_SCROLLWIN_PAGEDOWN, func) + win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) + win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE,func) def EVT_COMMAND_SCROLLWIN_TOP(win, id, func): win.Connect(id, -1, wxEVT_SCROLLWIN_TOP, func) @@ -1166,6 +1188,10 @@ def EVT_COMMAND_SCROLLWIN_PAGEDOWN(win, id, func): def EVT_COMMAND_SCROLLWIN_THUMBTRACK(win, id, func): win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBTRACK, func) +def EVT_COMMAND_SCROLLWIN_THUMBRELEASE(win, id, func): + win.Connect(id, -1, wxEVT_SCROLLWIN_THUMBRELEASE, func) + + # Convenience commands def EVT_BUTTON(win, id, func): win.Connect(id, -1, wxEVT_COMMAND_BUTTON_CLICKED, func) @@ -1212,15 +1238,25 @@ def EVT_COMBOBOX(win, id, func): def EVT_TOOL(win, id, func): win.Connect(id, -1, wxEVT_COMMAND_TOOL_CLICKED, func) +def EVT_TOOL_RANGE(win, id, id2, func): + win.Connect(id, id2, wxEVT_COMMAND_TOOL_CLICKED, func) + def EVT_TOOL_RCLICKED(win, id, func): win.Connect(id, -1, wxEVT_COMMAND_TOOL_RCLICKED, func) +def EVT_TOOL_RCLICKED_RANGE(win, id, id2, func): + win.Connect(id, id2, wxEVT_COMMAND_TOOL_RCLICKED, func) + def EVT_TOOL_ENTER(win, id, func): win.Connect(id, -1, wxEVT_COMMAND_TOOL_ENTER, func) def EVT_CHECKLISTBOX(win, id, func): win.Connect(id, -1, wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, func) +def EVT_SPINCTRL(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_SPINCTRL_UPDATED, func) + + # Generic command events @@ -1297,6 +1333,15 @@ def EVT_TREE_KEY_DOWN(win, id, func): def EVT_TREE_DELETE_ITEM(win, id, func): win.Connect(id, -1, wxEVT_COMMAND_TREE_DELETE_ITEM, func) +def EVT_TREE_ITEM_ACTIVATED(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_ACTIVATED, func) + +def EVT_TREE_ITEM_RIGHT_CLICK(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK, func) + +def EVT_TREE_ITEM_MIDDLE_CLICK(win, id, func): + win.Connect(id, -1, wxEVT_COMMAND_TREE_ITEM_MIDDLE_CLICK, func) + # wxSpinButton def EVT_SPIN_UP(win, id, func): @@ -1479,6 +1524,8 @@ wxPyDefaultSize.Set(-1,-1) wxDefaultPosition = wxPyDefaultPosition wxDefaultSize = wxPyDefaultSize +# backwards compatibility +wxNoRefBitmap = wxBitmap #---------------------------------------------------------------------- # This helper function will take a wxPython object and convert it to @@ -1508,7 +1555,8 @@ def wxPyTypeCast(obj, typeStr): newPtr = ptrcast(obj, typeStr+"_p") theClass = globals()[typeStr+"Ptr"] theObj = theClass(newPtr) - theObj.thisown = obj.thisown + if hasattr(obj, "this"): + theObj.thisown = obj.thisown return theObj @@ -1519,15 +1567,18 @@ class wxPyOnDemandOutputWindow: self.frame = None self.title = title + def SetParent(self, parent): self.parent = parent + def OnCloseWindow(self, event): if self.frame != None: self.frame.Destroy() self.frame = None self.text = None + # this provides the file-like behaviour def write(self, str): if not self.frame: @@ -1539,7 +1590,10 @@ class wxPyOnDemandOutputWindow: EVT_CLOSE(self.frame, self.OnCloseWindow) self.text.AppendText(str) + def close(self): + if self.frame != None: + self.frame.Destroy() self.frame = None self.text = None @@ -1575,29 +1629,48 @@ class wxApp(wxPyApp): def SetTopWindow(self, frame): if self.stdioWin: self.stdioWin.SetParent(frame) - sys.stdout = self.stdioWin #sys.stderr = + sys.stderr = sys.stdout = self.stdioWin wxPyApp.SetTopWindow(self, frame) + def MainLoop(self): wxPyApp.MainLoop(self) self.RestoreStdio() + def RedirectStdio(self, filename): if filename: sys.stdout = sys.stderr = open(filename, 'a') else: self.stdioWin = self.outputWindowClass() # wxPyOnDemandOutputWindow + def RestoreStdio(self): sys.stdout, sys.stderr = self.saveStdio if self.stdioWin != None: self.stdioWin.close() +#---------------------------------------------------------------------------- + +class wxPySimpleApp(wxApp): + def __init__(self): + wxApp.__init__(self, 0) + def OnInit(self): + return true #---------------------------------------------------------------------------- # DO NOT hold any other references to this object. This is how we know when -# to cleanup system resources that wxWin is holding... +# to cleanup system resources that wxWin is holding. When this module is +# unloaded, the refcount on __cleanMeUp goes to zero and it calls the +# wxApp_CleanUp function. + +class __wxPyCleanup: + def __init__(self): + self.cleanup = wxc.wxApp_CleanUp + def __del__(self): + self.cleanup() + __cleanMeUp = __wxPyCleanup() #----------------------------------------------------------------------------