wxGridBahSizer support
exception handling while loading resource some fixes (GetFirstChild, XRCID instead of FindByName, ...) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25156 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
0.1.2-1
|
||||
_______
|
||||
|
||||
Added support for wxGridBagSizer (supported in wxPython 2.5).
|
||||
|
||||
0.1.1-5
|
||||
-------
|
||||
|
||||
Added subclass attribute.
|
||||
|
||||
0.1.1-4
|
||||
-------
|
||||
|
||||
|
@@ -16,7 +16,7 @@ modernFont = wxFont(sysFont.GetPointSize(), wxMODERN, wxNORMAL, wxNORMAL)
|
||||
smallerFont = wxFont(sysFont.GetPointSize()-2, wxDEFAULT, wxNORMAL, wxNORMAL)
|
||||
|
||||
progname = 'XRCed'
|
||||
version = '0.1.1-4'
|
||||
version = '0.1.2-1'
|
||||
|
||||
try:
|
||||
True
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -87,13 +87,16 @@ class Panel(wxNotebook):
|
||||
sizer.Add(wxStaticText(self.page1, -1, 'Select a tree item.'))
|
||||
else:
|
||||
g.currentXXX = xxx.treeObject()
|
||||
# Normal or SizerItem page
|
||||
isGBSizerItem = isinstance(xxx.parent, xxxGridBagSizer)
|
||||
cacheID = (xxx.__class__, isGBSizerItem)
|
||||
try:
|
||||
page = self.pageCache[xxx.__class__]
|
||||
page = self.pageCache[cacheID]
|
||||
page.box.SetLabel(xxx.panelName())
|
||||
page.Reparent(self.page1)
|
||||
except KeyError:
|
||||
page = PropPage(self.page1, xxx.panelName(), xxx)
|
||||
self.pageCache[xxx.__class__] = page
|
||||
self.pageCache[cacheID] = page
|
||||
page.SetValues(xxx)
|
||||
self.pages.append(page)
|
||||
sizer.Add(page, 1, wxEXPAND)
|
||||
|
@@ -60,9 +60,9 @@ class ParamBinaryOr(PPanel):
|
||||
self.text.SetValue(value)
|
||||
self.freeze = False
|
||||
def OnButtonChoices(self, evt):
|
||||
dlg = wxDialog(self, -1, 'Choices')
|
||||
topSizer = wxBoxSizer(wxVERTICAL)
|
||||
listBox = wxCheckListBox(dlg, -1, choices=self.values, size=(250,200))
|
||||
dlg = g.frame.res.LoadDialog(self, 'DIALOG_CHOICES')
|
||||
listBox = XRCCTRL(dlg, 'CHECK_LIST')
|
||||
listBox.InsertItems(self.values, 0)
|
||||
value = map(string.strip, self.text.GetValue().split('|'))
|
||||
if value == ['']: value = []
|
||||
ignored = []
|
||||
@@ -76,18 +76,6 @@ class ParamBinaryOr(PPanel):
|
||||
else:
|
||||
print 'WARNING: unknown flag: %s: ignored.' % i
|
||||
ignored.append(i)
|
||||
topSizer.Add(listBox, 1, wxEXPAND)
|
||||
sizer = wxBoxSizer()
|
||||
buttonOk = wxButton(dlg, wxID_OK, 'OK')
|
||||
buttonOk.SetDefault()
|
||||
sizer.Add(buttonOk, 0, wxRIGHT, 10)
|
||||
sizer.Add((0, 0), 1)
|
||||
sizer.Add(wxButton(dlg, wxID_CANCEL, 'Cancel'))
|
||||
topSizer.Add(sizer, 0, wxALL | wxEXPAND, 10)
|
||||
dlg.SetAutoLayout(True)
|
||||
dlg.SetSizer(topSizer)
|
||||
topSizer.Fit(dlg)
|
||||
dlg.Center()
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
value = []
|
||||
for i in range(listBox.GetCount()):
|
||||
@@ -350,20 +338,6 @@ class ParamUnit(PPanel):
|
||||
def OnSpinDown(self, evt):
|
||||
self.Change(-1)
|
||||
|
||||
# Dialog for editing multi-line text
|
||||
class TextDialog(wxDialog):
|
||||
def __init__(self, parent, value):
|
||||
pre = wxPreDialog()
|
||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_TEXT')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.text = self.FindWindowByName('TEXT')
|
||||
self.text.SetValue(value)
|
||||
self.SetAutoLayout(True)
|
||||
self.SetSize((300,200))
|
||||
def GetValue(self):
|
||||
return self.text.GetValue()
|
||||
|
||||
class ParamMultilineText(PPanel):
|
||||
def __init__(self, parent, name, textWidth=-1):
|
||||
PPanel.__init__(self, parent, name)
|
||||
@@ -388,9 +362,11 @@ class ParamMultilineText(PPanel):
|
||||
self.text.SetValue(value)
|
||||
self.freeze = False # disable other handlers
|
||||
def OnButtonEdit(self, evt):
|
||||
dlg = TextDialog(self, self.text.GetValue())
|
||||
dlg = g.frame.res.LoadDialog(self, 'DIALOG_TEXT')
|
||||
textCtrl = XRCCTRL(dlg, 'TEXT')
|
||||
textCtrl.SetValue(self.text.GetValue())
|
||||
if dlg.ShowModal() == wxID_OK:
|
||||
self.text.SetValue(dlg.GetValue())
|
||||
self.text.SetValue(textCtrl.GetValue())
|
||||
self.SetModified()
|
||||
dlg.Destroy()
|
||||
|
||||
@@ -439,7 +415,7 @@ class ContentDialog(wxDialog):
|
||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.list = self.FindWindowByName('LIST')
|
||||
self.list = XRCCTRL(self, 'LIST')
|
||||
# Set list items
|
||||
for v in value:
|
||||
self.list.Append(v)
|
||||
@@ -489,7 +465,7 @@ class ContentCheckListDialog(wxDialog):
|
||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_CONTENT_CHECK_LIST')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.list = self.FindWindowByName('CHECK_LIST')
|
||||
self.list = XRCCTRL(self, 'CHECK_LIST')
|
||||
# Set list items
|
||||
i = 0
|
||||
for v,ch in value:
|
||||
@@ -622,7 +598,7 @@ class IntListDialog(wxDialog):
|
||||
g.frame.res.LoadOnDialog(pre, parent, 'DIALOG_INTLIST')
|
||||
self.this = pre.this
|
||||
self._setOORInfo(self)
|
||||
self.list = self.FindWindowByName('LIST')
|
||||
self.list = XRCCTRL(self, 'LIST')
|
||||
# Set list items
|
||||
value.sort()
|
||||
for v in value:
|
||||
@@ -791,11 +767,11 @@ class ParamBitmap(PPanel):
|
||||
self._setOORInfo(self)
|
||||
self.modified = self.freeze = False
|
||||
self.SetBackgroundColour(g.panel.GetBackgroundColour())
|
||||
self.radio_std = self.FindWindowByName('RADIO_STD')
|
||||
self.radio_file = self.FindWindowByName('RADIO_FILE')
|
||||
self.combo = self.FindWindowByName('COMBO_STD')
|
||||
self.text = self.FindWindowByName('TEXT_FILE')
|
||||
self.button = self.FindWindowByName('BUTTON_BROWSE')
|
||||
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.textModified = False
|
||||
self.SetAutoLayout(True)
|
||||
self.GetSizer().SetMinSize((260, -1))
|
||||
@@ -879,5 +855,3 @@ paramDict = {
|
||||
'tooltip': ParamText, 'bitmap': ParamBitmap, 'icon': ParamBitmap,
|
||||
'encoding': ParamEncoding
|
||||
}
|
||||
|
||||
|
||||
|
BIN
wxPython/wx/tools/XRCed/src-images/ToolGridBagSizer.png
Normal file
BIN
wxPython/wx/tools/XRCed/src-images/ToolGridBagSizer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 B |
BIN
wxPython/wx/tools/XRCed/src-images/TreeSizerGridBag.png
Normal file
BIN
wxPython/wx/tools/XRCed/src-images/TreeSizerGridBag.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 189 B |
@@ -51,6 +51,7 @@ class Tools(wxPanel):
|
||||
(ID_NEW.STATIC_BOX_SIZER, images.getToolStaticBoxSizerBitmap()),
|
||||
(ID_NEW.GRID_SIZER, images.getToolGridSizerBitmap()),
|
||||
(ID_NEW.FLEX_GRID_SIZER, images.getToolFlexGridSizerBitmap()),
|
||||
(ID_NEW.GRID_BAG_SIZER, images.getToolGridBagSizerBitmap()),
|
||||
(ID_NEW.SPACER, images.getToolSpacerBitmap())],
|
||||
["Controls",
|
||||
(ID_NEW.STATIC_TEXT, images.getToolStaticTextBitmap()),
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
from xxx import * # xxx imports globals and params
|
||||
import types
|
||||
import traceback
|
||||
|
||||
# Constant to define standart window name
|
||||
STD_NAME = '_XRCED_T_W'
|
||||
@@ -83,6 +84,7 @@ class ID_NEW:
|
||||
STATIC_BOX_SIZER = wxNewId()
|
||||
GRID_SIZER = wxNewId()
|
||||
FLEX_GRID_SIZER = wxNewId()
|
||||
GRID_BAG_SIZER = wxNewId()
|
||||
SPACER = wxNewId()
|
||||
TOOL_BAR = wxNewId()
|
||||
TOOL = wxNewId()
|
||||
@@ -154,6 +156,7 @@ class PullDownMenu:
|
||||
ID_NEW.STATIC_BOX_SIZER: 'wxStaticBoxSizer',
|
||||
ID_NEW.GRID_SIZER: 'wxGridSizer',
|
||||
ID_NEW.FLEX_GRID_SIZER: 'wxFlexGridSizer',
|
||||
ID_NEW.GRID_BAG_SIZER: 'wxGridBagSizer',
|
||||
ID_NEW.SPACER: 'spacer',
|
||||
ID_NEW.UNKNOWN: 'unknown',
|
||||
}
|
||||
@@ -178,6 +181,8 @@ class PullDownMenu:
|
||||
(ID_NEW.GRID_SIZER, 'GridSizer', 'Create grid sizer'),
|
||||
(ID_NEW.FLEX_GRID_SIZER, 'FlexGridSizer',
|
||||
'Create flexgrid sizer'),
|
||||
(ID_NEW.GRID_BAG_SIZER, 'GridBagSizer',
|
||||
'Create gridbag sizer'),
|
||||
(ID_NEW.SPACER, 'Spacer', 'Create spacer'),
|
||||
]
|
||||
self.controls = [
|
||||
@@ -225,6 +230,8 @@ class PullDownMenu:
|
||||
(ID_NEW.GRID_SIZER, 'GridSizer', 'Create grid sizer'),
|
||||
(ID_NEW.FLEX_GRID_SIZER, 'FlexGridSizer',
|
||||
'Create flexgrid sizer'),
|
||||
(ID_NEW.GRID_BAG_SIZER, 'GridBagSizer',
|
||||
'Create gridbag sizer'),
|
||||
(ID_NEW.SPACER, 'Spacer', 'Create spacer'),
|
||||
]
|
||||
]
|
||||
@@ -721,6 +728,7 @@ class XML_Tree(wxTreeCtrl):
|
||||
xmlFlags != wxXRC_USE_LOCALE
|
||||
res = wxXmlResource('', xmlFlags)
|
||||
res.Load('memory:xxx.xrc')
|
||||
try:
|
||||
if xxx.__class__ == xxxFrame:
|
||||
# Frame can't have many children,
|
||||
# but it's first child possibly can...
|
||||
@@ -776,12 +784,21 @@ class XML_Tree(wxTreeCtrl):
|
||||
testWin.toolBar = res.LoadToolBar(testWin, STD_NAME)
|
||||
testWin.SetToolBar(testWin.toolBar)
|
||||
testWin.Show(True)
|
||||
wxMemoryFSHandler_RemoveFile('xxx.xrc')
|
||||
testWin.item = item
|
||||
EVT_CLOSE(testWin, self.OnCloseTestWin)
|
||||
testWin.highLight = None
|
||||
if highLight and not self.pendingHighLight:
|
||||
self.HighLight(highLight)
|
||||
except:
|
||||
if g.testWin:
|
||||
self.SetItemBold(item, False)
|
||||
g.testWinPos = g.testWin.GetPosition()
|
||||
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')
|
||||
wxEndBusyCursor()
|
||||
|
||||
def OnCloseTestWin(self, evt):
|
||||
|
@@ -348,7 +348,7 @@ class Frame(wxFrame):
|
||||
# Expanded container (must have children)
|
||||
elif tree.IsExpanded(selected) and tree.GetChildrenCount(selected, False):
|
||||
# Insert as first child
|
||||
nextItem = tree.GetFirstChild(selected, 0)[0]
|
||||
nextItem = tree.GetFirstChild(selected)[0]
|
||||
parentLeaf = selected
|
||||
else:
|
||||
# No children or unexpanded item - appendChild stays True
|
||||
@@ -619,7 +619,7 @@ Homepage: http://xrced.sourceforge.net\
|
||||
# Expanded container (must have children)
|
||||
elif tree.shift and tree.IsExpanded(selected) \
|
||||
and tree.GetChildrenCount(selected, False):
|
||||
nextItem = tree.GetFirstChild(selected, 0)[0]
|
||||
nextItem = tree.GetFirstChild(selected)[0]
|
||||
parentLeaf = selected
|
||||
else:
|
||||
nextItem = wxTreeItemId()
|
||||
@@ -701,7 +701,7 @@ Homepage: http://xrced.sourceforge.net\
|
||||
xxx = MakeXXXFromDOM(parentXXX, elem)
|
||||
# Update parent in child objects
|
||||
if tree.ItemHasChildren(selected):
|
||||
i, cookie = tree.GetFirstChild(selected, 0)
|
||||
i, cookie = tree.GetFirstChild(selected)
|
||||
while i.IsOk():
|
||||
x = tree.GetPyData(i)
|
||||
x.parent = xxx
|
||||
@@ -1004,6 +1004,7 @@ class App(wxApp):
|
||||
|
||||
def main():
|
||||
app = App(0, useBestVisual=False)
|
||||
#app.SetAssertMode(wxPYAPP_ASSERT_LOG)
|
||||
app.MainLoop()
|
||||
app.OnExit()
|
||||
global conf
|
||||
|
@@ -10,6 +10,7 @@
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxTextCtrl" name="TEXT">
|
||||
<size>250,100</size>
|
||||
<style>wxTE_MULTILINE</style>
|
||||
</object>
|
||||
<option>1</option>
|
||||
@@ -217,6 +218,48 @@
|
||||
</object>
|
||||
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
|
||||
</object>
|
||||
<object class="wxDialog" name="DIALOG_CHOICES">
|
||||
<title>Choices</title>
|
||||
<centered>1</centered>
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxVERTICAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxCheckList" name="CHECK_LIST">
|
||||
<content/>
|
||||
<size>250,250</size>
|
||||
<style></style>
|
||||
</object>
|
||||
<option>1</option>
|
||||
<flag>wxALL|wxEXPAND</flag>
|
||||
<border>5</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxStaticLine"/>
|
||||
<flag>wxEXPAND</flag>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxBoxSizer">
|
||||
<orient>wxHORIZONTAL</orient>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_OK">
|
||||
<label>OK</label>
|
||||
<default>1</default>
|
||||
</object>
|
||||
<flag>wxRIGHT</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<object class="wxButton" name="wxID_CANCEL">
|
||||
<label>Cancel</label>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<flag>wxALL|wxALIGN_CENTRE_HORIZONTAL</flag>
|
||||
<border>10</border>
|
||||
</object>
|
||||
</object>
|
||||
<style>wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</style>
|
||||
</object>
|
||||
<object class="wxDialog" name="DIALOG_INTLIST">
|
||||
<title>Numbers</title>
|
||||
<centered>1</centered>
|
||||
|
@@ -643,6 +643,28 @@ class xxxFlexGridSizer(xxxGridSizer):
|
||||
self.element.appendChild(node)
|
||||
self.special(param, node)
|
||||
|
||||
class xxxGridBagSizer(xxxSizer):
|
||||
specials = ['growablecols', 'growablerows']
|
||||
allParams = ['vgap', 'hgap'] + specials
|
||||
paramDict = {'growablecols':ParamIntList, 'growablerows':ParamIntList}
|
||||
# Special processing for growable* parameters
|
||||
# (they are represented by several nodes)
|
||||
def special(self, tag, node):
|
||||
if not self.params.has_key(tag):
|
||||
# Create new multi-group
|
||||
self.params[tag] = xxxParamMulti(node)
|
||||
self.params[tag].append(xxxParamInt(node))
|
||||
def setSpecial(self, param, value):
|
||||
# Straightforward implementation: remove, add again
|
||||
self.params[param].remove()
|
||||
del self.params[param]
|
||||
for i in value:
|
||||
node = g.tree.dom.createElement(param)
|
||||
text = g.tree.dom.createTextNode(str(i))
|
||||
node.appendChild(text)
|
||||
self.element.appendChild(node)
|
||||
self.special(param, node)
|
||||
|
||||
# Container with only one child.
|
||||
# Not shown in tree.
|
||||
class xxxChildContainer(xxxObject):
|
||||
@@ -668,9 +690,13 @@ class xxxChildContainer(xxxObject):
|
||||
assert 0, 'no child found'
|
||||
|
||||
class xxxSizerItem(xxxChildContainer):
|
||||
allParams = ['option', 'flag', 'border', 'minsize']
|
||||
paramDict = {'option': ParamInt, 'minsize': ParamPosSize}
|
||||
allParams = ['option', 'flag', 'border', 'minsize', 'ratio']
|
||||
paramDict = {'option': ParamInt, 'minsize': ParamPosSize, 'ratio': ParamPosSize}
|
||||
#default = {'cellspan': '1,1'}
|
||||
def __init__(self, parent, element):
|
||||
# For GridBag sizer items, extra parameters added
|
||||
if isinstance(parent, xxxGridBagSizer):
|
||||
self.allParams = self.allParams + ['cellpos', 'cellspan']
|
||||
xxxChildContainer.__init__(self, parent, element)
|
||||
# Remove pos parameter - not needed for sizeritems
|
||||
if 'pos' in self.child.allParams:
|
||||
@@ -770,6 +796,7 @@ xxxDict = {
|
||||
'wxStaticBoxSizer': xxxStaticBoxSizer,
|
||||
'wxGridSizer': xxxGridSizer,
|
||||
'wxFlexGridSizer': xxxFlexGridSizer,
|
||||
'wxGridBagSizer': xxxGridBagSizer,
|
||||
'sizeritem': xxxSizerItem,
|
||||
'spacer': xxxSpacer,
|
||||
|
||||
@@ -784,7 +811,8 @@ 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()
|
||||
'tooltip': wxNewId(), 'encoding': wxNewId(),
|
||||
'cellpos': wxNewId(), 'cellspan': wxNewId()
|
||||
}
|
||||
for cl in xxxDict.values():
|
||||
if cl.allParams:
|
||||
|
Reference in New Issue
Block a user