#!/usr/bin/python2.4 """ DreamMaker 4.0 - by Crashed """ import wx, wx.aui from options import Options ID_OPTIONS=wx.NewId() def GrabImg(img): """ Grab an image from wx.ArtProvider_GetBitmap. """ return wx.ArtProvider_GetBitmap(img,wx.ART_OTHER,wx.Size(16,16)) class Application(wx.App): """ Application for the editor. """ def __init__(self,*args,**kwargs): wx.App.__init__(self,*args,**kwargs) class Editor(wx.Frame): """ The editor. """ def __init__(self,*args,**kwargs): wx.Frame.__init__(self,*args,**kwargs) #AUI Manager self.aui_manager=wx.aui.AuiManager() self.aui_manager.SetManagedWindow(self) #Menus menu_bar=wx.MenuBar() file_menu=wx.Menu() file_menu.Append(wx.ID_NEW,'New\tCtrl+N','Create a new file.') file_menu.Append(wx.ID_OPEN,'Open\tCtrl+O','Open a file or environment.') file_menu.Append(wx.ID_CLOSE,'Close\tCtrl+C','Close the active file.') file_menu.Append(wx.ID_SAVE,'Save\tCtrl+S','Save the active file.') file_menu.Append(wx.ID_SAVEAS,'Save As\tCtrl+A','Save the active file as another name.') file_menu.AppendSeparator() file_menu.Append(wx.ID_EXIT,'Exit\tCtrl+Q','Exit DreamMaker 4.0') menu_bar.Append(file_menu,'File') view_menu=wx.Menu() view_menu.Append(ID_OPTIONS,'Options','Change your preferences.') menu_bar.Append(view_menu,'View') self.SetMenuBar(menu_bar) #Statusbar self.statusbar=self.CreateStatusBar(3,wx.ST_SIZEGRIP) self.statusbar.SetStatusWidths([-5,-2,-1]) #Toolbar toolbar=wx.ToolBar(self,wx.ID_ANY,style=wx.TB_FLAT|wx.TB_NODIVIDER) toolbar.SetToolBitmapSize(wx.Size(16,16)) toolbar.AddLabelTool(wx.ID_NEW, 'New', GrabImg(wx.ART_NEW),shortHelp='New',longHelp='Create a new file.') toolbar.AddLabelTool(wx.ID_OPEN, 'Open', GrabImg(wx.ART_FILE_OPEN),shortHelp='Open',longHelp='Open a file or environment.') toolbar.AddLabelTool(wx.ID_CLOSE, 'Close', GrabImg(wx.ART_QUIT),shortHelp='Close',longHelp='Close the active file.') toolbar.AddLabelTool(wx.ID_SAVE, 'Save', GrabImg(wx.ART_FILE_SAVE),shortHelp='Save',longHelp='Save the active file.') toolbar.AddLabelTool(wx.ID_SAVEAS,'Save As',GrabImg(wx.ART_FILE_SAVE_AS),shortHelp='Save As',longHelp='Save the active file as another name.') toolbar.AddSeparator() toolbar.AddLabelTool(wx.ID_EXIT, 'Exit', GrabImg(wx.ART_QUIT),shortHelp='Exit',longHelp='Exit DreamMaker 4.0') toolbar.Realize() #AUI Manager self.aui_manager.AddPane(toolbar,wx.aui.AuiPaneInfo().Name("File Toolbar").Caption("File Toolbar").ToolbarPane().Top()) self.CreateFileList() self.CreateTextEditor() self.CreateErrorText() self.aui_manager.AddPane(Options(self,self),wx.aui.AuiPaneInfo().Name("settings").Caption("Dock Manager Settings").Dockable(False).Float().Hide().CloseButton(True).MaximizeButton(True)) self.aui_manager.Update() #Bindings self.Bind(wx.EVT_CLOSE,self.OnExit) self.Bind(wx.EVT_MENU,self.OnExit,id=wx.ID_EXIT) self.Bind(wx.EVT_MENU,self.OnOptions,id=ID_OPTIONS) def CreateFileList(self): """ Creates the file list and adds it to the AUI Manager. """ self.file_list=wx.TreeCtrl(self,wx.ID_ANY,style=wx.TR_DEFAULT_STYLE|wx.NO_BORDER) self.file_list.AddRoot('Self') self.aui_manager.AddPane(self.file_list,wx.aui.AuiPaneInfo().Left().Name("File List").Caption("File List")) def CreateTextEditor(self): """ Creates the text edtior and adds it to the AUI Manager. """ text_editor=wx.TextCtrl(self,wx.ID_ANY,'test',style=wx.NO_BORDER|wx.TE_MULTILINE) self.aui_manager.AddPane(text_editor,wx.aui.AuiPaneInfo().CenterPane().Name("Code Editor").Caption("Code Editor")) def CreateErrorText(self): """ Creates the error field and adds it to the AUI Manager. """ error_text=wx.TextCtrl(self,wx.ID_ANY,'kblkajsd',style=wx.NO_BORDER|wx.TE_MULTILINE) self.aui_manager.AddPane(error_text,wx.aui.AuiPaneInfo().Bottom().Name("Error Text").Caption("Errors")) def OnExit(self,event): """ Called before the program is killed. """ self.aui_manager.UnInit() del self.aui_manager self.Destroy() def OnOptions(self,event): """ Shows the options panel. """ settings_pane=self.aui_manager.GetPane("settings").Float().Show() self.aui_manager.Update() def GetDockArt(self): """ Returns the AUI Manager's art provider. """ return self.aui_manager.GetArtProvider() def DoUpdate(self): """ Updates the AUI Manager. """ self.aui_manager.Update() if __name__=='__main__': app=Application(0) window=Editor(None,wx.ID_ANY,title='DreamMaker 4.0',style=wx.DEFAULT_FRAME_STYLE|wx.SUNKEN_BORDER|wx.CLIP_CHILDREN) window.Show() app.MainLoop()