def __init__(self, tab, name, pos = (0, 0)): g = globals.getInstance() self.__WIDGET_H = g.uiWidgetHeight self.__WIDGET_W = g.uiWidgetWidth self.__TEXT_H = g.uiTextHeight self.__TEXT_W = g.uiTextWidth Basic.Panel.panel.__init__(self, tab.frame, tab, (pos[0], pos[1]+1)) self.__moduleName = name self.width = None self.height = None self.onCreate() if self.width == None: self.width = self.maxWidth if self.height == None: self.height = self.maxHeight x = pos[0] * self.__TEXT_W - self.__WIDGET_W y = pos[1] * self.__TEXT_H + self.__WIDGET_H w = self.width + self.__WIDGET_W - x h = self.height + self.__WIDGET_H * 2 - y wx.StaticBox(self.panel, -1, self.__moduleName, pos=(x, y), size=(w, h)) tab.getMaxPosition(x, y, w, h)
def __init__(self, parent, frame): wx.ScrolledWindow.__init__(self, parent = parent, style=wx.SUNKEN_BORDER) Basic.Panel.panel.__init__(self, frame) self.tabName = None self.frameHeight = None self.isCreated = False g = globals.getInstance() self.__WIDGET_H = g.uiWidgetHeight self.__WIDGET_W = g.uiWidgetWidth self.__TEXT_H = g.uiTextHeight self.__TEXT_W = g.uiTextWidth
def __init__(self, frame, panel = None , pos = None): g = globals.getInstance() self.__WIDGET_H = g.uiWidgetHeight self.__WIDGET_W = g.uiWidgetWidth self.__TEXT_H = g.uiTextHeight self.__TEXT_W = g.uiTextWidth self.frame = frame self.output = frame.output self.status = frame.statusBar if panel == None: self.panel = self self.offset_x = 0 self.offset_y = 0 else: self.panel = panel self.offset_x = pos[0] self.offset_y = pos[1] self.__CURRENT_X = 0 self.__CURRENT_Y = 0 self.maxWidth = 0 self.maxHeight = 0 self.cfg_sel = "TAB_" + self.__class__.__name__ if not self.frame.config.has_section(self.cfg_sel): self.frame.config.add_section(self.cfg_sel) self.frame.config.write(open(self.frame.cfg_name, "w")) #self.Bind(wx.EVT_LEFT_DOWN, self.__onMouseLeftDown) self.__leftClickZone = [] self.enableWidgetCbk = {}
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()