pyMez.Code.FrontEnds.XMLEditPanel module
This module defines a simple xml editor that shows the xsl if available
Help
#----------------------------------------------------------------------------- # Name: XMLEditPanel.py # Purpose: A panel to edit general XML files # Author: Aric Sanders # Created: 3/02/2016 # License: MIT License #----------------------------------------------------------------------------- #Boa:FramePanel:XMLEditPanel """ This module defines a simple xml editor that shows the xsl if available Help --------------- <a href="./index.html">`pyMez.Code.FrontEnds`</a> <div> <a href="../../../pyMez_Documentation.html">Documentation Home</a> | <a href="../../index.html">API Documentation Home</a> | <a href="../../../Examples/html/Examples_Home.html">Examples Home</a> | <a href="../../../Reference_Index.html">Index</a> </div>""" import wx import wx.html import wx.stc # This determines PYMEASURE_ROOT below and checks if everything is installed properly try: import pyMez except: print("The topmost pyMez folder was not found please make sure that the directory directly above it is on sys.path") raise try: from pyMez.Code.FrontEnds.XMLGeneral import * from pyMez.Code.FrontEnds.StyledTextCtrlPanel import * except: print("Could not import XMLGeneral") raise #------------------------------------------------------------------------------- # Constants PYMEASURE_ROOT=os.path.dirname(os.path.realpath(pyMez.__file__)) [wxID_XMLEDITPANEL, wxID_XMLEDITPANELEDITDISPLAYPANEL, wxID_XMLEDITPANELEDITPANEL, wxID_XMLEDITPANELFILECONTROLPANEL, wxID_XMLEDITPANELFILEOPENBUTTON, wxID_XMLEDITPANELFILESAVEBUTTON, wxID_XMLEDITPANELNOTEBOOK1, wxID_XMLEDITPANELSOURCEVIEW, wxID_XMLEDITPANELTRANSFORMEDXML, wxID_XMLEDITPANELVIEWSOURCE, wxID_XMLEDITPANELXSLVIEW, ] = [wx.NewId() for _init_ctrls in range(11)] class XMLEditPanel(wx.Panel): _custom_classes = {'wx.stc.StyledTextCtrl': ['XMLSTC']} def _init_coll_EditSizer_Items(self, parent): # generated method, don't edit parent.Add(self.notebook1, 1, border=1, flag=wx.ALL | wx.EXPAND) def _init_coll_FileControlSizer_Items(self, parent): # generated method, don't edit parent.Add(self.FileOpenButton, 0, border=0, flag=0) parent.Add(self.FileSaveButton, 0, border=0, flag=0) parent.Add(self.ViewSource, 0, border=0, flag=0) def _init_coll_MainPanelSizer_Items(self, parent): # generated method, don't edit parent.Add(self.FileControlPanel, 1, border=1, flag=wx.EXPAND) parent.Add(self.EditDisplayPanel, 9, border=1, flag=wx.EXPAND) def _init_coll_notebook1_Pages(self, parent): # generated method, don't edit parent.AddPage(imageId=-1, page=self.EditPanel, select=True, text='Edit') parent.AddPage(imageId=-1, page=self.SourceView, select=False, text='Source') parent.AddPage(imageId=-1, page=self.XSLView, select=False, text='XSL') parent.AddPage(imageId=-1, page=self.TransformedXML, select=False, text='HTML') def _init_sizers(self): # generated method, don't edit self.MainPanelSizer = wx.BoxSizer(orient=wx.VERTICAL) self.FileControlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) self.EditSizer = wx.BoxSizer(orient=wx.VERTICAL) self.EditControlSizer = wx.BoxSizer(orient=wx.VERTICAL) self._init_coll_MainPanelSizer_Items(self.MainPanelSizer) self._init_coll_FileControlSizer_Items(self.FileControlSizer) self._init_coll_EditSizer_Items(self.EditSizer) self.SetSizer(self.MainPanelSizer) self.FileControlPanel.SetSizer(self.FileControlSizer) self.EditDisplayPanel.SetSizer(self.EditSizer) self.EditPanel.SetSizer(self.EditControlSizer) def _init_ctrls(self, prnt): # generated method, don't edit wx.Panel.__init__(self, id=wxID_XMLEDITPANEL, name='XMLEditPanel', parent=prnt, pos=wx.Point(358, 257), size=wx.Size(722, 545), style=wx.TAB_TRAVERSAL) self.SetClientSize(wx.Size(706, 507)) self.FileControlPanel = wx.Panel(id=wxID_XMLEDITPANELFILECONTROLPANEL, name='FileControlPanel', parent=self, pos=wx.Point(0, 0), size=wx.Size(706, 50), style=wx.TAB_TRAVERSAL) self.FileControlPanel.SetBackgroundColour(wx.Colour(192, 192, 192)) self.EditDisplayPanel = wx.Panel(id=wxID_XMLEDITPANELEDITDISPLAYPANEL, name='EditDisplayPanel', parent=self, pos=wx.Point(0, 50), size=wx.Size(706, 457), style=wx.TAB_TRAVERSAL) self.FileOpenButton = wx.Button(id=wxID_XMLEDITPANELFILEOPENBUTTON, label='Open', name='FileOpenButton', parent=self.FileControlPanel, pos=wx.Point(0, 0), size=wx.Size(75, 23), style=0) self.FileOpenButton.Bind(wx.EVT_BUTTON, self.OnFileOpenButtonButton, id=wxID_XMLEDITPANELFILEOPENBUTTON) self.FileSaveButton = wx.Button(id=wxID_XMLEDITPANELFILESAVEBUTTON, label='Save', name='FileSaveButton', parent=self.FileControlPanel, pos=wx.Point(75, 0), size=wx.Size(75, 23), style=0) self.FileSaveButton.Bind(wx.EVT_BUTTON, self.OnFileSaveButtonButton, id=wxID_XMLEDITPANELFILESAVEBUTTON) self.ViewSource = wx.Button(id=wxID_XMLEDITPANELVIEWSOURCE, label='View Source', name='ViewSource', parent=self.FileControlPanel, pos=wx.Point(150, 0), size=wx.Size(75, 23), style=0) self.notebook1 = wx.Notebook(id=wxID_XMLEDITPANELNOTEBOOK1, name='notebook1', parent=self.EditDisplayPanel, pos=wx.Point(1, 1), size=wx.Size(704, 455), style=0) self.EditPanel = XMLSTC(id=wxID_XMLEDITPANELEDITPANEL, name='EditPanel', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=wx.TAB_TRAVERSAL) self.EditPanel.SetLexer(wx.stc.STC_LEX_XML) self.EditPanel.SetHighlightGuide(0) self.EditPanel.SetTargetEnd(100) self.SourceView = XMLSTC(id=wxID_XMLEDITPANELSOURCEVIEW, name='SourceView', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=0) self.SourceView.SetLexer(wx.stc.STC_LEX_XML) self.SourceView.SetHighlightGuide(0) self.SourceView.SetTargetEnd(100) self.XSLView = XMLSTC(id=wxID_XMLEDITPANELXSLVIEW, name='XSLView', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=0) self.TransformedXML = wx.html.HtmlWindow(id=wxID_XMLEDITPANELTRANSFORMEDXML, name='TransformedXML', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=wx.html.HW_SCROLLBAR_AUTO) self._init_coll_notebook1_Pages(self.notebook1) self._init_sizers() def __init__(self, parent, id, pos, size, style, name): self._init_ctrls(parent) def OnFileOpenButtonButton(self, event): dlg = wx.FileDialog(self, 'Choose an XML file to open', '.', '', '*.*', wx.FD_OPEN) try: if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() self.open_file(filename) finally: dlg.Destroy() def OnFileSaveButtonButton(self, event): try: path=self.current_xml.path.split('/')[-1] except: path='' #print path dlg = wx.FileDialog(self, 'Save the file', '.', path, '', wx.FD_SAVE) try: if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() try: self.new_xml=EtreeXML(self.EditPanel.GetText()) self.new_xml.save(filename) self.open_file(filename) except: raise finally: dlg.Destroy() event.Skip() def open_file(self,filename): os.chdir(os.path.dirname(filename)) try: self.current_xml=EtreeXML(filename) text=str(self.current_xml) lenText = len(text.encode('utf8')) self.EditPanel.SetStyling(lenText, 0) self.EditPanel.SetText(text) self.EditPanel.EnsureCaretVisible() self.EditPanel.SetEditable(True) self.SourceView.SetStyling(lenText, 0) self.SourceView.SetText(text) self.SourceView.EnsureCaretVisible() self.notebook1.ChangeSelection(1) try: #print filename.split('.')[-1] if re.search('htm|html',filename.split('.')[-1]): self.TransformedXML.SetPage(str(self.current_xml)) else: self.TransformedXML.SetPage(str(self.current_xml.to_HTML())) except: self.TransformedXML.SetPage("<strong> No html available</strong>") try: self.XSLView.SetText(etree.tostring(self.current_xml.xsl, pretty_print=True)) except: self.XSLView.SetText("Sorry no xsl available") except: raise ## def build_edit_control(self): ## """This method builds the edit control given a XMLEtree class""" ## self.edit_controls=[] ## for index,node in self.current_xml.node_dictionary.iteritems(): ## new_control_tag=wx.TextCtrl(id=wx.NewId(), name='textCtrl1', ## parent=self.EditPanel, pos=wx.Point(64, 32), size=wx.Size(100, 21), style=0, ## value=node.tag) ## new_control_text=wx.TextCtrl(id=wx.NewId(), name='textCtrl1', ## parent=self.EditPanel, pos=wx.Point(64, 32), size=wx.Size(100, 21), style=0, ## value=node.text) ## for attribute,attribute_value in node.attrib.iteritems(): ## new_control_attribute=wx.TextCtrl(id=wx.NewId(), name='textCtrl1', ## parent=self.EditPanel, pos=wx.Point(64, 32), size=wx.Size(100, 21), style=0, ## value=attribute) ## new_control_attribute.Bind(wx.EVT_BUTTON, lambda self.current_xml.node_dicitionary[index]., ## id=wxID_XMLEDITPANELFILESAVEBUTTON) ## new_control_value=wx.TextCtrl(id=wx.NewId(), name='textCtrl1', ## parent=self.EditPanel, pos=wx.Point(64, 32), size=wx.Size(100, 21), style=0, ## value=attribute_value) ## ## #self.current_xml ## pass def test_XMLEditPanel(): app = wx.App(False) frame = wx.Frame(None,size=wx.Size(900, 800)) panel=XMLEditPanel(id=1, name='IV Panel', parent=frame, pos=wx.Point(350, 204), size=wx.Size(200, 800), style=wx.TAB_TRAVERSAL) sizer=wx.BoxSizer() sizer.Add(panel,1,wx.EXPAND,2) frame.SetSizerAndFit(sizer) frame.SetSize(wx.Size(800, 600)) frame.Show() app.MainLoop() if __name__ == '__main__': test_XMLEditPanel()
Functions
def test_XMLEditPanel(
)
def test_XMLEditPanel(): app = wx.App(False) frame = wx.Frame(None,size=wx.Size(900, 800)) panel=XMLEditPanel(id=1, name='IV Panel', parent=frame, pos=wx.Point(350, 204), size=wx.Size(200, 800), style=wx.TAB_TRAVERSAL) sizer=wx.BoxSizer() sizer.Add(panel,1,wx.EXPAND,2) frame.SetSizerAndFit(sizer) frame.SetSize(wx.Size(800, 600)) frame.Show() app.MainLoop()
Classes
class XMLEditPanel
Panel() Panel(parent, id=ID_ANY, pos=DefaultPosition, size=DefaultSize, style=TAB_TRAVERSAL, name=PanelNameStr)
A panel is a window on which controls are placed.
class XMLEditPanel(wx.Panel): _custom_classes = {'wx.stc.StyledTextCtrl': ['XMLSTC']} def _init_coll_EditSizer_Items(self, parent): # generated method, don't edit parent.Add(self.notebook1, 1, border=1, flag=wx.ALL | wx.EXPAND) def _init_coll_FileControlSizer_Items(self, parent): # generated method, don't edit parent.Add(self.FileOpenButton, 0, border=0, flag=0) parent.Add(self.FileSaveButton, 0, border=0, flag=0) parent.Add(self.ViewSource, 0, border=0, flag=0) def _init_coll_MainPanelSizer_Items(self, parent): # generated method, don't edit parent.Add(self.FileControlPanel, 1, border=1, flag=wx.EXPAND) parent.Add(self.EditDisplayPanel, 9, border=1, flag=wx.EXPAND) def _init_coll_notebook1_Pages(self, parent): # generated method, don't edit parent.AddPage(imageId=-1, page=self.EditPanel, select=True, text='Edit') parent.AddPage(imageId=-1, page=self.SourceView, select=False, text='Source') parent.AddPage(imageId=-1, page=self.XSLView, select=False, text='XSL') parent.AddPage(imageId=-1, page=self.TransformedXML, select=False, text='HTML') def _init_sizers(self): # generated method, don't edit self.MainPanelSizer = wx.BoxSizer(orient=wx.VERTICAL) self.FileControlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) self.EditSizer = wx.BoxSizer(orient=wx.VERTICAL) self.EditControlSizer = wx.BoxSizer(orient=wx.VERTICAL) self._init_coll_MainPanelSizer_Items(self.MainPanelSizer) self._init_coll_FileControlSizer_Items(self.FileControlSizer) self._init_coll_EditSizer_Items(self.EditSizer) self.SetSizer(self.MainPanelSizer) self.FileControlPanel.SetSizer(self.FileControlSizer) self.EditDisplayPanel.SetSizer(self.EditSizer) self.EditPanel.SetSizer(self.EditControlSizer) def _init_ctrls(self, prnt): # generated method, don't edit wx.Panel.__init__(self, id=wxID_XMLEDITPANEL, name='XMLEditPanel', parent=prnt, pos=wx.Point(358, 257), size=wx.Size(722, 545), style=wx.TAB_TRAVERSAL) self.SetClientSize(wx.Size(706, 507)) self.FileControlPanel = wx.Panel(id=wxID_XMLEDITPANELFILECONTROLPANEL, name='FileControlPanel', parent=self, pos=wx.Point(0, 0), size=wx.Size(706, 50), style=wx.TAB_TRAVERSAL) self.FileControlPanel.SetBackgroundColour(wx.Colour(192, 192, 192)) self.EditDisplayPanel = wx.Panel(id=wxID_XMLEDITPANELEDITDISPLAYPANEL, name='EditDisplayPanel', parent=self, pos=wx.Point(0, 50), size=wx.Size(706, 457), style=wx.TAB_TRAVERSAL) self.FileOpenButton = wx.Button(id=wxID_XMLEDITPANELFILEOPENBUTTON, label='Open', name='FileOpenButton', parent=self.FileControlPanel, pos=wx.Point(0, 0), size=wx.Size(75, 23), style=0) self.FileOpenButton.Bind(wx.EVT_BUTTON, self.OnFileOpenButtonButton, id=wxID_XMLEDITPANELFILEOPENBUTTON) self.FileSaveButton = wx.Button(id=wxID_XMLEDITPANELFILESAVEBUTTON, label='Save', name='FileSaveButton', parent=self.FileControlPanel, pos=wx.Point(75, 0), size=wx.Size(75, 23), style=0) self.FileSaveButton.Bind(wx.EVT_BUTTON, self.OnFileSaveButtonButton, id=wxID_XMLEDITPANELFILESAVEBUTTON) self.ViewSource = wx.Button(id=wxID_XMLEDITPANELVIEWSOURCE, label='View Source', name='ViewSource', parent=self.FileControlPanel, pos=wx.Point(150, 0), size=wx.Size(75, 23), style=0) self.notebook1 = wx.Notebook(id=wxID_XMLEDITPANELNOTEBOOK1, name='notebook1', parent=self.EditDisplayPanel, pos=wx.Point(1, 1), size=wx.Size(704, 455), style=0) self.EditPanel = XMLSTC(id=wxID_XMLEDITPANELEDITPANEL, name='EditPanel', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=wx.TAB_TRAVERSAL) self.EditPanel.SetLexer(wx.stc.STC_LEX_XML) self.EditPanel.SetHighlightGuide(0) self.EditPanel.SetTargetEnd(100) self.SourceView = XMLSTC(id=wxID_XMLEDITPANELSOURCEVIEW, name='SourceView', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=0) self.SourceView.SetLexer(wx.stc.STC_LEX_XML) self.SourceView.SetHighlightGuide(0) self.SourceView.SetTargetEnd(100) self.XSLView = XMLSTC(id=wxID_XMLEDITPANELXSLVIEW, name='XSLView', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=0) self.TransformedXML = wx.html.HtmlWindow(id=wxID_XMLEDITPANELTRANSFORMEDXML, name='TransformedXML', parent=self.notebook1, pos=wx.Point(0, 0), size=wx.Size(696, 429), style=wx.html.HW_SCROLLBAR_AUTO) self._init_coll_notebook1_Pages(self.notebook1) self._init_sizers() def __init__(self, parent, id, pos, size, style, name): self._init_ctrls(parent) def OnFileOpenButtonButton(self, event): dlg = wx.FileDialog(self, 'Choose an XML file to open', '.', '', '*.*', wx.FD_OPEN) try: if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() self.open_file(filename) finally: dlg.Destroy() def OnFileSaveButtonButton(self, event): try: path=self.current_xml.path.split('/')[-1] except: path='' #print path dlg = wx.FileDialog(self, 'Save the file', '.', path, '', wx.FD_SAVE) try: if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() try: self.new_xml=EtreeXML(self.EditPanel.GetText()) self.new_xml.save(filename) self.open_file(filename) except: raise finally: dlg.Destroy() event.Skip() def open_file(self,filename): os.chdir(os.path.dirname(filename)) try: self.current_xml=EtreeXML(filename) text=str(self.current_xml) lenText = len(text.encode('utf8')) self.EditPanel.SetStyling(lenText, 0) self.EditPanel.SetText(text) self.EditPanel.EnsureCaretVisible() self.EditPanel.SetEditable(True) self.SourceView.SetStyling(lenText, 0) self.SourceView.SetText(text) self.SourceView.EnsureCaretVisible() self.notebook1.ChangeSelection(1) try: #print filename.split('.')[-1] if re.search('htm|html',filename.split('.')[-1]): self.TransformedXML.SetPage(str(self.current_xml)) else: self.TransformedXML.SetPage(str(self.current_xml.to_HTML())) except: self.TransformedXML.SetPage("<strong> No html available</strong>") try: self.XSLView.SetText(etree.tostring(self.current_xml.xsl, pretty_print=True)) except: self.XSLView.SetText("Sorry no xsl available") except: raise
Ancestors (in MRO)
- XMLEditPanel
- wx._core.Panel
- wx._core.Window
- wx._core.WindowBase
- wx._core.EvtHandler
- wx._core.Object
- wx._core.Trackable
- sip.wrapper
- sip.simplewrapper
- builtins.object
Class variables
var ChildrenRepositioningGuard
Static methods
def __init__(
self, parent, id, pos, size, style, name)
Initialize self. See help(type(self)) for accurate signature.
def __init__(self, parent, id, pos, size, style, name): self._init_ctrls(parent)
def Bind(
self, event, handler, source=None, id=-1, id2=-1)
Bind an event to an event handler.
:param event: One of the EVT_*
event binder objects that
specifies the type of event to bind.
:param handler: A callable object to be invoked when the
event is delivered to self. Pass None
to
disconnect an event handler.
:param source: Sometimes the event originates from a different window than self, but you still want to catch it in self. (For example, a button event delivered to a frame.) By passing the source of the event, the event handling system is able to differentiate between the same event type from different controls.
:param id: Used to spcify the event source by ID instead of instance.
:param id2: Used when it is desirable to bind a handler to a range of IDs, such as with EVT_MENU_RANGE.
def _EvtHandler_Bind(self, event, handler, source=None, id=wx.ID_ANY, id2=wx.ID_ANY): """ Bind an event to an event handler. :param event: One of the ``EVT_*`` event binder objects that specifies the type of event to bind. :param handler: A callable object to be invoked when the event is delivered to self. Pass ``None`` to disconnect an event handler. :param source: Sometimes the event originates from a different window than self, but you still want to catch it in self. (For example, a button event delivered to a frame.) By passing the source of the event, the event handling system is able to differentiate between the same event type from different controls. :param id: Used to spcify the event source by ID instead of instance. :param id2: Used when it is desirable to bind a handler to a range of IDs, such as with EVT_MENU_RANGE. """ assert isinstance(event, wx.PyEventBinder) assert callable(handler) or handler is None assert source is None or hasattr(source, 'GetId') if source is not None: id = source.GetId() event.Bind(self, id, id2, handler)
def ConvertDialogPointToPixels(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def ConvertDialogSizeToPixels(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def DLG_UNIT(
self, dlg_unit)
A convenience wrapper for :meth:ConvertDialogToPixels
.
def _Window_DLG_UNIT(self, dlg_unit): """ A convenience wrapper for :meth:`ConvertDialogToPixels`. """ is_wxType = isinstance(dlg_unit, (wx.Size, wx.Point)) pix = self.ConvertDialogToPixels(dlg_unit) if not is_wxType: pix = tuple(pix) return pix
def DestroyLater(
self)
Schedules the window to be destroyed in the near future.
This should be used whenever Destroy could happen too soon, such as when there may still be events for this window or its children waiting in the event queue.
def _Window_DestroyLater(self): """ Schedules the window to be destroyed in the near future. This should be used whenever Destroy could happen too soon, such as when there may still be events for this window or its children waiting in the event queue. """ self.Hide() wx.GetApp().ScheduleForDestruction(self)
def GetPositionTuple(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def GetSizeTuple(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def GetVirtualSizeTuple(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def MoveXY(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def OnFileOpenButtonButton(
self, event)
def OnFileOpenButtonButton(self, event): dlg = wx.FileDialog(self, 'Choose an XML file to open', '.', '', '*.*', wx.FD_OPEN) try: if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() self.open_file(filename) finally: dlg.Destroy()
def OnFileSaveButtonButton(
self, event)
def OnFileSaveButtonButton(self, event): try: path=self.current_xml.path.split('/')[-1] except: path='' #print path dlg = wx.FileDialog(self, 'Save the file', '.', path, '', wx.FD_SAVE) try: if dlg.ShowModal() == wx.ID_OK: filename = dlg.GetPath() try: self.new_xml=EtreeXML(self.EditPanel.GetText()) self.new_xml.save(filename) self.open_file(filename) except: raise finally: dlg.Destroy() event.Skip()
def PostCreate(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def SetClientRect(
self, rect)
def _Window_SetClientRect(self, rect): return self.SetClientSize(rect)
def SetDimensions(
*args, **kw)
SetDimensions(x, y, width, height, sizeFlags=SIZE_AUTO)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def SetRect(
self, rect)
def _Window_SetRect(self, rect): return self.SetSize(rect)
def SetSizeHintsSz(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def SetSizeWH(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def SetToolTipString(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def SetVirtualSizeWH(
*args, **kw)
def deprecated_func(*args, **kw): warnings.warn("Call to deprecated item%s. %s" % (name, msg), wxPyDeprecationWarning, stacklevel=2) if not kw: return item(*args) return item(*args, **kw)
def Unbind(
self, event, source=None, id=-1, id2=-1, handler=None)
Disconnects the event handler binding for event from self
.
Returns True
if successful.
def _EvtHandler_Unbind(self, event, source=None, id=wx.ID_ANY, id2=wx.ID_ANY, handler=None): """ Disconnects the event handler binding for event from `self`. Returns ``True`` if successful. """ if source is not None: id = source.GetId() return event.Unbind(self, id, id2, handler)
def open_file(
self, filename)
def open_file(self,filename): os.chdir(os.path.dirname(filename)) try: self.current_xml=EtreeXML(filename) text=str(self.current_xml) lenText = len(text.encode('utf8')) self.EditPanel.SetStyling(lenText, 0) self.EditPanel.SetText(text) self.EditPanel.EnsureCaretVisible() self.EditPanel.SetEditable(True) self.SourceView.SetStyling(lenText, 0) self.SourceView.SetText(text) self.SourceView.EnsureCaretVisible() self.notebook1.ChangeSelection(1) try: #print filename.split('.')[-1] if re.search('htm|html',filename.split('.')[-1]): self.TransformedXML.SetPage(str(self.current_xml)) else: self.TransformedXML.SetPage(str(self.current_xml.to_HTML())) except: self.TransformedXML.SetPage("<strong> No html available</strong>") try: self.XSLView.SetText(etree.tostring(self.current_xml.xsl, pretty_print=True)) except: self.XSLView.SetText("Sorry no xsl available") except: raise
Instance variables
var AcceleratorTable
GetAcceleratorTable() -> AcceleratorTable
Gets the accelerator table for this window.
var AutoLayout
GetAutoLayout() -> bool
Returns the sizer of which this window is a member, if any, otherwise NULL.
var BackgroundColour
GetBackgroundColour() -> Colour
Returns the background colour of the window.
var BackgroundStyle
GetBackgroundStyle() -> BackgroundStyle
Returns the background style of the window.
var BestSize
GetBestSize() -> Size
This functions returns the best acceptable minimal size for the window.
var BestVirtualSize
GetBestVirtualSize() -> Size
Return the largest of ClientSize and BestSize (as determined by a sizer, interior children, or other means)
var Border
GetBorder(flags) -> Border GetBorder() -> Border
Get the window border style from the given flags: this is different from simply doing flags & wxBORDER_MASK because it uses GetDefaultBorder() to translate wxBORDER_DEFAULT to something reasonable.
var Caret
GetCaret() -> Caret
Returns the caret() associated with the window.
var CharHeight
GetCharHeight() -> int
Returns the character height for this window.
var CharWidth
GetCharWidth() -> int
Returns the average character width for this window.
var Children
GetChildren() -> WindowList
Returns a reference to the list of the window's children.
var ClassInfo
GetClassInfo() -> ClassInfo
This virtual function is redefined for every class that requires run- time type information, when using the wxDECLARE_CLASS macro (or similar).
var ClassName
GetClassName() -> Char
Returns the class name of the C++ class using wxRTTI.
var ClientAreaOrigin
GetClientAreaOrigin() -> Point
Get the origin of the client area of the window relative to the window top left corner (the client area may be shifted because of the borders, scrollbars, other decorations...)
var ClientRect
GetClientRect() -> Rect
Get the client rectangle in window (i.e. client) coordinates.
var ClientSize
GetClientSize() -> Size
Returns the size of the window 'client area' in pixels.
var Constraints
GetConstraints() -> LayoutConstraints
Returns a pointer to the window's layout constraints, or NULL if there are none.
var ContainingSizer
GetContainingSizer() -> Sizer
Returns the sizer of which this window is a member, if any, otherwise NULL.
var Cursor
GetCursor() -> Cursor
Return the cursor associated with this window.
var DefaultAttributes
GetDefaultAttributes() -> VisualAttributes
Currently this is the same as calling wxWindow::GetClassDefaultAttributes(wxWindow::GetWindowVariant()).
var DropTarget
GetDropTarget() -> DropTarget
Returns the associated drop target, which may be NULL.
var EffectiveMinSize
GetEffectiveMinSize() -> Size
Merges the window's best size into the min size and returns the result.
var Enabled
IsEnabled() -> bool
Returns true if the window is enabled, i.e. if it accepts user input, false otherwise.
var EventHandler
GetEventHandler() -> EvtHandler
Returns the event handler for this window.
var EvtHandlerEnabled
GetEvtHandlerEnabled() -> bool
Returns true if the event handler is enabled, false otherwise.
var ExtraStyle
GetExtraStyle() -> long
Returns the extra style bits for the window.
var Font
GetFont() -> Font
Returns the font for this window.
var ForegroundColour
GetForegroundColour() -> Colour
Returns the foreground colour of the window.
var GrandParent
GetGrandParent() -> Window
Returns the grandparent of a window, or NULL if there isn't one.
var Handle
GetHandle() -> UIntPtr
Returns the platform-specific handle of the physical window.
var HelpText
GetHelpText() -> String
Gets the help text to be used as context-sensitive help for this window.
var Id
GetId() -> WindowID
Returns the identifier of the window.
var Label
GetLabel() -> String
Generic way of getting a label from any window, for identification purposes.
var LayoutDirection
GetLayoutDirection() -> LayoutDirection
Returns the layout direction for this window, Note that wxLayout_Default is returned if layout direction is not supported.
var MaxClientSize
GetMaxClientSize() -> Size
Returns the maximum size of window's client area.
var MaxHeight
GetMaxHeight() -> int
Returns the vertical component of window maximal size.
var MaxSize
GetMaxSize() -> Size
Returns the maximum size of the window.
var MaxWidth
GetMaxWidth() -> int
Returns the horizontal component of window maximal size.
var MinClientSize
GetMinClientSize() -> Size
Returns the minimum size of window's client area, an indication to the sizer layout mechanism that this is the minimum required size of its client area.
var MinHeight
GetMinHeight() -> int
Returns the vertical component of window minimal size.
var MinSize
GetMinSize() -> Size
Returns the minimum size of the window, an indication to the sizer layout mechanism that this is the minimum required size.
var MinWidth
GetMinWidth() -> int
Returns the horizontal component of window minimal size.
var Name
GetName() -> String
Returns the window's name.
var NextHandler
GetNextHandler() -> EvtHandler
Returns the pointer to the next handler in the chain.
var Parent
GetParent() -> Window
Returns the parent of the window, or NULL if there is no parent.
var Position
GetPosition() -> Point
This gets the position of the window in pixels, relative to the parent window for the child windows or relative to the display origin for the top level windows.
var PreviousHandler
GetPreviousHandler() -> EvtHandler
Returns the pointer to the previous handler in the chain.
var Rect
GetRect() -> Rect
Returns the position and size of the window as a wxRect object.
var RefData
GetRefData() -> ObjectRefData
Returns the wxObject::m_refData pointer, i.e. the data referenced by this object.
var ScreenPosition
GetScreenPosition() -> Point
Returns the window position in screen coordinates, whether the window is a child window or a top level one.
var ScreenRect
GetScreenRect() -> Rect
Returns the position and size of the window on the screen as a wxRect object.
var Shown
IsShown() -> bool
Returns true if the window is shown, false if it has been hidden.
var Size
GetSize() -> Size
Returns the size of the entire window in pixels, including title bar, border, scrollbars, etc.
var Sizer
GetSizer() -> Sizer
Returns the sizer associated with the window by a previous call to SetSizer(), or NULL.
var ThemeEnabled
GetThemeEnabled() -> bool
Clears the window by filling it with the current background colour.
var ToolTip
GetToolTip() -> ToolTip
Get the associated tooltip or NULL if none.
var TopLevel
IsTopLevel() -> bool
Returns true if the given window is a top-level one.
var TopLevelParent
GetTopLevelParent() -> Window
Returns the first ancestor of this window which is a top-level window.
var UpdateClientRect
GetUpdateClientRect() -> Rect
Get the update rectangle bounding box in client coords.
var UpdateRegion
GetUpdateRegion() -> Region
Returns the region specifying which parts of the window have been damaged.
var Validator
GetValidator() -> Validator
Validator functions.
var VirtualSize
GetVirtualSize() -> Size
This gets the virtual size of the window in pixels.
var WindowStyle
GetWindowStyle() -> long
See GetWindowStyleFlag() for more info.
var WindowStyleFlag
GetWindowStyleFlag() -> long
Gets the window style that was passed to the constructor or Create() method.
var WindowVariant
GetWindowVariant() -> WindowVariant
Returns the value previously passed to SetWindowVariant().
Module variables
var METHOD_ALIASES
var PYMEASURE_ROOT
var TESTS_DIRECTORY
var XSLT_CAPABLE
var demoText
var faces
var overview
var wxID_STYLEDTEXTCTRLPANEL
var wxID_STYLEDTEXTCTRLPANELSTYLEDTEXTCTRL1
var wxID_XMLEDITPANEL
var wxID_XMLEDITPANELEDITDISPLAYPANEL
var wxID_XMLEDITPANELEDITPANEL
var wxID_XMLEDITPANELFILECONTROLPANEL
var wxID_XMLEDITPANELFILEOPENBUTTON
var wxID_XMLEDITPANELFILESAVEBUTTON
var wxID_XMLEDITPANELNOTEBOOK1
var wxID_XMLEDITPANELSOURCEVIEW
var wxID_XMLEDITPANELTRANSFORMEDXML
var wxID_XMLEDITPANELVIEWSOURCE
var wxID_XMLEDITPANELXSLVIEW