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