Attachment 'EditorPanel_Demo.py'

Download

   1 #!/usr/bin/python
   2 
   3 """
   4 EditorPanel_DEMO.py
   5 
   6     The EditorPanel class in ths app demonstrates
   7     a complete and reusable text editor class.
   8     It can be used within any container control, 
   9     including a Frame, but is independent of
  10     that control for its operation.
  11 
  12 Ray Pasco   pascor(at)verizon(dot)net
  13         1.0     2012-05-04
  14 
  15 Based on:
  16     "Another Tutorial", Njan Bodnar 2005-2006
  17     http://code.google.com/p/hltdi-l3/source/browse/PhraseAlignTool/example_editor.py?spec=svncb25b316c69f33df8f8c2805e263665d39fbb306&r=8f996c4f2e04c01b01f37257042bb6a6654e8fcb
  18 """
  19 
  20 import os, sys
  21 
  22 import wx
  23 
  24 #------------------------------------------------------------------------------
  25 #==============================================================================
  26 #------------------------------------------------------------------------------
  27 
  28 class AppFrame( wx.Frame ) :
  29 
  30     def __init__( self, editorLabel=None, DEBUG=False ) :
  31         
  32         wx.Frame.__init__( self, parent=None, id=-1, pos=(250, 0), title='EditorPanel class demo' )
  33         self.SetClientSize( (700, 400) )
  34         
  35         #-----
  36         
  37         self.frmPanel = wx.Panel( self, -1 )    # So the Frame appears the same on all platforms.
  38         self.frmPanel.SetBackgroundColour( (211, 218, 237) )
  39         
  40         #-----
  41         
  42         self.edPanel = EditorPanel( self.frmPanel, label=editorLabel, DEBUG=DEBUG )
  43         # For the Frame's "X" close button or pressing <Alt-F4>.
  44         self.Bind( wx.EVT_CLOSE, self.edPanel.QuitApplication )     
  45         
  46         #-----
  47         
  48         # There's no need to make this panel a stand-alone class 
  49         #   since it's very application-specific.
  50         self.controlsPanel = self.RightSidePanel( self.frmPanel )
  51         
  52         #-----
  53         
  54         frmPanelSizer = wx.BoxSizer( wx.HORIZONTAL )
  55         
  56         frmPanelSizer.Add( self.edPanel,       proportion=1, flag=wx.EXPAND )
  57         frmPanelSizer.Add( self.controlsPanel, proportion=0, flag=wx.EXPAND )
  58         self.frmPanel.SetSizer( frmPanelSizer )
  59         
  60         self.frmPanel.Layout()
  61         
  62         #-----
  63         
  64         if DEBUG :              # Only for development and demo purposes.
  65             self.SetFocus()     # De-select edPanels' textCtrl's initial test text.
  66         self.Show()
  67         
  68     #end def __init__
  69     
  70     #----------------------------------
  71     
  72     class RightSidePanel( wx.Panel ) :
  73         """ A very basic panel to show that the container holding EditorPanel can be shared
  74         with all other controls. In a real app this panel could hold all the controls
  75         for the user to control the app outside of directly using the editor.
  76         """
  77         
  78         def __init__( self, parent=-1, size=(300, -1) ) :
  79             
  80             # Create a simple container widget to hold the editor textCtrl and its header staticText.
  81             wx.Panel.__init__( self, parent=parent, id=-1, size=size )
  82             self.SetBackgroundColour( (230, 250, 230) )     # Color of toolbar bottom edge.
  83             
  84             infoBtnID = wx.NewId()
  85             infoBtn = wx.BitmapButton( self, infoBtnID, bitmap=Info_32_PNG.GetBitmap() )
  86             infoBtn.Bind( wx.EVT_BUTTON, self.OnAppInfo )
  87             
  88             # Have a little fun randomly varying the sizer's control
  89             #  of the butoon's vertical position within this panel.
  90             import random
  91             CENTER_BUTTON_IN_PANEL = random.randint( 0, 1 )
  92             if CENTER_BUTTON_IN_PANEL :
  93                 # Position the button within the exact center of the panel client area.
  94                 rsPanel_innerSizer = wx.BoxSizer( wx.VERTICAL )
  95             else :
  96                 # Place the button "border" distance from the top, 
  97                 #   centered along the sizer's minor axis, wx.HORIZONTAL
  98                 rsPanel_innerSizer = wx.BoxSizer( wx.HORIZONTAL )
  99             
 100             rsPanel_innerSizer.AddStretchSpacer( prop=1 )
 101             # Must NOT use wx.ALIGH_CENTER flag when adding the button !
 102             rsPanel_innerSizer.Add( infoBtn, proportion=0, flag=wx.ALL, border=135 )
 103             rsPanel_innerSizer.AddStretchSpacer( prop=1 )
 104             
 105             self.SetSizer( rsPanel_innerSizer )
 106             self.Layout()
 107             
 108         #end __init__
 109         
 110         #----------------------------------
 111     
 112         def OnAppInfo( self, event ) :
 113 
 114             msg = """\
 115             The EditorPanel class in ths app demonstrates
 116             a complete and reusable text editor class.
 117             It can be used within any container control, 
 118             including a Frame, but is independent of
 119             that control for its operation.
 120 
 121             """
 122             dlg = wx.MessageDialog( self, msg, 'EditorPanel Info', wx.OK )
 123 
 124             result = dlg.ShowModal()
 125             dlg.Destroy()
 126         
 127     #end class
 128     
 129 #end AppFrame class
 130 
 131 #------------------------------------------------------------------------------
 132 #==============================================================================
 133 #------------------------------------------------------------------------------
 134 
 135 class EditorPanel( wx.Panel ) :
 136 
 137     def __init__( self, parent=-1, label='', DEBUG=False ) :
 138         
 139         # Create a simple container widget to hold the editor textCtrl and its header staticText.
 140         wx.Panel.__init__( self, parent=parent, id=-1, style=wx.RAISED_BORDER )
 141         self.SetBackgroundColour( (224, 229, 245) )     # Color of toolbar bottom edge.
 142         
 143         #-----
 144         
 145         self.iconToolbar = self.CreateIconToolbar()
 146         
 147         #-----  EDITOR STATE VARS
 148         
 149         self.editorTextIsDirty = False
 150         self.edLastFilenameSaved = ''
 151         self.fileOpenDir = os.getcwd()
 152         self.edOverwriteMode = False        # For future overwrite-mode implementation.
 153         
 154         initialEdText =  \
 155         """\
 156 The EditorPanel class in ths app demonstrates
 157 a complete and reusable text editor class.
 158 It can be used within any container control, 
 159 including a Frame, but is independent of
 160 that control for its operation.
 161 
 162 """
 163         if label :      # Editor title/description text
 164             edLabel = wx.StaticText( self, -1, label=' '+label, style=wx.RAISED_BORDER )
 165             edLabelFont = edLabel.GetFont()   # Enbolden (?) the font.
 166             edLabelFont.SetWeight( wx.BOLD )
 167             edLabelPointSize = edLabelFont.GetPointSize()   # Enlarge the default font
 168             edLabelFont.SetPointSize( edLabelPointSize + 3 )
 169             edLabel.SetFont( edLabelFont )
 170         
 171         # Editor textCtrl
 172         edTxtCtrlID = wx.NewId()
 173         edTxtCtrlStyle = wx.TE_MULTILINE | wx.TE_PROCESS_ENTER | wx.TE_DONTWRAP
 174         self.edTextCtrl = wx.TextCtrl( self, edTxtCtrlID, style=edTxtCtrlStyle )
 175         self.edTextCtrl.SetBackgroundColour( wx.WHITE )
 176         
 177         edTxtFont = self.edTextCtrl.GetFont()
 178         edTxtPointSize = edTxtFont.GetPointSize()
 179         edTxtFont.SetPointSize( edTxtPointSize + 2 )    # Enlarge the default font
 180         self.edTextCtrl.SetFont( edTxtFont )
 181         
 182         if DEBUG :      # Only for development and demo purposes.
 183             # Add lots of initial text to make sure the vert scrollbar is shown.
 184             for ctr in range( 5 ) :     
 185                 self.edTextCtrl.AppendText( initialEdText )
 186             self.editorTextIsDirty = False      # Would normally be set True for additions.
 187         
 188         self.Bind( wx.EVT_TEXT,     self.OnTextChanged, id=edTxtCtrlID )
 189         self.Bind( wx.EVT_KEY_DOWN, self.OnKeyDown,     id=edTxtCtrlID )
 190         
 191         #-----
 192         
 193         edPanelSizer = wx.BoxSizer( wx.VERTICAL )    # Positions the staticText & textCtrl
 194         
 195         if label :     # Include in the sizer only if defined.
 196             edPanelSizer.Add( edLabel,      proportion=0, flag=wx.EXPAND )
 197         
 198         edPanelSizer.Add( self.iconToolbar, proportion=0, flag=wx.EXPAND )
 199         
 200         edPanelSizer.Add( self.edTextCtrl,  proportion=1, flag=wx.EXPAND )
 201         
 202         self.SetSizer( edPanelSizer )    # Associate the sizer to container control
 203         
 204         #-----
 205         
 206     #end __init__
 207     
 208     #----------------------------------
 209     
 210     def CreateIconToolbar( self ) :
 211     
 212         toolbar = wx.ToolBar( self, -1 )
 213         
 214         # Open file
 215         openFileID = wx.NewId()
 216         tool = toolbar.AddLabelTool( openFileID, label='Open File', 
 217                                      bitmap=Open_32_PNG.GetBitmap() )
 218         self.Bind( wx.EVT_TOOL, self.OnOpenFile, id=openFileID )
 219         
 220         toolbar.AddSeparator()
 221         
 222         # COPY
 223         copySelectedID = wx.NewId()
 224         tool = toolbar.AddLabelTool( copySelectedID, label='Copy', 
 225                                      bitmap=Copy_32_PNG.GetBitmap() )
 226         self.Bind( wx.EVT_TOOL, self.OnCopy, id=copySelectedID )
 227         
 228         # CUT
 229         cutSelectedID = wx.NewId()
 230         tool = toolbar.AddLabelTool( cutSelectedID, label='Cut', 
 231                                      bitmap=Cut_32_PNG.GetBitmap() )
 232         self.Bind( wx.EVT_TOOL, self.OnCut, id=cutSelectedID )
 233         #Open_32_PNG.GetBitmap().SaveFile( 'Open-32.PNG', wx.BITMAP_TYPE_PNG )
 234         
 235         # PASTE any text previously copied text
 236         pasteID = wx.NewId()
 237         tool = toolbar.AddLabelTool( pasteID, label='Paste', 
 238                                      bitmap=Paste_32_PNG.GetBitmap() )
 239         self.Bind( wx.EVT_TOOL, self.OnPaste, id=pasteID )
 240         
 241         toolbar.AddSeparator()
 242         
 243         # SAVE TO FILE editor's current text
 244         saveFileID = wx.NewId()
 245         tool = toolbar.AddLabelTool( saveFileID, label='Save', 
 246                                      bitmap=Save_32_PNG.GetBitmap() )
 247         self.Bind( wx.EVT_TOOL, self.OnSaveFile, id=saveFileID )
 248         Save_32_PNG.GetBitmap().SaveFile( 'Save-32.PNG', wx.BITMAP_TYPE_PNG )
 249         
 250         # EXIT this app.
 251         exitAppID = wx.NewId()
 252         tool = toolbar.AddLabelTool( exitAppID, label='Exit', 
 253                                      bitmap=Exit_32_PNG.GetBitmap() )
 254         tool.SetLabel( 'Exit' )
 255         self.Bind( wx.EVT_TOOL, self.QuitApplication, id=exitAppID )
 256         
 257         toolbar.Realize()
 258         
 259         return toolbar
 260         
 261     #end CreateIconToolbar def
 262     
 263     #----------------------------------
 264     
 265     def OnTextChanged( self, event ) :
 266         
 267         self.editorTextIsDirty = True
 268         
 269         event.Skip()        # ???  What other handler would care ?
 270         
 271     #end def
 272     
 273     #----------------------------------
 274     
 275     def OnKeyDown( self, event ) :
 276         
 277         keycode = event.GetKeyCode()
 278         if keycode == wx.WXK_INSERT:
 279             
 280             pass    # Overwrite mode is not implemented yet.
 281             
 282             """
 283             if not self.edOverwriteMode:
 284                 self.edOverwriteMode = True
 285                 # Insert code here to implement text overwriting...
 286                 
 287             else:
 288                 self.edOverwriteMode = False
 289             #end if
 290             """
 291             
 292         #end if
 293         
 294         event.Skip()
 295         
 296     #end OnKeyDown def
 297     
 298     #----------------------------------
 299     
 300     def OnOpenFile( self, event ) :
 301     
 302         wildcardStr = 'All files ( * )|*'
 303         
 304         fileOpenDlg = wx.FileDialog( self, message='Choose a file to open', 
 305                                      defaultDir=self.fileOpenDir, defaultFile='', 
 306                                      wildcard=wildcardStr, style=wx.OPEN|wx.CHANGE_DIR )
 307             
 308         if (fileOpenDlg.ShowModal() == wx.ID_OK) :
 309             
 310             filePathname = fileOpenDlg.GetPath()
 311 
 312             try:
 313                 file = open( filePathname, 'r' )
 314                 text = file.read()
 315                 file.close()
 316                 
 317                 self.edTextCtrl.AppendText( text )            
 318                 self.editorTextIsDirty = True
 319                 
 320                 self.fileOpenDir, unusedBaseName = os.path.split( filePathname )
 321                 
 322             except IOError, error:
 323                 dlg = wx.MessageDialog( self, 'Error opening file\n' + str( error ) )
 324                 dlg.ShowModal()
 325                 
 326             except UnicodeDecodeError, error:
 327                 dlg = wx.MessageDialog( self, 'Error opening file\n' + str( error ) )
 328                 dlg.ShowModal()
 329             #end try
 330             
 331         #end if
 332         
 333         fileOpenDlg.Destroy()
 334         
 335     #end DoOpenFile def
 336 
 337     #----------------------------------
 338         
 339     def QuitApplication( self, event ) :
 340         """ Ask to save to a file since there were modifications. """
 341     
 342         if self.editorTextIsDirty :
 343             
 344             dlg = wx.MessageDialog( self, 'Save before Exit?', '', 
 345                                     wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | wx.ICON_QUESTION )
 346             val = dlg.ShowModal()
 347             if (val == wx.ID_YES) :
 348             
 349                 self.OnSaveFile( event )
 350                 if not self.editorTextIsDirty :
 351                     wx.Exit()   # Exit wx.App.MainLoop()
 352                     #-----
 353                 
 354             elif val == wx.ID_CANCEL:
 355                 dlg.Destroy()
 356             else:
 357                 wx.Exit()   # Exit wx.App.MainLoop()
 358             #end if
 359         else:
 360             wx.Exit()   # Exit wx.App.MainLoop()
 361         #end if
 362         
 363     #end QuitApplication def
 364     
 365     #----------------------------------
 366         
 367     def OnSaveFile( self, event ) :
 368     
 369         if self.edLastFilenameSaved:
 370 
 371             try:
 372                 file = open( self.edLastFilenameSaved, 'w' )
 373                 text = self.edTextCtrl.GetValue()
 374                 file.write( text )
 375                 file.close()
 376                 
 377                 self.statusbar.SetStatusText( os.path.basename( self.edLastFilenameSaved ) + ' saved', 0 )
 378                 self.editorTextIsDirty = False
 379 
 380             except IOError, error:
 381                 dlg = wx.MessageDialog( self, 'Error saving file\n' + str( error ) )
 382                 dlg.ShowModal()
 383             #end try
 384             
 385         else:
 386             self.OnSaveAsFile( event )
 387         #end if
 388 
 389     #end OnSaveFile def
 390 
 391     #----------------------------------
 392         
 393     def OnSaveAsFile( self, event ) :
 394         
 395         dir = os.getcwd()
 396         
 397         wildcardStr = 'All files|*'
 398         save_dlg = wx.FileDialog( self, message='Save file As...', defaultDir=dir, defaultFile='', 
 399                                   wildcard=wildcardStr, style=wx.SAVE | wx.OVERWRITE_PROMPT )
 400             
 401         if save_dlg.ShowModal() == wx.ID_OK:
 402             
 403             path = save_dlg.GetPath()
 404 
 405             try:
 406                 file = open( path, 'w' )
 407                 text = self.edTextCtrl.GetValue()
 408                 file.write( text )
 409                 file.close()
 410                 
 411                 self.edLastFilenameSaved = os.path.basename( path )
 412                 #self.statusbar.SetStatusText( self.edLastFilenameSaved + ' saved', 0 )
 413                 self.editorTextIsDirty = False
 414                 #self.statusbar.SetStatusText( '', 1 )
 415 
 416             except IOError, error:
 417                 dlg = wx.MessageDialog( self, 'Error saving file\n' + str( error ) )
 418                 dlg.ShowModal()
 419             #end try
 420             
 421         #end if
 422         
 423         save_dlg.Destroy()
 424 
 425     #end OnSaveAsFile def
 426 
 427     #----------------------------------
 428         
 429     def OnCut( self, event ) :
 430         self.edTextCtrl.Cut()
 431         self.editorTextIsDirty = True
 432 
 433     def OnCopy( self, event ) :     # A "meta-edit" ?
 434         self.edTextCtrl.Copy()
 435 
 436     def OnPaste( self, event ) :
 437         self.edTextCtrl.Paste()
 438         self.editorTextIsDirty = True
 439 
 440     def OnDelete( self, event ) :
 441     
 442         frm, to = self.edTextCtrl.GetSelection()
 443         self.edTextCtrl.Remove( frm, to )
 444         self.editorTextIsDirty = True
 445         
 446 #end EditorPanel Class
 447 
 448 #---------------------------------------------------------------------
 449 
 450 # This file was generated by Image2PyFile.py
 451 
 452 from wx.lib.embeddedimage import PyEmbeddedImage
 453 
 454 #----------------------------
 455 
 456 Open_32_PNG = PyEmbeddedImage( 
 457     "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAmVJ"
 458     "REFUWIXNlz1v00AYx3/xS+zYCVBYKKqgJROqOhQJmgGWKmtHhIRg7gfgC+QL8AGYg0DM7Cyl"
 459     "EmFAYmIKQgxVqVQhoSbn89kxQ+LKTRzntQn/LM7d+f4/3XPP47tcTtNZprTLmHS3Xol265Vo"
 460     "nLG5/hV4XXuc+eJ+7SA3yjz5/+OLz5njjbTG58/unz+/efu1v+2CQRIoNtfvtgAIf7js1itR"
 461     "FkTqCiQBhkAM9L0vKwBuPXRoizYATsHh6Ev3eRjEWHsgNo7N+vti883qKkXHpeSWKLklio7L"
 462     "ZnUVGAzNRABZEHuNBgBb1TUs06Jg2biOg+s4FCwby7TYqq4NhZgoC/pDEJtvPLgOYUQURuia"
 463     "jp23sPMWuqYThRGEUXdMCsTUaRibr6wbBFIh2h6+VHSCDlrv1wk6+L2+QCpW1o0BiNQsGEfF"
 464     "fJEz/4w/PwNOjFM6RojlFbj36CamZQKgpOL7p2OkLdACHTPIn787M8C77c2Btr1GA9uxCFSA"
 465     "lAopJACHT74NTcOpAYbJlwrpSaTw8Tw5cvyllOJJNPcVEC2B11uB02YwXSmeRnuNBne2r9Ju"
 466     "CTzPRwp/rOmXHoKlA8wlBHFRarcE0vNRvkIcm4sBiM1vlI1uxVMB3u9uwRm1AWHGEMTm1zY0"
 467     "hPBQvjo3f9ocbwVm/hZcuQ1SSNpHBvLEAuDDzg7QPVuMOmFNFIK088DfXwDmBWPIPkNMDZCc"
 468     "OGmWpkL5FaL5cuR8S0/D/xsgp9uLB9ivHeTijROF3uIB+iGm1TgbEDKyoHfhGHpHmJcy0zAN"
 469     "YtTVbK4ASYh5miY1cDVbtP4BMBQL9l9YAsoAAAAASUVORK5CYII="
 470     )
 471 GetBitmap_Open_32_PNG = Open_32_PNG.GetBitmap
 472 
 473 #----------------------------
 474 
 475 Copy_32_PNG = PyEmbeddedImage( 
 476     "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAbNJ"
 477     "REFUWIXtl09Kw0AUh38vSWMluBG6kBpc9ADiwkN4GXsQQaibLnoTD+EF1FWoQgV3LlKTPjfO"
 478     "OCbzL5NAF/ogtAnNm+998yaTEkUx9hmJ+MK7mrvcSFFMgwIAALMfAxGBdzUPAZE0LxDZcwpI"
 479     "ZgYR9YZoAfhaGAoi2MBQEL0MDAERbED3u5DGDDJg+o0LXheRLol6iLi4ecB0UXQewBUknoS8"
 480     "q9lU2cndKyKukKQxqm2N9TyXsF6DWKbFagAArm7vkY4Y2WyCg/wYSRpLE8zsPERxvQxMFwWy"
 481     "2USel8W7l4nv1SE/dSZaAM1kAsoFYa6Qfq2cJkRrCnQKAWA9z/Hx/CbPm9MhB7D0BTO3psO5"
 482     "CtSkLggV+nL16AXhNOBr4mz5Iq+dL5+wqTJjUcBPYzp7QAcI6HsCAKptjaj8RDlOsbk+NeYR"
 483     "/eBtwMcEACRpjOhojLiqtdU3C/TuAfVmW0+ISA9HxoKsAL4GVBNqqBCdDbiq1yXQ7Q8qhKsI"
 484     "uRt22UZFB4vB1WlohnbbViAo5LXc9tj2DbEKWu8DXZOEhArfC6Cvhd4A/wb+toHQ6tt59vz3"
 485     "/AuRMXpI0l6G7wAAAABJRU5ErkJggg=="
 486     )
 487 GetBitmap_Copy_32_PNG = Copy_32_PNG.GetBitmap
 488 
 489 #----------------------------
 490 
 491 Cut_32_PNG = PyEmbeddedImage( 
 492     "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAZRJ"
 493     "REFUWIXFVTFOxDAQXCO4GgnxhiBa/nEdruKCNogKUSFKKoTorkMUvsrNSeEBvABR3yvoD4ml"
 494     "II4Wx07WiWNGsmQnjne8O7MBmIjzi6tjstRksLA3lQAhoQEAELFMcSYDZwdkoQFAYwPIk4H3"
 495     "L7oae/MUJWDfdg4CnboLIdY5CYRSr7IRoIi9/VQC3to/vWzuchHI6XkvWt9T/yOiiDkkmQZo"
 496     "/RFRGGMWnO/2UxFooIRoE7AzxiyklDtnzx/tJHWBD5u3j0NwflKIWFr90AzooqqDotqulmuI"
 497     "8DcAgJTy2c5dwdqS2Xz1Bg+Q0JwO6HMK2ft7VlHVWFR1319Mkz3tM0f9LDQx9PX9wylAV4Sh"
 498     "FCsAKC1Z9zacfuBkSD3e3oCPQBQ4wd3A7nuXgPZtAlKa7WrZ+qyoajy5fLXa6ENQvFNE2JaD"
 499     "koqF7QNq6BauA6gWBgTcizHMg9ka0yuiEbCsz6YsTGnFKjDPRiAJOASOmvFvBGYFh8BnM1zo"
 500     "wDwKHBtakt82WEobju1gHRJz94DRrXYIP3Eu9Jfu15GbAAAAAElFTkSuQmCC"
 501     )
 502 GetBitmap_Cut_32_PNG = Cut_32_PNG.GetBitmap
 503 
 504 #----------------------------
 505 
 506 Paste_32_PNG = PyEmbeddedImage( 
 507     "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAgJJ"
 508     "REFUWIXNl71Lw0AYxp9La9oiLkIHKV1crVgHB0cXwUEoGUqp/gciBUehU8BFECoVB1ctoUNQ"
 509     "HASXjm6iaCc/llKECl1EFG0bh5JwTXPJ5aPUBwLJm9z7/vJc7iOECCGMU2HeB0/PKhrr3uZG"
 510     "nowcAADy2exQrFKteq3tHkAvls9mfRdmAmytpyytvlH2AADLud2hGKvN0eWjY9dYOrAyP2uc"
 511     "f8/lmI1pGACI1hXjvPbw6lSbDWBWPjfc9+ZYRfHWJYKnVgHK0YFoXUFFcXpq0P5AAfwkDwyA"
 512     "Fu/HFSiAJKsAALUoAQDKF/e8+S2HJxFCxvB0BJBkFYv7t2iJcTRlFbVMup9ZY87MtiJkcGqw"
 513     "BZBkFTOHbxDEOMJiCIlSA83zO5SpJOaEdrKCZgJIsoq1g2uIsRQiyXg/2GgjUWoMJPLqhC7m"
 514     "PKAWJVztrKLz0zVikeS04YQuQgj34QpAh2gWkvh8eWdCaJrGfbgG4IVgybcDvBBmkKWTJwDD"
 515     "7ngGcIKg3Vg4fkarMwkgQAecIAAYEO0PAV+/PQABO6BrO5O2hRCmogh1+iMncAd0EUKYEAAg"
 516     "xiYAjMgBWs1CcuCahtBBR+KALqthSEPwOOB6OTYXp7vBLPNbu1oLnGS230o864QlgJtNh9/V"
 517     "kHj5N9R6Xc3PfoDekPz/XTFLbqy3zzPm3/M/wVYENaoecsEAAAAASUVORK5CYII="
 518     )
 519 GetBitmap_Paste_32_PNG = Paste_32_PNG.GetBitmap
 520 
 521 #----------------------------
 522 
 523 Save_32_PNG = PyEmbeddedImage( 
 524     "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAj9J"
 525     "REFUWIXNls1u00AUhT/P2I7HkVBThFJ1gVKKilSEhNgSiQXZ8Arta3WTByBPEXbpBhYsEEJC"
 526     "ggQWJQKRQOrE8V/NokpIwHX+nLR3ZY/GPp/PmTtjqtWqUa1WDa6p9NFFqVCI1yHQ6na1VADT"
 527     "NOXoptnpZCq+t709c47IVHGJ0pMG5yGfVfO6mQiQdRRpdTMjgOVjWNS9KwE2FcPNjQA2E0Mq"
 528     "wCZi0IvF4lq24LkBkgYXtX4Vp659I0pdA2lVqZX/G6sfNbIBmBXBpEO37kLgB7htYwy1CMjS"
 529     "EdSPGlRqZXpfYWsvh7brE4UR3vcclVp5bgjhOE7sOM5SnTAS+dW8QCkLwzSwij6QHFFSrdwF"
 530     "zU6HSq3Mz08hdw4svKGPtnMZyf7JIa3j08UBFu2CURx2XiGlYCgF7Pi47dlrPNOz4Mvb39h5"
 531     "hZ23sPMWAM9fPk2NN7OzYBSFyiuEFEghEQcePz76qc9lfhaYOQMhNISUCCmAdIDxL3OpUIgX"
 532     "FUxa6U9elCCGMIgIvIAPjTae5SJCiRGa43mvjk81WKELJmFvP5bYlo2yLIIwQNd1dEMihMbD"
 533     "Z7t4Qw/P9XF6Lt1WOPWelRyAvy5sPQJb2aichZXLYegGQhPEUUwYhDiOS/NNZ+rrIYMuGG9G"
 534     "76DnnHM+6NN3Bwx9j+giQpMaSC1RHP5xYBWQ/ZNDANQDH1upcSSGrvO+/i1RfAogixr1vHnf"
 535     "vYRQNmevB1eKZw4wCSHv9Yk+51PF1wIQx3E82Z5p4gB/AF8v6tam65qxAAAAAElFTkSuQmCC"
 536     )
 537 GetBitmap_Save_32_PNG = Save_32_PNG.GetBitmap
 538 
 539 #----------------------------
 540 
 541 Exit_32_PNG = PyEmbeddedImage( 
 542     "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAABatJ"
 543     "REFUWIXFl3+IXFcVxz/n3Pvmvc7u7GR2M901W6W0K9JutmNMEwJW0xakSAVFVPxPgoIRsf6n"
 544     "aCP+KME/xD8jSguR1KZ/SUURSm2lLU1KGpI6S2sK2exuadwf7uzMJk1mZufHu/5xX2Z26ySZ"
 545     "TREPHO57j/vu+Z7f58L/maTfjYW9+64G1oJzOOeIcTgHLnkHEBFUlbjdph23e0oTEXCCOGrT"
 546     "Z97YbvsFMJrfnn7m6FOUVkosLi+ytlahXC6zslKiVFphdXWVkeHt7N69m7/+5XlOvnkKG2r3"
 547     "AAdihdRtBuMiXNOmAfoGULhviuHhYay1pMKAkZHt7NhRpVqtsrZW4e23/0ljvUEYhojAwsIs"
 548     "Q6NhYmIhbjmCtJLLR9jmGHHLVLcEIAgCRBUbBIRRROzAGEsYhkRRSLPZplarkR4YxCG42CEd"
 549     "DyeriH92Xc/3DcD/b4iBRr1Oo9Fgfb3O+nqden2dbHYbY2NjZDIZcrkcIoKI4ABBEPHrRuEA"
 550     "2lNSD2pmMlvBytBYSOxifKTS5Q9Q3wDS8/Ncnp2h3W5jBgb8wQnFcUyr1UJVyWQGuWN8fLNA"
 551     "3cC3CuCh48d58/69VBcXCfP5TuptJOcccRx7F6h4NoIxJmFFVX0qbhUAwLlKhenHvs+Vs2cZ"
 552     "3DkFcbzJEtdqQpAKUKMJJ8JtwsbHwy0BOFgosPC3Fyn+6HGunHiNYHwcjSLazSZhGJLP5xkd"
 553     "HSUVBKh6ba01GKsYa7DWoMZsArClLIiBbxYKPPXS3zlfrXHHLw/DUIYom+W+e+7p7Gs0mxhr"
 554     "vIZGMcagAsb4SrmxAG/JAhpFAHyrUGD59GkWf/w4reV/k5+YAGBq6pPs2nV/IlgS9q4wgaJW"
 555     "EfMhAKAKYQjAtycnuXjydZaeOIydmwPg4sWLzM/PA2BTik0pQWgIIkMQWs8p9cGZYLAAL+dy"
 556     "PTK0B5XLEARgvHm/Uyhw9ORJ3vnpz8g/e5xKpQTAc3/8M0HkvWsDi7UGYsGEgkkp7Q1qd2Jg"
 557     "/8Td3YiON+BR9SX08mW4ehWyWf9uLTSbHCgUOPr8C7zwuUe469e/YsfkTrCpLoAk+JwDkxKM"
 558     "vV4l9L31v7ndhlbLmz6b9do757+p//1AoUC5OM2lJw7TWFrCDWVJ3aaeIyWIbMIGkzKI9uoF"
 559     "G3M67lUz1QuP4+63VgsaDeoiHLz3Xp598SVqX/0aK5/ahwm8m4wxGDXg/O9qXBKD8gEAN6Nr"
 560     "FulrL51qJ5JURAQ1oLL5jK4LVG/M0mN4shaiiCgM+c1bb5H97AN8/OljDH/pi6gFtSDJqgGY"
 561     "AIzlOqVY5Oa8kYKg447fF4tsm9rJwA9/ACMjxOVKB4C5tqYETQlqBemVBa/MXLipZfffead3"
 562     "QxRBrdYRrnv2MPDdg9iJCYa35UgbiyYni8Gb3iTa2+5c0gHwYKVy0+H05VzOYYyPpET4kWKR"
 563     "/L69fPTQIaIHPo3OvsulpVXWyrWOlps9qahujoEt9QKcg3odgCfPneOu/Z8h95NDZCZ34uYX"
 564     "WKlUeP3Ma0zP/ANj/NHGmE5jEpHOjHhLAFyrhQC/Kxb52EMPMnnkCK2hQd6bnePC9HneXZrh"
 565     "ndVTlFr/IkgHiQXU9wRNSrDGmy4DW5sJgWPFInd/5ct84tDPuTRwO8vnzvPqmecozp2i0Whw"
 566     "hRIStgnsAFb8ICsqqAhiYuTDuODpYpHbH/48Iwce4w3qnD72C96//D6zl6Ypt95jMJ1lMBjE"
 567     "mgBV6VxErpldRBAnqOumQd8AZtoxuT27iL/3dV69eoETTz5DSeYwxhAOhXxEx8GAivoo72jq"
 568     "usO5JjXgVlxw5uFH+MI3HuV8s8WJ2d/SzFUZ1CC5jjlUWpAM4YnCHeoY3QDiQMOO6L4BnG03"
 569     "SS38qd/tN6RaWSFma1ez2vJi9ZU/KHHcxDmHSJob322v3zdcLEhMrW/E/0v6D2nb6JESJEFI"
 570     "AAAAAElFTkSuQmCC"
 571     )
 572 GetBitmap_Exit_32_PNG = Exit_32_PNG.GetBitmap
 573 
 574 #----------------------------
 575 
 576 Info_32_PNG = PyEmbeddedImage( 
 577     "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAACAJJ"
 578     "REFUWIXFl1tslMcVx38z32XXa69va8BAwTENwcaI3EouJQ6gEkAQKVRVm4emUlGbPqRq1VZV"
 579     "nwJ9aBQpqhop6lMbpUmbKoSiKIFaRICJIbdCisElThywEy6xAzjGBu/lu85MH3a9XgeSkIeq"
 580     "Rxp9M9/3zZz/+Z8z58wIIS3+n2Jf74+nB0+ZXC6HVyh87j9VqRRSSmpra1nQukhcz7riyxgY"
 581     "HHjfTIyPU1dfz+K2tusC+25fH77n0dzcTMuNi78QyBcCOPLG6yZVU0PH8uUz3r/8xBPE4+MY"
 582     "38cA2nVRtbU8tHUrBpgE6oB/Hz6MBFasvOdzQVwTwNiF82bgvfdoW7aMTFMTx/v7GXzlFeKB"
 583     "AVIFj7Rjk0wksBwHtCb2fbL5PBdzOcZcB7FkCb/4w1NYjmRoaIiRM2dYs37DNUFcBeDSxQvm"
 584     "vf5+7lm9umjt00+T37uXeVqTbmxEuS5KSrRS6ChC+T4q8JFK4wLK8zjvBUw01PCTv23HTlfz"
 585     "yegoHxw/ztqNm64CcRWAN147YFauWgXAC9u2kT56lObmZsJUCoPBxBodheggQCtFYXiYyPcR"
 586     "WpOYNQu0JgwCbMvGS6T49o4XsGvTnB0Z4dwHH7Bq3XrxuQCO/utt07JoEZmmJnZs20ZDby/1"
 587     "C1sIbAvCsGhxEKLjEBPF+GNjNN19NwvXreOTw4c5t2MHTroOHUegDbZtM6kMD/Z0Y1Wn6Ovr"
 588     "wwaW3/4NcRWA4bNnzOUrV1ja0cHeZ59F79xJY+siAhVjwhDlh2gVYmKFDkJiL4/bmOG+nTvL"
 589     "BvRs2cLFffuwM7MBBbHGTlhcUpIfvvMWVjLFwe5ubr71VjKz5wgAOTV5dHSUpR0dAOS6umho"
 590     "bsYr5Imzk0T5LMovoPwA5fvEUUSUy4OUmAo6rVQKf3ISHfko3yfyC3iXJkjlJ/h9x3K0Uqxe"
 591     "u5bTH31UniMBzg9/bGqqqwHoevxx6j2Pgu8TZbPEno/yQ+KgqFz5Ptr3ELbNRO8xjj72GFcG"
 592     "B+l/5hmGd+0i0dRUBqr8gNgP8Ccmqbs8zu++tR6AQkUyE0JaDPS/a5a0twPw9wceYCHgS4lR"
 593     "Ch3H0884RiuFKb2LPY/86dNoY9C+T/X8+ZBIoH0fFUaYKMKoGOIIwpizrs1vCx69/f3UOQ43"
 594     "Le0QM1Lxwe3bESMjhHPnoCIzQ+EUEKM1KpsjNzKMMQanoYGqpiZwHHJnz6KzWYgidAwIjVEK"
 595     "K9bYQpEOinpuX7aMvmPHgFItsB0HgOzASVIIfL8ACozS6CiqYCAizBeonj+fO7c+SiKToWrh"
 596     "Qua2t3NgyxY+6u0lbcCyAC2RQmMbgwSEgYyJ+eOaNfysp4cwiioA2EUi1OgFhJQYL0Rrg1Yx"
 597     "Jp5iIMJExf6VkycZO3KEzqeeKrM3sns3rjE4gFQgUEgDFiBKwZYE8iMjRV1aTwehnUwyEYWo"
 598     "bA4Ta2IvRAX+dNQHBXQ+T1woEExOcuHiRQaff76sfLCri8vj46QBp2SVc42+C7i5XDH4Sqzb"
 599     "AFopQGDFEZEKEMpgtELHCh2HqCgi9jx0IUfghcTAkocfLgO4+OqrmJICWWqioj/VbMAVxRyk"
 600     "SwzYAGEQUG/b4LiobB6kKPo/VqiguO2iMEKFIRJIA1+7//4ygLE9e6guLSYo0j4FonJsI7DT"
 601     "6aILwnAaQBSGgMBprCdb8BAWYDTaD1FBgAojhIpwDfjAnHnzaOnsLPr+nXeYPHOGmpKiKWWf"
 602     "ZUEAljBYCxYAYJWYkFMuEALS7R14KkKHIcrz0LkChD5WHOOYoh8NMG/Tpmnr9+4lBFwx7XOr"
 603     "wvdTYxdQBh7cvx+AhOtOA3BKgwUbNkAiifIDTD6PViEy1liY8kJVwNyNG6f9v307NUJQVVeP"
 604     "XaF4CoRdUp5EEpbm7Dl0iIbGxmkAs2bN4nhvL62tN9C4ehUm4YABR89cUANNmQyLNm8GYLin"
 605     "h9zAAMu2bsVJp5HMjPzyUwgc1yEonTHsQoEbb1oyXYwaM01CWsWquPmvf0G4CWzLxbLljIWM"
 606     "gNlr15atd2yb5c89R3DqFN7HH5OosLrsCilIuhZZV/Cdnh7++fbbzJ4zp7xGuRq2tLTw1uuv"
 607     "Y1sO8x75KbqmBlvaWMIqJhegygi8oaHy5DmdnQT9/Xzy4ovlXVDZXAFJWyJsh7EfbAFAjI5y"
 608     "24o7rj4PALz/7gmTDwJuu+UWXvr+Q5juAySyVxBhgNQGC0GEIbNiBQ0338ylA91Mnj5DNdMZ"
 609     "r3LbuUJiuQ4Da+7lu6/u4+Vdu1je0cHiJW3XBgDw1qGDpm7uXJa23sArP/4Rons/iUuXkYGH"
 610     "UMW8HgJaQNJIEuhrbrsaS+IJwan1G/heVxe7u7tpTqW4q/PeGUcyyWdk5arVYuzcOU4Mfcj9"
 611     "f/ozqUd+jmltxUrVUiWKEV0N1BmowmALsCXYpW81lqRGCkYtm1O//FVR+f79NEh5lfJrMjAl"
 612     "b/S8ZqTrctedK4iuZDn4m18Tv/Qy1ePjJC2JSCSQjo0QYCmBiGO0Dsklq5i8bwObdv4DgF27"
 613     "dzO7sZGVq1Zf37G8Uk70HTefnj/PmnX3YUpnr+4nn4S+/5AY/ZQkMQKJchwK9XX4be1sfPRR"
 614     "ALrefBMxNsaNbW20dyz7aheTShkf+9R8ODREIZ+ns7SPAUysIdIICdo2SKtYCfYcPIjteTRm"
 615     "Mtxx9ze/9H74pQAqZejUSZPLZgnCEE2xphtjkEKA1iSTSerr6/n64puu62L6lQH8L+S/rprk"
 616     "8jjZs4gAAAAASUVORK5CYII="
 617     )
 618 GetBitmap_Info_32_PNG = Info_32_PNG.GetBitmap
 619 
 620 #==============================================================================
 621 
 622 def Main() :
 623     
 624     app = wx.App( redirect=False )
 625     appFrame = AppFrame( editorLabel='Text Editor with an Icon Toolbar', 
 626                          DEBUG=True )
 627     app.MainLoop()
 628     
 629 if __name__ == '__main__' :
 630     
 631     Main()

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2012-05-04 19:57:15, 33.3 KB) [[attachment:EditorPanel_Demo.png]]
  • [get | view] (2012-05-04 19:57:22, 26.8 KB) [[attachment:EditorPanel_Demo.py]]
  • [get | view] (2011-05-26 18:16:27, 2.6 KB) [[attachment:EmbeddedGraphicData.py]]
  • [get | view] (2011-05-26 06:11:57, 2.9 KB) [[attachment:Hand.png]]
  • [get | view] (2012-04-30 18:47:53, 38.0 KB) [[attachment:Image2PyFile.PY]]
  • [get | view] (2012-04-26 21:18:00, 31.9 KB) [[attachment:Image2PyFile.py]]
  • [get | view] (2012-04-30 18:36:42, 7.1 KB) [[attachment:Image2PyFile_GUI.py]]
  • [get | view] (2012-04-27 03:22:42, 20.5 KB) [[attachment:Image2PyFile_GUI_Output.png]]
  • [get | view] (2011-05-26 06:41:02, 42.1 KB) [[attachment:Image2PyFile_GUI_Output_Again.png]]
  • [get | view] (2012-04-26 23:27:42, 26.8 KB) [[attachment:Image2PyFile_Output.png]]
  • [get | view] (2011-05-26 06:12:55, 2.9 KB) [[attachment:Minus.png]]
  • [get | view] (2011-05-26 06:13:18, 2.9 KB) [[attachment:Plus.png]]
  • [get | view] (2011-05-26 18:13:55, 2.8 KB) [[attachment:Separator.png]]
  • [get | view] (2012-05-04 19:44:48, 19.8 KB) [[attachment:wxToolBar_Embedded_Demo.png]]
  • [get | view] (2012-05-04 19:45:04, 11.2 KB) [[attachment:wxToolBar_Embedded_Demo.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.

NOTE: To edit pages in this wiki you must be a member of the TrustedEditorsGroup.