Beispiel #1
0
 def addModule(self, name, x, y):
     moduleFolder = 'Tabs.Modules'
     dyn = dynLoad(moduleFolder+'.'+name,['*'])
     x = self.getPosX(x, 0)
     y = self.getPosY(y, 0)
     ins = dyn.getClassInstance('moduleFrame', self, name, (x, y))
     self.getPosX(x, int(ins.width/self.__TEXT_W))
     self.getPosY(y, int(ins.height/self.__TEXT_H) - y + 1)
     
     return ins
Beispiel #2
0
    def __init__(self, _name, _pos=(0,0), _size = None):
        g = globals.getInstance()
        
        self.cfg_name = g.configFileName #'cfg.ini'
        
        self.TEXT_W = g.uiTextWidth
        
        if (_size == None):
            size = wx.DisplaySize()
            _size = (size[0], size[1] - 50)
        
        #width = _size[0]
        height = _size[1] - 100
        
        wx.Frame.__init__(self, None, -1, _name, pos=_pos, size=_size)

        self.timers = {}

        if (not os.path.isfile(self.cfg_name)):
            tmpFile = open(self.cfg_name, "w")
            tmpFile.close()
            pass

        tmpDir = 'Temp'
        if not os.path.isdir(tmpDir):
            os.makedirs(tmpDir)

        self.config = ConfigParser.ConfigParser()
        self.config.readfp(open(self.cfg_name, 'r'))

        if not self.config.has_section('fileDialog'):
            self.config.add_section('fileDialog')
            self.config.write(open(self.cfg_name, "w"))
        if not self.config.has_section('dirDialog'):
            self.config.add_section('dirDialog')
            self.config.write(open(self.cfg_name, "w"))

        self.misc = misc.getInstance()
        self.misc.setFrame(self)


        self.menuBar = wx.MenuBar()
        self.SetMenuBar(self.menuBar)

        Mode = 1

        if (Mode == 0):
            self.panel = wx.Panel(self, -1)
        elif (Mode == 1):
            splitter = wx.SplitterWindow(self, style = wx.SP_3D| wx.SP_LIVE_UPDATE)
            TopPanel = wx.Panel(splitter)
            BottomPanel = wx.Panel(splitter)
            splitter.SplitHorizontally(TopPanel, BottomPanel)
            PanelSizer=wx.BoxSizer(wx.VERTICAL)
            PanelSizer.Add(splitter, 1, wx.EXPAND | wx.ALL)
            self.SetSizer(PanelSizer)
            
            splitter.SetSashPosition(height - 200)
            
            self.panel = TopPanel
            self.outPanel = BottomPanel
        elif (Mode == 2):
            TBsplitter = wx.SplitterWindow(self, style = wx.SP_3D| wx.SP_LIVE_UPDATE)
            topPanel = wx.Panel(TBsplitter)
            bottomPanel = wx.Panel(TBsplitter)
            TLRsplitter = wx.SplitterWindow(topPanel, style = wx.SP_3D| wx.SP_LIVE_UPDATE)
            leftPanel = wx.Panel(TLRsplitter)
            rightPanel = wx.Panel(TLRsplitter)
            topPanel.SetBackgroundColour('YELLOW GREEN')
            bottomPanel.SetBackgroundColour('SLATE BLUE')
            leftPanel.SetBackgroundColour('SEA GREEN')
            rightPanel.SetBackgroundColour('STEEL BLUE')
            
            TLRsplitter.SplitVertically(leftPanel, rightPanel) 
            PanelSizer = wx.BoxSizer(wx.VERTICAL)
            PanelSizer.Add(TLRsplitter, 1, wx.EXPAND | wx.ALL)
            topPanel.SetSizer(PanelSizer)
            
            TBsplitter.SplitHorizontally(topPanel, bottomPanel)
            PanelSizer = wx.BoxSizer(wx.VERTICAL)
            PanelSizer.Add(TBsplitter, 1, wx.EXPAND | wx.ALL)
            self.SetSizer(PanelSizer)
            self.panel = leftPanel
            self.outPanel = BottomPanel 

        self.Vsplitter = splitter

#output
        notebookLog = wx.Notebook(self.outPanel)
        
        pt = wx.Panel(notebookLog)
        #ot = wx.TextCtrl(self.outPanel, -1, "Welcome!\n", style=wx.TE_MULTILINE|wx.TE_RICH2)
        ot = wx.TextCtrl(pt, -1, "Welcome!\n", style = wx.TE_MULTILINE | wx.TE_READONLY | wx.HSCROLL)
        #wx.Log.SetActiveTarget(wx.LogTextCtrl(ot))
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(ot, 1, wx.ALL|wx.EXPAND, 5)
        pt.SetSizer(sizer)
        notebookLog.AddPage(pt, 'Message')
        self.output = ot
        
#Log
        pt = wx.Panel(notebookLog)
        ot = wx.ListCtrl(pt, style = wx.LC_REPORT )
        columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M']
        for i in range(len(columns)):
            ot.InsertColumn(i, columns[i])
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(ot, 1, wx.ALL|wx.EXPAND, 5)
        pt.SetSizer(sizer)
        notebookLog.AddPage(pt, 'Log')
        self.outList = ot
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(notebookLog, 1, wx.ALL|wx.EXPAND, 5)
        self.outPanel.SetSizer(sizer)
        self.maxLogNumber = 1000
        self.clearLogNumber = 100
        self.curLogNumber = 0
        
#status
        self.statusBar = self.CreateStatusBar()


#menu
        menuFolder = 'Menus'
        files = util.listFile(menuFolder)
        for filename in files:
            name = util.dir2module(filename)
            if (name != None):
#                try:
                    dyn = dynLoad(menuFolder + '.' + name, ['*'])
                    ins = dyn.getClassInstance('menuFrame', self)
                    if ins.menuName == None:
                        ins.menuName = name
                    self.menuBar.Append(ins, ins.menuName)
#                except:
#                    print 'Menu(' + name + ') error.'

        menuHelp = wx.Menu()
        g = globals.getInstance()
        menuHelp.Append(-1, g.version)
        self.menuBar.Append(menuHelp, 'Help')
        
#tab
        self.tabFrames = {}
        tabId = 0
        notebook = wx.Notebook(self.panel)
        tabFolder = 'Tabs'
        files = util.listFile(tabFolder)
        
        for filename in files:
            name = util.dir2module(filename)
            if (name != None):
#                try:
                dyn = dynLoad(tabFolder+'.'+name,['*'])
                ins = dyn.getClassInstance('tabFrame', notebook, self)
                ins.performConfig()
                #ins.performCreate()
                if ins.tabName == None:
                    ins.tabName = name
                notebook.AddPage(ins, ins.tabName)
                self.tabFrames[ins.tabName] = [ tabId, ins ]
                tabId = tabId + 1
#               except Exception as e:
#                   ins.Destroy()
#                   print 'Tab(' + name + ') error.'
#                   print e
        notebook.GetPage(0).performCreateIfNeed()
        notebook.GetPage(0).performResume(None)
        notebook.SetSelection(0)
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(notebook, 1, wx.ALL|wx.EXPAND, 5)
        self.panel.SetSizer(sizer)
        notebook.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED, self.onNotebookPageChange, notebook)
        
        self.notebook = notebook
        
        self.Bind(wx.EVT_CLOSE, self.onCloseWindow)  
        
        self.EVENT_CUSTOMER = wx.NewEventType()
        EVT_CUSTOMER = wx.PyEventBinder(self.EVENT_CUSTOMER, 1)
        self.Bind(EVT_CUSTOMER, self.onCustomerEvent, self.panel)
        
        
        self.panel.Layout()
        self.panel.Refresh()
        self.Layout()
        self.Refresh()
        self.Show()