Ported XRCed to the wx namespace, and also enabled the selected,
focus, and disabled bitmaps of wxBitmapButton to actually be treated like bitmaps. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39174 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4,10 +4,10 @@
|
|||||||
# Created: 02.12.2002
|
# Created: 02.12.2002
|
||||||
# RCS-ID: $Id$
|
# RCS-ID: $Id$
|
||||||
|
|
||||||
from wxPython.wx import *
|
import wx
|
||||||
from wxPython.xrc import *
|
import wx.xrc as xrc
|
||||||
try:
|
try:
|
||||||
from wxPython.wizard import *
|
import wx.wizard
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
import sys
|
import sys
|
||||||
@@ -16,19 +16,19 @@ import sys
|
|||||||
|
|
||||||
progname = 'XRCed'
|
progname = 'XRCed'
|
||||||
version = '0.1.7-4'
|
version = '0.1.7-4'
|
||||||
# Minimal wxWindows version
|
# Minimal wxWidgets version
|
||||||
MinWxVersion = (2,6,0)
|
MinWxVersion = (2,6,0)
|
||||||
if wxVERSION[:3] < MinWxVersion:
|
if wx.VERSION[:3] < MinWxVersion:
|
||||||
print '''\
|
print '''\
|
||||||
******************************* WARNING **************************************
|
******************************* WARNING **************************************
|
||||||
This version of XRCed may not work correctly on your version of wxWidgets.
|
This version of XRCed may not work correctly on your version of wxWidgets.
|
||||||
Please upgrade wxWindows to %d.%d.%d or higher.
|
Please upgrade wxWidgets to %d.%d.%d or higher.
|
||||||
******************************************************************************''' % MinWxVersion
|
******************************************************************************''' % MinWxVersion
|
||||||
|
|
||||||
# Can be changed to set other default encoding different
|
# Can be changed to set other default encoding different
|
||||||
#defaultEncoding = ''
|
#defaultEncoding = ''
|
||||||
# you comment above and can uncomment this:
|
# you comment above and can uncomment this:
|
||||||
defaultEncoding = wxGetDefaultPyEncoding()
|
defaultEncoding = wx.GetDefaultPyEncoding()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
True
|
True
|
||||||
@@ -45,15 +45,15 @@ class Globals:
|
|||||||
tools = None
|
tools = None
|
||||||
undoMan = None
|
undoMan = None
|
||||||
testWin = None
|
testWin = None
|
||||||
testWinPos = wxDefaultPosition
|
testWinPos = wx.DefaultPosition
|
||||||
currentXXX = None
|
currentXXX = None
|
||||||
currentEncoding = defaultEncoding
|
currentEncoding = defaultEncoding
|
||||||
|
|
||||||
def _makeFonts(self):
|
def _makeFonts(self):
|
||||||
self._sysFont = wxSystemSettings_GetFont(wxSYS_SYSTEM_FONT)
|
self._sysFont = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT)
|
||||||
self._labelFont = wxFont(self._sysFont.GetPointSize(), wxDEFAULT, wxNORMAL, wxBOLD)
|
self._labelFont = wx.Font(self._sysFont.GetPointSize(), wx.DEFAULT, wx.NORMAL, wx.BOLD)
|
||||||
self._modernFont = wxFont(self._sysFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL)
|
self._modernFont = wx.Font(self._sysFont.GetPointSize(), wx.MODERN, wx.NORMAL, wx.NORMAL)
|
||||||
self._smallerFont = wxFont(self._sysFont.GetPointSize()-2, wxDEFAULT, wxNORMAL, wxNORMAL)
|
self._smallerFont = wx.Font(self._sysFont.GetPointSize()-2, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
|
||||||
|
|
||||||
def sysFont(self):
|
def sysFont(self):
|
||||||
if not hasattr(self, "_sysFont"): self._makeFonts()
|
if not hasattr(self, "_sysFont"): self._makeFonts()
|
||||||
|
@@ -6,21 +6,21 @@
|
|||||||
|
|
||||||
from xxx import * # xxx imports globals and params
|
from xxx import * # xxx imports globals and params
|
||||||
from undo import *
|
from undo import *
|
||||||
from wxPython.html import wxHtmlWindow
|
from wx.html import HtmlWindow
|
||||||
|
|
||||||
# Properties panel containing notebook
|
# Properties panel containing notebook
|
||||||
class Panel(wxNotebook):
|
class Panel(wx.Notebook):
|
||||||
def __init__(self, parent, id = -1):
|
def __init__(self, parent, id = -1):
|
||||||
if wxPlatform != '__WXMAC__': # some problems with this style on macs
|
if wx.Platform != '__WXMAC__': # some problems with this style on macs
|
||||||
wxNotebook.__init__(self, parent, id, style=wxNB_BOTTOM)
|
wx.Notebook.__init__(self, parent, id, style=wx.NB_BOTTOM)
|
||||||
else:
|
else:
|
||||||
wxNotebook.__init__(self, parent, id)
|
wx.Notebook.__init__(self, parent, id)
|
||||||
global panel
|
global panel
|
||||||
g.panel = panel = self
|
g.panel = panel = self
|
||||||
self.modified = False
|
self.modified = False
|
||||||
|
|
||||||
# Set common button size for parameter buttons
|
# Set common button size for parameter buttons
|
||||||
bTmp = wxButton(self, -1, '')
|
bTmp = wx.Button(self, -1, '')
|
||||||
import params
|
import params
|
||||||
params.buttonSize = (self.DLG_SZE(buttonSize)[0], bTmp.GetSize()[1])
|
params.buttonSize = (self.DLG_SZE(buttonSize)[0], bTmp.GetSize()[1])
|
||||||
bTmp.Destroy()
|
bTmp.Destroy()
|
||||||
@@ -29,17 +29,17 @@ class Panel(wxNotebook):
|
|||||||
# List of child windows
|
# List of child windows
|
||||||
self.pages = []
|
self.pages = []
|
||||||
# Create scrolled windows for pages
|
# Create scrolled windows for pages
|
||||||
self.page1 = wxScrolledWindow(self, -1)
|
self.page1 = wx.ScrolledWindow(self, -1)
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
sizer.Add(wxBoxSizer()) # dummy sizer
|
sizer.Add(wx.BoxSizer()) # dummy sizer
|
||||||
self.page1.SetAutoLayout(True)
|
self.page1.SetAutoLayout(True)
|
||||||
self.page1.SetSizer(sizer)
|
self.page1.SetSizer(sizer)
|
||||||
self.AddPage(self.page1, 'Properties')
|
self.AddPage(self.page1, 'Properties')
|
||||||
# Second page
|
# Second page
|
||||||
self.page2 = wxScrolledWindow(self, -1)
|
self.page2 = wx.ScrolledWindow(self, -1)
|
||||||
self.page2.Hide()
|
self.page2.Hide()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
sizer.Add(wxBoxSizer()) # dummy sizer
|
sizer.Add(wx.BoxSizer()) # dummy sizer
|
||||||
self.page2.SetAutoLayout(True)
|
self.page2.SetAutoLayout(True)
|
||||||
self.page2.SetSizer(sizer)
|
self.page2.SetSizer(sizer)
|
||||||
# Cache for already used panels
|
# Cache for already used panels
|
||||||
@@ -59,12 +59,12 @@ class Panel(wxNotebook):
|
|||||||
w.Destroy()
|
w.Destroy()
|
||||||
topSizer.Remove(sizer)
|
topSizer.Remove(sizer)
|
||||||
# Create new windows
|
# Create new windows
|
||||||
sizer = wxBoxSizer(wxVERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
# Special case - resize html window
|
# Special case - resize html window
|
||||||
if g.conf.panic:
|
if g.conf.panic:
|
||||||
topSizer.Add(sizer, 1, wxEXPAND)
|
topSizer.Add(sizer, 1, wx.EXPAND)
|
||||||
else:
|
else:
|
||||||
topSizer.Add(sizer, 0, wxALL, 5)
|
topSizer.Add(sizer, 0, wx.ALL, 5)
|
||||||
return sizer
|
return sizer
|
||||||
|
|
||||||
def SetData(self, xxx):
|
def SetData(self, xxx):
|
||||||
@@ -74,17 +74,17 @@ class Panel(wxNotebook):
|
|||||||
sizer = self.ResetPage(self.page1)
|
sizer = self.ResetPage(self.page1)
|
||||||
if not xxx or (not xxx.allParams and not xxx.hasName and not xxx.hasChild):
|
if not xxx or (not xxx.allParams and not xxx.hasName and not xxx.hasChild):
|
||||||
if g.tree.selection:
|
if g.tree.selection:
|
||||||
sizer.Add(wxStaticText(self.page1, -1, 'This item has no properties.'))
|
sizer.Add(wx.StaticText(self.page1, -1, 'This item has no properties.'))
|
||||||
else: # nothing selected
|
else: # nothing selected
|
||||||
# If first time, show some help
|
# If first time, show some help
|
||||||
if g.conf.panic:
|
if g.conf.panic:
|
||||||
html = wxHtmlWindow(self.page1, -1, wxDefaultPosition,
|
html = HtmlWindow(self.page1, -1, wx.DefaultPosition,
|
||||||
wxDefaultSize, wxSUNKEN_BORDER)
|
wx.DefaultSize, wx.SUNKEN_BORDER)
|
||||||
html.SetPage(g.helpText)
|
html.SetPage(g.helpText)
|
||||||
sizer.Add(html, 1, wxEXPAND)
|
sizer.Add(html, 1, wx.EXPAND)
|
||||||
g.conf.panic = False
|
g.conf.panic = False
|
||||||
else:
|
else:
|
||||||
sizer.Add(wxStaticText(self.page1, -1, 'Select a tree item.'))
|
sizer.Add(wx.StaticText(self.page1, -1, 'Select a tree item.'))
|
||||||
else:
|
else:
|
||||||
g.currentXXX = xxx.treeObject()
|
g.currentXXX = xxx.treeObject()
|
||||||
# Normal or SizerItem page
|
# Normal or SizerItem page
|
||||||
@@ -99,7 +99,7 @@ class Panel(wxNotebook):
|
|||||||
self.pageCache[cacheID] = page
|
self.pageCache[cacheID] = page
|
||||||
page.SetValues(xxx)
|
page.SetValues(xxx)
|
||||||
self.pages.append(page)
|
self.pages.append(page)
|
||||||
sizer.Add(page, 1, wxEXPAND)
|
sizer.Add(page, 1, wx.EXPAND)
|
||||||
if xxx.hasChild:
|
if xxx.hasChild:
|
||||||
# Special label for child objects - they may have different GUI
|
# Special label for child objects - they may have different GUI
|
||||||
cacheID = (xxx.child.__class__, xxx.__class__)
|
cacheID = (xxx.child.__class__, xxx.__class__)
|
||||||
@@ -112,7 +112,7 @@ class Panel(wxNotebook):
|
|||||||
self.pageCache[cacheID] = page
|
self.pageCache[cacheID] = page
|
||||||
page.SetValues(xxx.child)
|
page.SetValues(xxx.child)
|
||||||
self.pages.append(page)
|
self.pages.append(page)
|
||||||
sizer.Add(page, 0, wxEXPAND | wxTOP, 5)
|
sizer.Add(page, 0, wx.EXPAND | wx.TOP, 5)
|
||||||
self.page1.Layout()
|
self.page1.Layout()
|
||||||
size = self.page1.GetSizer().GetMinSize()
|
size = self.page1.GetSizer().GetMinSize()
|
||||||
self.page1.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)
|
self.page1.SetScrollbars(1, 1, size.width, size.height, 0, 0, True)
|
||||||
@@ -131,7 +131,7 @@ class Panel(wxNotebook):
|
|||||||
self.stylePageCache[xxx.__class__] = page
|
self.stylePageCache[xxx.__class__] = page
|
||||||
page.SetValues(xxx)
|
page.SetValues(xxx)
|
||||||
self.pages.append(page)
|
self.pages.append(page)
|
||||||
sizer.Add(page, 0, wxEXPAND)
|
sizer.Add(page, 0, wx.EXPAND)
|
||||||
# Add page if not exists
|
# Add page if not exists
|
||||||
if not self.GetPageCount() == 2:
|
if not self.GetPageCount() == 2:
|
||||||
self.AddPage(self.page2, 'Style')
|
self.AddPage(self.page2, 'Style')
|
||||||
@@ -168,13 +168,13 @@ class Panel(wxNotebook):
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# General class for notebook pages
|
# General class for notebook pages
|
||||||
class ParamPage(wxPanel):
|
class ParamPage(wx.Panel):
|
||||||
def __init__(self, parent, xxx):
|
def __init__(self, parent, xxx):
|
||||||
wxPanel.__init__(self, parent, -1)
|
wx.Panel.__init__(self, parent, -1)
|
||||||
self.xxx = xxx
|
self.xxx = xxx
|
||||||
# Register event handlers
|
# Register event handlers
|
||||||
for id in paramIDs.values():
|
for id in paramIDs.values():
|
||||||
EVT_CHECKBOX(self, id, self.OnCheckParams)
|
wx.EVT_CHECKBOX(self, id, self.OnCheckParams)
|
||||||
self.checks = {}
|
self.checks = {}
|
||||||
self.controls = {} # save python objects
|
self.controls = {} # save python objects
|
||||||
self.controlName = None
|
self.controlName = None
|
||||||
@@ -269,27 +269,27 @@ LABEL_WIDTH = 125
|
|||||||
class PropPage(ParamPage):
|
class PropPage(ParamPage):
|
||||||
def __init__(self, parent, label, xxx):
|
def __init__(self, parent, label, xxx):
|
||||||
ParamPage.__init__(self, parent, xxx)
|
ParamPage.__init__(self, parent, xxx)
|
||||||
self.box = wxStaticBox(self, -1, label)
|
self.box = wx.StaticBox(self, -1, label)
|
||||||
self.box.SetFont(g.labelFont())
|
self.box.SetFont(g.labelFont())
|
||||||
topSizer = wxStaticBoxSizer(self.box, wxVERTICAL)
|
topSizer = wx.StaticBoxSizer(self.box, wx.VERTICAL)
|
||||||
sizer = wxFlexGridSizer(len(xxx.allParams), 2, 0, 1)
|
sizer = wx.FlexGridSizer(len(xxx.allParams), 2, 0, 1)
|
||||||
sizer.AddGrowableCol(1)
|
sizer.AddGrowableCol(1)
|
||||||
if xxx.hasName:
|
if xxx.hasName:
|
||||||
label = wxStaticText(self, -1, 'XML ID:', size=(LABEL_WIDTH,-1))
|
label = wx.StaticText(self, -1, 'XML ID:', size=(LABEL_WIDTH,-1))
|
||||||
control = ParamText(self, 'XML_name', 200)
|
control = ParamText(self, 'XML_name', 200)
|
||||||
sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
|
sizer.AddMany([ (label, 0, wx.ALIGN_CENTER_VERTICAL),
|
||||||
(control, 0, wxALIGN_CENTER_VERTICAL | wxBOTTOM | wxGROW, 10) ])
|
(control, 0, wx.ALIGN_CENTER_VERTICAL | wx.BOTTOM | wx.GROW, 10) ])
|
||||||
self.controlName = control
|
self.controlName = control
|
||||||
for param in xxx.allParams:
|
for param in xxx.allParams:
|
||||||
present = xxx.params.has_key(param)
|
present = xxx.params.has_key(param)
|
||||||
if param in xxx.required:
|
if param in xxx.required:
|
||||||
label = wxStaticText(self, paramIDs[param], param + ':',
|
label = wx.StaticText(self, paramIDs[param], param + ':',
|
||||||
size = (LABEL_WIDTH,-1), name = param)
|
size = (LABEL_WIDTH,-1), name = param)
|
||||||
else:
|
else:
|
||||||
# Notebook has one very loooooong parameter
|
# Notebook has one very loooooong parameter
|
||||||
if param == 'usenotebooksizer': sParam = 'usesizer:'
|
if param == 'usenotebooksizer': sParam = 'usesizer:'
|
||||||
else: sParam = param + ':'
|
else: sParam = param + ':'
|
||||||
label = wxCheckBox(self, paramIDs[param], sParam,
|
label = wx.CheckBox(self, paramIDs[param], sParam,
|
||||||
size = (LABEL_WIDTH,-1), name = param)
|
size = (LABEL_WIDTH,-1), name = param)
|
||||||
self.checks[param] = label
|
self.checks[param] = label
|
||||||
try:
|
try:
|
||||||
@@ -303,10 +303,10 @@ class PropPage(ParamPage):
|
|||||||
typeClass = ParamText
|
typeClass = ParamText
|
||||||
control = typeClass(self, param)
|
control = typeClass(self, param)
|
||||||
control.Enable(present)
|
control.Enable(present)
|
||||||
sizer.AddMany([ (label, 0, wxALIGN_CENTER_VERTICAL),
|
sizer.AddMany([ (label, 0, wx.ALIGN_CENTER_VERTICAL),
|
||||||
(control, 0, wxALIGN_CENTER_VERTICAL | wxGROW) ])
|
(control, 0, wx.ALIGN_CENTER_VERTICAL | wx.GROW) ])
|
||||||
self.controls[param] = control
|
self.controls[param] = control
|
||||||
topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)
|
topSizer.Add(sizer, 1, wx.ALL | wx.EXPAND, 3)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(topSizer)
|
self.SetSizer(topSizer)
|
||||||
topSizer.Fit(self)
|
topSizer.Fit(self)
|
||||||
@@ -342,23 +342,23 @@ class PropPage(ParamPage):
|
|||||||
class StylePage(ParamPage):
|
class StylePage(ParamPage):
|
||||||
def __init__(self, parent, label, xxx):
|
def __init__(self, parent, label, xxx):
|
||||||
ParamPage.__init__(self, parent, xxx)
|
ParamPage.__init__(self, parent, xxx)
|
||||||
box = wxStaticBox(self, -1, label)
|
box = wx.StaticBox(self, -1, label)
|
||||||
box.SetFont(g.labelFont())
|
box.SetFont(g.labelFont())
|
||||||
topSizer = wxStaticBoxSizer(box, wxVERTICAL)
|
topSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
|
||||||
sizer = wxFlexGridSizer(len(xxx.styles), 2, 0, 1)
|
sizer = wx.FlexGridSizer(len(xxx.styles), 2, 0, 1)
|
||||||
sizer.AddGrowableCol(1)
|
sizer.AddGrowableCol(1)
|
||||||
for param in xxx.styles:
|
for param in xxx.styles:
|
||||||
present = xxx.params.has_key(param)
|
present = xxx.params.has_key(param)
|
||||||
check = wxCheckBox(self, paramIDs[param],
|
check = wx.CheckBox(self, paramIDs[param],
|
||||||
param + ':', size = (LABEL_WIDTH,-1), name = param)
|
param + ':', size = (LABEL_WIDTH,-1), name = param)
|
||||||
check.SetValue(present)
|
check.SetValue(present)
|
||||||
control = paramDict[param](self, name = param)
|
control = paramDict[param](self, name = param)
|
||||||
control.Enable(present)
|
control.Enable(present)
|
||||||
sizer.AddMany([ (check, 0, wxALIGN_CENTER_VERTICAL),
|
sizer.AddMany([ (check, 0, wx.ALIGN_CENTER_VERTICAL),
|
||||||
(control, 0, wxALIGN_CENTER_VERTICAL | wxGROW) ])
|
(control, 0, wx.ALIGN_CENTER_VERTICAL | wx.GROW) ])
|
||||||
self.checks[param] = check
|
self.checks[param] = check
|
||||||
self.controls[param] = control
|
self.controls[param] = control
|
||||||
topSizer.Add(sizer, 1, wxALL | wxEXPAND, 3)
|
topSizer.Add(sizer, 1, wx.ALL | wx.EXPAND, 3)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(topSizer)
|
self.SetSizer(topSizer)
|
||||||
topSizer.Fit(self)
|
topSizer.Fit(self)
|
||||||
|
@@ -8,7 +8,6 @@ import string
|
|||||||
import os.path
|
import os.path
|
||||||
from globals import *
|
from globals import *
|
||||||
from types import *
|
from types import *
|
||||||
from wxPython.xrc import *
|
|
||||||
|
|
||||||
genericStyles = [
|
genericStyles = [
|
||||||
'wxSIMPLE_BORDER', 'wxSUNKEN_BORDER', 'wxDOUBLE_BORDER',
|
'wxSIMPLE_BORDER', 'wxSUNKEN_BORDER', 'wxDOUBLE_BORDER',
|
||||||
@@ -29,15 +28,15 @@ genericExStyles = [
|
|||||||
buttonSize = (35,-1) # in dialog units, transformed to pixels in panel ctor
|
buttonSize = (35,-1) # in dialog units, transformed to pixels in panel ctor
|
||||||
|
|
||||||
# Class that can properly disable children
|
# Class that can properly disable children
|
||||||
class PPanel(wxPanel):
|
class PPanel(wx.Panel):
|
||||||
def __init__(self, parent, name):
|
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
|
self.modified = self.freeze = False
|
||||||
def Enable(self, value):
|
def Enable(self, value):
|
||||||
# Something strange is going on with enable so we make sure...
|
# Something strange is going on with enable so we make sure...
|
||||||
for w in self.GetChildren():
|
for w in self.GetChildren():
|
||||||
w.Enable(value)
|
w.Enable(value)
|
||||||
#wxPanel.Enable(self, value)
|
#wx.Panel.Enable(self, value)
|
||||||
def SetModified(self):
|
def SetModified(self):
|
||||||
self.modified = True
|
self.modified = True
|
||||||
g.panel.SetModified(True)
|
g.panel.SetModified(True)
|
||||||
@@ -50,18 +49,18 @@ class PPanel(wxPanel):
|
|||||||
class ParamBinaryOr(PPanel):
|
class ParamBinaryOr(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_TEXT_CTRL = wxNewId()
|
self.ID_TEXT_CTRL = wx.NewId()
|
||||||
self.ID_BUTTON_CHOICES = wxNewId()
|
self.ID_BUTTON_CHOICES = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1))
|
||||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||||
self.button = wxButton(self, self.ID_BUTTON_CHOICES, 'Edit...', size=buttonSize)
|
self.button = wx.Button(self, self.ID_BUTTON_CHOICES, 'Edit...', size=buttonSize)
|
||||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
sizer.Fit(self)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoices)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_CHOICES, self.OnButtonChoices)
|
||||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||||
def GetValue(self):
|
def GetValue(self):
|
||||||
return self.text.GetValue()
|
return self.text.GetValue()
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -73,7 +72,7 @@ class ParamBinaryOr(PPanel):
|
|||||||
if self.GetName() == 'flag': dlg.SetTitle('Sizer item flags')
|
if self.GetName() == 'flag': dlg.SetTitle('Sizer item flags')
|
||||||
elif self.GetName() == 'style': dlg.SetTitle('Window styles')
|
elif self.GetName() == 'style': dlg.SetTitle('Window styles')
|
||||||
elif self.GetName() == 'exstyle': dlg.SetTitle('Extended 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)
|
listBox.InsertItems(self.values, 0)
|
||||||
value = map(string.strip, self.text.GetValue().split('|'))
|
value = map(string.strip, self.text.GetValue().split('|'))
|
||||||
if value == ['']: value = []
|
if value == ['']: value = []
|
||||||
@@ -88,7 +87,7 @@ class ParamBinaryOr(PPanel):
|
|||||||
else:
|
else:
|
||||||
print 'WARNING: unknown flag: %s: ignored.' % i
|
print 'WARNING: unknown flag: %s: ignored.' % i
|
||||||
ignored.append(i)
|
ignored.append(i)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
value = []
|
value = []
|
||||||
for i in range(listBox.GetCount()):
|
for i in range(listBox.GetCount()):
|
||||||
if listBox.IsChecked(i):
|
if listBox.IsChecked(i):
|
||||||
@@ -132,14 +131,14 @@ class ParamStyle(ParamBinaryOr):
|
|||||||
# Remove duplicates
|
# Remove duplicates
|
||||||
self.valuesGeneric = [s for s in genericStyles
|
self.valuesGeneric = [s for s in genericStyles
|
||||||
if s not in self.valuesSpecific]
|
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:
|
else:
|
||||||
self.values = genericStyles
|
self.values = genericStyles
|
||||||
def OnButtonChoicesBoth(self, evt):
|
def OnButtonChoicesBoth(self, evt):
|
||||||
dlg = g.frame.res.LoadDialog(self, 'DIALOG_STYLES')
|
dlg = g.frame.res.LoadDialog(self, 'DIALOG_STYLES')
|
||||||
listBoxSpecific = XRCCTRL(dlg, 'CHECKLIST_SPECIFIC')
|
listBoxSpecific = xrc.XRCCTRL(dlg, 'CHECKLIST_SPECIFIC')
|
||||||
listBoxSpecific.InsertItems(self.valuesSpecific, 0)
|
listBoxSpecific.InsertItems(self.valuesSpecific, 0)
|
||||||
listBoxGeneric = XRCCTRL(dlg, 'CHECKLIST_GENERIC')
|
listBoxGeneric = xrc.XRCCTRL(dlg, 'CHECKLIST_GENERIC')
|
||||||
listBoxGeneric.InsertItems(self.valuesGeneric, 0)
|
listBoxGeneric.InsertItems(self.valuesGeneric, 0)
|
||||||
value = map(string.strip, self.text.GetValue().split('|'))
|
value = map(string.strip, self.text.GetValue().split('|'))
|
||||||
if value == ['']: value = []
|
if value == ['']: value = []
|
||||||
@@ -166,7 +165,7 @@ class ParamStyle(ParamBinaryOr):
|
|||||||
else:
|
else:
|
||||||
print 'WARNING: unknown flag: %s: ignored.' % i
|
print 'WARNING: unknown flag: %s: ignored.' % i
|
||||||
ignored.append(i)
|
ignored.append(i)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
value = [self.valuesSpecific[i]
|
value = [self.valuesSpecific[i]
|
||||||
for i in range(listBoxSpecific.GetCount())
|
for i in range(listBoxSpecific.GetCount())
|
||||||
if listBoxSpecific.IsChecked(i)] + \
|
if listBoxSpecific.IsChecked(i)] + \
|
||||||
@@ -191,20 +190,20 @@ class ParamExStyle(ParamBinaryOr):
|
|||||||
class ParamColour(PPanel):
|
class ParamColour(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_TEXT_CTRL = wxNewId()
|
self.ID_TEXT_CTRL = wx.NewId()
|
||||||
self.ID_BUTTON = wxNewId()
|
self.ID_BUTTON = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(80,-1))
|
self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=(80,-1))
|
||||||
sizer.Add(self.text, 0, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, 2)
|
sizer.Add(self.text, 0, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2)
|
||||||
self.button = wxPanel(self, self.ID_BUTTON, wxDefaultPosition, wxSize(20, 20))
|
self.button = wx.Panel(self, self.ID_BUTTON, wx.DefaultPosition, wx.Size(20, 20))
|
||||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5)
|
sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 5)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
sizer.Fit(self)
|
||||||
self.textModified = False
|
self.textModified = False
|
||||||
EVT_PAINT(self.button, self.OnPaintButton)
|
wx.EVT_PAINT(self.button, self.OnPaintButton)
|
||||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||||
EVT_LEFT_DOWN(self.button, self.OnLeftDown)
|
wx.EVT_LEFT_DOWN(self.button, self.OnLeftDown)
|
||||||
def GetValue(self):
|
def GetValue(self):
|
||||||
return self.text.GetValue()
|
return self.text.GetValue()
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -212,24 +211,24 @@ class ParamColour(PPanel):
|
|||||||
if not value: value = '#FFFFFF'
|
if not value: value = '#FFFFFF'
|
||||||
self.text.SetValue(str(value)) # update text ctrl
|
self.text.SetValue(str(value)) # update text ctrl
|
||||||
try:
|
try:
|
||||||
colour = wxColour(int(value[1:3], 16), int(value[3:5], 16), int(value[5:7], 16))
|
colour = wx.Colour(int(value[1:3], 16), int(value[3:5], 16), int(value[5:7], 16))
|
||||||
self.button.SetBackgroundColour(colour)
|
self.button.SetBackgroundColour(colour)
|
||||||
except: # ignore errors
|
except: # ignore errors
|
||||||
pass
|
pass
|
||||||
self.button.Refresh()
|
self.button.Refresh()
|
||||||
self.freeze = False
|
self.freeze = False
|
||||||
def OnPaintButton(self, evt):
|
def OnPaintButton(self, evt):
|
||||||
dc = wxPaintDC(self.button)
|
dc = wx.PaintDC(self.button)
|
||||||
dc.SetBrush(wxTRANSPARENT_BRUSH)
|
dc.SetBrush(wx.TRANSPARENT_BRUSH)
|
||||||
if self.IsEnabled(): dc.SetPen(wxBLACK_PEN)
|
if self.IsEnabled(): dc.SetPen(wx.BLACK_PEN)
|
||||||
else: dc.SetPen(wxGREY_PEN)
|
else: dc.SetPen(wx.GREY_PEN)
|
||||||
size = self.button.GetSize()
|
size = self.button.GetSize()
|
||||||
dc.DrawRectangle(0, 0, size.width, size.height)
|
dc.DrawRectangle(0, 0, size.width, size.height)
|
||||||
def OnLeftDown(self, evt):
|
def OnLeftDown(self, evt):
|
||||||
data = wxColourData()
|
data = wx.ColourData()
|
||||||
data.SetColour(self.GetValue())
|
data.SetColour(self.GetValue())
|
||||||
dlg = wxColourDialog(self, data)
|
dlg = wx.ColourDialog(self, data)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get())
|
self.SetValue('#%02X%02X%02X' % dlg.GetColourData().GetColour().Get())
|
||||||
self.SetModified()
|
self.SetModified()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
@@ -237,11 +236,11 @@ class ParamColour(PPanel):
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Mapping from wx constants to XML strings
|
# Mapping from wx constants to XML strings
|
||||||
fontFamiliesWx2Xml = {wxDEFAULT: 'default', wxDECORATIVE: 'decorative',
|
fontFamiliesWx2Xml = {wx.DEFAULT: 'default', wx.DECORATIVE: 'decorative',
|
||||||
wxROMAN: 'roman', wxSCRIPT: 'script', wxSWISS: 'swiss',
|
wx.ROMAN: 'roman', wx.SCRIPT: 'script', wx.SWISS: 'swiss',
|
||||||
wxMODERN: 'modern'}
|
wx.MODERN: 'modern'}
|
||||||
fontStylesWx2Xml = {wxNORMAL: 'normal', wxSLANT: 'slant', wxITALIC: 'italic'}
|
fontStylesWx2Xml = {wx.NORMAL: 'normal', wx.SLANT: 'slant', wx.ITALIC: 'italic'}
|
||||||
fontWeightsWx2Xml = {wxNORMAL: 'normal', wxLIGHT: 'light', wxBOLD: 'bold'}
|
fontWeightsWx2Xml = {wx.NORMAL: 'normal', wx.LIGHT: 'light', wx.BOLD: 'bold'}
|
||||||
def ReverseMap(m):
|
def ReverseMap(m):
|
||||||
rm = {}
|
rm = {}
|
||||||
for k,v in m.items(): rm[v] = k
|
for k,v in m.items(): rm[v] = k
|
||||||
@@ -253,19 +252,19 @@ fontWeightsXml2wx = ReverseMap(fontWeightsWx2Xml)
|
|||||||
class ParamFont(PPanel):
|
class ParamFont(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_TEXT_CTRL = wxNewId()
|
self.ID_TEXT_CTRL = wx.NewId()
|
||||||
self.ID_BUTTON_SELECT = wxNewId()
|
self.ID_BUTTON_SELECT = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=(200,-1))
|
self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=(200,-1))
|
||||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||||
self.button = wxButton(self, self.ID_BUTTON_SELECT, 'Select...', size=buttonSize)
|
self.button = wx.Button(self, self.ID_BUTTON_SELECT, 'Select...', size=buttonSize)
|
||||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
sizer.Fit(self)
|
||||||
self.textModified = False
|
self.textModified = False
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_SELECT, self.OnButtonSelect)
|
||||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||||
def OnChange(self, evt):
|
def OnChange(self, evt):
|
||||||
PPanel.OnChange(self, evt)
|
PPanel.OnChange(self, evt)
|
||||||
self.textModified = True
|
self.textModified = True
|
||||||
@@ -276,7 +275,7 @@ class ParamFont(PPanel):
|
|||||||
try:
|
try:
|
||||||
return eval(self.text.GetValue())
|
return eval(self.text.GetValue())
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
wx.LogError('Syntax error in parameter value: ' + self.GetName())
|
||||||
return self._defaultValue()
|
return self._defaultValue()
|
||||||
return self.value
|
return self.value
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -290,48 +289,48 @@ class ParamFont(PPanel):
|
|||||||
try:
|
try:
|
||||||
self.value = eval(self.text.GetValue())
|
self.value = eval(self.text.GetValue())
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
wx.LogError('Syntax error in parameter value: ' + self.GetName())
|
||||||
self.value = self._defaultValue()
|
self.value = self._defaultValue()
|
||||||
# Make initial font
|
# Make initial font
|
||||||
# Default values
|
# Default values
|
||||||
size = g._sysFont.GetPointSize()
|
size = g._sysFont.GetPointSize()
|
||||||
family = wxDEFAULT
|
family = wx.DEFAULT
|
||||||
style = weight = wxNORMAL
|
style = weight = wx.NORMAL
|
||||||
underlined = 0
|
underlined = 0
|
||||||
face = ''
|
face = ''
|
||||||
enc = wxFONTENCODING_DEFAULT
|
enc = wx.FONTENCODING_DEFAULT
|
||||||
# Fall back to default if exceptions
|
# Fall back to default if exceptions
|
||||||
error = False
|
error = False
|
||||||
try:
|
try:
|
||||||
try: size = int(self.value[0])
|
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]]
|
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]]
|
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]]
|
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])
|
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]
|
face = self.value[5]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
error = True
|
error = True
|
||||||
mapper = wxFontMapper()
|
mapper = wx.FontMapper()
|
||||||
if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6])
|
if not self.value[6]: enc = mapper.CharsetToEncoding(self.value[6])
|
||||||
|
|
||||||
if error: wxLogError('Invalid font specification')
|
if error: wx.LogError('Invalid font specification')
|
||||||
if enc == wxFONTENCODING_DEFAULT: enc = wxFONTENCODING_SYSTEM
|
if enc == wx.FONTENCODING_DEFAULT: enc = wx.FONTENCODING_SYSTEM
|
||||||
font = wxFont(size, family, style, weight, underlined, face, enc)
|
font = wx.Font(size, family, style, weight, underlined, face, enc)
|
||||||
data = wxFontData()
|
data = wx.FontData()
|
||||||
data.SetInitialFont(font)
|
data.SetInitialFont(font)
|
||||||
dlg = wxFontDialog(self, data)
|
dlg = wx.FontDialog(self, data)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
font = dlg.GetFontData().GetChosenFont()
|
font = dlg.GetFontData().GetChosenFont()
|
||||||
print font.GetEncoding()
|
print font.GetEncoding()
|
||||||
if font.GetEncoding() == wxFONTENCODING_SYSTEM:
|
if font.GetEncoding() == wx.FONTENCODING_SYSTEM:
|
||||||
encName = ''
|
encName = ''
|
||||||
else:
|
else:
|
||||||
encName = wxFontMapper_GetEncodingName(font.GetEncoding()).encode()
|
encName = wx.FontMapper.GetEncodingName(font.GetEncoding()).encode()
|
||||||
value = [str(font.GetPointSize()),
|
value = [str(font.GetPointSize()),
|
||||||
fontFamiliesWx2Xml.get(font.GetFamily(), "default"),
|
fontFamiliesWx2Xml.get(font.GetFamily(), "default"),
|
||||||
fontStylesWx2Xml.get(font.GetStyle(), "normal"),
|
fontStylesWx2Xml.get(font.GetStyle(), "normal"),
|
||||||
@@ -350,15 +349,15 @@ class ParamFont(PPanel):
|
|||||||
class ParamInt(PPanel):
|
class ParamInt(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_SPIN_CTRL = wxNewId()
|
self.ID_SPIN_CTRL = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1))
|
self.spin = wx.SpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1))
|
||||||
self.spin.SetRange(-2147483648, 2147483647) # min/max integers
|
self.spin.SetRange(-2147483648, 2147483647) # min/max integers
|
||||||
sizer.Add(self.spin)
|
sizer.Add(self.spin)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
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):
|
def GetValue(self):
|
||||||
return str(self.spin.GetValue())
|
return str(self.spin.GetValue())
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -371,15 +370,15 @@ class ParamInt(PPanel):
|
|||||||
class ParamIntNN(PPanel):
|
class ParamIntNN(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_SPIN_CTRL = wxNewId()
|
self.ID_SPIN_CTRL = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.spin = wxSpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1))
|
self.spin = wx.SpinCtrl(self, self.ID_SPIN_CTRL, size=(60,-1))
|
||||||
self.spin.SetRange(0, 10000) # min/max integers
|
self.spin.SetRange(0, 10000) # min/max integers
|
||||||
sizer.Add(self.spin)
|
sizer.Add(self.spin)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
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):
|
def GetValue(self):
|
||||||
return str(self.spin.GetValue())
|
return str(self.spin.GetValue())
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -392,21 +391,21 @@ class ParamIntNN(PPanel):
|
|||||||
class ParamUnit(PPanel):
|
class ParamUnit(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_TEXT_CTRL = wxNewId()
|
self.ID_TEXT_CTRL = wx.NewId()
|
||||||
self.ID_SPIN_BUTTON = wxNewId()
|
self.ID_SPIN_BUTTON = wx.NewId()
|
||||||
sizer = wxBoxSizer(wxHORIZONTAL)
|
sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
self.spin = wxSpinButton(self, self.ID_SPIN_BUTTON, style = wxSP_VERTICAL, size=(-1,1))
|
self.spin = wx.SpinButton(self, self.ID_SPIN_BUTTON, style = wx.SP_VERTICAL, size=(-1,1))
|
||||||
textW = 60 - self.spin.GetSize()[0]
|
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)
|
self.spin.SetRange(-10000, 10000)
|
||||||
sizer.Add(self.text, 0, wxEXPAND)
|
sizer.Add(self.text, 0, wx.EXPAND)
|
||||||
sizer.Add(self.spin, 0, wxEXPAND)
|
sizer.Add(self.spin, 0, wx.EXPAND)
|
||||||
#sizer.SetMinSize((50,-1))
|
#sizer.SetMinSize((50,-1))
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
sizer.Fit(self)
|
||||||
EVT_SPIN_UP(self, self.ID_SPIN_BUTTON, self.OnSpinUp)
|
wx.EVT_SPIN_UP(self, self.ID_SPIN_BUTTON, self.OnSpinUp)
|
||||||
EVT_SPIN_DOWN(self, self.ID_SPIN_BUTTON, self.OnSpinDown)
|
wx.EVT_SPIN_DOWN(self, self.ID_SPIN_BUTTON, self.OnSpinDown)
|
||||||
def GetValue(self):
|
def GetValue(self):
|
||||||
return self.text.GetValue()
|
return self.text.GetValue()
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -427,7 +426,7 @@ class ParamUnit(PPanel):
|
|||||||
self.text.SetValue(str(intValue) + units)
|
self.text.SetValue(str(intValue) + units)
|
||||||
self.SetModified()
|
self.SetModified()
|
||||||
except:
|
except:
|
||||||
# !!! Strange, if I use wxLogWarning, event is re-generated
|
# !!! Strange, if I use wx.LogWarning, event is re-generated
|
||||||
print 'incorrect unit format'
|
print 'incorrect unit format'
|
||||||
def OnSpinUp(self, evt):
|
def OnSpinUp(self, evt):
|
||||||
self.Change(1)
|
self.Change(1)
|
||||||
@@ -437,18 +436,18 @@ class ParamUnit(PPanel):
|
|||||||
class ParamMultilineText(PPanel):
|
class ParamMultilineText(PPanel):
|
||||||
def __init__(self, parent, name, textWidth=-1):
|
def __init__(self, parent, name, textWidth=-1):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_TEXT_CTRL = wxNewId()
|
self.ID_TEXT_CTRL = wx.NewId()
|
||||||
self.ID_BUTTON_EDIT = wxNewId()
|
self.ID_BUTTON_EDIT = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1))
|
||||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||||
self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize)
|
self.button = wx.Button(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize)
|
||||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
sizer.Fit(self)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit)
|
||||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||||
def GetValue(self):
|
def GetValue(self):
|
||||||
return self.text.GetValue()
|
return self.text.GetValue()
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -457,9 +456,9 @@ class ParamMultilineText(PPanel):
|
|||||||
self.freeze = False # disable other handlers
|
self.freeze = False # disable other handlers
|
||||||
def OnButtonEdit(self, evt):
|
def OnButtonEdit(self, evt):
|
||||||
dlg = g.frame.res.LoadDialog(self, 'DIALOG_TEXT')
|
dlg = g.frame.res.LoadDialog(self, 'DIALOG_TEXT')
|
||||||
textCtrl = XRCCTRL(dlg, 'TEXT')
|
textCtrl = xrc.XRCCTRL(dlg, 'TEXT')
|
||||||
textCtrl.SetValue(self.text.GetValue())
|
textCtrl.SetValue(self.text.GetValue())
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
self.text.SetValue(textCtrl.GetValue())
|
self.text.SetValue(textCtrl.GetValue())
|
||||||
self.SetModified()
|
self.SetModified()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
@@ -467,17 +466,17 @@ class ParamMultilineText(PPanel):
|
|||||||
class ParamText(PPanel):
|
class ParamText(PPanel):
|
||||||
def __init__(self, parent, name, textWidth=-1):
|
def __init__(self, parent, name, textWidth=-1):
|
||||||
PPanel.__init__(self, parent, name)
|
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
|
# We use sizer even here to have the same size of text control
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(textWidth,-1))
|
self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(textWidth,-1))
|
||||||
if textWidth == -1: option = 1
|
if textWidth == -1: option = 1
|
||||||
else: option = 0
|
else: option = 0
|
||||||
sizer.Add(self.text, option, wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM, 2)
|
sizer.Add(self.text, option, wx.ALIGN_CENTER_VERTICAL | wx.TOP | wx.BOTTOM, 2)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
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):
|
def GetValue(self):
|
||||||
return self.text.GetValue()
|
return self.text.GetValue()
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -501,31 +500,30 @@ class ParamEncoding(ParamText):
|
|||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
ParamText.__init__(self, parent, name, 100)
|
ParamText.__init__(self, parent, name, 100)
|
||||||
|
|
||||||
class ContentDialog(wxDialog):
|
class ContentDialog(wx.Dialog):
|
||||||
def __init__(self, parent, value):
|
def __init__(self, parent, value):
|
||||||
# Load from resource
|
# Load from resource
|
||||||
pre = wxPreDialog()
|
pre = wx.PreDialog()
|
||||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT')
|
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT')
|
||||||
self.this = pre.this
|
self.PostCreate(pre)
|
||||||
self._setOORInfo(self)
|
self.list = xrc.XRCCTRL(self, 'LIST')
|
||||||
self.list = XRCCTRL(self, 'LIST')
|
|
||||||
# Set list items
|
# Set list items
|
||||||
for v in value:
|
for v in value:
|
||||||
self.list.Append(v)
|
self.list.Append(v)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.GetSizer().Fit(self)
|
self.GetSizer().Fit(self)
|
||||||
# Callbacks
|
# Callbacks
|
||||||
self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND')
|
self.ID_BUTTON_APPEND = xrc.XRCID('BUTTON_APPEND')
|
||||||
self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
|
self.ID_BUTTON_REMOVE = xrc.XRCID('BUTTON_REMOVE')
|
||||||
self.ID_BUTTON_UP = XRCID('BUTTON_UP')
|
self.ID_BUTTON_UP = xrc.XRCID('BUTTON_UP')
|
||||||
self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN')
|
self.ID_BUTTON_DOWN = xrc.XRCID('BUTTON_DOWN')
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
||||||
EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
||||||
def OnButtonUp(self, evt):
|
def OnButtonUp(self, evt):
|
||||||
i = self.list.GetSelection()
|
i = self.list.GetSelection()
|
||||||
str = self.list.GetString(i)
|
str = self.list.GetString(i)
|
||||||
@@ -539,7 +537,7 @@ class ContentDialog(wxDialog):
|
|||||||
self.list.InsertItems([str], i+1)
|
self.list.InsertItems([str], i+1)
|
||||||
self.list.SetSelection(i+1)
|
self.list.SetSelection(i+1)
|
||||||
def OnButtonAppend(self, evt):
|
def OnButtonAppend(self, evt):
|
||||||
str = wxGetTextFromUser('Enter new item:', 'Append', '', self)
|
str = wx.GetTextFromUser('Enter new item:', 'Append', '', self)
|
||||||
self.list.Append(str)
|
self.list.Append(str)
|
||||||
def OnButtonRemove(self, evt):
|
def OnButtonRemove(self, evt):
|
||||||
self.list.Delete(self.list.GetSelection())
|
self.list.Delete(self.list.GetSelection())
|
||||||
@@ -552,13 +550,12 @@ class ContentDialog(wxDialog):
|
|||||||
evt.Enable(self.list.GetSelection() != -1 and \
|
evt.Enable(self.list.GetSelection() != -1 and \
|
||||||
self.list.GetSelection() < self.list.GetCount() - 1)
|
self.list.GetSelection() < self.list.GetCount() - 1)
|
||||||
|
|
||||||
class ContentCheckListDialog(wxDialog):
|
class ContentCheckListDialog(wx.Dialog):
|
||||||
def __init__(self, parent, value):
|
def __init__(self, parent, value):
|
||||||
pre = wxPreDialog()
|
pre = wx.PreDialog()
|
||||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECKLIST')
|
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECKLIST')
|
||||||
self.this = pre.this
|
self.PostCreate(pre)
|
||||||
self._setOORInfo(self)
|
self.list = xrc.XRCCTRL(self, 'CHECKLIST')
|
||||||
self.list = XRCCTRL(self, 'CHECKLIST')
|
|
||||||
# Set list items
|
# Set list items
|
||||||
i = 0
|
i = 0
|
||||||
for v,ch in value:
|
for v,ch in value:
|
||||||
@@ -568,18 +565,18 @@ class ContentCheckListDialog(wxDialog):
|
|||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.GetSizer().Fit(self)
|
self.GetSizer().Fit(self)
|
||||||
# Callbacks
|
# Callbacks
|
||||||
self.ID_BUTTON_APPEND = XRCID('BUTTON_APPEND')
|
self.ID_BUTTON_APPEND = xrc.XRCID('BUTTON_APPEND')
|
||||||
self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
|
self.ID_BUTTON_REMOVE = xrc.XRCID('BUTTON_REMOVE')
|
||||||
self.ID_BUTTON_UP = XRCID('BUTTON_UP')
|
self.ID_BUTTON_UP = xrc.XRCID('BUTTON_UP')
|
||||||
self.ID_BUTTON_DOWN = XRCID('BUTTON_DOWN')
|
self.ID_BUTTON_DOWN = xrc.XRCID('BUTTON_DOWN')
|
||||||
EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck)
|
wx.EVT_CHECKLISTBOX(self, self.list.GetId(), self.OnCheck)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_UP, self.OnButtonUp)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_DOWN, self.OnButtonDown)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_APPEND, self.OnButtonAppend)
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
||||||
EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_BUTTON_UP, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_BUTTON_DOWN, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
||||||
def OnCheck(self, evt):
|
def OnCheck(self, evt):
|
||||||
# !!! Wrong wxGTK (wxMSW?) behavior: toggling selection if checking
|
# !!! Wrong wxGTK (wxMSW?) behavior: toggling selection if checking
|
||||||
self.list.Deselect(evt.GetSelection())
|
self.list.Deselect(evt.GetSelection())
|
||||||
@@ -598,7 +595,7 @@ class ContentCheckListDialog(wxDialog):
|
|||||||
self.list.Check(i+1, ch)
|
self.list.Check(i+1, ch)
|
||||||
self.list.SetSelection(i+1)
|
self.list.SetSelection(i+1)
|
||||||
def OnButtonAppend(self, evt):
|
def OnButtonAppend(self, evt):
|
||||||
str = wxGetTextFromUser('Enter new item:', 'Append', '', self)
|
str = wx.GetTextFromUser('Enter new item:', 'Append', '', self)
|
||||||
self.list.Append(str)
|
self.list.Append(str)
|
||||||
def OnButtonRemove(self, evt):
|
def OnButtonRemove(self, evt):
|
||||||
self.list.Delete(self.list.GetSelection())
|
self.list.Delete(self.list.GetSelection())
|
||||||
@@ -614,19 +611,19 @@ class ContentCheckListDialog(wxDialog):
|
|||||||
class ParamContent(PPanel):
|
class ParamContent(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_TEXT_CTRL = wxNewId()
|
self.ID_TEXT_CTRL = wx.NewId()
|
||||||
self.ID_BUTTON_EDIT = wxNewId()
|
self.ID_BUTTON_EDIT = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1))
|
||||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||||
self.button = wxButton(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize)
|
self.button = wx.Button(self, self.ID_BUTTON_EDIT, 'Edit...', size=buttonSize)
|
||||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
sizer.Fit(self)
|
||||||
self.textModified = False
|
self.textModified = False
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_EDIT, self.OnButtonEdit)
|
||||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||||
def OnChange(self, evt):
|
def OnChange(self, evt):
|
||||||
PPanel.OnChange(self, evt)
|
PPanel.OnChange(self, evt)
|
||||||
self.textModified = True
|
self.textModified = True
|
||||||
@@ -635,7 +632,7 @@ class ParamContent(PPanel):
|
|||||||
try:
|
try:
|
||||||
return eval(self.text.GetValue())
|
return eval(self.text.GetValue())
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
wx.LogError('Syntax error in parameter value: ' + self.GetName())
|
||||||
return []
|
return []
|
||||||
return self.value
|
return self.value
|
||||||
def SetValue(self, value):
|
def SetValue(self, value):
|
||||||
@@ -649,10 +646,10 @@ class ParamContent(PPanel):
|
|||||||
try:
|
try:
|
||||||
self.value = eval(self.text.GetValue())
|
self.value = eval(self.text.GetValue())
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
wx.LogError('Syntax error in parameter value: ' + self.GetName())
|
||||||
self.value = []
|
self.value = []
|
||||||
dlg = ContentDialog(self, self.value)
|
dlg = ContentDialog(self, self.value)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
value = []
|
value = []
|
||||||
for i in range(dlg.list.GetCount()):
|
for i in range(dlg.list.GetCount()):
|
||||||
value.append(dlg.list.GetString(i))
|
value.append(dlg.list.GetString(i))
|
||||||
@@ -670,10 +667,10 @@ class ParamContentCheckList(ParamContent):
|
|||||||
try:
|
try:
|
||||||
self.value = eval(self.text.GetValue())
|
self.value = eval(self.text.GetValue())
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
wx.LogError('Syntax error in parameter value: ' + self.GetName())
|
||||||
self.value = []
|
self.value = []
|
||||||
dlg = ContentCheckListDialog(self, self.value)
|
dlg = ContentCheckListDialog(self, self.value)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
value = []
|
value = []
|
||||||
for i in range(dlg.list.GetCount()):
|
for i in range(dlg.list.GetCount()):
|
||||||
value.append((dlg.list.GetString(i), int(dlg.list.IsChecked(i))))
|
value.append((dlg.list.GetString(i), int(dlg.list.IsChecked(i))))
|
||||||
@@ -682,29 +679,28 @@ class ParamContentCheckList(ParamContent):
|
|||||||
self.textModified = False
|
self.textModified = False
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
class IntListDialog(wxDialog):
|
class IntListDialog(wx.Dialog):
|
||||||
def __init__(self, parent, value):
|
def __init__(self, parent, value):
|
||||||
pre = wxPreDialog()
|
pre = wx.PreDialog()
|
||||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_INTLIST')
|
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_INTLIST')
|
||||||
self.this = pre.this
|
self.PostCreate(pre)
|
||||||
self._setOORInfo(self)
|
self.list = xrc.XRCCTRL(self, 'LIST')
|
||||||
self.list = XRCCTRL(self, 'LIST')
|
|
||||||
# Set list items
|
# Set list items
|
||||||
value.sort()
|
value.sort()
|
||||||
for v in value:
|
for v in value:
|
||||||
if type(v) != IntType:
|
if type(v) != IntType:
|
||||||
wxLogError('Invalid item type')
|
wx.LogError('Invalid item type')
|
||||||
else:
|
else:
|
||||||
self.list.Append(str(v))
|
self.list.Append(str(v))
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.GetSizer().Fit(self)
|
self.GetSizer().Fit(self)
|
||||||
# Callbacks
|
# Callbacks
|
||||||
self.spinCtrl = XRCCTRL(self, 'SPIN')
|
self.spinCtrl = xrc.XRCCTRL(self, 'SPIN')
|
||||||
EVT_BUTTON(self, XRCID('BUTTON_ADD'), self.OnButtonAdd)
|
wx.EVT_BUTTON(self, xrc.XRCID('BUTTON_ADD'), self.OnButtonAdd)
|
||||||
self.ID_BUTTON_REMOVE = XRCID('BUTTON_REMOVE')
|
self.ID_BUTTON_REMOVE = xrc.XRCID('BUTTON_REMOVE')
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_REMOVE, self.OnButtonRemove)
|
||||||
EVT_BUTTON(self, XRCID('BUTTON_CLEAR'), self.OnButtonClear)
|
wx.EVT_BUTTON(self, xrc.XRCID('BUTTON_CLEAR'), self.OnButtonClear)
|
||||||
EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_BUTTON_REMOVE, self.OnUpdateUI)
|
||||||
def OnButtonAdd(self, evt):
|
def OnButtonAdd(self, evt):
|
||||||
# Check that it's unique
|
# Check that it's unique
|
||||||
try:
|
try:
|
||||||
@@ -721,7 +717,7 @@ class IntListDialog(wxDialog):
|
|||||||
if found: self.list.InsertItems([s], i)
|
if found: self.list.InsertItems([s], i)
|
||||||
else: self.list.Append(s)
|
else: self.list.Append(s)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
wxLogError('List item is not an int!')
|
wx.LogError('List item is not an int!')
|
||||||
def OnButtonRemove(self, evt):
|
def OnButtonRemove(self, evt):
|
||||||
self.list.Delete(self.list.GetSelection())
|
self.list.Delete(self.list.GetSelection())
|
||||||
def OnButtonClear(self, evt):
|
def OnButtonClear(self, evt):
|
||||||
@@ -739,10 +735,10 @@ class ParamIntList(ParamContent):
|
|||||||
try:
|
try:
|
||||||
self.value = eval(self.text.GetValue())
|
self.value = eval(self.text.GetValue())
|
||||||
except SyntaxError:
|
except SyntaxError:
|
||||||
wxLogError('Syntax error in parameter value: ' + self.GetName())
|
wx.LogError('Syntax error in parameter value: ' + self.GetName())
|
||||||
self.value = []
|
self.value = []
|
||||||
dlg = IntListDialog(self, self.value)
|
dlg = IntListDialog(self, self.value)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
value = []
|
value = []
|
||||||
for i in range(dlg.list.GetCount()):
|
for i in range(dlg.list.GetCount()):
|
||||||
value.append(int(dlg.list.GetString(i)))
|
value.append(int(dlg.list.GetString(i)))
|
||||||
@@ -754,14 +750,14 @@ class ParamIntList(ParamContent):
|
|||||||
# Boxless radiobox
|
# Boxless radiobox
|
||||||
class RadioBox(PPanel):
|
class RadioBox(PPanel):
|
||||||
def __init__(self, parent, id, choices,
|
def __init__(self, parent, id, choices,
|
||||||
pos=wxDefaultPosition, name='radiobox'):
|
pos=wx.DefaultPosition, name='radiobox'):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.choices = choices
|
self.choices = choices
|
||||||
topSizer = wxBoxSizer()
|
topSizer = wx.BoxSizer()
|
||||||
for i in choices:
|
for i in choices:
|
||||||
button = wxRadioButton(self, -1, i, size=(-1,buttonSize[1]), name=i)
|
button = wx.RadioButton(self, -1, i, size=(-1,buttonSize[1]), name=i)
|
||||||
topSizer.Add(button, 0, wxRIGHT, 5)
|
topSizer.Add(button, 0, wx.RIGHT, 5)
|
||||||
EVT_RADIOBUTTON(self, button.GetId(), self.OnRadioChoice)
|
wx.EVT_RADIOBUTTON(self, button.GetId(), self.OnRadioChoice)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(topSizer)
|
self.SetSizer(topSizer)
|
||||||
topSizer.Fit(self)
|
topSizer.Fit(self)
|
||||||
@@ -815,19 +811,19 @@ class ParamOrientation(RadioBox):
|
|||||||
class ParamFile(PPanel):
|
class ParamFile(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
PPanel.__init__(self, parent, name)
|
PPanel.__init__(self, parent, name)
|
||||||
self.ID_TEXT_CTRL = wxNewId()
|
self.ID_TEXT_CTRL = wx.NewId()
|
||||||
self.ID_BUTTON_BROWSE = wxNewId()
|
self.ID_BUTTON_BROWSE = wx.NewId()
|
||||||
sizer = wxBoxSizer()
|
sizer = wx.BoxSizer()
|
||||||
self.text = wxTextCtrl(self, self.ID_TEXT_CTRL, size=wxSize(200,-1))
|
self.text = wx.TextCtrl(self, self.ID_TEXT_CTRL, size=wx.Size(200,-1))
|
||||||
sizer.Add(self.text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5)
|
sizer.Add(self.text, 0, wx.RIGHT | wx.ALIGN_CENTER_VERTICAL, 5)
|
||||||
self.button = wxButton(self, self.ID_BUTTON_BROWSE, 'Browse...',size=buttonSize)
|
self.button = wx.Button(self, self.ID_BUTTON_BROWSE, 'Browse...',size=buttonSize)
|
||||||
sizer.Add(self.button, 0, wxALIGN_CENTER_VERTICAL)
|
sizer.Add(self.button, 0, wx.ALIGN_CENTER_VERTICAL)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
sizer.Fit(self)
|
sizer.Fit(self)
|
||||||
self.textModified = False
|
self.textModified = False
|
||||||
EVT_BUTTON(self, self.ID_BUTTON_BROWSE, self.OnButtonBrowse)
|
wx.EVT_BUTTON(self, self.ID_BUTTON_BROWSE, self.OnButtonBrowse)
|
||||||
EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
wx.EVT_TEXT(self, self.ID_TEXT_CTRL, self.OnChange)
|
||||||
def OnChange(self, evt):
|
def OnChange(self, evt):
|
||||||
PPanel.OnChange(self, evt)
|
PPanel.OnChange(self, evt)
|
||||||
self.textModified = True
|
self.textModified = True
|
||||||
@@ -843,10 +839,10 @@ class ParamFile(PPanel):
|
|||||||
def OnButtonBrowse(self, evt):
|
def OnButtonBrowse(self, evt):
|
||||||
if self.textModified: # text has newer value
|
if self.textModified: # text has newer value
|
||||||
self.value = self.text.GetValue()
|
self.value = self.text.GetValue()
|
||||||
dlg = wxFileDialog(self,
|
dlg = wx.FileDialog(self,
|
||||||
defaultDir = os.path.abspath(os.path.dirname(self.value)),
|
defaultDir = os.path.abspath(os.path.dirname(self.value)),
|
||||||
defaultFile = os.path.basename(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
|
# Get common part of selected path and current
|
||||||
if g.frame.dataFile:
|
if g.frame.dataFile:
|
||||||
curpath = os.path.abspath(g.frame.dataFile)
|
curpath = os.path.abspath(g.frame.dataFile)
|
||||||
@@ -860,26 +856,25 @@ class ParamFile(PPanel):
|
|||||||
|
|
||||||
class ParamBitmap(PPanel):
|
class ParamBitmap(PPanel):
|
||||||
def __init__(self, parent, name):
|
def __init__(self, parent, name):
|
||||||
pre = wxPrePanel()
|
pre = wx.PrePanel()
|
||||||
g.frame.res.LoadOnPanel(pre, parent, 'PANEL_BITMAP')
|
g.frame.res.LoadOnPanel(pre, parent, 'PANEL_BITMAP')
|
||||||
self.this = pre.this
|
self.PostCreate(pre)
|
||||||
self._setOORInfo(self)
|
|
||||||
self.modified = self.freeze = False
|
self.modified = self.freeze = False
|
||||||
self.radio_std = XRCCTRL(self, 'RADIO_STD')
|
self.radio_std = xrc.XRCCTRL(self, 'RADIO_STD')
|
||||||
self.radio_file = XRCCTRL(self, 'RADIO_FILE')
|
self.radio_file = xrc.XRCCTRL(self, 'RADIO_FILE')
|
||||||
self.combo = XRCCTRL(self, 'COMBO_STD')
|
self.combo = xrc.XRCCTRL(self, 'COMBO_STD')
|
||||||
self.text = XRCCTRL(self, 'TEXT_FILE')
|
self.text = xrc.XRCCTRL(self, 'TEXT_FILE')
|
||||||
self.button = XRCCTRL(self, 'BUTTON_BROWSE')
|
self.button = xrc.XRCCTRL(self, 'BUTTON_BROWSE')
|
||||||
self.textModified = False
|
self.textModified = False
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.GetSizer().SetMinSize((260, -1))
|
self.GetSizer().SetMinSize((260, -1))
|
||||||
self.GetSizer().Fit(self)
|
self.GetSizer().Fit(self)
|
||||||
EVT_RADIOBUTTON(self, XRCID('RADIO_STD'), self.OnRadioStd)
|
wx.EVT_RADIOBUTTON(self, xrc.XRCID('RADIO_STD'), self.OnRadioStd)
|
||||||
EVT_RADIOBUTTON(self, XRCID('RADIO_FILE'), self.OnRadioFile)
|
wx.EVT_RADIOBUTTON(self, xrc.XRCID('RADIO_FILE'), self.OnRadioFile)
|
||||||
EVT_BUTTON(self, XRCID('BUTTON_BROWSE'), self.OnButtonBrowse)
|
wx.EVT_BUTTON(self, xrc.XRCID('BUTTON_BROWSE'), self.OnButtonBrowse)
|
||||||
EVT_COMBOBOX(self, XRCID('COMBO_STD'), self.OnCombo)
|
wx.EVT_COMBOBOX(self, xrc.XRCID('COMBO_STD'), self.OnCombo)
|
||||||
EVT_TEXT(self, XRCID('COMBO_STD'), self.OnChange)
|
wx.EVT_TEXT(self, xrc.XRCID('COMBO_STD'), self.OnChange)
|
||||||
EVT_TEXT(self, XRCID('TEXT_FILE'), self.OnChange)
|
wx.EVT_TEXT(self, xrc.XRCID('TEXT_FILE'), self.OnChange)
|
||||||
def OnRadioStd(self, evt):
|
def OnRadioStd(self, evt):
|
||||||
self.SetModified()
|
self.SetModified()
|
||||||
self.SetValue(['wxART_MISSING_IMAGE',''])
|
self.SetValue(['wxART_MISSING_IMAGE',''])
|
||||||
@@ -922,10 +917,10 @@ class ParamBitmap(PPanel):
|
|||||||
def OnButtonBrowse(self, evt):
|
def OnButtonBrowse(self, evt):
|
||||||
if self.textModified: # text has newer value
|
if self.textModified: # text has newer value
|
||||||
self.value[1] = self.text.GetValue()
|
self.value[1] = self.text.GetValue()
|
||||||
dlg = wxFileDialog(self,
|
dlg = wx.FileDialog(self,
|
||||||
defaultDir = os.path.abspath(os.path.dirname(self.value[1])),
|
defaultDir = os.path.abspath(os.path.dirname(self.value[1])),
|
||||||
defaultFile = os.path.basename(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
|
# Get common part of selected path and current
|
||||||
if g.frame.dataFile:
|
if g.frame.dataFile:
|
||||||
curpath = os.path.abspath(g.frame.dataFile)
|
curpath = os.path.abspath(g.frame.dataFile)
|
||||||
|
@@ -18,16 +18,16 @@ GROUP_WINDOWS, GROUP_MENUS, GROUP_SIZERS, GROUP_CONTROLS = range(GROUPNUM)
|
|||||||
STATE_ROOT, STATE_MENUBAR, STATE_TOOLBAR, STATE_MENU, STATE_STDDLGBTN, STATE_ELSE = range(6)
|
STATE_ROOT, STATE_MENUBAR, STATE_TOOLBAR, STATE_MENU, STATE_STDDLGBTN, STATE_ELSE = range(6)
|
||||||
|
|
||||||
# Left toolbar for GUI elements
|
# Left toolbar for GUI elements
|
||||||
class Tools(wxPanel):
|
class Tools(wx.Panel):
|
||||||
TOOL_SIZE = (30, 30)
|
TOOL_SIZE = (30, 30)
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
if wxPlatform == '__WXGTK__':
|
if wx.Platform == '__WXGTK__':
|
||||||
wxPanel.__init__(self, parent, -1,
|
wx.Panel.__init__(self, parent, -1,
|
||||||
style=wxRAISED_BORDER|wxWANTS_CHARS)
|
style=wx.RAISED_BORDER|wx.WANTS_CHARS)
|
||||||
else:
|
else:
|
||||||
wxPanel.__init__(self, parent, -1, style=wxWANTS_CHARS)
|
wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS)
|
||||||
# Create sizer for groups
|
# Create sizer for groups
|
||||||
self.sizer = wxBoxSizer(wxVERTICAL)
|
self.sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
# Data to create buttons
|
# Data to create buttons
|
||||||
pullDownMenu = g.pullDownMenu
|
pullDownMenu = g.pullDownMenu
|
||||||
self.groups = []
|
self.groups = []
|
||||||
@@ -96,31 +96,31 @@ class Tools(wxPanel):
|
|||||||
# Allow to be resized in vertical direction only
|
# Allow to be resized in vertical direction only
|
||||||
self.SetSizeHints(self.GetSize()[0], -1)
|
self.SetSizeHints(self.GetSize()[0], -1)
|
||||||
# Events
|
# Events
|
||||||
EVT_COMMAND_RANGE(self, ID_NEW.PANEL, ID_NEW.LAST,
|
wx.EVT_COMMAND_RANGE(self, ID_NEW.PANEL, ID_NEW.LAST,
|
||||||
wxEVT_COMMAND_BUTTON_CLICKED, g.frame.OnCreate)
|
wx.wxEVT_COMMAND_BUTTON_CLICKED, g.frame.OnCreate)
|
||||||
EVT_KEY_DOWN(self, self.OnKeyDown)
|
wx.EVT_KEY_DOWN(self, self.OnKeyDown)
|
||||||
EVT_KEY_UP(self, self.OnKeyUp)
|
wx.EVT_KEY_UP(self, self.OnKeyUp)
|
||||||
|
|
||||||
def AddButton(self, id, image, text):
|
def AddButton(self, id, image, text):
|
||||||
from wxPython.lib import buttons
|
from wx.lib import buttons
|
||||||
button = buttons.wxGenBitmapButton(self, id, image, size=self.TOOL_SIZE,
|
button = buttons.GenBitmapButton(self, id, image, size=self.TOOL_SIZE,
|
||||||
style=wxNO_BORDER|wxWANTS_CHARS)
|
style=wx.NO_BORDER|wx.WANTS_CHARS)
|
||||||
button.SetBezelWidth(0)
|
button.SetBezelWidth(0)
|
||||||
EVT_KEY_DOWN(button, self.OnKeyDown)
|
wx.EVT_KEY_DOWN(button, self.OnKeyDown)
|
||||||
EVT_KEY_UP(button, self.OnKeyUp)
|
wx.EVT_KEY_UP(button, self.OnKeyUp)
|
||||||
button.SetToolTipString(text)
|
button.SetToolTipString(text)
|
||||||
self.curSizer.Add(button)
|
self.curSizer.Add(button)
|
||||||
self.groups[-1][1][id] = button
|
self.groups[-1][1][id] = button
|
||||||
|
|
||||||
def AddGroup(self, name):
|
def AddGroup(self, name):
|
||||||
# Each group is inside box
|
# Each group is inside box
|
||||||
box = wxStaticBox(self, -1, name, style=wxWANTS_CHARS)
|
box = wx.StaticBox(self, -1, name, style=wx.WANTS_CHARS)
|
||||||
box.SetFont(g.smallerFont())
|
box.SetFont(g.smallerFont())
|
||||||
boxSizer = wxStaticBoxSizer(box, wxVERTICAL)
|
boxSizer = wx.StaticBoxSizer(box, wx.VERTICAL)
|
||||||
boxSizer.Add((0, 4))
|
boxSizer.Add((0, 4))
|
||||||
self.curSizer = wxGridSizer(0, 3)
|
self.curSizer = wx.GridSizer(0, 3)
|
||||||
boxSizer.Add(self.curSizer)
|
boxSizer.Add(self.curSizer)
|
||||||
self.sizer.Add(boxSizer, 0, wxTOP | wxLEFT | wxRIGHT, 4)
|
self.sizer.Add(boxSizer, 0, wx.TOP | wx.LEFT | wx.RIGHT, 4)
|
||||||
self.groups.append((box,{}))
|
self.groups.append((box,{}))
|
||||||
|
|
||||||
# Enable/disable group
|
# Enable/disable group
|
||||||
@@ -142,17 +142,17 @@ class Tools(wxPanel):
|
|||||||
|
|
||||||
# Process key events
|
# Process key events
|
||||||
def OnKeyDown(self, evt):
|
def OnKeyDown(self, evt):
|
||||||
if evt.GetKeyCode() == WXK_CONTROL:
|
if evt.GetKeyCode() == wx.WXK_CONTROL:
|
||||||
g.tree.ctrl = True
|
g.tree.ctrl = True
|
||||||
elif evt.GetKeyCode() == WXK_SHIFT:
|
elif evt.GetKeyCode() == wx.WXK_SHIFT:
|
||||||
g.tree.shift = True
|
g.tree.shift = True
|
||||||
self.UpdateIfNeeded()
|
self.UpdateIfNeeded()
|
||||||
evt.Skip()
|
evt.Skip()
|
||||||
|
|
||||||
def OnKeyUp(self, evt):
|
def OnKeyUp(self, evt):
|
||||||
if evt.GetKeyCode() == WXK_CONTROL:
|
if evt.GetKeyCode() == wx.WXK_CONTROL:
|
||||||
g.tree.ctrl = False
|
g.tree.ctrl = False
|
||||||
elif evt.GetKeyCode() == WXK_SHIFT:
|
elif evt.GetKeyCode() == wx.WXK_SHIFT:
|
||||||
g.tree.shift = False
|
g.tree.shift = False
|
||||||
self.UpdateIfNeeded()
|
self.UpdateIfNeeded()
|
||||||
evt.Skip()
|
evt.Skip()
|
||||||
|
@@ -22,14 +22,14 @@ class MemoryFile:
|
|||||||
if g.currentEncoding:
|
if g.currentEncoding:
|
||||||
encoding = g.currentEncoding
|
encoding = g.currentEncoding
|
||||||
else:
|
else:
|
||||||
encoding = wxGetDefaultPyEncoding()
|
encoding = wx.GetDefaultPyEncoding()
|
||||||
try:
|
try:
|
||||||
self.buffer += data.encode(encoding)
|
self.buffer += data.encode(encoding)
|
||||||
except UnicodeEncodeError:
|
except UnicodeEncodeError:
|
||||||
self.buffer += data.encode(encoding, 'xmlcharrefreplace')
|
self.buffer += data.encode(encoding, 'xmlcharrefreplace')
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
wxMemoryFSHandler_AddFile(self.name, self.buffer)
|
wx.MemoryFSHandler.AddFile(self.name, self.buffer)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
@@ -49,103 +49,103 @@ class MyDocument(minidom.Document):
|
|||||||
|
|
||||||
# Ids for menu commands
|
# Ids for menu commands
|
||||||
class ID_NEW:
|
class ID_NEW:
|
||||||
PANEL = wxNewId()
|
PANEL = wx.NewId()
|
||||||
DIALOG = wxNewId()
|
DIALOG = wx.NewId()
|
||||||
FRAME = wxNewId()
|
FRAME = wx.NewId()
|
||||||
TOOL_BAR = wxNewId()
|
TOOL_BAR = wx.NewId()
|
||||||
TOOL = wxNewId()
|
TOOL = wx.NewId()
|
||||||
MENU_BAR = wxNewId()
|
MENU_BAR = wx.NewId()
|
||||||
MENU = wxNewId()
|
MENU = wx.NewId()
|
||||||
STATUS_BAR = wxNewId()
|
STATUS_BAR = wx.NewId()
|
||||||
|
|
||||||
STATIC_TEXT = wxNewId()
|
STATIC_TEXT = wx.NewId()
|
||||||
TEXT_CTRL = wxNewId()
|
TEXT_CTRL = wx.NewId()
|
||||||
|
|
||||||
BUTTON = wxNewId()
|
BUTTON = wx.NewId()
|
||||||
BITMAP_BUTTON = wxNewId()
|
BITMAP_BUTTON = wx.NewId()
|
||||||
RADIO_BUTTON = wxNewId()
|
RADIO_BUTTON = wx.NewId()
|
||||||
SPIN_BUTTON = wxNewId()
|
SPIN_BUTTON = wx.NewId()
|
||||||
TOGGLE_BUTTON = wxNewId()
|
TOGGLE_BUTTON = wx.NewId()
|
||||||
|
|
||||||
STATIC_BOX = wxNewId()
|
STATIC_BOX = wx.NewId()
|
||||||
CHECK_BOX = wxNewId()
|
CHECK_BOX = wx.NewId()
|
||||||
RADIO_BOX = wxNewId()
|
RADIO_BOX = wx.NewId()
|
||||||
COMBO_BOX = wxNewId()
|
COMBO_BOX = wx.NewId()
|
||||||
LIST_BOX = wxNewId()
|
LIST_BOX = wx.NewId()
|
||||||
|
|
||||||
STATIC_LINE = wxNewId()
|
STATIC_LINE = wx.NewId()
|
||||||
STATIC_BITMAP = wxNewId()
|
STATIC_BITMAP = wx.NewId()
|
||||||
CHOICE = wxNewId()
|
CHOICE = wx.NewId()
|
||||||
SLIDER = wxNewId()
|
SLIDER = wx.NewId()
|
||||||
GAUGE = wxNewId()
|
GAUGE = wx.NewId()
|
||||||
SCROLL_BAR = wxNewId()
|
SCROLL_BAR = wx.NewId()
|
||||||
TREE_CTRL = wxNewId()
|
TREE_CTRL = wx.NewId()
|
||||||
LIST_CTRL = wxNewId()
|
LIST_CTRL = wx.NewId()
|
||||||
CHECK_LIST = wxNewId()
|
CHECK_LIST = wx.NewId()
|
||||||
NOTEBOOK = wxNewId()
|
NOTEBOOK = wx.NewId()
|
||||||
CHOICEBOOK = wxNewId()
|
CHOICEBOOK = wx.NewId()
|
||||||
LISTBOOK = wxNewId()
|
LISTBOOK = wx.NewId()
|
||||||
SPLITTER_WINDOW = wxNewId()
|
SPLITTER_WINDOW = wx.NewId()
|
||||||
SCROLLED_WINDOW = wxNewId()
|
SCROLLED_WINDOW = wx.NewId()
|
||||||
HTML_WINDOW = wxNewId()
|
HTML_WINDOW = wx.NewId()
|
||||||
CALENDAR_CTRL = wxNewId()
|
CALENDAR_CTRL = wx.NewId()
|
||||||
DATE_CTRL = wxNewId()
|
DATE_CTRL = wx.NewId()
|
||||||
GENERIC_DIR_CTRL = wxNewId()
|
GENERIC_DIR_CTRL = wx.NewId()
|
||||||
SPIN_CTRL = wxNewId()
|
SPIN_CTRL = wx.NewId()
|
||||||
UNKNOWN = wxNewId()
|
UNKNOWN = wx.NewId()
|
||||||
WIZARD = wxNewId()
|
WIZARD = wx.NewId()
|
||||||
WIZARD_PAGE = wxNewId()
|
WIZARD_PAGE = wx.NewId()
|
||||||
WIZARD_PAGE_SIMPLE = wxNewId()
|
WIZARD_PAGE_SIMPLE = wx.NewId()
|
||||||
BITMAP = wxNewId()
|
BITMAP = wx.NewId()
|
||||||
ICON = wxNewId()
|
ICON = wx.NewId()
|
||||||
STATUS_BAR = wxNewId()
|
STATUS_BAR = wx.NewId()
|
||||||
|
|
||||||
BOX_SIZER = wxNewId()
|
BOX_SIZER = wx.NewId()
|
||||||
STATIC_BOX_SIZER = wxNewId()
|
STATIC_BOX_SIZER = wx.NewId()
|
||||||
GRID_SIZER = wxNewId()
|
GRID_SIZER = wx.NewId()
|
||||||
FLEX_GRID_SIZER = wxNewId()
|
FLEX_GRID_SIZER = wx.NewId()
|
||||||
GRID_BAG_SIZER = wxNewId()
|
GRID_BAG_SIZER = wx.NewId()
|
||||||
STD_DIALOG_BUTTON_SIZER = wxNewId()
|
STD_DIALOG_BUTTON_SIZER = wx.NewId()
|
||||||
SPACER = wxNewId()
|
SPACER = wx.NewId()
|
||||||
|
|
||||||
TOOL_BAR = wxNewId()
|
TOOL_BAR = wx.NewId()
|
||||||
TOOL = wxNewId()
|
TOOL = wx.NewId()
|
||||||
MENU = wxNewId()
|
MENU = wx.NewId()
|
||||||
MENU_ITEM = wxNewId()
|
MENU_ITEM = wx.NewId()
|
||||||
SEPARATOR = wxNewId()
|
SEPARATOR = wx.NewId()
|
||||||
|
|
||||||
OK_BUTTON = wxNewId()
|
OK_BUTTON = wx.NewId()
|
||||||
YES_BUTTON = wxNewId()
|
YES_BUTTON = wx.NewId()
|
||||||
SAVE_BUTTON = wxNewId()
|
SAVE_BUTTON = wx.NewId()
|
||||||
APPLY_BUTTON = wxNewId()
|
APPLY_BUTTON = wx.NewId()
|
||||||
NO_BUTTON = wxNewId()
|
NO_BUTTON = wx.NewId()
|
||||||
CANCEL_BUTTON = wxNewId()
|
CANCEL_BUTTON = wx.NewId()
|
||||||
HELP_BUTTON = wxNewId()
|
HELP_BUTTON = wx.NewId()
|
||||||
CONTEXT_HELP_BUTTON = wxNewId()
|
CONTEXT_HELP_BUTTON = wx.NewId()
|
||||||
|
|
||||||
REF = wxNewId()
|
REF = wx.NewId()
|
||||||
|
|
||||||
LAST = wxNewId()
|
LAST = wx.NewId()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PullDownMenu:
|
class PullDownMenu:
|
||||||
ID_EXPAND = wxNewId()
|
ID_EXPAND = wx.NewId()
|
||||||
ID_COLLAPSE = wxNewId()
|
ID_COLLAPSE = wx.NewId()
|
||||||
ID_PASTE_SIBLING = wxNewId()
|
ID_PASTE_SIBLING = wx.NewId()
|
||||||
ID_TOOL_PASTE = wxNewId()
|
ID_TOOL_PASTE = wx.NewId()
|
||||||
ID_SUBCLASS = wxNewId()
|
ID_SUBCLASS = wx.NewId()
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
self.ID_DELETE = parent.ID_DELETE
|
self.ID_DELETE = parent.ID_DELETE
|
||||||
EVT_MENU_RANGE(parent, ID_NEW.PANEL, ID_NEW.LAST, parent.OnCreate)
|
wx.EVT_MENU_RANGE(parent, ID_NEW.PANEL, ID_NEW.LAST, parent.OnCreate)
|
||||||
EVT_MENU_RANGE(parent, 1000 + ID_NEW.PANEL, 1000 + ID_NEW.LAST, parent.OnReplace)
|
wx.EVT_MENU_RANGE(parent, 1000 + ID_NEW.PANEL, 1000 + ID_NEW.LAST, parent.OnReplace)
|
||||||
EVT_MENU(parent, self.ID_COLLAPSE, parent.OnCollapse)
|
wx.EVT_MENU(parent, self.ID_COLLAPSE, parent.OnCollapse)
|
||||||
EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand)
|
wx.EVT_MENU(parent, self.ID_EXPAND, parent.OnExpand)
|
||||||
EVT_MENU(parent, self.ID_PASTE_SIBLING, parent.OnPaste)
|
wx.EVT_MENU(parent, self.ID_PASTE_SIBLING, parent.OnPaste)
|
||||||
EVT_MENU(parent, self.ID_SUBCLASS, parent.OnSubclass)
|
wx.EVT_MENU(parent, self.ID_SUBCLASS, parent.OnSubclass)
|
||||||
# We connect to tree, but process in frame
|
# We connect to tree, but process in frame
|
||||||
EVT_MENU_HIGHLIGHT_ALL(g.tree, parent.OnPullDownHighlight)
|
wx.EVT_MENU_HIGHLIGHT_ALL(g.tree, parent.OnPullDownHighlight)
|
||||||
|
|
||||||
# Mapping from IDs to element names
|
# Mapping from IDs to element names
|
||||||
self.createMap = {
|
self.createMap = {
|
||||||
@@ -387,9 +387,9 @@ def SetMenu(m, list, shift=False):
|
|||||||
if shift: l = (1000 + l[0],) + l[1:]
|
if shift: l = (1000 + l[0],) + l[1:]
|
||||||
apply(m.Append, l)
|
apply(m.Append, l)
|
||||||
elif type(l) == types.ListType:
|
elif type(l) == types.ListType:
|
||||||
subMenu = wxMenu()
|
subMenu = wx.Menu()
|
||||||
SetMenu(subMenu, l[2:], shift)
|
SetMenu(subMenu, l[2:], shift)
|
||||||
m.AppendMenu(wxNewId(), l[0], subMenu, l[1])
|
m.AppendMenu(wx.NewId(), l[0], subMenu, l[1])
|
||||||
else: # separator
|
else: # separator
|
||||||
m.AppendSeparator()
|
m.AppendSeparator()
|
||||||
|
|
||||||
@@ -400,14 +400,14 @@ class HighLightBox:
|
|||||||
if size.width == -1: size.width = 0
|
if size.width == -1: size.width = 0
|
||||||
if size.height == -1: size.height = 0
|
if size.height == -1: size.height = 0
|
||||||
w = g.testWin.panel
|
w = g.testWin.panel
|
||||||
l1 = wxWindow(w, -1, pos, wxSize(size.width, 2))
|
l1 = wx.Window(w, -1, pos, wx.Size(size.width, 2))
|
||||||
l1.SetBackgroundColour(wxRED)
|
l1.SetBackgroundColour(wx.RED)
|
||||||
l2 = wxWindow(w, -1, pos, wxSize(2, size.height))
|
l2 = wx.Window(w, -1, pos, wx.Size(2, size.height))
|
||||||
l2.SetBackgroundColour(wxRED)
|
l2.SetBackgroundColour(wx.RED)
|
||||||
l3 = wxWindow(w, -1, wxPoint(pos.x + size.width - 2, pos.y), wxSize(2, size.height))
|
l3 = wx.Window(w, -1, wx.Point(pos.x + size.width - 2, pos.y), wx.Size(2, size.height))
|
||||||
l3.SetBackgroundColour(wxRED)
|
l3.SetBackgroundColour(wx.RED)
|
||||||
l4 = wxWindow(w, -1, wxPoint(pos.x, pos.y + size.height - 2), wxSize(size.width, 2))
|
l4 = wx.Window(w, -1, wx.Point(pos.x, pos.y + size.height - 2), wx.Size(size.width, 2))
|
||||||
l4.SetBackgroundColour(wxRED)
|
l4.SetBackgroundColour(wx.RED)
|
||||||
self.lines = [l1, l2, l3, l4]
|
self.lines = [l1, l2, l3, l4]
|
||||||
# Move highlight to a new position
|
# Move highlight to a new position
|
||||||
def Replace(self, pos, size):
|
def Replace(self, pos, size):
|
||||||
@@ -419,27 +419,27 @@ class HighLightBox:
|
|||||||
self.lines[3].SetDimensions(pos.x, pos.y + size.height - 2, size.width, 2)
|
self.lines[3].SetDimensions(pos.x, pos.y + size.height - 2, size.width, 2)
|
||||||
# Remove it
|
# Remove it
|
||||||
def Remove(self):
|
def Remove(self):
|
||||||
map(wxWindow.Destroy, self.lines)
|
map(wx.Window.Destroy, self.lines)
|
||||||
g.testWin.highLight = None
|
g.testWin.highLight = None
|
||||||
def Refresh(self):
|
def Refresh(self):
|
||||||
map(wxWindow.Refresh, self.lines)
|
map(wx.Window.Refresh, self.lines)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
class XML_Tree(wxTreeCtrl):
|
class XML_Tree(wx.TreeCtrl):
|
||||||
def __init__(self, parent, id):
|
def __init__(self, parent, id):
|
||||||
wxTreeCtrl.__init__(self, parent, id, style = wxTR_HAS_BUTTONS | wxTR_MULTIPLE)
|
wx.TreeCtrl.__init__(self, parent, id, style = wx.TR_HAS_BUTTONS | wx.TR_MULTIPLE)
|
||||||
self.SetBackgroundColour(wxColour(224, 248, 224))
|
self.SetBackgroundColour(wx.Colour(224, 248, 224))
|
||||||
# Register events
|
# Register events
|
||||||
EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
|
wx.EVT_TREE_SEL_CHANGED(self, self.GetId(), self.OnSelChanged)
|
||||||
# One works on Linux, another on Windows
|
# One works on Linux, another on Windows
|
||||||
if wxPlatform == '__WXGTK__':
|
if wx.Platform == '__WXGTK__':
|
||||||
EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
|
wx.EVT_TREE_ITEM_ACTIVATED(self, self.GetId(), self.OnItemActivated)
|
||||||
else:
|
else:
|
||||||
EVT_LEFT_DCLICK(self, self.OnDClick)
|
wx.EVT_LEFT_DCLICK(self, self.OnDClick)
|
||||||
EVT_RIGHT_DOWN(self, self.OnRightDown)
|
wx.EVT_RIGHT_DOWN(self, self.OnRightDown)
|
||||||
EVT_TREE_ITEM_EXPANDED(self, self.GetId(), self.OnItemExpandedCollapsed)
|
wx.EVT_TREE_ITEM_EXPANDED(self, self.GetId(), self.OnItemExpandedCollapsed)
|
||||||
EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemExpandedCollapsed)
|
wx.EVT_TREE_ITEM_COLLAPSED(self, self.GetId(), self.OnItemExpandedCollapsed)
|
||||||
|
|
||||||
self.selection = None
|
self.selection = None
|
||||||
self.selectionChanging = False
|
self.selectionChanging = False
|
||||||
@@ -448,7 +448,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
self.ctrl = self.shift = False
|
self.ctrl = self.shift = False
|
||||||
self.dom = None
|
self.dom = None
|
||||||
# Create image list
|
# Create image list
|
||||||
il = wxImageList(16, 16, True)
|
il = wx.ImageList(16, 16, True)
|
||||||
self.rootImage = il.Add(images.getTreeRootImage().Scale(16,16).ConvertToBitmap())
|
self.rootImage = il.Add(images.getTreeRootImage().Scale(16,16).ConvertToBitmap())
|
||||||
xxxObject.image = il.Add(images.getTreeDefaultImage().Scale(16,16).ConvertToBitmap())
|
xxxObject.image = il.Add(images.getTreeDefaultImage().Scale(16,16).ConvertToBitmap())
|
||||||
xxxPanel.image = il.Add(images.getTreePanelImage().Scale(16,16).ConvertToBitmap())
|
xxxPanel.image = il.Add(images.getTreePanelImage().Scale(16,16).ConvertToBitmap())
|
||||||
@@ -470,10 +470,10 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
self.SetImageList(il)
|
self.SetImageList(il)
|
||||||
|
|
||||||
def RegisterKeyEvents(self):
|
def RegisterKeyEvents(self):
|
||||||
EVT_KEY_DOWN(self, g.tools.OnKeyDown)
|
wx.EVT_KEY_DOWN(self, g.tools.OnKeyDown)
|
||||||
EVT_KEY_UP(self, g.tools.OnKeyUp)
|
wx.EVT_KEY_UP(self, g.tools.OnKeyUp)
|
||||||
EVT_ENTER_WINDOW(self, g.tools.OnMouse)
|
wx.EVT_ENTER_WINDOW(self, g.tools.OnMouse)
|
||||||
EVT_LEAVE_WINDOW(self, g.tools.OnMouse)
|
wx.EVT_LEAVE_WINDOW(self, g.tools.OnMouse)
|
||||||
|
|
||||||
def ExpandAll(self, item):
|
def ExpandAll(self, item):
|
||||||
if self.ItemHasChildren(item):
|
if self.ItemHasChildren(item):
|
||||||
@@ -510,7 +510,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
self.dom.appendChild(self.mainNode)
|
self.dom.appendChild(self.mainNode)
|
||||||
self.rootObj = xxxMainNode(self.dom)
|
self.rootObj = xxxMainNode(self.dom)
|
||||||
self.root = self.AddRoot('XML tree', self.rootImage,
|
self.root = self.AddRoot('XML tree', self.rootImage,
|
||||||
data=wxTreeItemData(self.rootObj))
|
data=wx.TreeItemData(self.rootObj))
|
||||||
self.SetItemHasChildren(self.root)
|
self.SetItemHasChildren(self.root)
|
||||||
self.testElem = self.dom.createElement('dummy')
|
self.testElem = self.dom.createElement('dummy')
|
||||||
self.mainNode.appendChild(self.testElem)
|
self.mainNode.appendChild(self.testElem)
|
||||||
@@ -529,7 +529,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
self.mainNode = dom.documentElement
|
self.mainNode = dom.documentElement
|
||||||
self.rootObj = xxxMainNode(self.dom)
|
self.rootObj = xxxMainNode(self.dom)
|
||||||
self.root = self.AddRoot('XML tree', self.rootImage,
|
self.root = self.AddRoot('XML tree', self.rootImage,
|
||||||
data=wxTreeItemData(self.rootObj))
|
data=wx.TreeItemData(self.rootObj))
|
||||||
self.SetItemHasChildren(self.root)
|
self.SetItemHasChildren(self.root)
|
||||||
nodes = self.mainNode.childNodes[:]
|
nodes = self.mainNode.childNodes[:]
|
||||||
for node in nodes:
|
for node in nodes:
|
||||||
@@ -559,7 +559,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# Append tree item
|
# Append tree item
|
||||||
item = self.AppendItem(itemParent, treeObj.treeName(),
|
item = self.AppendItem(itemParent, treeObj.treeName(),
|
||||||
image=treeObj.treeImage(),
|
image=treeObj.treeImage(),
|
||||||
data=wxTreeItemData(xxx))
|
data=wx.TreeItemData(xxx))
|
||||||
# Different color for references
|
# Different color for references
|
||||||
if treeObj.ref:
|
if treeObj.ref:
|
||||||
self.SetItemTextColour(item, 'DarkGreen')
|
self.SetItemTextColour(item, 'DarkGreen')
|
||||||
@@ -589,7 +589,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
else:
|
else:
|
||||||
parent.element.appendChild(elem)
|
parent.element.appendChild(elem)
|
||||||
newItem = self.AppendItem(itemParent, xxx.treeName(), image=xxx.treeImage(),
|
newItem = self.AppendItem(itemParent, xxx.treeName(), image=xxx.treeImage(),
|
||||||
data=wxTreeItemData(xxx))
|
data=wx.TreeItemData(xxx))
|
||||||
# Different color for references
|
# Different color for references
|
||||||
if xxx.treeObject().ref: self.SetItemTextColour(newItem, 'DarkGreen')
|
if xxx.treeObject().ref: self.SetItemTextColour(newItem, 'DarkGreen')
|
||||||
# Add children items
|
# Add children items
|
||||||
@@ -613,7 +613,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# Find position relative to the top-level window
|
# Find position relative to the top-level window
|
||||||
def FindNodePos(self, item, obj=None):
|
def FindNodePos(self, item, obj=None):
|
||||||
# Root at (0,0)
|
# Root at (0,0)
|
||||||
if item == g.testWin.item: return wxPoint(0, 0)
|
if item == g.testWin.item: return wx.Point(0, 0)
|
||||||
itemParent = self.GetItemParent(item)
|
itemParent = self.GetItemParent(item)
|
||||||
# Select book page
|
# Select book page
|
||||||
if not obj: obj = self.FindNodeObject(item)
|
if not obj: obj = self.FindNodeObject(item)
|
||||||
@@ -635,7 +635,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
winParent = self.GetItemParent(winParent)
|
winParent = self.GetItemParent(winParent)
|
||||||
# Notebook children are layed out in a little strange way
|
# Notebook children are layed out in a little strange way
|
||||||
if self.GetPyData(itemParent).treeObject().__class__ == xxxNotebook:
|
if self.GetPyData(itemParent).treeObject().__class__ == xxxNotebook:
|
||||||
parentPos = wxPoint(0,0)
|
parentPos = wx.Point(0,0)
|
||||||
else:
|
else:
|
||||||
parentPos = self.FindNodePos(winParent)
|
parentPos = self.FindNodePos(winParent)
|
||||||
# Position (-1,-1) is really (0,0)
|
# Position (-1,-1) is really (0,0)
|
||||||
@@ -652,7 +652,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
xxx = self.GetPyData(item).treeObject()
|
xxx = self.GetPyData(item).treeObject()
|
||||||
parentWin = self.FindNodeObject(itemParent)
|
parentWin = self.FindNodeObject(itemParent)
|
||||||
# Top-level sizer? return window's sizer
|
# Top-level sizer? return window's sizer
|
||||||
if xxx.isSizer and isinstance(parentWin, wxWindow):
|
if xxx.isSizer and isinstance(parentWin, wx.Window):
|
||||||
return parentWin.GetSizer()
|
return parentWin.GetSizer()
|
||||||
elif xxx.__class__ in [xxxMenu, xxxMenuItem, xxxSeparator]: return None
|
elif xxx.__class__ in [xxxMenu, xxxMenuItem, xxxSeparator]: return None
|
||||||
elif xxx.__class__ in [xxxToolBar, xxxMenuBar]:
|
elif xxx.__class__ in [xxxToolBar, xxxMenuBar]:
|
||||||
@@ -764,16 +764,16 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
while item and self.GetPyData(item).treeObject().className not in availableViews:
|
while item and self.GetPyData(item).treeObject().className not in availableViews:
|
||||||
item = self.GetItemParent(item)
|
item = self.GetItemParent(item)
|
||||||
if not item or not item.IsOk():
|
if not item or not item.IsOk():
|
||||||
wxLogMessage('No view for this element (yet)')
|
wx.LogMessage('No view for this element (yet)')
|
||||||
return
|
return
|
||||||
# Show item in bold
|
# Show item in bold
|
||||||
if g.testWin: # Reset old
|
if g.testWin: # Reset old
|
||||||
self.SetItemBold(g.testWin.item, False)
|
self.SetItemBold(g.testWin.item, False)
|
||||||
try:
|
try:
|
||||||
wxBeginBusyCursor()
|
wx.BeginBusyCursor()
|
||||||
self.CreateTestWin(item)
|
self.CreateTestWin(item)
|
||||||
finally:
|
finally:
|
||||||
wxEndBusyCursor()
|
wx.EndBusyCursor()
|
||||||
# Maybe an error occurred, so we need to test
|
# Maybe an error occurred, so we need to test
|
||||||
if g.testWin:
|
if g.testWin:
|
||||||
self.SetItemBold(g.testWin.item)
|
self.SetItemBold(g.testWin.item)
|
||||||
@@ -788,7 +788,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# Double-click on Windows
|
# Double-click on Windows
|
||||||
def OnDClick(self, evt):
|
def OnDClick(self, evt):
|
||||||
item, flags = self.HitTest(evt.GetPosition())
|
item, flags = self.HitTest(evt.GetPosition())
|
||||||
if flags in [wxTREE_HITTEST_ONITEMBUTTON, wxTREE_HITTEST_ONITEMLABEL]:
|
if flags in [wx.TREE_HITTEST_ONITEMBUTTON, wx.TREE_HITTEST_ONITEMLABEL]:
|
||||||
if item != self.root: self.ShowTestWindow(item)
|
if item != self.root: self.ShowTestWindow(item)
|
||||||
else:
|
else:
|
||||||
evt.Skip()
|
evt.Skip()
|
||||||
@@ -811,8 +811,8 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# child = self.GetFirstChild(item)[0]
|
# child = self.GetFirstChild(item)[0]
|
||||||
# if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
|
# if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
|
||||||
# # Clean-up before recursive call or error
|
# # Clean-up before recursive call or error
|
||||||
# wxMemoryFSHandler_RemoveFile('xxx.xrc')
|
# wx.MemoryFSHandler.RemoveFile('xxx.xrc')
|
||||||
# wxEndBusyCursor()
|
# wx.EndBusyCursor()
|
||||||
# self.CreateTestWin(child)
|
# self.CreateTestWin(child)
|
||||||
# return
|
# return
|
||||||
|
|
||||||
@@ -862,15 +862,15 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
self.dom.writexml(memFile, encoding=encd)
|
self.dom.writexml(memFile, encoding=encd)
|
||||||
except:
|
except:
|
||||||
inf = sys.exc_info()
|
inf = sys.exc_info()
|
||||||
wxLogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
wx.LogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
||||||
wxLogError('Error writing temporary file')
|
wx.LogError('Error writing temporary file')
|
||||||
if debug: raise
|
if debug: raise
|
||||||
memFile.close() # write to wxMemoryFS
|
memFile.close() # write to wxMemoryFS
|
||||||
xmlFlags = wxXRC_NO_SUBCLASSING
|
xmlFlags = xrc.XRC_NO_SUBCLASSING
|
||||||
# Use translations if encoding is not specified
|
# Use translations if encoding is not specified
|
||||||
if not g.currentEncoding:
|
if not g.currentEncoding:
|
||||||
xmlFlags != wxXRC_USE_LOCALE
|
xmlFlags != xrc.XRC_USE_LOCALE
|
||||||
res = wxXmlResource('', xmlFlags)
|
res = xrc.XmlResource('', xmlFlags)
|
||||||
res.Load('memory:xxx.xrc')
|
res.Load('memory:xxx.xrc')
|
||||||
try:
|
try:
|
||||||
if xxx.__class__ == xxxFrame:
|
if xxx.__class__ == xxxFrame:
|
||||||
@@ -879,12 +879,12 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# child = self.GetFirstChild(item)[0]
|
# child = self.GetFirstChild(item)[0]
|
||||||
# if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
|
# if child.IsOk() and self.GetPyData(child).__class__ == xxxPanel:
|
||||||
# # Clean-up before recursive call or error
|
# # Clean-up before recursive call or error
|
||||||
# wxMemoryFSHandler_RemoveFile('xxx.xrc')
|
# wx.MemoryFSHandler.RemoveFile('xxx.xrc')
|
||||||
# wxEndBusyCursor()
|
# wx.EndBusyCursor()
|
||||||
# self.CreateTestWin(child)
|
# self.CreateTestWin(child)
|
||||||
# return
|
# return
|
||||||
# This currently works under GTK, but not under MSW
|
# This currently works under GTK, but not under MSW
|
||||||
testWin = g.testWin = wxPreFrame()
|
testWin = g.testWin = wx.PreFrame()
|
||||||
res.LoadOnFrame(testWin, g.frame, STD_NAME)
|
res.LoadOnFrame(testWin, g.frame, STD_NAME)
|
||||||
# Create status bar
|
# Create status bar
|
||||||
testWin.panel = testWin
|
testWin.panel = testWin
|
||||||
@@ -895,7 +895,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
elif xxx.__class__ == xxxPanel:
|
elif xxx.__class__ == xxxPanel:
|
||||||
# Create new frame
|
# Create new frame
|
||||||
if not testWin:
|
if not testWin:
|
||||||
testWin = g.testWin = wxFrame(g.frame, -1, 'Panel: ' + name,
|
testWin = g.testWin = wx.Frame(g.frame, -1, 'Panel: ' + name,
|
||||||
pos=pos, name=STD_NAME)
|
pos=pos, name=STD_NAME)
|
||||||
testWin.panel = res.LoadPanel(testWin, STD_NAME)
|
testWin.panel = res.LoadPanel(testWin, STD_NAME)
|
||||||
testWin.SetClientSize(testWin.GetBestSize())
|
testWin.SetClientSize(testWin.GetBestSize())
|
||||||
@@ -906,20 +906,20 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
testWin.Layout()
|
testWin.Layout()
|
||||||
testWin.SetPosition(pos)
|
testWin.SetPosition(pos)
|
||||||
testWin.Show(True)
|
testWin.Show(True)
|
||||||
# Dialog's default code does not produce EVT_CLOSE
|
# Dialog's default code does not produce wx.EVT_CLOSE
|
||||||
EVT_BUTTON(testWin, wxID_OK, self.OnCloseTestWin)
|
wx.EVT_BUTTON(testWin, wx.ID_OK, self.OnCloseTestWin)
|
||||||
EVT_BUTTON(testWin, wxID_CANCEL, self.OnCloseTestWin)
|
wx.EVT_BUTTON(testWin, wx.ID_CANCEL, self.OnCloseTestWin)
|
||||||
elif xxx.__class__ == xxxWizard:
|
elif xxx.__class__ == xxxWizard:
|
||||||
wiz = wxPreWizard()
|
wiz = wx.wizard.PreWizard()
|
||||||
res.LoadOnObject(wiz, None, STD_NAME, 'wxWizard')
|
res.LoadOnObject(wiz, None, STD_NAME, 'wxWizard')
|
||||||
# Find first page (don't know better way)
|
# Find first page (don't know better way)
|
||||||
firstPage = None
|
firstPage = None
|
||||||
for w in wiz.GetChildren():
|
for w in wiz.GetChildren():
|
||||||
if isinstance(w, wxWizardPage):
|
if isinstance(w, wx.wizard.WizardPage):
|
||||||
firstPage = w
|
firstPage = w
|
||||||
break
|
break
|
||||||
if not firstPage:
|
if not firstPage:
|
||||||
wxLogError('Wizard is empty')
|
wx.LogError('Wizard is empty')
|
||||||
else:
|
else:
|
||||||
# Wizard should be modal
|
# Wizard should be modal
|
||||||
self.SetItemBold(item)
|
self.SetItemBold(item)
|
||||||
@@ -929,14 +929,14 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
elif xxx.__class__ in [xxxWizardPage, xxxWizardPageSimple]:
|
elif xxx.__class__ in [xxxWizardPage, xxxWizardPageSimple]:
|
||||||
# Create new frame
|
# Create new frame
|
||||||
if not testWin:
|
if not testWin:
|
||||||
testWin = g.testWin = wxFrame(g.frame, -1, 'Wizard page: ' + name,
|
testWin = g.testWin = wx.Frame(g.frame, -1, 'Wizard page: ' + name,
|
||||||
pos=pos, name=STD_NAME)
|
pos=pos, name=STD_NAME)
|
||||||
testWin.panel = wxPrePanel()
|
testWin.panel = wx.PrePanel()
|
||||||
res.LoadOnObject(testWin.panel, testWin, STD_NAME, 'wxPanel')
|
res.LoadOnObject(testWin.panel, testWin, STD_NAME, 'wxPanel')
|
||||||
testWin.SetClientSize(testWin.GetBestSize())
|
testWin.SetClientSize(testWin.GetBestSize())
|
||||||
testWin.Show(True)
|
testWin.Show(True)
|
||||||
elif xxx.__class__ == xxxMenuBar:
|
elif xxx.__class__ == xxxMenuBar:
|
||||||
testWin = g.testWin = wxFrame(g.frame, -1, 'MenuBar: ' + name,
|
testWin = g.testWin = wx.Frame(g.frame, -1, 'MenuBar: ' + name,
|
||||||
pos=pos, name=STD_NAME)
|
pos=pos, name=STD_NAME)
|
||||||
testWin.panel = None
|
testWin.panel = None
|
||||||
# Set status bar to display help
|
# Set status bar to display help
|
||||||
@@ -945,7 +945,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
testWin.SetMenuBar(testWin.menuBar)
|
testWin.SetMenuBar(testWin.menuBar)
|
||||||
testWin.Show(True)
|
testWin.Show(True)
|
||||||
elif xxx.__class__ == xxxToolBar:
|
elif xxx.__class__ == xxxToolBar:
|
||||||
testWin = g.testWin = wxFrame(g.frame, -1, 'ToolBar: ' + name,
|
testWin = g.testWin = wx.Frame(g.frame, -1, 'ToolBar: ' + name,
|
||||||
pos=pos, name=STD_NAME)
|
pos=pos, name=STD_NAME)
|
||||||
testWin.panel = None
|
testWin.panel = None
|
||||||
# Set status bar to display help
|
# Set status bar to display help
|
||||||
@@ -955,7 +955,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
testWin.Show(True)
|
testWin.Show(True)
|
||||||
if testWin:
|
if testWin:
|
||||||
testWin.item = item
|
testWin.item = item
|
||||||
EVT_CLOSE(testWin, self.OnCloseTestWin)
|
wx.EVT_CLOSE(testWin, self.OnCloseTestWin)
|
||||||
testWin.highLight = None
|
testWin.highLight = None
|
||||||
if highLight and not self.pendingHighLight:
|
if highLight and not self.pendingHighLight:
|
||||||
self.HighLight(highLight)
|
self.HighLight(highLight)
|
||||||
@@ -966,9 +966,9 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
g.testWin.Destroy()
|
g.testWin.Destroy()
|
||||||
g.testWin = None
|
g.testWin = None
|
||||||
inf = sys.exc_info()
|
inf = sys.exc_info()
|
||||||
wxLogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
wx.LogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
||||||
wxLogError('Error loading resource')
|
wx.LogError('Error loading resource')
|
||||||
wxMemoryFSHandler_RemoveFile('xxx.xrc')
|
wx.MemoryFSHandler.RemoveFile('xxx.xrc')
|
||||||
|
|
||||||
def CloseTestWindow(self):
|
def CloseTestWindow(self):
|
||||||
if not g.testWin: return
|
if not g.testWin: return
|
||||||
@@ -1011,7 +1011,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
return l
|
return l
|
||||||
# Get item position from full index
|
# Get item position from full index
|
||||||
def ItemAtFullIndex(self, index):
|
def ItemAtFullIndex(self, index):
|
||||||
if index is None: return wxTreeItemId()
|
if index is None: return wx.TreeItemId()
|
||||||
item = self.root
|
item = self.root
|
||||||
for i in index:
|
for i in index:
|
||||||
item = self.GetFirstChild(item)[0]
|
item = self.GetFirstChild(item)[0]
|
||||||
@@ -1032,7 +1032,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
def SelectItem(self, item):
|
def SelectItem(self, item):
|
||||||
self.UnselectAll()
|
self.UnselectAll()
|
||||||
self.ChangeSelection(item)
|
self.ChangeSelection(item)
|
||||||
wxTreeCtrl.SelectItem(self, item)
|
wx.TreeCtrl.SelectItem(self, item)
|
||||||
|
|
||||||
# Pull-down
|
# Pull-down
|
||||||
def OnRightDown(self, evt):
|
def OnRightDown(self, evt):
|
||||||
@@ -1040,11 +1040,11 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# select this item
|
# select this item
|
||||||
pt = evt.GetPosition();
|
pt = evt.GetPosition();
|
||||||
item, flags = self.HitTest(pt)
|
item, flags = self.HitTest(pt)
|
||||||
if item.Ok() and flags & wxTREE_HITTEST_ONITEM:
|
if item.Ok() and flags & wx.TREE_HITTEST_ONITEM:
|
||||||
self.SelectItem(item)
|
self.SelectItem(item)
|
||||||
|
|
||||||
# Setup menu
|
# Setup menu
|
||||||
menu = wxMenu()
|
menu = wx.Menu()
|
||||||
|
|
||||||
item = self.selection
|
item = self.selection
|
||||||
if not item:
|
if not item:
|
||||||
@@ -1053,7 +1053,7 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
else:
|
else:
|
||||||
# self.ctrl = evt.ControlDown() # save Ctrl state
|
# self.ctrl = evt.ControlDown() # save Ctrl state
|
||||||
# self.shift = evt.ShiftDown() # and Shift too
|
# self.shift = evt.ShiftDown() # and Shift too
|
||||||
m = wxMenu() # create menu
|
m = wx.Menu() # create menu
|
||||||
if self.ctrl:
|
if self.ctrl:
|
||||||
needInsert = True
|
needInsert = True
|
||||||
else:
|
else:
|
||||||
@@ -1088,22 +1088,22 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
# Select correct label for create menu
|
# Select correct label for create menu
|
||||||
if not needInsert:
|
if not needInsert:
|
||||||
if self.shift:
|
if self.shift:
|
||||||
menu.AppendMenu(wxNewId(), 'Insert Child', m,
|
menu.AppendMenu(wx.NewId(), 'Insert Child', m,
|
||||||
'Create child object as the first child')
|
'Create child object as the first child')
|
||||||
else:
|
else:
|
||||||
menu.AppendMenu(wxNewId(), 'Append Child', m,
|
menu.AppendMenu(wx.NewId(), 'Append Child', m,
|
||||||
'Create child object as the last child')
|
'Create child object as the last child')
|
||||||
else:
|
else:
|
||||||
if self.shift:
|
if self.shift:
|
||||||
menu.AppendMenu(wxNewId(), 'Create Sibling', m,
|
menu.AppendMenu(wx.NewId(), 'Create Sibling', m,
|
||||||
'Create sibling before selected object')
|
'Create sibling before selected object')
|
||||||
else:
|
else:
|
||||||
menu.AppendMenu(wxNewId(), 'Create Sibling', m,
|
menu.AppendMenu(wx.NewId(), 'Create Sibling', m,
|
||||||
'Create sibling after selected object')
|
'Create sibling after selected object')
|
||||||
# Build replace menu
|
# Build replace menu
|
||||||
if item != self.root:
|
if item != self.root:
|
||||||
xxx = self.GetPyData(item).treeObject()
|
xxx = self.GetPyData(item).treeObject()
|
||||||
m = wxMenu() # create replace menu
|
m = wx.Menu() # create replace menu
|
||||||
if xxx.__class__ == xxxMenuBar:
|
if xxx.__class__ == xxxMenuBar:
|
||||||
m.Append(1000 + ID_NEW.MENU, 'Menu', 'Create menu')
|
m.Append(1000 + ID_NEW.MENU, 'Menu', 'Create menu')
|
||||||
elif xxx.__class__ in [xxxMenu, xxxMenuItem]:
|
elif xxx.__class__ in [xxxMenu, xxxMenuItem]:
|
||||||
@@ -1120,20 +1120,20 @@ class XML_Tree(wxTreeCtrl):
|
|||||||
SetMenu(m, pullDownMenu.sizers, shift=True)
|
SetMenu(m, pullDownMenu.sizers, shift=True)
|
||||||
else:
|
else:
|
||||||
SetMenu(m, pullDownMenu.controls, shift=True)
|
SetMenu(m, pullDownMenu.controls, shift=True)
|
||||||
id = wxNewId()
|
id = wx.NewId()
|
||||||
menu.AppendMenu(id, 'Replace With', m)
|
menu.AppendMenu(id, 'Replace With', m)
|
||||||
if not m.GetMenuItemCount(): menu.Enable(id, False)
|
if not m.GetMenuItemCount(): menu.Enable(id, False)
|
||||||
menu.Append(pullDownMenu.ID_SUBCLASS, 'Subclass...',
|
menu.Append(pullDownMenu.ID_SUBCLASS, 'Subclass...',
|
||||||
'Set "subclass" property')
|
'Set "subclass" property')
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
# Not using standart IDs because we don't want to show shortcuts
|
# Not using standart IDs because we don't want to show shortcuts
|
||||||
menu.Append(wxID_CUT, 'Cut', 'Cut to the clipboard')
|
menu.Append(wx.ID_CUT, 'Cut', 'Cut to the clipboard')
|
||||||
menu.Append(wxID_COPY, 'Copy', 'Copy to the clipboard')
|
menu.Append(wx.ID_COPY, 'Copy', 'Copy to the clipboard')
|
||||||
if self.ctrl and item != self.root:
|
if self.ctrl and item != self.root:
|
||||||
menu.Append(pullDownMenu.ID_PASTE_SIBLING, 'Paste Sibling',
|
menu.Append(pullDownMenu.ID_PASTE_SIBLING, 'Paste Sibling',
|
||||||
'Paste from the clipboard as a sibling')
|
'Paste from the clipboard as a sibling')
|
||||||
else:
|
else:
|
||||||
menu.Append(wxID_PASTE, 'Paste', 'Paste from the clipboard')
|
menu.Append(wx.ID_PASTE, 'Paste', 'Paste from the clipboard')
|
||||||
menu.Append(pullDownMenu.ID_DELETE,
|
menu.Append(pullDownMenu.ID_DELETE,
|
||||||
'Delete', 'Delete object')
|
'Delete', 'Delete object')
|
||||||
if self.ItemHasChildren(item):
|
if self.ItemHasChildren(item):
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
xrced -- Simple resource editor for XRC format used by wxWindows/wxPython
|
xrced -- Simple resource editor for XRC format used by wxWidgets/wxPython
|
||||||
GUI toolkit.
|
GUI toolkit.
|
||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
@@ -62,35 +62,35 @@ defaultName = 'UNTITLED.xrc'
|
|||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# ScrolledMessageDialog - modified from wxPython lib to set fixed-width font
|
# ScrolledMessageDialog - modified from wxPython lib to set fixed-width font
|
||||||
class ScrolledMessageDialog(wxDialog):
|
class ScrolledMessageDialog(wx.Dialog):
|
||||||
def __init__(self, parent, msg, caption, pos = wxDefaultPosition, size = (500,300)):
|
def __init__(self, parent, msg, caption, pos = wx.DefaultPosition, size = (500,300)):
|
||||||
from wxPython.lib.layoutf import Layoutf
|
from wx.lib.layoutf import Layoutf
|
||||||
wxDialog.__init__(self, parent, -1, caption, pos, size)
|
wx.Dialog.__init__(self, parent, -1, caption, pos, size)
|
||||||
text = wxTextCtrl(self, -1, msg, wxDefaultPosition,
|
text = wx.TextCtrl(self, -1, msg, wx.DefaultPosition,
|
||||||
wxDefaultSize, wxTE_MULTILINE | wxTE_READONLY)
|
wx.DefaultSize, wx.TE_MULTILINE | wx.TE_READONLY)
|
||||||
text.SetFont(g.modernFont())
|
text.SetFont(g.modernFont())
|
||||||
dc = wxWindowDC(text)
|
dc = wx.WindowDC(text)
|
||||||
# !!! possible bug - GetTextExtent without font returns sysfont dims
|
# !!! possible bug - GetTextExtent without font returns sysfont dims
|
||||||
w, h = dc.GetFullTextExtent(' ', g.modernFont())[:2]
|
w, h = dc.GetFullTextExtent(' ', g.modernFont())[:2]
|
||||||
ok = wxButton(self, wxID_OK, "OK")
|
ok = wx.Button(self, wx.ID_OK, "OK")
|
||||||
text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok)))
|
text.SetConstraints(Layoutf('t=t5#1;b=t5#2;l=l5#1;r=r5#1', (self,ok)))
|
||||||
text.SetSize((w * 80 + 30, h * 40))
|
text.SetSize((w * 80 + 30, h * 40))
|
||||||
text.ShowPosition(1)
|
text.ShowPosition(1)
|
||||||
ok.SetConstraints(Layoutf('b=b5#1;x%w50#1;w!80;h!25', (self,)))
|
ok.SetConstraints(Layoutf('b=b5#1;x%w50#1;w!80;h!25', (self,)))
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.Fit()
|
self.Fit()
|
||||||
self.CenterOnScreen(wxBOTH)
|
self.CenterOnScreen(wx.BOTH)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Event handler for using during location
|
# Event handler for using during location
|
||||||
class Locator(wxEvtHandler):
|
class Locator(wx.EvtHandler):
|
||||||
def ProcessEvent(self, evt):
|
def ProcessEvent(self, evt):
|
||||||
print evt
|
print evt
|
||||||
|
|
||||||
class Frame(wxFrame):
|
class Frame(wx.Frame):
|
||||||
def __init__(self, pos, size):
|
def __init__(self, pos, size):
|
||||||
wxFrame.__init__(self, None, -1, '', pos, size)
|
wx.Frame.__init__(self, None, -1, '', pos, size)
|
||||||
global frame
|
global frame
|
||||||
frame = g.frame = self
|
frame = g.frame = self
|
||||||
bar = self.CreateStatusBar(2)
|
bar = self.CreateStatusBar(2)
|
||||||
@@ -101,7 +101,7 @@ class Frame(wxFrame):
|
|||||||
self.inIdle = False
|
self.inIdle = False
|
||||||
|
|
||||||
# Load our own resources
|
# Load our own resources
|
||||||
self.res = wxXmlResource('')
|
self.res = xrc.XmlResource('')
|
||||||
# !!! Blocking of assert failure occurring in older unicode builds
|
# !!! Blocking of assert failure occurring in older unicode builds
|
||||||
try:
|
try:
|
||||||
quietlog = wx.LogNull()
|
quietlog = wx.LogNull()
|
||||||
@@ -110,78 +110,78 @@ class Frame(wxFrame):
|
|||||||
print 'PyAssertionError was ignored'
|
print 'PyAssertionError was ignored'
|
||||||
|
|
||||||
# Make menus
|
# Make menus
|
||||||
menuBar = wxMenuBar()
|
menuBar = wx.MenuBar()
|
||||||
|
|
||||||
menu = wxMenu()
|
menu = wx.Menu()
|
||||||
menu.Append(wxID_NEW, '&New\tCtrl-N', 'New file')
|
menu.Append(wx.ID_NEW, '&New\tCtrl-N', 'New file')
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
menu.Append(wxID_OPEN, '&Open...\tCtrl-O', 'Open XRC file')
|
menu.Append(wx.ID_OPEN, '&Open...\tCtrl-O', 'Open XRC file')
|
||||||
self.recentMenu = wxMenu()
|
self.recentMenu = wx.Menu()
|
||||||
self.AppendRecent(self.recentMenu)
|
self.AppendRecent(self.recentMenu)
|
||||||
menu.AppendMenu(-1, 'Open Recent', self.recentMenu, 'Open a recent file')
|
menu.AppendMenu(-1, 'Open Recent', self.recentMenu, 'Open a recent file')
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
menu.Append(wxID_SAVE, '&Save\tCtrl-S', 'Save XRC file')
|
menu.Append(wx.ID_SAVE, '&Save\tCtrl-S', 'Save XRC file')
|
||||||
menu.Append(wxID_SAVEAS, 'Save &As...', 'Save XRC file under different name')
|
menu.Append(wx.ID_SAVEAS, 'Save &As...', 'Save XRC file under different name')
|
||||||
self.ID_GENERATE_PYTHON = wxNewId()
|
self.ID_GENERATE_PYTHON = wx.NewId()
|
||||||
menu.Append(self.ID_GENERATE_PYTHON, '&Generate Python...',
|
menu.Append(self.ID_GENERATE_PYTHON, '&Generate Python...',
|
||||||
'Generate a Python module that uses this XRC')
|
'Generate a Python module that uses this XRC')
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
menu.Append(wxID_EXIT, '&Quit\tCtrl-Q', 'Exit application')
|
menu.Append(wx.ID_EXIT, '&Quit\tCtrl-Q', 'Exit application')
|
||||||
|
|
||||||
menuBar.Append(menu, '&File')
|
menuBar.Append(menu, '&File')
|
||||||
|
|
||||||
menu = wxMenu()
|
menu = wx.Menu()
|
||||||
menu.Append(wxID_UNDO, '&Undo\tCtrl-Z', 'Undo')
|
menu.Append(wx.ID_UNDO, '&Undo\tCtrl-Z', 'Undo')
|
||||||
menu.Append(wxID_REDO, '&Redo\tCtrl-Y', 'Redo')
|
menu.Append(wx.ID_REDO, '&Redo\tCtrl-Y', 'Redo')
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
menu.Append(wxID_CUT, 'Cut\tCtrl-X', 'Cut to the clipboard')
|
menu.Append(wx.ID_CUT, 'Cut\tCtrl-X', 'Cut to the clipboard')
|
||||||
menu.Append(wxID_COPY, '&Copy\tCtrl-C', 'Copy to the clipboard')
|
menu.Append(wx.ID_COPY, '&Copy\tCtrl-C', 'Copy to the clipboard')
|
||||||
menu.Append(wxID_PASTE, '&Paste\tCtrl-V', 'Paste from the clipboard')
|
menu.Append(wx.ID_PASTE, '&Paste\tCtrl-V', 'Paste from the clipboard')
|
||||||
self.ID_DELETE = wxNewId()
|
self.ID_DELETE = wx.NewId()
|
||||||
menu.Append(self.ID_DELETE, '&Delete\tCtrl-D', 'Delete object')
|
menu.Append(self.ID_DELETE, '&Delete\tCtrl-D', 'Delete object')
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
self.ID_LOCATE = wxNewId()
|
self.ID_LOCATE = wx.NewId()
|
||||||
self.ID_TOOL_LOCATE = wxNewId()
|
self.ID_TOOL_LOCATE = wx.NewId()
|
||||||
self.ID_TOOL_PASTE = wxNewId()
|
self.ID_TOOL_PASTE = wx.NewId()
|
||||||
menu.Append(self.ID_LOCATE, '&Locate\tCtrl-L', 'Locate control in test window and select it')
|
menu.Append(self.ID_LOCATE, '&Locate\tCtrl-L', 'Locate control in test window and select it')
|
||||||
menuBar.Append(menu, '&Edit')
|
menuBar.Append(menu, '&Edit')
|
||||||
|
|
||||||
menu = wxMenu()
|
menu = wx.Menu()
|
||||||
self.ID_EMBED_PANEL = wxNewId()
|
self.ID_EMBED_PANEL = wx.NewId()
|
||||||
menu.Append(self.ID_EMBED_PANEL, '&Embed Panel',
|
menu.Append(self.ID_EMBED_PANEL, '&Embed Panel',
|
||||||
'Toggle embedding properties panel in the main window', True)
|
'Toggle embedding properties panel in the main window', True)
|
||||||
menu.Check(self.ID_EMBED_PANEL, conf.embedPanel)
|
menu.Check(self.ID_EMBED_PANEL, conf.embedPanel)
|
||||||
self.ID_SHOW_TOOLS = wxNewId()
|
self.ID_SHOW_TOOLS = wx.NewId()
|
||||||
menu.Append(self.ID_SHOW_TOOLS, 'Show &Tools', 'Toggle tools', True)
|
menu.Append(self.ID_SHOW_TOOLS, 'Show &Tools', 'Toggle tools', True)
|
||||||
menu.Check(self.ID_SHOW_TOOLS, conf.showTools)
|
menu.Check(self.ID_SHOW_TOOLS, conf.showTools)
|
||||||
menu.AppendSeparator()
|
menu.AppendSeparator()
|
||||||
self.ID_TEST = wxNewId()
|
self.ID_TEST = wx.NewId()
|
||||||
menu.Append(self.ID_TEST, '&Test\tF5', 'Show test window')
|
menu.Append(self.ID_TEST, '&Test\tF5', 'Show test window')
|
||||||
self.ID_REFRESH = wxNewId()
|
self.ID_REFRESH = wx.NewId()
|
||||||
menu.Append(self.ID_REFRESH, '&Refresh\tCtrl-R', 'Refresh test window')
|
menu.Append(self.ID_REFRESH, '&Refresh\tCtrl-R', 'Refresh test window')
|
||||||
self.ID_AUTO_REFRESH = wxNewId()
|
self.ID_AUTO_REFRESH = wx.NewId()
|
||||||
menu.Append(self.ID_AUTO_REFRESH, '&Auto-refresh\tCtrl-A',
|
menu.Append(self.ID_AUTO_REFRESH, '&Auto-refresh\tCtrl-A',
|
||||||
'Toggle auto-refresh mode', True)
|
'Toggle auto-refresh mode', True)
|
||||||
menu.Check(self.ID_AUTO_REFRESH, conf.autoRefresh)
|
menu.Check(self.ID_AUTO_REFRESH, conf.autoRefresh)
|
||||||
self.ID_TEST_HIDE = wxNewId()
|
self.ID_TEST_HIDE = wx.NewId()
|
||||||
menu.Append(self.ID_TEST_HIDE, '&Hide\tCtrl-H', 'Close test window')
|
menu.Append(self.ID_TEST_HIDE, '&Hide\tCtrl-H', 'Close test window')
|
||||||
menuBar.Append(menu, '&View')
|
menuBar.Append(menu, '&View')
|
||||||
|
|
||||||
menu = wxMenu()
|
menu = wx.Menu()
|
||||||
menu.Append(wxID_ABOUT, '&About...', 'About XCRed')
|
menu.Append(wx.ID_ABOUT, '&About...', 'About XCRed')
|
||||||
self.ID_README = wxNewId()
|
self.ID_README = wx.NewId()
|
||||||
menu.Append(self.ID_README, '&Readme...', 'View the README file')
|
menu.Append(self.ID_README, '&Readme...', 'View the README file')
|
||||||
if debug:
|
if debug:
|
||||||
self.ID_DEBUG_CMD = wxNewId()
|
self.ID_DEBUG_CMD = wx.NewId()
|
||||||
menu.Append(self.ID_DEBUG_CMD, 'CMD', 'Python command line')
|
menu.Append(self.ID_DEBUG_CMD, 'CMD', 'Python command line')
|
||||||
EVT_MENU(self, self.ID_DEBUG_CMD, self.OnDebugCMD)
|
wx.EVT_MENU(self, self.ID_DEBUG_CMD, self.OnDebugCMD)
|
||||||
menuBar.Append(menu, '&Help')
|
menuBar.Append(menu, '&Help')
|
||||||
|
|
||||||
self.menuBar = menuBar
|
self.menuBar = menuBar
|
||||||
self.SetMenuBar(menuBar)
|
self.SetMenuBar(menuBar)
|
||||||
|
|
||||||
# Create toolbar
|
# Create toolbar
|
||||||
tb = self.CreateToolBar(wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT)
|
tb = self.CreateToolBar(wx.TB_HORIZONTAL | wx.NO_BORDER | wx.TB_FLAT)
|
||||||
tb.SetToolBitmapSize((24,24))
|
tb.SetToolBitmapSize((24,24))
|
||||||
new_bmp = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR)
|
new_bmp = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_TOOLBAR)
|
||||||
open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR)
|
open_bmp = wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR)
|
||||||
@@ -192,27 +192,27 @@ class Frame(wxFrame):
|
|||||||
copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR)
|
copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR)
|
||||||
paste_bmp= wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR)
|
paste_bmp= wx.ArtProvider.GetBitmap(wx.ART_PASTE, wx.ART_TOOLBAR)
|
||||||
|
|
||||||
tb.AddSimpleTool(wxID_NEW, new_bmp, 'New', 'New file')
|
tb.AddSimpleTool(wx.ID_NEW, new_bmp, 'New', 'New file')
|
||||||
tb.AddSimpleTool(wxID_OPEN, open_bmp, 'Open', 'Open file')
|
tb.AddSimpleTool(wx.ID_OPEN, open_bmp, 'Open', 'Open file')
|
||||||
tb.AddSimpleTool(wxID_SAVE, save_bmp, 'Save', 'Save file')
|
tb.AddSimpleTool(wx.ID_SAVE, save_bmp, 'Save', 'Save file')
|
||||||
tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL))
|
tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL))
|
||||||
tb.AddSimpleTool(wxID_UNDO, undo_bmp, 'Undo', 'Undo')
|
tb.AddSimpleTool(wx.ID_UNDO, undo_bmp, 'Undo', 'Undo')
|
||||||
tb.AddSimpleTool(wxID_REDO, redo_bmp, 'Redo', 'Redo')
|
tb.AddSimpleTool(wx.ID_REDO, redo_bmp, 'Redo', 'Redo')
|
||||||
tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL))
|
tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL))
|
||||||
tb.AddSimpleTool(wxID_CUT, cut_bmp, 'Cut', 'Cut')
|
tb.AddSimpleTool(wx.ID_CUT, cut_bmp, 'Cut', 'Cut')
|
||||||
tb.AddSimpleTool(wxID_COPY, copy_bmp, 'Copy', 'Copy')
|
tb.AddSimpleTool(wx.ID_COPY, copy_bmp, 'Copy', 'Copy')
|
||||||
tb.AddSimpleTool(self.ID_TOOL_PASTE, paste_bmp, 'Paste', 'Paste')
|
tb.AddSimpleTool(self.ID_TOOL_PASTE, paste_bmp, 'Paste', 'Paste')
|
||||||
tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL))
|
tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL))
|
||||||
tb.AddSimpleTool(self.ID_TOOL_LOCATE,
|
tb.AddSimpleTool(self.ID_TOOL_LOCATE,
|
||||||
images.getLocateBitmap(), #images.getLocateArmedBitmap(),
|
images.getLocateBitmap(), #images.getLocateArmedBitmap(),
|
||||||
'Locate', 'Locate control in test window and select it', True)
|
'Locate', 'Locate control in test window and select it', True)
|
||||||
tb.AddControl(wxStaticLine(tb, -1, size=(-1,23), style=wxLI_VERTICAL))
|
tb.AddControl(wx.StaticLine(tb, -1, size=(-1,23), style=wx.LI_VERTICAL))
|
||||||
tb.AddSimpleTool(self.ID_TEST, images.getTestBitmap(), 'Test', 'Test window')
|
tb.AddSimpleTool(self.ID_TEST, images.getTestBitmap(), 'Test', 'Test window')
|
||||||
tb.AddSimpleTool(self.ID_REFRESH, images.getRefreshBitmap(),
|
tb.AddSimpleTool(self.ID_REFRESH, images.getRefreshBitmap(),
|
||||||
'Refresh', 'Refresh view')
|
'Refresh', 'Refresh view')
|
||||||
tb.AddSimpleTool(self.ID_AUTO_REFRESH, images.getAutoRefreshBitmap(),
|
tb.AddSimpleTool(self.ID_AUTO_REFRESH, images.getAutoRefreshBitmap(),
|
||||||
'Auto-refresh', 'Toggle auto-refresh mode', True)
|
'Auto-refresh', 'Toggle auto-refresh mode', True)
|
||||||
# if wxPlatform == '__WXGTK__':
|
# if wx.Platform == '__WXGTK__':
|
||||||
# tb.AddSeparator() # otherwise auto-refresh sticks in status line
|
# tb.AddSeparator() # otherwise auto-refresh sticks in status line
|
||||||
tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh)
|
tb.ToggleTool(self.ID_AUTO_REFRESH, conf.autoRefresh)
|
||||||
tb.Realize()
|
tb.Realize()
|
||||||
@@ -221,53 +221,53 @@ class Frame(wxFrame):
|
|||||||
self.minWidth = tb.GetSize()[0] # minimal width is the size of toolbar
|
self.minWidth = tb.GetSize()[0] # minimal width is the size of toolbar
|
||||||
|
|
||||||
# File
|
# File
|
||||||
EVT_MENU(self, wxID_NEW, self.OnNew)
|
wx.EVT_MENU(self, wx.ID_NEW, self.OnNew)
|
||||||
EVT_MENU(self, wxID_OPEN, self.OnOpen)
|
wx.EVT_MENU(self, wx.ID_OPEN, self.OnOpen)
|
||||||
EVT_MENU(self, wxID_SAVE, self.OnSaveOrSaveAs)
|
wx.EVT_MENU(self, wx.ID_SAVE, self.OnSaveOrSaveAs)
|
||||||
EVT_MENU(self, wxID_SAVEAS, self.OnSaveOrSaveAs)
|
wx.EVT_MENU(self, wx.ID_SAVEAS, self.OnSaveOrSaveAs)
|
||||||
EVT_MENU(self, self.ID_GENERATE_PYTHON, self.OnGeneratePython)
|
wx.EVT_MENU(self, self.ID_GENERATE_PYTHON, self.OnGeneratePython)
|
||||||
EVT_MENU(self, wxID_EXIT, self.OnExit)
|
wx.EVT_MENU(self, wx.ID_EXIT, self.OnExit)
|
||||||
# Edit
|
# Edit
|
||||||
EVT_MENU(self, wxID_UNDO, self.OnUndo)
|
wx.EVT_MENU(self, wx.ID_UNDO, self.OnUndo)
|
||||||
EVT_MENU(self, wxID_REDO, self.OnRedo)
|
wx.EVT_MENU(self, wx.ID_REDO, self.OnRedo)
|
||||||
EVT_MENU(self, wxID_CUT, self.OnCutDelete)
|
wx.EVT_MENU(self, wx.ID_CUT, self.OnCutDelete)
|
||||||
EVT_MENU(self, wxID_COPY, self.OnCopy)
|
wx.EVT_MENU(self, wx.ID_COPY, self.OnCopy)
|
||||||
EVT_MENU(self, wxID_PASTE, self.OnPaste)
|
wx.EVT_MENU(self, wx.ID_PASTE, self.OnPaste)
|
||||||
EVT_MENU(self, self.ID_TOOL_PASTE, self.OnPaste)
|
wx.EVT_MENU(self, self.ID_TOOL_PASTE, self.OnPaste)
|
||||||
EVT_MENU(self, self.ID_DELETE, self.OnCutDelete)
|
wx.EVT_MENU(self, self.ID_DELETE, self.OnCutDelete)
|
||||||
EVT_MENU(self, self.ID_LOCATE, self.OnLocate)
|
wx.EVT_MENU(self, self.ID_LOCATE, self.OnLocate)
|
||||||
EVT_MENU(self, self.ID_TOOL_LOCATE, self.OnLocate)
|
wx.EVT_MENU(self, self.ID_TOOL_LOCATE, self.OnLocate)
|
||||||
# View
|
# View
|
||||||
EVT_MENU(self, self.ID_EMBED_PANEL, self.OnEmbedPanel)
|
wx.EVT_MENU(self, self.ID_EMBED_PANEL, self.OnEmbedPanel)
|
||||||
EVT_MENU(self, self.ID_SHOW_TOOLS, self.OnShowTools)
|
wx.EVT_MENU(self, self.ID_SHOW_TOOLS, self.OnShowTools)
|
||||||
EVT_MENU(self, self.ID_TEST, self.OnTest)
|
wx.EVT_MENU(self, self.ID_TEST, self.OnTest)
|
||||||
EVT_MENU(self, self.ID_REFRESH, self.OnRefresh)
|
wx.EVT_MENU(self, self.ID_REFRESH, self.OnRefresh)
|
||||||
EVT_MENU(self, self.ID_AUTO_REFRESH, self.OnAutoRefresh)
|
wx.EVT_MENU(self, self.ID_AUTO_REFRESH, self.OnAutoRefresh)
|
||||||
EVT_MENU(self, self.ID_TEST_HIDE, self.OnTestHide)
|
wx.EVT_MENU(self, self.ID_TEST_HIDE, self.OnTestHide)
|
||||||
# Help
|
# Help
|
||||||
EVT_MENU(self, wxID_ABOUT, self.OnAbout)
|
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout)
|
||||||
EVT_MENU(self, self.ID_README, self.OnReadme)
|
wx.EVT_MENU(self, self.ID_README, self.OnReadme)
|
||||||
|
|
||||||
# Update events
|
# Update events
|
||||||
EVT_UPDATE_UI(self, wxID_SAVE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, wx.ID_SAVE, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, wxID_CUT, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, wx.ID_CUT, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, wxID_COPY, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, wx.ID_COPY, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, wxID_PASTE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, wx.ID_PASTE, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_LOCATE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_LOCATE, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_TOOL_LOCATE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_TOOL_LOCATE, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_TOOL_PASTE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_TOOL_PASTE, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, wxID_UNDO, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, wx.ID_UNDO, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, wxID_REDO, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, wx.ID_REDO, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_DELETE, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_DELETE, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_TEST, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_TEST, self.OnUpdateUI)
|
||||||
EVT_UPDATE_UI(self, self.ID_REFRESH, self.OnUpdateUI)
|
wx.EVT_UPDATE_UI(self, self.ID_REFRESH, self.OnUpdateUI)
|
||||||
|
|
||||||
# Build interface
|
# Build interface
|
||||||
sizer = wxBoxSizer(wxVERTICAL)
|
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
sizer.Add(wxStaticLine(self, -1), 0, wxEXPAND)
|
sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND)
|
||||||
# Horizontal sizer for toolbar and splitter
|
# Horizontal sizer for toolbar and splitter
|
||||||
self.toolsSizer = sizer1 = wxBoxSizer()
|
self.toolsSizer = sizer1 = wx.BoxSizer()
|
||||||
splitter = wxSplitterWindow(self, -1, style=wxSP_3DSASH)
|
splitter = wx.SplitterWindow(self, -1, style=wx.SP_3DSASH)
|
||||||
self.splitter = splitter
|
self.splitter = splitter
|
||||||
splitter.SetMinimumPaneSize(100)
|
splitter.SetMinimumPaneSize(100)
|
||||||
# Create tree
|
# Create tree
|
||||||
@@ -281,20 +281,20 @@ class Frame(wxFrame):
|
|||||||
# Vertical toolbar for GUI buttons
|
# Vertical toolbar for GUI buttons
|
||||||
g.tools = tools = Tools(self)
|
g.tools = tools = Tools(self)
|
||||||
tools.Show(conf.showTools)
|
tools.Show(conf.showTools)
|
||||||
if conf.showTools: sizer1.Add(tools, 0, wxEXPAND)
|
if conf.showTools: sizer1.Add(tools, 0, wx.EXPAND)
|
||||||
|
|
||||||
tree.RegisterKeyEvents()
|
tree.RegisterKeyEvents()
|
||||||
|
|
||||||
# !!! frame styles are broken
|
# !!! frame styles are broken
|
||||||
# Miniframe for not embedded mode
|
# Miniframe for not embedded mode
|
||||||
miniFrame = wxFrame(self, -1, 'Properties & Style',
|
miniFrame = wx.Frame(self, -1, 'Properties & Style',
|
||||||
(conf.panelX, conf.panelY),
|
(conf.panelX, conf.panelY),
|
||||||
(conf.panelWidth, conf.panelHeight))
|
(conf.panelWidth, conf.panelHeight))
|
||||||
self.miniFrame = miniFrame
|
self.miniFrame = miniFrame
|
||||||
sizer2 = wxBoxSizer()
|
sizer2 = wx.BoxSizer()
|
||||||
miniFrame.SetAutoLayout(True)
|
miniFrame.SetAutoLayout(True)
|
||||||
miniFrame.SetSizer(sizer2)
|
miniFrame.SetSizer(sizer2)
|
||||||
EVT_CLOSE(self.miniFrame, self.OnCloseMiniFrame)
|
wx.EVT_CLOSE(self.miniFrame, self.OnCloseMiniFrame)
|
||||||
# Create panel for parameters
|
# Create panel for parameters
|
||||||
global panel
|
global panel
|
||||||
if conf.embedPanel:
|
if conf.embedPanel:
|
||||||
@@ -303,11 +303,11 @@ class Frame(wxFrame):
|
|||||||
splitter.SplitVertically(tree, panel, conf.sashPos)
|
splitter.SplitVertically(tree, panel, conf.sashPos)
|
||||||
else:
|
else:
|
||||||
panel = Panel(miniFrame)
|
panel = Panel(miniFrame)
|
||||||
sizer2.Add(panel, 1, wxEXPAND)
|
sizer2.Add(panel, 1, wx.EXPAND)
|
||||||
miniFrame.Show(True)
|
miniFrame.Show(True)
|
||||||
splitter.Initialize(tree)
|
splitter.Initialize(tree)
|
||||||
sizer1.Add(splitter, 1, wxEXPAND)
|
sizer1.Add(splitter, 1, wx.EXPAND)
|
||||||
sizer.Add(sizer1, 1, wxEXPAND)
|
sizer.Add(sizer1, 1, wx.EXPAND)
|
||||||
self.SetAutoLayout(True)
|
self.SetAutoLayout(True)
|
||||||
self.SetSizer(sizer)
|
self.SetSizer(sizer)
|
||||||
|
|
||||||
@@ -315,23 +315,23 @@ class Frame(wxFrame):
|
|||||||
self.Clear()
|
self.Clear()
|
||||||
|
|
||||||
# Other events
|
# Other events
|
||||||
EVT_IDLE(self, self.OnIdle)
|
wx.EVT_IDLE(self, self.OnIdle)
|
||||||
EVT_CLOSE(self, self.OnCloseWindow)
|
wx.EVT_CLOSE(self, self.OnCloseWindow)
|
||||||
EVT_KEY_DOWN(self, tools.OnKeyDown)
|
wx.EVT_KEY_DOWN(self, tools.OnKeyDown)
|
||||||
EVT_KEY_UP(self, tools.OnKeyUp)
|
wx.EVT_KEY_UP(self, tools.OnKeyUp)
|
||||||
EVT_ICONIZE(self, self.OnIconize)
|
wx.EVT_ICONIZE(self, self.OnIconize)
|
||||||
|
|
||||||
def AppendRecent(self, menu):
|
def AppendRecent(self, menu):
|
||||||
# add recently used files to the menu
|
# add recently used files to the menu
|
||||||
for id,name in conf.recentfiles.iteritems():
|
for id,name in conf.recentfiles.iteritems():
|
||||||
menu.Append(id,name)
|
menu.Append(id,name)
|
||||||
EVT_MENU(self,id,self.OnRecentFile)
|
wx.EVT_MENU(self,id,self.OnRecentFile)
|
||||||
return
|
return
|
||||||
|
|
||||||
def OnRecentFile(self,evt):
|
def OnRecentFile(self,evt):
|
||||||
# open recently used file
|
# open recently used file
|
||||||
if not self.AskSave(): return
|
if not self.AskSave(): return
|
||||||
wxBeginBusyCursor()
|
wx.BeginBusyCursor()
|
||||||
try:
|
try:
|
||||||
path=conf.recentfiles[evt.GetId()]
|
path=conf.recentfiles[evt.GetId()]
|
||||||
if self.Open(path):
|
if self.Open(path):
|
||||||
@@ -340,7 +340,7 @@ class Frame(wxFrame):
|
|||||||
self.SetStatusText('Failed')
|
self.SetStatusText('Failed')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self.SetStatusText('No such file')
|
self.SetStatusText('No such file')
|
||||||
wxEndBusyCursor()
|
wx.EndBusyCursor()
|
||||||
|
|
||||||
def OnNew(self, evt):
|
def OnNew(self, evt):
|
||||||
if not self.AskSave(): return
|
if not self.AskSave(): return
|
||||||
@@ -348,12 +348,12 @@ class Frame(wxFrame):
|
|||||||
|
|
||||||
def OnOpen(self, evt):
|
def OnOpen(self, evt):
|
||||||
if not self.AskSave(): return
|
if not self.AskSave(): return
|
||||||
dlg = wxFileDialog(self, 'Open', os.path.dirname(self.dataFile),
|
dlg = wx.FileDialog(self, 'Open', os.path.dirname(self.dataFile),
|
||||||
'', '*.xrc', wxOPEN | wxCHANGE_DIR)
|
'', '*.xrc', wx.OPEN | wx.CHANGE_DIR)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
path = dlg.GetPath()
|
path = dlg.GetPath()
|
||||||
self.SetStatusText('Loading...')
|
self.SetStatusText('Loading...')
|
||||||
wxBeginBusyCursor()
|
wx.BeginBusyCursor()
|
||||||
try:
|
try:
|
||||||
if self.Open(path):
|
if self.Open(path):
|
||||||
self.SetStatusText('Data loaded')
|
self.SetStatusText('Data loaded')
|
||||||
@@ -361,17 +361,17 @@ class Frame(wxFrame):
|
|||||||
self.SetStatusText('Failed')
|
self.SetStatusText('Failed')
|
||||||
self.SaveRecent(path)
|
self.SaveRecent(path)
|
||||||
finally:
|
finally:
|
||||||
wxEndBusyCursor()
|
wx.EndBusyCursor()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
def OnSaveOrSaveAs(self, evt):
|
def OnSaveOrSaveAs(self, evt):
|
||||||
if evt.GetId() == wxID_SAVEAS or not self.dataFile:
|
if evt.GetId() == wx.ID_SAVEAS or not self.dataFile:
|
||||||
if self.dataFile: name = ''
|
if self.dataFile: name = ''
|
||||||
else: name = defaultName
|
else: name = defaultName
|
||||||
dirname = os.path.abspath(os.path.dirname(self.dataFile))
|
dirname = os.path.abspath(os.path.dirname(self.dataFile))
|
||||||
dlg = wxFileDialog(self, 'Save As', dirname, name, '*.xrc',
|
dlg = wx.FileDialog(self, 'Save As', dirname, name, '*.xrc',
|
||||||
wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR)
|
wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
path = dlg.GetPath()
|
path = dlg.GetPath()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
else:
|
else:
|
||||||
@@ -394,7 +394,7 @@ class Frame(wxFrame):
|
|||||||
else:
|
else:
|
||||||
path = self.dataFile
|
path = self.dataFile
|
||||||
self.SetStatusText('Saving...')
|
self.SetStatusText('Saving...')
|
||||||
wxBeginBusyCursor()
|
wx.BeginBusyCursor()
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
tmpFile,tmpName = tempfile.mkstemp(prefix='xrced-')
|
tmpFile,tmpName = tempfile.mkstemp(prefix='xrced-')
|
||||||
@@ -413,14 +413,14 @@ class Frame(wxFrame):
|
|||||||
except IOError:
|
except IOError:
|
||||||
self.SetStatusText('Failed')
|
self.SetStatusText('Failed')
|
||||||
finally:
|
finally:
|
||||||
wxEndBusyCursor()
|
wx.EndBusyCursor()
|
||||||
|
|
||||||
def SaveRecent(self,path):
|
def SaveRecent(self,path):
|
||||||
# append to recently used files
|
# append to recently used files
|
||||||
if path not in conf.recentfiles.values():
|
if path not in conf.recentfiles.values():
|
||||||
newid = wxNewId()
|
newid = wx.NewId()
|
||||||
self.recentMenu.Append(newid, path)
|
self.recentMenu.Append(newid, path)
|
||||||
EVT_MENU(self, newid, self.OnRecentFile)
|
wx.EVT_MENU(self, newid, self.OnRecentFile)
|
||||||
conf.recentfiles[newid] = path
|
conf.recentfiles[newid] = path
|
||||||
|
|
||||||
def GeneratePython(self, dataFile, pypath, embed, genGettext):
|
def GeneratePython(self, dataFile, pypath, embed, genGettext):
|
||||||
@@ -430,8 +430,8 @@ class Frame(wxFrame):
|
|||||||
rescomp.MakePythonModule(dataFile, pypath, embed, genGettext)
|
rescomp.MakePythonModule(dataFile, pypath, embed, genGettext)
|
||||||
except:
|
except:
|
||||||
inf = sys.exc_info()
|
inf = sys.exc_info()
|
||||||
wxLogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
wx.LogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
||||||
wxLogError('Error generating python code : %s' % pypath)
|
wx.LogError('Error generating python code : %s' % pypath)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
@@ -495,7 +495,7 @@ class Frame(wxFrame):
|
|||||||
parentLeaf = selected
|
parentLeaf = selected
|
||||||
else:
|
else:
|
||||||
# No children or unexpanded item - appendChild stays True
|
# No children or unexpanded item - appendChild stays True
|
||||||
nextItem = wxTreeItemId() # no next item
|
nextItem = wx.TreeItemId() # no next item
|
||||||
parentLeaf = selected
|
parentLeaf = selected
|
||||||
parent = tree.GetPyData(parentLeaf).treeObject()
|
parent = tree.GetPyData(parentLeaf).treeObject()
|
||||||
|
|
||||||
@@ -551,7 +551,7 @@ class Frame(wxFrame):
|
|||||||
if error:
|
if error:
|
||||||
if parent.__class__ == xxxMainNode: parentClass = 'root'
|
if parent.__class__ == xxxMainNode: parentClass = 'root'
|
||||||
else: parentClass = parent.className
|
else: parentClass = parent.className
|
||||||
wxLogError('Incompatible parent/child: parent is %s, child is %s!' %
|
wx.LogError('Incompatible parent/child: parent is %s, child is %s!' %
|
||||||
(parentClass, x.className))
|
(parentClass, x.className))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -612,7 +612,7 @@ class Frame(wxFrame):
|
|||||||
selected = tree.selection
|
selected = tree.selection
|
||||||
if not selected: return # key pressed event
|
if not selected: return # key pressed event
|
||||||
# Undo info
|
# Undo info
|
||||||
if evt.GetId() == wxID_CUT:
|
if evt.GetId() == wx.ID_CUT:
|
||||||
self.lastOp = 'CUT'
|
self.lastOp = 'CUT'
|
||||||
status = 'Removed to clipboard'
|
status = 'Removed to clipboard'
|
||||||
else:
|
else:
|
||||||
@@ -635,7 +635,7 @@ class Frame(wxFrame):
|
|||||||
parent = tree.GetPyData(tree.GetItemParent(selected)).treeObject()
|
parent = tree.GetPyData(tree.GetItemParent(selected)).treeObject()
|
||||||
elem = tree.RemoveLeaf(selected)
|
elem = tree.RemoveLeaf(selected)
|
||||||
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
|
undoMan.RegisterUndo(UndoCutDelete(index, parent, elem))
|
||||||
if evt.GetId() == wxID_CUT:
|
if evt.GetId() == wx.ID_CUT:
|
||||||
if wx.TheClipboard.Open():
|
if wx.TheClipboard.Open():
|
||||||
data = wx.CustomDataObject('XRCED')
|
data = wx.CustomDataObject('XRCED')
|
||||||
# (False, True)
|
# (False, True)
|
||||||
@@ -659,8 +659,8 @@ class Frame(wxFrame):
|
|||||||
xxx = tree.GetPyData(selected).treeObject()
|
xxx = tree.GetPyData(selected).treeObject()
|
||||||
elem = xxx.element
|
elem = xxx.element
|
||||||
subclass = xxx.subclass
|
subclass = xxx.subclass
|
||||||
dlg = wxTextEntryDialog(self, 'Subclass:', defaultValue=subclass)
|
dlg = wx.TextEntryDialog(self, 'Subclass:', defaultValue=subclass)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
subclass = dlg.GetValue()
|
subclass = dlg.GetValue()
|
||||||
if subclass:
|
if subclass:
|
||||||
elem.setAttribute('subclass', subclass)
|
elem.setAttribute('subclass', subclass)
|
||||||
@@ -696,7 +696,7 @@ class Frame(wxFrame):
|
|||||||
sizer = self.miniFrame.GetSizer()
|
sizer = self.miniFrame.GetSizer()
|
||||||
panel.Reparent(self.miniFrame)
|
panel.Reparent(self.miniFrame)
|
||||||
panel.Show(True)
|
panel.Show(True)
|
||||||
sizer.Add(panel, 1, wxEXPAND)
|
sizer.Add(panel, 1, wx.EXPAND)
|
||||||
self.miniFrame.Show(True)
|
self.miniFrame.Show(True)
|
||||||
self.miniFrame.SetDimensions(conf.panelX, conf.panelY,
|
self.miniFrame.SetDimensions(conf.panelX, conf.panelY,
|
||||||
conf.panelWidth, conf.panelHeight)
|
conf.panelWidth, conf.panelHeight)
|
||||||
@@ -708,7 +708,7 @@ class Frame(wxFrame):
|
|||||||
conf.showTools = evt.IsChecked()
|
conf.showTools = evt.IsChecked()
|
||||||
g.tools.Show(conf.showTools)
|
g.tools.Show(conf.showTools)
|
||||||
if conf.showTools:
|
if conf.showTools:
|
||||||
self.toolsSizer.Prepend(g.tools, 0, wxEXPAND)
|
self.toolsSizer.Prepend(g.tools, 0, wx.EXPAND)
|
||||||
else:
|
else:
|
||||||
self.toolsSizer.Remove(g.tools)
|
self.toolsSizer.Remove(g.tools)
|
||||||
self.toolsSizer.Layout()
|
self.toolsSizer.Layout()
|
||||||
@@ -725,7 +725,7 @@ class Frame(wxFrame):
|
|||||||
# We simply perform depth-first traversal, sinse it's too much
|
# We simply perform depth-first traversal, sinse it's too much
|
||||||
# hassle to deal with all sizer/window combinations
|
# hassle to deal with all sizer/window combinations
|
||||||
w = tree.FindNodeObject(item)
|
w = tree.FindNodeObject(item)
|
||||||
if w == obj or isinstance(w, wxGBSizerItem) and w.GetWindow() == obj:
|
if w == obj or isinstance(w, wx.GBSizerItem) and w.GetWindow() == obj:
|
||||||
return item
|
return item
|
||||||
if tree.ItemHasChildren(item):
|
if tree.ItemHasChildren(item):
|
||||||
child = tree.GetFirstChild(item)[0]
|
child = tree.GetFirstChild(item)[0]
|
||||||
@@ -738,7 +738,7 @@ class Frame(wxFrame):
|
|||||||
def OnTestWinLeftDown(self, evt):
|
def OnTestWinLeftDown(self, evt):
|
||||||
pos = evt.GetPosition()
|
pos = evt.GetPosition()
|
||||||
self.SetHandler(g.testWin)
|
self.SetHandler(g.testWin)
|
||||||
g.testWin.Disconnect(wxID_ANY, wxID_ANY, wxEVT_LEFT_DOWN)
|
g.testWin.Disconnect(wx.ID_ANY, wx.ID_ANY, wx.wxEVT_LEFT_DOWN)
|
||||||
item = self.FindObject(g.testWin.item, evt.GetEventObject())
|
item = self.FindObject(g.testWin.item, evt.GetEventObject())
|
||||||
if item:
|
if item:
|
||||||
tree.EnsureVisible(item)
|
tree.EnsureVisible(item)
|
||||||
@@ -752,10 +752,10 @@ class Frame(wxFrame):
|
|||||||
def SetHandler(self, w, h=None):
|
def SetHandler(self, w, h=None):
|
||||||
if h:
|
if h:
|
||||||
w.SetEventHandler(h)
|
w.SetEventHandler(h)
|
||||||
w.SetCursor(wxCROSS_CURSOR)
|
w.SetCursor(wx.CROSS_CURSOR)
|
||||||
else:
|
else:
|
||||||
w.SetEventHandler(w)
|
w.SetEventHandler(w)
|
||||||
w.SetCursor(wxNullCursor)
|
w.SetCursor(wx.NullCursor)
|
||||||
for ch in w.GetChildren():
|
for ch in w.GetChildren():
|
||||||
self.SetHandler(ch, h)
|
self.SetHandler(ch, h)
|
||||||
|
|
||||||
@@ -764,12 +764,12 @@ class Frame(wxFrame):
|
|||||||
if evt.GetId() == self.ID_LOCATE or \
|
if evt.GetId() == self.ID_LOCATE or \
|
||||||
evt.GetId() == self.ID_TOOL_LOCATE and evt.IsChecked():
|
evt.GetId() == self.ID_TOOL_LOCATE and evt.IsChecked():
|
||||||
self.SetHandler(g.testWin, g.testWin)
|
self.SetHandler(g.testWin, g.testWin)
|
||||||
g.testWin.Connect(wxID_ANY, wxID_ANY, wxEVT_LEFT_DOWN, self.OnTestWinLeftDown)
|
g.testWin.Connect(wx.ID_ANY, wx.ID_ANY, wx.wxEVT_LEFT_DOWN, self.OnTestWinLeftDown)
|
||||||
if evt.GetId() == self.ID_LOCATE:
|
if evt.GetId() == self.ID_LOCATE:
|
||||||
self.tb.ToggleTool(self.ID_TOOL_LOCATE, True)
|
self.tb.ToggleTool(self.ID_TOOL_LOCATE, True)
|
||||||
elif evt.GetId() == self.ID_TOOL_LOCATE and not evt.IsChecked():
|
elif evt.GetId() == self.ID_TOOL_LOCATE and not evt.IsChecked():
|
||||||
self.SetHandler(g.testWin, None)
|
self.SetHandler(g.testWin, None)
|
||||||
g.testWin.Disconnect(wxID_ANY, wxID_ANY, wxEVT_LEFT_DOWN)
|
g.testWin.Disconnect(wx.ID_ANY, wx.ID_ANY, wx.wxEVT_LEFT_DOWN)
|
||||||
self.SetStatusText('Click somewhere in your test window now')
|
self.SetStatusText('Click somewhere in your test window now')
|
||||||
|
|
||||||
def OnRefresh(self, evt):
|
def OnRefresh(self, evt):
|
||||||
@@ -797,7 +797,7 @@ XRCed version %s
|
|||||||
(c) Roman Rolinsky <rollrom@users.sourceforge.net>
|
(c) Roman Rolinsky <rollrom@users.sourceforge.net>
|
||||||
Homepage: http://xrced.sourceforge.net\
|
Homepage: http://xrced.sourceforge.net\
|
||||||
''' % version
|
''' % version
|
||||||
dlg = wxMessageDialog(self, str, 'About XRCed', wxOK | wxCENTRE)
|
dlg = wx.MessageDialog(self, str, 'About XRCed', wx.OK | wx.CENTRE)
|
||||||
dlg.ShowModal()
|
dlg.ShowModal()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
@@ -843,14 +843,14 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
nextItem = tree.GetFirstChild(selected)[0]
|
nextItem = tree.GetFirstChild(selected)[0]
|
||||||
parentLeaf = selected
|
parentLeaf = selected
|
||||||
else:
|
else:
|
||||||
nextItem = wxTreeItemId()
|
nextItem = wx.TreeItemId()
|
||||||
parentLeaf = selected
|
parentLeaf = selected
|
||||||
parent = tree.GetPyData(parentLeaf)
|
parent = tree.GetPyData(parentLeaf)
|
||||||
if parent.hasChild: parent = parent.child
|
if parent.hasChild: parent = parent.child
|
||||||
|
|
||||||
# Create object_ref?
|
# Create object_ref?
|
||||||
if evt.GetId() == ID_NEW.REF:
|
if evt.GetId() == ID_NEW.REF:
|
||||||
ref = wxGetTextFromUser('Create reference to:', 'Create reference')
|
ref = wx.GetTextFromUser('Create reference to:', 'Create reference')
|
||||||
if not ref: return
|
if not ref: return
|
||||||
xxx = MakeEmptyRefXXX(parent, ref)
|
xxx = MakeEmptyRefXXX(parent, ref)
|
||||||
else:
|
else:
|
||||||
@@ -1021,18 +1021,18 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
self.SetStatusText('')
|
self.SetStatusText('')
|
||||||
|
|
||||||
def OnUpdateUI(self, evt):
|
def OnUpdateUI(self, evt):
|
||||||
if evt.GetId() in [wxID_CUT, wxID_COPY, self.ID_DELETE]:
|
if evt.GetId() in [wx.ID_CUT, wx.ID_COPY, self.ID_DELETE]:
|
||||||
evt.Enable(tree.selection is not None and tree.selection != tree.root)
|
evt.Enable(tree.selection is not None and tree.selection != tree.root)
|
||||||
elif evt.GetId() == wxID_SAVE:
|
elif evt.GetId() == wx.ID_SAVE:
|
||||||
evt.Enable(self.modified)
|
evt.Enable(self.modified)
|
||||||
elif evt.GetId() in [wxID_PASTE, self.ID_TOOL_PASTE]:
|
elif evt.GetId() in [wx.ID_PASTE, self.ID_TOOL_PASTE]:
|
||||||
evt.Enable(tree.selection is not None)
|
evt.Enable(tree.selection is not None)
|
||||||
elif evt.GetId() == self.ID_TEST:
|
elif evt.GetId() == self.ID_TEST:
|
||||||
evt.Enable(tree.selection is not None and tree.selection != tree.root)
|
evt.Enable(tree.selection is not None and tree.selection != tree.root)
|
||||||
elif evt.GetId() in [self.ID_LOCATE, self.ID_TOOL_LOCATE]:
|
elif evt.GetId() in [self.ID_LOCATE, self.ID_TOOL_LOCATE]:
|
||||||
evt.Enable(g.testWin is not None)
|
evt.Enable(g.testWin is not None)
|
||||||
elif evt.GetId() == wxID_UNDO: evt.Enable(undoMan.CanUndo())
|
elif evt.GetId() == wx.ID_UNDO: evt.Enable(undoMan.CanUndo())
|
||||||
elif evt.GetId() == wxID_REDO: evt.Enable(undoMan.CanRedo())
|
elif evt.GetId() == wx.ID_REDO: evt.Enable(undoMan.CanRedo())
|
||||||
|
|
||||||
def OnIdle(self, evt):
|
def OnIdle(self, evt):
|
||||||
if self.inIdle: return # Recursive call protection
|
if self.inIdle: return # Recursive call protection
|
||||||
@@ -1128,7 +1128,7 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
|
|
||||||
def Open(self, path):
|
def Open(self, path):
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
wxLogError('File does not exists: %s' % path)
|
wx.LogError('File does not exists: %s' % path)
|
||||||
return False
|
return False
|
||||||
# Try to read the file
|
# Try to read the file
|
||||||
try:
|
try:
|
||||||
@@ -1152,8 +1152,8 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
except:
|
except:
|
||||||
# Nice exception printing
|
# Nice exception printing
|
||||||
inf = sys.exc_info()
|
inf = sys.exc_info()
|
||||||
wxLogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
wx.LogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
||||||
wxLogError('Error reading file: %s' % path)
|
wx.LogError('Error reading file: %s' % path)
|
||||||
if debug: raise
|
if debug: raise
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
@@ -1180,7 +1180,7 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
import codecs
|
import codecs
|
||||||
# Apply changes
|
# Apply changes
|
||||||
if tree.selection and panel.IsModified():
|
if tree.selection and panel.IsModified():
|
||||||
self.OnRefresh(wxCommandEvent())
|
self.OnRefresh(wx.CommandEvent())
|
||||||
if g.currentEncoding:
|
if g.currentEncoding:
|
||||||
f = codecs.open(path, 'wt', g.currentEncoding)
|
f = codecs.open(path, 'wt', g.currentEncoding)
|
||||||
else:
|
else:
|
||||||
@@ -1204,23 +1204,23 @@ Homepage: http://xrced.sourceforge.net\
|
|||||||
conf.localconf.Flush()
|
conf.localconf.Flush()
|
||||||
except:
|
except:
|
||||||
inf = sys.exc_info()
|
inf = sys.exc_info()
|
||||||
wxLogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
wx.LogError(traceback.format_exception(inf[0], inf[1], None)[-1])
|
||||||
wxLogError('Error writing file: %s' % path)
|
wx.LogError('Error writing file: %s' % path)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def AskSave(self):
|
def AskSave(self):
|
||||||
if not (self.modified or panel.IsModified()): return True
|
if not (self.modified or panel.IsModified()): return True
|
||||||
flags = wxICON_EXCLAMATION | wxYES_NO | wxCANCEL | wxCENTRE
|
flags = wx.ICON_EXCLAMATION | wx.YES_NO | wx.CANCEL | wx.CENTRE
|
||||||
dlg = wxMessageDialog( self, 'File is modified. Save before exit?',
|
dlg = wx.MessageDialog( self, 'File is modified. Save before exit?',
|
||||||
'Save before too late?', flags )
|
'Save before too late?', flags )
|
||||||
say = dlg.ShowModal()
|
say = dlg.ShowModal()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
wxYield()
|
wx.Yield()
|
||||||
if say == wxID_YES:
|
if say == wx.ID_YES:
|
||||||
self.OnSaveOrSaveAs(wxCommandEvent(wxID_SAVE))
|
self.OnSaveOrSaveAs(wx.CommandEvent(wx.ID_SAVE))
|
||||||
# If save was successful, modified flag is unset
|
# If save was successful, modified flag is unset
|
||||||
if not self.modified: return True
|
if not self.modified: return True
|
||||||
elif say == wxID_NO:
|
elif say == wx.ID_NO:
|
||||||
self.SetModified(False)
|
self.SetModified(False)
|
||||||
panel.SetModified(False)
|
panel.SetModified(False)
|
||||||
return True
|
return True
|
||||||
@@ -1241,14 +1241,14 @@ class PythonOptions(wx.Dialog):
|
|||||||
self.cfg = cfg
|
self.cfg = cfg
|
||||||
self.dataFile = dataFile
|
self.dataFile = dataFile
|
||||||
|
|
||||||
self.AutoGenerateCB = XRCCTRL(self, "AutoGenerateCB")
|
self.AutoGenerateCB = xrc.XRCCTRL(self, "AutoGenerateCB")
|
||||||
self.EmbedCB = XRCCTRL(self, "EmbedCB")
|
self.EmbedCB = xrc.XRCCTRL(self, "EmbedCB")
|
||||||
self.GettextCB = XRCCTRL(self, "GettextCB")
|
self.GettextCB = xrc.XRCCTRL(self, "GettextCB")
|
||||||
self.MakeXRSFileCB = XRCCTRL(self, "MakeXRSFileCB")
|
self.MakeXRSFileCB = xrc.XRCCTRL(self, "MakeXRSFileCB")
|
||||||
self.FileNameTC = XRCCTRL(self, "FileNameTC")
|
self.FileNameTC = xrc.XRCCTRL(self, "FileNameTC")
|
||||||
self.BrowseBtn = XRCCTRL(self, "BrowseBtn")
|
self.BrowseBtn = xrc.XRCCTRL(self, "BrowseBtn")
|
||||||
self.GenerateBtn = XRCCTRL(self, "GenerateBtn")
|
self.GenerateBtn = xrc.XRCCTRL(self, "GenerateBtn")
|
||||||
self.SaveOptsBtn = XRCCTRL(self, "SaveOptsBtn")
|
self.SaveOptsBtn = xrc.XRCCTRL(self, "SaveOptsBtn")
|
||||||
|
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnBrowse, self.BrowseBtn)
|
self.Bind(wx.EVT_BUTTON, self.OnBrowse, self.BrowseBtn)
|
||||||
self.Bind(wx.EVT_BUTTON, self.OnGenerate, self.GenerateBtn)
|
self.Bind(wx.EVT_BUTTON, self.OnGenerate, self.GenerateBtn)
|
||||||
@@ -1270,9 +1270,9 @@ class PythonOptions(wx.Dialog):
|
|||||||
path = self.FileNameTC.GetValue()
|
path = self.FileNameTC.GetValue()
|
||||||
dirname = os.path.abspath(os.path.dirname(path))
|
dirname = os.path.abspath(os.path.dirname(path))
|
||||||
name = os.path.split(path)[1]
|
name = os.path.split(path)[1]
|
||||||
dlg = wxFileDialog(self, 'Save As', dirname, name, '*.py',
|
dlg = wx.FileDialog(self, 'Save As', dirname, name, '*.py',
|
||||||
wxSAVE | wxOVERWRITE_PROMPT)
|
wx.SAVE | wx.OVERWRITE_PROMPT)
|
||||||
if dlg.ShowModal() == wxID_OK:
|
if dlg.ShowModal() == wx.ID_OK:
|
||||||
path = dlg.GetPath()
|
path = dlg.GetPath()
|
||||||
self.FileNameTC.SetValue(path)
|
self.FileNameTC.SetValue(path)
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
@@ -1301,13 +1301,13 @@ class PythonOptions(wx.Dialog):
|
|||||||
def usage():
|
def usage():
|
||||||
print >> sys.stderr, 'usage: xrced [-dhiv] [file]'
|
print >> sys.stderr, 'usage: xrced [-dhiv] [file]'
|
||||||
|
|
||||||
class App(wxApp):
|
class App(wx.App):
|
||||||
def OnInit(self):
|
def OnInit(self):
|
||||||
# Check version
|
# Check version
|
||||||
if wxVERSION[:3] < MinWxVersion:
|
if wx.VERSION[:3] < MinWxVersion:
|
||||||
wxLogWarning('''\
|
wx.LogWarning('''\
|
||||||
This version of XRCed may not work correctly on your version of wxWindows. \
|
This version of XRCed may not work correctly on your version of wxWidgets. \
|
||||||
Please upgrade wxWindows to %d.%d.%d or higher.''' % MinWxVersion)
|
Please upgrade wxWidgets to %d.%d.%d or higher.''' % MinWxVersion)
|
||||||
global debug
|
global debug
|
||||||
# Process comand-line
|
# Process comand-line
|
||||||
opts = args = None
|
opts = args = None
|
||||||
@@ -1324,7 +1324,7 @@ Please upgrade wxWindows to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
if wxPlatform != '__WXMAC__': # macs have some extra parameters
|
if wx.Platform != '__WXMAC__': # macs have some extra parameters
|
||||||
print >> sys.stderr, 'Unknown option'
|
print >> sys.stderr, 'Unknown option'
|
||||||
usage()
|
usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
@@ -1332,7 +1332,7 @@ Please upgrade wxWindows to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
self.SetAppName('xrced')
|
self.SetAppName('xrced')
|
||||||
# Settings
|
# Settings
|
||||||
global conf
|
global conf
|
||||||
conf = g.conf = wxConfig(style = wxCONFIG_USE_LOCAL_FILE)
|
conf = g.conf = wx.Config(style = wx.CONFIG_USE_LOCAL_FILE)
|
||||||
conf.localconf = None
|
conf.localconf = None
|
||||||
conf.autoRefresh = conf.ReadInt('autorefresh', True)
|
conf.autoRefresh = conf.ReadInt('autorefresh', True)
|
||||||
pos = conf.ReadInt('x', -1), conf.ReadInt('y', -1)
|
pos = conf.ReadInt('x', -1), conf.ReadInt('y', -1)
|
||||||
@@ -1345,7 +1345,7 @@ Please upgrade wxWindows to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
conf.recentfiles={}
|
conf.recentfiles={}
|
||||||
if recentfiles:
|
if recentfiles:
|
||||||
for fil in recentfiles.split('|'):
|
for fil in recentfiles.split('|'):
|
||||||
conf.recentfiles[wxNewId()]=fil
|
conf.recentfiles[wx.NewId()]=fil
|
||||||
if not conf.embedPanel:
|
if not conf.embedPanel:
|
||||||
conf.panelX = conf.ReadInt('panelX', -1)
|
conf.panelX = conf.ReadInt('panelX', -1)
|
||||||
conf.panelY = conf.ReadInt('panelY', -1)
|
conf.panelY = conf.ReadInt('panelY', -1)
|
||||||
@@ -1355,7 +1355,7 @@ Please upgrade wxWindows to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
conf.panelHeight = conf.ReadInt('panelHeight', 200)
|
conf.panelHeight = conf.ReadInt('panelHeight', 200)
|
||||||
conf.panic = not conf.HasEntry('nopanic')
|
conf.panic = not conf.HasEntry('nopanic')
|
||||||
# Add handlers
|
# Add handlers
|
||||||
wxFileSystem_AddHandler(wxMemoryFSHandler())
|
wx.FileSystem.AddHandler(wx.MemoryFSHandler())
|
||||||
# Create main frame
|
# Create main frame
|
||||||
frame = Frame(pos, size)
|
frame = Frame(pos, size)
|
||||||
frame.Show(True)
|
frame.Show(True)
|
||||||
@@ -1390,7 +1390,7 @@ Please upgrade wxWindows to %d.%d.%d or higher.''' % MinWxVersion)
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
app = App(0, useBestVisual=False)
|
app = App(0, useBestVisual=False)
|
||||||
#app.SetAssertMode(wxPYAPP_ASSERT_LOG)
|
#app.SetAssertMode(wx.PYAPP_ASSERT_LOG)
|
||||||
app.MainLoop()
|
app.MainLoop()
|
||||||
app.OnExit()
|
app.OnExit()
|
||||||
global conf
|
global conf
|
||||||
|
@@ -40,7 +40,7 @@ class xxxParam(xxxNode):
|
|||||||
# Use convertion from unicode to current encoding
|
# Use convertion from unicode to current encoding
|
||||||
self.textNode = text
|
self.textNode = text
|
||||||
# Value returns string
|
# Value returns string
|
||||||
if wxUSE_UNICODE: # no conversion is needed
|
if wx.USE_UNICODE: # no conversion is needed
|
||||||
def value(self):
|
def value(self):
|
||||||
return self.textNode.data
|
return self.textNode.data
|
||||||
def update(self, value):
|
def update(self, value):
|
||||||
@@ -56,7 +56,7 @@ class xxxParam(xxxNode):
|
|||||||
self.textNode.data = unicode(value, g.currentEncoding)
|
self.textNode.data = unicode(value, g.currentEncoding)
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
self.textNode.data = unicode(value)
|
self.textNode.data = unicode(value)
|
||||||
#wxLogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate")
|
#wx.LogMessage("Unicode error: set encoding in file\nglobals.py to something appropriate")
|
||||||
|
|
||||||
# Integer parameter
|
# Integer parameter
|
||||||
class xxxParamInt(xxxParam):
|
class xxxParamInt(xxxParam):
|
||||||
@@ -285,7 +285,7 @@ class xxxObject:
|
|||||||
else:
|
else:
|
||||||
self.element.appendChild(elem)
|
self.element.appendChild(elem)
|
||||||
else:
|
else:
|
||||||
wxLogWarning('Required parameter %s of %s missing' %
|
wx.LogWarning('Required parameter %s of %s missing' %
|
||||||
(param, self.className))
|
(param, self.className))
|
||||||
# Returns real tree object
|
# Returns real tree object
|
||||||
def treeObject(self):
|
def treeObject(self):
|
||||||
@@ -338,7 +338,7 @@ def DoFindResource(parent, name, classname, recursive):
|
|||||||
def FindResource(name, classname='', recursive=True):
|
def FindResource(name, classname='', recursive=True):
|
||||||
found = DoFindResource(g.tree.mainNode, name, classname, recursive)
|
found = DoFindResource(g.tree.mainNode, name, classname, recursive)
|
||||||
if found: return found
|
if found: return found
|
||||||
wxLogError('XRC resource "%s" not found!' % name)
|
wx.LogError('XRC resource "%s" not found!' % name)
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
@@ -649,6 +649,8 @@ class xxxButton(xxxObject):
|
|||||||
class xxxBitmapButton(xxxObject):
|
class xxxBitmapButton(xxxObject):
|
||||||
allParams = ['bitmap', 'selected', 'focus', 'disabled', 'default',
|
allParams = ['bitmap', 'selected', 'focus', 'disabled', 'default',
|
||||||
'pos', 'size', 'style']
|
'pos', 'size', 'style']
|
||||||
|
paramDict = {'selected': ParamBitmap, 'focus': ParamBitmap, 'disabled': ParamBitmap,
|
||||||
|
'default': ParamBool}
|
||||||
required = ['bitmap']
|
required = ['bitmap']
|
||||||
winStyles = ['wxBU_AUTODRAW', 'wxBU_LEFT', 'wxBU_RIGHT',
|
winStyles = ['wxBU_AUTODRAW', 'wxBU_LEFT', 'wxBU_RIGHT',
|
||||||
'wxBU_TOP', 'wxBU_BOTTOM', 'wxBU_EXACTFIT']
|
'wxBU_TOP', 'wxBU_BOTTOM', 'wxBU_EXACTFIT']
|
||||||
@@ -978,16 +980,16 @@ xxxDict = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Create IDs for all parameters of all classes
|
# Create IDs for all parameters of all classes
|
||||||
paramIDs = {'fg': wxNewId(), 'bg': wxNewId(), 'exstyle': wxNewId(), 'font': wxNewId(),
|
paramIDs = {'fg': wx.NewId(), 'bg': wx.NewId(), 'exstyle': wx.NewId(), 'font': wx.NewId(),
|
||||||
'enabled': wxNewId(), 'focused': wxNewId(), 'hidden': wxNewId(),
|
'enabled': wx.NewId(), 'focused': wx.NewId(), 'hidden': wx.NewId(),
|
||||||
'tooltip': wxNewId(), 'encoding': wxNewId(),
|
'tooltip': wx.NewId(), 'encoding': wx.NewId(),
|
||||||
'cellpos': wxNewId(), 'cellspan': wxNewId()
|
'cellpos': wx.NewId(), 'cellspan': wx.NewId()
|
||||||
}
|
}
|
||||||
for cl in xxxDict.values():
|
for cl in xxxDict.values():
|
||||||
if cl.allParams:
|
if cl.allParams:
|
||||||
for param in cl.allParams + cl.paramDict.keys():
|
for param in cl.allParams + cl.paramDict.keys():
|
||||||
if not paramIDs.has_key(param):
|
if not paramIDs.has_key(param):
|
||||||
paramIDs[param] = wxNewId()
|
paramIDs[param] = wx.NewId()
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Helper functions
|
# Helper functions
|
||||||
|
Reference in New Issue
Block a user