X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c032d94e606dae4cd9712a02eb7bf6e2f42dcf51..e98e70622703a1d12e47ad74d1264c421597a667:/wxPython/wx/tools/XRCed/params.py diff --git a/wxPython/wx/tools/XRCed/params.py b/wxPython/wx/tools/XRCed/params.py index 5ba1bccd68..1fdb088342 100644 --- a/wxPython/wx/tools/XRCed/params.py +++ b/wxPython/wx/tools/XRCed/params.py @@ -8,17 +8,12 @@ import string import os.path from globals import * from types import * -from wxPython.xrc import * genericStyles = [ - 'wxSIMPLE_BORDER', 'wxDOUBLE_BORDER', 'wxSUNKEN_BORDER', + 'wxSIMPLE_BORDER', 'wxSUNKEN_BORDER', 'wxDOUBLE_BORDER', 'wxRAISED_BORDER', 'wxSTATIC_BORDER', 'wxNO_BORDER', - 'wxTRANSPARENT_WINDOW', 'wxTAB_TRAVERSAL', - 'wxWANTS_CHARS', - 'wxNO_FULL_REPAINT_ON_RESIZE', - 'wxVSCROLL', 'wxHSCROLL', 'wxALWAYS_SHOW_SB', - 'wxCLIP_CHILDREN', - 'wxFULL_REPAINT_ON_RESIZE' + 'wxCLIP_CHILDREN', 'wxTRANSPARENT_WINDOW', 'wxWANTS_CHARS', + 'wxNO_FULL_REPAINT_ON_RESIZE', 'wxFULL_REPAINT_ON_RESIZE' ] genericExStyles = [ @@ -33,15 +28,15 @@ genericExStyles = [ buttonSize = (35,-1) # in dialog units, transformed to pixels in panel ctor # Class that can properly disable children -class PPanel(wxPanel): +class PPanel(wx.Panel): def __init__(self, parent, name): - wxPanel.__init__(self, parent, -1, name=name) + wx.Panel.__init__(self, parent, -1, name=name) self.modified = self.freeze = False def Enable(self, value): # Something strange is going on with enable so we make sure... for w in self.GetChildren(): w.Enable(value) - wxPanel.Enable(self, value) + #wx.Panel.Enable(self, value) def SetModified(self): self.modified = True g.panel.SetModified(True) @@ -54,18 +49,18 @@ class PPanel(wxPanel): class ParamBinaryOr(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_BUTTON_CHOICES = wxNewId() - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) - self.button = wxButton(self, self.ID_BUTTON_CHOICES, 'Edit...', size=buttonSize) - sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) + self.ID_TEXT_CTRL = wx.NewId() + self.ID_BUTTON_CHOICES = wx.NewId() + sizer = wx.BoxSizer() + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1)) + sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) + self.button = wx.Button(self, self.ID_BUTTON_CHOICES, 'Edit...', size=buttonSize) + sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) - EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoices) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + wx.EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoices) + wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def GetValue(self): return self.text.GetValue() def SetValue(self, value): @@ -77,7 +72,7 @@ class ParamBinaryOr(PPanel): if self.GetName() == 'flag': dlg.SetTitle('Sizer item flags') elif self.GetName() == 'style': dlg.SetTitle('Window styles') elif self.GetName() == 'exstyle': dlg.SetTitle('Extended window styles') - listBox = XRCCTRL(dlg, 'CHECKLIST') + listBox = xrc.XRCCTRL(dlg, 'CHECKLIST') listBox.InsertItems(self.values, 0) value = map(string.strip, self.text.GetValue().split('|')) if value == ['']: value = [] @@ -92,7 +87,7 @@ class ParamBinaryOr(PPanel): else: print 'WARNING: unknown flag: %s: ignored.' % i ignored.append(i) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: value = [] for i in range(listBox.GetCount()): if listBox.IsChecked(i): @@ -108,14 +103,17 @@ class ParamBinaryOr(PPanel): class ParamFlag(ParamBinaryOr): values = ['wxTOP', 'wxBOTTOM', 'wxLEFT', 'wxRIGHT', 'wxALL', - 'wxEXPAND', 'wxGROW', 'wxSHAPED', 'wxALIGN_CENTRE', 'wxALIGN_RIGHT', - 'wxFIXED_MINSIZE', - 'wxALIGN_BOTTOM', 'wxALIGN_CENTRE_VERTICAL', - 'wxALIGN_CENTRE_HORIZONTAL', + 'wxEXPAND', 'wxGROW', 'wxSHAPED', 'wxSTRETCH_NOT', + 'wxALIGN_CENTRE', 'wxALIGN_LEFT', 'wxALIGN_RIGHT', + 'wxALIGN_TOP', 'wxALIGN_BOTTOM', + 'wxALIGN_CENTRE_VERTICAL', 'wxALIGN_CENTRE_HORIZONTAL', + 'wxADJUST_MINSIZE', 'wxFIXED_MINSIZE' ] equal = {'wxALIGN_CENTER': 'wxALIGN_CENTRE', 'wxALIGN_CENTER_VERTICAL': 'wxALIGN_CENTRE_VERTICAL', - 'wxALIGN_CENTER_HORIZONTAL': 'wxALIGN_CENTRE_HORIZONTAL'} + 'wxALIGN_CENTER_HORIZONTAL': 'wxALIGN_CENTRE_HORIZONTAL', + 'wxUP': 'wxTOP', 'wxDOWN': 'wxBOTTOM', 'wxNORTH': 'wxTOP', + 'wxSOUTH': 'wxBOTTOM', 'wxWEST': 'wxLEFT', 'wxEAST': 'wxRIGHT'} def __init__(self, parent, name): ParamBinaryOr.__init__(self, parent, name) @@ -133,14 +131,14 @@ class ParamStyle(ParamBinaryOr): # Remove duplicates self.valuesGeneric = [s for s in genericStyles if s not in self.valuesSpecific] - EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoicesBoth) + wx.EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoicesBoth) else: self.values = genericStyles def OnButtonChoicesBoth(self, evt): dlg = g.frame.res.LoadDialog(self, 'DIALOG_STYLES') - listBoxSpecific = XRCCTRL(dlg, 'CHECKLIST_SPECIFIC') + listBoxSpecific = xrc.XRCCTRL(dlg, 'CHECKLIST_SPECIFIC') listBoxSpecific.InsertItems(self.valuesSpecific, 0) - listBoxGeneric = XRCCTRL(dlg, 'CHECKLIST_GENERIC') + listBoxGeneric = xrc.XRCCTRL(dlg, 'CHECKLIST_GENERIC') listBoxGeneric.InsertItems(self.valuesGeneric, 0) value = map(string.strip, self.text.GetValue().split('|')) if value == ['']: value = [] @@ -167,7 +165,7 @@ class ParamStyle(ParamBinaryOr): else: print 'WARNING: unknown flag: %s: ignored.' % i ignored.append(i) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: value = [self.valuesSpecific[i] for i in range(listBoxSpecific.GetCount()) if listBoxSpecific.IsChecked(i)] + \ @@ -188,59 +186,61 @@ class ParamExStyle(ParamBinaryOr): else: self.values = [] ParamBinaryOr.__init__(self, parent, name) - self.SetTitle('Extended window styles') class ParamColour(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_BUTTON = wxNewId() - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(65,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) - self.button = wxPanel(self, self.ID_BUTTON, wxDefaultPosition, wxSize(20, 1)) - sizer.Add(self.button, 0, wxGROW | wxALIGN_CENTER_VERTICAL) + self.ID_TEXT_CTRL = wx.NewId() + self.ID_BUTTON = wx.NewId() + sizer = wx.BoxSizer() + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=(80,-1)) + sizer.Add(self.text, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2) + self.button = wx.Panel(self, self.ID_BUTTON, wx.DefaultPosition, wx.Size(20, 20)) + sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) self.textModified = False - EVT_PAINT(self.button, self.OnPaintButton) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) - EVT_LEFT_DOWN(self.button, self.OnLeftDown) + wx.EVT_PAINT(self.button, self.OnPaintButton) + wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + wx.EVT_LEFT_DOWN(self.button, self.OnLeftDown) def GetValue(self): return self.text.GetValue() def SetValue(self, value): self.freeze = True if not value: value = '#FFFFFF' self.text.SetValue(str(value)) # update text ctrl - colour = wxColour(int(value[1:3], 16), int(value[3:5], 16), int(value[5:7], 16)) - self.button.SetBackgroundColour(colour) + try: + colour = wx.Colour(int(value[1:3], 16), int(value[3:5], 16), int(value[5:7], 16)) + self.button.SetBackgroundColour(colour) + except: # ignore errors + pass self.button.Refresh() self.freeze = False def OnPaintButton(self, evt): - dc = wxPaintDC(self.button) - dc.SetBrush(wxTRANSPARENT_BRUSH) - if self.IsEnabled(): dc.SetPen(wxBLACK_PEN) - else: dc.SetPen(wxGREY_PEN) + dc = wx.PaintDC(self.button) + dc.SetBrush(wx.TRANSPARENT_BRUSH) + if self.IsEnabled(): dc.SetPen(wx.BLACK_PEN) + else: dc.SetPen(wx.GREY_PEN) size = self.button.GetSize() dc.DrawRectangle(0, 0, size.width, size.height) def OnLeftDown(self, evt): - data = wxColourData() + data = wx.ColourData() data.SetColour(self.GetValue()) - dlg = wxColourDialog(self, data) - if dlg.ShowModal() == wxID_OK: + dlg = wx.ColourDialog(self, data) + if dlg.ShowModal() == wx.ID_OK: self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get()) self.SetModified() dlg.Destroy() ################################################################################ -# Mapping from wx constants ro XML strings -fontFamiliesWx2Xml = {wxDEFAULT: 'default', wxDECORATIVE: 'decorative', - wxROMAN: 'roman', wxSCRIPT: 'script', wxSWISS: 'swiss', - wxMODERN: 'modern'} -fontStylesWx2Xml = {wxNORMAL: 'normal', wxSLANT: 'slant', wxITALIC: 'italic'} -fontWeightsWx2Xml = {wxNORMAL: 'normal', wxLIGHT: 'light', wxBOLD: 'bold'} +# Mapping from wx constants to XML strings +fontFamiliesWx2Xml = {wx.DEFAULT: 'default', wx.DECORATIVE: 'decorative', + wx.ROMAN: 'roman', wx.SCRIPT: 'script', wx.SWISS: 'swiss', + wx.MODERN: 'modern'} +fontStylesWx2Xml = {wx.NORMAL: 'normal', wx.SLANT: 'slant', wx.ITALIC: 'italic'} +fontWeightsWx2Xml = {wx.NORMAL: 'normal', wx.LIGHT: 'light', wx.BOLD: 'bold'} def ReverseMap(m): rm = {} for k,v in m.items(): rm[v] = k @@ -252,30 +252,30 @@ fontWeightsXml2wx = ReverseMap(fontWeightsWx2Xml) class ParamFont(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_BUTTON_SELECT = wxNewId() - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) - self.button = wxButton(self, self.ID_BUTTON_SELECT, 'Select...', size=buttonSize) - sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) + self.ID_TEXT_CTRL = wx.NewId() + self.ID_BUTTON_SELECT = wx.NewId() + sizer = wx.BoxSizer() + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=(200,-1)) + sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) + self.button = wx.Button(self, self.ID_BUTTON_SELECT, 'Select...', size=buttonSize) + sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) self.textModified = False - EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + wx.EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect) + wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def OnChange(self, evt): PPanel.OnChange(self, evt) self.textModified = True def _defaultValue(self): - return ['12', 'default', 'normal', 'normal', '0', '', ''] + return [`g._sysFont.GetPointSize()`, 'default', 'normal', 'normal', '0', '', ''] def GetValue(self): if self.textModified: # text has newer value try: return eval(self.text.GetValue()) except SyntaxError: - wxLogError('Syntax error in parameter value: ' + self.GetName()) + wx.LogError('Syntax error in parameter value: ' + self.GetName()) return self._defaultValue() return self.value def SetValue(self, value): @@ -289,48 +289,48 @@ class ParamFont(PPanel): try: self.value = eval(self.text.GetValue()) except SyntaxError: - wxLogError('Syntax error in parameter value: ' + self.GetName()) + wx.LogError('Syntax error in parameter value: ' + self.GetName()) self.value = self._defaultValue() # Make initial font # Default values - size = 12 - family = wxDEFAULT - style = weight = wxNORMAL + size = g._sysFont.GetPointSize() + family = wx.DEFAULT + style = weight = wx.NORMAL underlined = 0 face = '' - enc = wxFONTENCODING_DEFAULT + enc = wx.FONTENCODING_DEFAULT # Fall back to default if exceptions error = False try: try: size = int(self.value[0]) - except ValueError: error = True; wxLogError('Invalid size specification') + except ValueError: error = True; wx.LogError('Invalid size specification') try: family = fontFamiliesXml2wx[self.value[1]] - except KeyError: error = True; wxLogError('Invalid family specification') + except KeyError: error = True; wx.LogError('Invalid family specification') try: style = fontStylesXml2wx[self.value[2]] - except KeyError: error = True; wxLogError('Invalid style specification') + except KeyError: error = True; wx.LogError('Invalid style specification') try: weight = fontWeightsXml2wx[self.value[3]] - except KeyError: error = True; wxLogError('Invalid weight specification') + except KeyError: error = True; wx.LogError('Invalid weight specification') try: underlined = bool(self.value[4]) - except ValueError: error = True; wxLogError('Invalid underlined flag specification') + except ValueError: error = True; wx.LogError('Invalid underlined flag specification') face = self.value[5] except IndexError: error = True - mapper = wxFontMapper() + mapper = wx.FontMapper() if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6]) - if error: wxLogError('Invalid font specification') - if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM - font = wxFont(size, family, style, weight, underlined, face, enc) - data = wxFontData() + if error: wx.LogError('Invalid font specification') + if enc == wx.FONTENCODING_DEFAULT: enc = wx.FONTENCODING_SYSTEM + font = wx.Font(size, family, style, weight, underlined, face, enc) + data = wx.FontData() data.SetInitialFont(font) - dlg = wxFontDialog(self, data) - if dlg.ShowModal() == wxID_OK: + dlg = wx.FontDialog(self, data) + if dlg.ShowModal() == wx.ID_OK: font = dlg.GetFontData().GetChosenFont() print font.GetEncoding() - if font.GetEncoding() == wxFONTENCODING_SYSTEM: + if font.GetEncoding() == wx.FONTENCODING_SYSTEM: encName = '' else: - encName = wxFontMapper_GetEncodingName(font.GetEncoding()).encode() + encName = wx.FontMapper.GetEncodingName(font.GetEncoding()).encode() value = [str(font.GetPointSize()), fontFamiliesWx2Xml.get(font.GetFamily(), "default"), fontStylesWx2Xml.get(font.GetStyle(), "normal"), @@ -349,15 +349,15 @@ class ParamFont(PPanel): class ParamInt(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_SPIN_CTRL = wxNewId() - sizer = wxBoxSizer() - self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) + self.ID_SPIN_CTRL = wx.NewId() + sizer = wx.BoxSizer() + self.spin = wx.SpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) self.spin.SetRange(-2147483648, 2147483647) # min/max integers sizer.Add(self.spin) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) - EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) + wx.EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) def GetValue(self): return str(self.spin.GetValue()) def SetValue(self, value): @@ -370,15 +370,15 @@ class ParamInt(PPanel): class ParamIntNN(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_SPIN_CTRL = wxNewId() - sizer = wxBoxSizer() - self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) + self.ID_SPIN_CTRL = wx.NewId() + sizer = wx.BoxSizer() + self.spin = wx.SpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1)) self.spin.SetRange(0, 10000) # min/max integers sizer.Add(self.spin) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) - EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) + wx.EVT_SPINCTRL(self, self.ID_SPIN_CTRL, self.OnChange) def GetValue(self): return str(self.spin.GetValue()) def SetValue(self, value): @@ -391,21 +391,21 @@ class ParamIntNN(PPanel): class ParamUnit(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_SPIN_BUTTON = wxNewId() - sizer = wxBoxSizer(wxHORIZONTAL) - self.spin = wxSpinButton(self, self.ID_SPIN_BUTTON, style = wxSP_VERTICAL, size=(-1,1)) + self.ID_TEXT_CTRL = wx.NewId() + self.ID_SPIN_BUTTON = wx.NewId() + sizer = wx.BoxSizer(wx.HORIZONTAL) + self.spin = wx.SpinButton(self, self.ID_SPIN_BUTTON, style = wx.SP_VERTICAL, size=(-1,1)) textW = 60 - self.spin.GetSize()[0] - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(textW,-1)) + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=(textW,-1)) self.spin.SetRange(-10000, 10000) - sizer.Add(self.text, 0, wxEXPAND) - sizer.Add(self.spin, 0, wxEXPAND) + sizer.Add(self.text, 0, wx.EXPAND) + sizer.Add(self.spin, 0, wx.EXPAND) #sizer.SetMinSize((50,-1)) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) - EVT_SPIN_UP(self, self.ID_SPIN_BUTTON, self.OnSpinUp) - EVT_SPIN_DOWN(self, self.ID_SPIN_BUTTON, self.OnSpinDown) + wx.EVT_SPIN_UP(self, self.ID_SPIN_BUTTON, self.OnSpinUp) + wx.EVT_SPIN_DOWN(self, self.ID_SPIN_BUTTON, self.OnSpinDown) def GetValue(self): return self.text.GetValue() def SetValue(self, value): @@ -426,7 +426,7 @@ class ParamUnit(PPanel): self.text.SetValue(str(intValue) + units) self.SetModified() except: - # !!! Strange, if I use wxLogWarning, event is re-generated + # !!! Strange, if I use wx.LogWarning, event is re-generated print 'incorrect unit format' def OnSpinUp(self, evt): self.Change(1) @@ -436,18 +436,18 @@ class ParamUnit(PPanel): class ParamMultilineText(PPanel): def __init__(self, parent, name, textWidth=-1): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_BUTTON_EDIT = wxNewId() - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) - self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) - sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) + self.ID_TEXT_CTRL = wx.NewId() + self.ID_BUTTON_EDIT = wx.NewId() + sizer = wx.BoxSizer() + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1)) + sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) + self.button = wx.Button(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) + sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) - EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + wx.EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit) + wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def GetValue(self): return self.text.GetValue() def SetValue(self, value): @@ -456,9 +456,9 @@ class ParamMultilineText(PPanel): self.freeze = False # disable other handlers def OnButtonEdit(self, evt): dlg = g.frame.res.LoadDialog(self, 'DIALOG_TEXT') - textCtrl = XRCCTRL(dlg, 'TEXT') + textCtrl = xrc.XRCCTRL(dlg, 'TEXT') textCtrl.SetValue(self.text.GetValue()) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: self.text.SetValue(textCtrl.GetValue()) self.SetModified() dlg.Destroy() @@ -466,17 +466,17 @@ class ParamMultilineText(PPanel): class ParamText(PPanel): def __init__(self, parent, name, textWidth=-1): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() + self.ID_TEXT_CTRL = wx.NewId() # We use sizer even here to have the same size of text control - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(textWidth,-1)) + sizer = wx.BoxSizer() + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(textWidth,-1)) if textWidth == -1: option = 1 else: option = 0 - sizer.Add(self.text, option, wxALIGN_CENTER_VERTICAL) + sizer.Add(self.text, option, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def GetValue(self): return self.text.GetValue() def SetValue(self, value): @@ -500,31 +500,30 @@ class ParamEncoding(ParamText): def __init__(self, parent, name): ParamText.__init__(self, parent, name, 100) -class ContentDialog(wxDialog): +class ContentDialog(wx.Dialog): def __init__(self, parent, value): # Load from resource - pre = wxPreDialog() + pre = wx.PreDialog() g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT') - self.this = pre.this - self._setOORInfo(self) - self.list = XRCCTRL(self, 'LIST') + self.PostCreate(pre) + self.list = xrc.XRCCTRL(self, 'LIST') # Set list items for v in value: self.list.Append(v) self.SetAutoLayout(True) self.GetSizer().Fit(self) # Callbacks - self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND') - self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE') - self.ID_BUTTON_UP = XRCID('BUTTON_UP') - self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN') - EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp) - EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown) - EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend) - EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) - EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI) - EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI) - EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) + self.ID_BUTTON_APPEND = xrc.XRCID('BUTTON_APPEND') + self.ID_BUTTON_REMOVE = xrc.XRCID('BUTTON_REMOVE') + self.ID_BUTTON_UP = xrc.XRCID('BUTTON_UP') + self.ID_BUTTON_DOWN = xrc.XRCID('BUTTON_DOWN') + wx.EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp) + wx.EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown) + wx.EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend) + wx.EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) + wx.EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI) + wx.EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI) + wx.EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) def OnButtonUp(self, evt): i = self.list.GetSelection() str = self.list.GetString(i) @@ -538,7 +537,7 @@ class ContentDialog(wxDialog): self.list.InsertItems([str], i+1) self.list.SetSelection(i+1) def OnButtonAppend(self, evt): - str = wxGetTextFromUser('Enter new item:', 'Append', '', self) + str = wx.GetTextFromUser('Enter new item:', 'Append', '', self) self.list.Append(str) def OnButtonRemove(self, evt): self.list.Delete(self.list.GetSelection()) @@ -551,13 +550,12 @@ class ContentDialog(wxDialog): evt.Enable(self.list.GetSelection() != -1 and \ self.list.GetSelection() < self.list.GetCount() - 1) -class ContentCheckListDialog(wxDialog): +class ContentCheckListDialog(wx.Dialog): def __init__(self, parent, value): - pre = wxPreDialog() + pre = wx.PreDialog() g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECKLIST') - self.this = pre.this - self._setOORInfo(self) - self.list = XRCCTRL(self, 'CHECKLIST') + self.PostCreate(pre) + self.list = xrc.XRCCTRL(self, 'CHECKLIST') # Set list items i = 0 for v,ch in value: @@ -567,18 +565,18 @@ class ContentCheckListDialog(wxDialog): self.SetAutoLayout(True) self.GetSizer().Fit(self) # Callbacks - self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND') - self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE') - self.ID_BUTTON_UP = XRCID('BUTTON_UP') - self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN') - EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck) - EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp) - EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown) - EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend) - EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) - EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI) - EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI) - EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) + self.ID_BUTTON_APPEND = xrc.XRCID('BUTTON_APPEND') + self.ID_BUTTON_REMOVE = xrc.XRCID('BUTTON_REMOVE') + self.ID_BUTTON_UP = xrc.XRCID('BUTTON_UP') + self.ID_BUTTON_DOWN = xrc.XRCID('BUTTON_DOWN') + wx.EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck) + wx.EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp) + wx.EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown) + wx.EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend) + wx.EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) + wx.EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI) + wx.EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI) + wx.EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) def OnCheck(self, evt): # !!! Wrong wxGTK (wxMSW?) behavior: toggling selection if checking self.list.Deselect(evt.GetSelection()) @@ -597,7 +595,7 @@ class ContentCheckListDialog(wxDialog): self.list.Check(i+1, ch) self.list.SetSelection(i+1) def OnButtonAppend(self, evt): - str = wxGetTextFromUser('Enter new item:', 'Append', '', self) + str = wx.GetTextFromUser('Enter new item:', 'Append', '', self) self.list.Append(str) def OnButtonRemove(self, evt): self.list.Delete(self.list.GetSelection()) @@ -613,19 +611,19 @@ class ContentCheckListDialog(wxDialog): class ParamContent(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_BUTTON_EDIT = wxNewId() - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) - self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) - sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) + self.ID_TEXT_CTRL = wx.NewId() + self.ID_BUTTON_EDIT = wx.NewId() + sizer = wx.BoxSizer() + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1)) + sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) + self.button = wx.Button(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize) + sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) self.textModified = False - EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + wx.EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit) + wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def OnChange(self, evt): PPanel.OnChange(self, evt) self.textModified = True @@ -634,7 +632,7 @@ class ParamContent(PPanel): try: return eval(self.text.GetValue()) except SyntaxError: - wxLogError('Syntax error in parameter value: ' + self.GetName()) + wx.LogError('Syntax error in parameter value: ' + self.GetName()) return [] return self.value def SetValue(self, value): @@ -648,10 +646,10 @@ class ParamContent(PPanel): try: self.value = eval(self.text.GetValue()) except SyntaxError: - wxLogError('Syntax error in parameter value: ' + self.GetName()) + wx.LogError('Syntax error in parameter value: ' + self.GetName()) self.value = [] dlg = ContentDialog(self, self.value) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: value = [] for i in range(dlg.list.GetCount()): value.append(dlg.list.GetString(i)) @@ -669,10 +667,10 @@ class ParamContentCheckList(ParamContent): try: self.value = eval(self.text.GetValue()) except SyntaxError: - wxLogError('Syntax error in parameter value: ' + self.GetName()) + wx.LogError('Syntax error in parameter value: ' + self.GetName()) self.value = [] dlg = ContentCheckListDialog(self, self.value) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: value = [] for i in range(dlg.list.GetCount()): value.append((dlg.list.GetString(i), int(dlg.list.IsChecked(i)))) @@ -681,29 +679,28 @@ class ParamContentCheckList(ParamContent): self.textModified = False dlg.Destroy() -class IntListDialog(wxDialog): +class IntListDialog(wx.Dialog): def __init__(self, parent, value): - pre = wxPreDialog() + pre = wx.PreDialog() g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_INTLIST') - self.this = pre.this - self._setOORInfo(self) - self.list = XRCCTRL(self, 'LIST') + self.PostCreate(pre) + self.list = xrc.XRCCTRL(self, 'LIST') # Set list items value.sort() for v in value: if type(v) != IntType: - wxLogError('Invalid item type') + wx.LogError('Invalid item type') else: self.list.Append(str(v)) self.SetAutoLayout(True) self.GetSizer().Fit(self) # Callbacks - self.spinCtrl = XRCCTRL(self, 'SPIN') - EVT_BUTTON(self, XRCID('BUTTON_ADD'), self.OnButtonAdd) - self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE') - EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) - EVT_BUTTON(self, XRCID('BUTTON_CLEAR'), self.OnButtonClear) - EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) + self.spinCtrl = xrc.XRCCTRL(self, 'SPIN') + wx.EVT_BUTTON(self, xrc.XRCID('BUTTON_ADD'), self.OnButtonAdd) + self.ID_BUTTON_REMOVE = xrc.XRCID('BUTTON_REMOVE') + wx.EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove) + wx.EVT_BUTTON(self, xrc.XRCID('BUTTON_CLEAR'), self.OnButtonClear) + wx.EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI) def OnButtonAdd(self, evt): # Check that it's unique try: @@ -720,7 +717,7 @@ class IntListDialog(wxDialog): if found: self.list.InsertItems([s], i) else: self.list.Append(s) except ValueError: - wxLogError('List item is not an int!') + wx.LogError('List item is not an int!') def OnButtonRemove(self, evt): self.list.Delete(self.list.GetSelection()) def OnButtonClear(self, evt): @@ -738,10 +735,10 @@ class ParamIntList(ParamContent): try: self.value = eval(self.text.GetValue()) except SyntaxError: - wxLogError('Syntax error in parameter value: ' + self.GetName()) + wx.LogError('Syntax error in parameter value: ' + self.GetName()) self.value = [] dlg = IntListDialog(self, self.value) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: value = [] for i in range(dlg.list.GetCount()): value.append(int(dlg.list.GetString(i))) @@ -753,14 +750,14 @@ class ParamIntList(ParamContent): # Boxless radiobox class RadioBox(PPanel): def __init__(self, parent, id, choices, - pos=wxDefaultPosition, name='radiobox'): + pos=wx.DefaultPosition, name='radiobox'): PPanel.__init__(self, parent, name) self.choices = choices - topSizer = wxBoxSizer() + topSizer = wx.BoxSizer() for i in choices: - button = wxRadioButton(self, -1, i, size=(-1,buttonSize[1]), name=i) - topSizer.Add(button, 0, wxRIGHT, 5) - EVT_RADIOBUTTON(self, button.GetId(), self.OnRadioChoice) + button = wx.RadioButton(self, -1, i, size=(-1,buttonSize[1]), name=i) + topSizer.Add(button, 0, wx.RIGHT, 5) + wx.EVT_RADIOBUTTON(self, button.GetId(), self.OnRadioChoice) self.SetAutoLayout(True) self.SetSizer(topSizer) topSizer.Fit(self) @@ -814,19 +811,19 @@ class ParamOrientation(RadioBox): class ParamFile(PPanel): def __init__(self, parent, name): PPanel.__init__(self, parent, name) - self.ID_TEXT_CTRL = wxNewId() - self.ID_BUTTON_BROWSE = wxNewId() - sizer = wxBoxSizer() - self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1)) - sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5) - self.button = wxButton(self, self.ID_BUTTON_BROWSE, 'Browse...',size=buttonSize) - sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL) + self.ID_TEXT_CTRL = wx.NewId() + self.ID_BUTTON_BROWSE = wx.NewId() + sizer = wx.BoxSizer() + self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1)) + sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5) + self.button = wx.Button(self, self.ID_BUTTON_BROWSE, 'Browse...',size=buttonSize) + sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL) self.SetAutoLayout(True) self.SetSizer(sizer) sizer.Fit(self) self.textModified = False - EVT_BUTTON(self, self.ID_BUTTON_BROWSE, self.OnButtonBrowse) - EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) + wx.EVT_BUTTON(self, self.ID_BUTTON_BROWSE, self.OnButtonBrowse) + wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange) def OnChange(self, evt): PPanel.OnChange(self, evt) self.textModified = True @@ -842,10 +839,10 @@ class ParamFile(PPanel): def OnButtonBrowse(self, evt): if self.textModified: # text has newer value self.value = self.text.GetValue() - dlg = wxFileDialog(self, + dlg = wx.FileDialog(self, defaultDir = os.path.abspath(os.path.dirname(self.value)), defaultFile = os.path.basename(self.value)) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: # Get common part of selected path and current if g.frame.dataFile: curpath = os.path.abspath(g.frame.dataFile) @@ -859,26 +856,25 @@ class ParamFile(PPanel): class ParamBitmap(PPanel): def __init__(self, parent, name): - pre = wxPrePanel() + pre = wx.PrePanel() g.frame.res.LoadOnPanel(pre, parent, 'PANEL_BITMAP') - self.this = pre.this - self._setOORInfo(self) + self.PostCreate(pre) self.modified = self.freeze = False - self.radio_std = XRCCTRL(self, 'RADIO_STD') - self.radio_file = XRCCTRL(self, 'RADIO_FILE') - self.combo = XRCCTRL(self, 'COMBO_STD') - self.text = XRCCTRL(self, 'TEXT_FILE') - self.button = XRCCTRL(self, 'BUTTON_BROWSE') + self.radio_std = xrc.XRCCTRL(self, 'RADIO_STD') + self.radio_file = xrc.XRCCTRL(self, 'RADIO_FILE') + self.combo = xrc.XRCCTRL(self, 'COMBO_STD') + self.text = xrc.XRCCTRL(self, 'TEXT_FILE') + self.button = xrc.XRCCTRL(self, 'BUTTON_BROWSE') self.textModified = False self.SetAutoLayout(True) self.GetSizer().SetMinSize((260, -1)) self.GetSizer().Fit(self) - EVT_RADIOBUTTON(self, XRCID('RADIO_STD'), self.OnRadioStd) - EVT_RADIOBUTTON(self, XRCID('RADIO_FILE'), self.OnRadioFile) - EVT_BUTTON(self, XRCID('BUTTON_BROWSE'), self.OnButtonBrowse) - EVT_COMBOBOX(self, XRCID('COMBO_STD'), self.OnCombo) - EVT_TEXT(self, XRCID('COMBO_STD'), self.OnChange) - EVT_TEXT(self, XRCID('TEXT_FILE'), self.OnChange) + wx.EVT_RADIOBUTTON(self, xrc.XRCID('RADIO_STD'), self.OnRadioStd) + wx.EVT_RADIOBUTTON(self, xrc.XRCID('RADIO_FILE'), self.OnRadioFile) + wx.EVT_BUTTON(self, xrc.XRCID('BUTTON_BROWSE'), self.OnButtonBrowse) + wx.EVT_COMBOBOX(self, xrc.XRCID('COMBO_STD'), self.OnCombo) + wx.EVT_TEXT(self, xrc.XRCID('COMBO_STD'), self.OnChange) + wx.EVT_TEXT(self, xrc.XRCID('TEXT_FILE'), self.OnChange) def OnRadioStd(self, evt): self.SetModified() self.SetValue(['wxART_MISSING_IMAGE','']) @@ -921,10 +917,10 @@ class ParamBitmap(PPanel): def OnButtonBrowse(self, evt): if self.textModified: # text has newer value self.value[1] = self.text.GetValue() - dlg = wxFileDialog(self, + dlg = wx.FileDialog(self, defaultDir = os.path.abspath(os.path.dirname(self.value[1])), defaultFile = os.path.basename(self.value[1])) - if dlg.ShowModal() == wxID_OK: + if dlg.ShowModal() == wx.ID_OK: # Get common part of selected path and current if g.frame.dataFile: curpath = os.path.abspath(g.frame.dataFile) @@ -951,5 +947,5 @@ paramDict = { 'fg': ParamColour, 'bg': ParamColour, 'font': ParamFont, 'enabled': ParamBool, 'focused': ParamBool, 'hidden': ParamBool, 'tooltip': ParamText, 'bitmap': ParamBitmap, 'icon': ParamBitmap, - 'encoding': ParamEncoding + 'encoding': ParamEncoding, 'borders': ParamUnit }