def __init__(self,size=(800,600),pos=(0,0)): """Constructs the GUI. The GUI has a central canvas for drawing, a menubar and a toolbar on top, and a statusbar at the bottom. """ self.main = QtGui.QMainWindow() self.main.setWindowTitle(GD.Version) # add widgets to the main window self.statusbar = self.main.statusBar() self.curfile = QtGui.QLabel('No File') self.curfile.setLineWidth(0) self.statusbar.addWidget(self.curfile) self.smiley = QtGui.QLabel() self.statusbar.addWidget(self.smiley) self.menu = self.main.menuBar() self.toolbar = self.main.addToolBar('Top ToolBar') self.editor = None # Create a box for the central widget self.box = QtGui.QWidget() self.boxlayout = QtGui.QVBoxLayout() self.box.setLayout(self.boxlayout) self.main.setCentralWidget(self.box) #self.box.setFrameStyle(qt.QFrame.Sunken | qt.QFrame.Panel) #self.box.setLineWidth(2) # Create a splitter s = QtGui.QSplitter() s.setOrientation(QtCore.Qt.Vertical) s.show() #s.moveSplitter(300,0) #s.moveSplitter(300,1) #s.setLineWidth(0) # Create an OpenGL canvas with a nice frame around it fmt = QtOpenGL.QGLFormat.defaultFormat() if GD.options.dri: fmt.setDirectRendering(True) if GD.options.nodri: fmt.setDirectRendering(False) #fmt.setRgba(False) if GD.options.debug: printFormat(fmt) QtOpenGL.QGLFormat.setDefaultFormat(fmt) c = QtCanvas() c.setBgColor(GD.cfg['draw/bgcolor']) c.resize(*GD.cfg['gui/size']) ## if GD.options.splash: ## c.addDecoration(decorations.TextActor(_start_message,wd/2,ht/2,font='tr24',adjust='center',color='red')) self.canvas = c # Create the message board self.board = Board() self.board.setPlainText(GD.Version+' started') self.boxlayout.addWidget(s) s.addWidget(self.canvas) s.addWidget(self.board) self.box.setLayout(self.boxlayout) # Create the top menu and keep a dict with the main menu items menu.addMenuItems(self.menu, menu.MenuData) self.menus = dict([ [str(a.text()),a] for a in self.menu.actions()]) #print self.menus # ... and the toolbar self.actions = toolbar.addActionButtons(self.toolbar) self.toolbar.addSeparator() if GD.cfg['gui/camerabuttons']: toolbar.addCameraButtons(self.toolbar) # Create a menu with standard views # and insert it before the help menu self.viewsMenu = None if GD.cfg['gui/viewsmenu']: self.viewsMenu = views.ViewsMenu() self.menu.insertMenu(self.menus['&Help'],self.viewsMenu) # Install the default canvas views # defviews = self.canvas.views.keys() # NO, these are not sorted, better: defviews = [ 'front', 'back', 'top', 'bottom', 'left', 'right', 'iso' ] self.views = views.Views(defviews,self.viewsMenu,self.toolbar) # Create a menu with pyFormex examples # and insert it before the help menu self.examples = scriptsMenu.ScriptsMenu(GD.cfg['exampledir']) self.menu.insertMenu(self.menus['&Help'],self.examples) # Display the main menubar self.menu.show() self.resize(*size) self.moveto(pos[0],pos[1]) if GD.options.redirect: sys.stderr = self.board sys.stdout = self.board if GD.options.debug: printsize(self.main,'Main:') printsize(self.canvas,'Canvas:') printsize(self.board,'Board:')
def __init__(self,windowname,size=(800,600),pos=(0,0),bdsize=(0,0)): """Constructs the GUI. The GUI has a central canvas for drawing, a menubar and a toolbar on top, and a statusbar at the bottom. """ QtGui.QMainWindow.__init__(self) self.setWindowTitle(windowname) # add widgets to the main window self.statusbar = self.statusBar() self.curfile = QtGui.QLabel('No File') self.curfile.setLineWidth(0) self.statusbar.addWidget(self.curfile) self.smiley = QtGui.QLabel() self.statusbar.addWidget(self.smiley) self.menu = widgets.MenuBar() self.setMenuBar(self.menu) self.toolbar = self.addToolBar('Top ToolBar') self.editor = None # Create a box for the central widget self.box = QtGui.QWidget() self.setCentralWidget(self.box) self.boxlayout = QtGui.QVBoxLayout() self.box.setLayout(self.boxlayout) #self.box.setFrameStyle(qt.QFrame.Sunken | qt.QFrame.Panel) #self.box.setLineWidth(2) # Create a splitter self.splitter = QtGui.QSplitter() self.boxlayout.addWidget(self.splitter) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.show() #s.moveSplitter(300,0) #s.moveSplitter(300,1) #s.setLineWidth(0) # Create an OpenGL canvas with a nice frame around it viewport.setOpenglFormat() self.viewports = viewport.MultiCanvas() # and update the default settings self.viewports.setDefaults(GD.cfg['canvas']) # self.canvas is the complete central widget of the main window self.canvas = QtGui.QWidget() #self.canvas.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken) self.canvas.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,QtGui.QSizePolicy.MinimumExpanding) self.canvas.resize(*GD.cfg['gui/size']) self.canvas.setLayout(self.viewports) # Create the message board self.board = Board() #self.board.setPlainText(GD.Version+' started') # Put everything together self.splitter.addWidget(self.canvas) self.splitter.addWidget(self.board) #self.splitter.setSizes([(800,200),(800,600)]) self.box.setLayout(self.boxlayout) # Create the top menu menu.createMenuData() self.menu.insertItems(menu.MenuData) # ... and the toolbar self.actions = toolbar.addActionButtons(self.toolbar) if GD.cfg.get('gui/camerabuttons','True'): self.toolbar.addSeparator() toolbar.addCameraButtons(self.toolbar) self.menu.show() ## RENDER MODE menu and toolbar ## modes = [ 'wireframe', 'smooth', 'smoothwire', 'flat', 'flatwire' ] if GD.cfg['gui/modemenu']: mmenu = QtGui.QMenu('Render Mode') else: mmenu = None # we add a modebar depending on the config: # modebar = None: forget it # modebar = 'left', 'right', 'top' or 'bottom' : seperate toolbar # modebar = 'default' (or anything else): in the default top toolbar area = GD.cfg['gui/modebar'] if area: area = self.toolbarArea.get(area,None) if area: self.modebar = QtGui.QToolBar('Render Mode ToolBar',self) self.addToolBar(area,self.modebar) else: # default self.modebar = self.toolbar self.toolbar.addSeparator() else: self.modebar = None # OK, we know where the actions will go, so create them # Add the perspective button if self.modebar: toolbar.addPerspectiveButton(self.modebar) self.modebtns = widgets.ActionList( modes,draw.renderMode,menu=mmenu,toolbar=self.modebar) # Add the transparency button if self.modebar: toolbar.addTransparencyButton(self.modebar) if mmenu: # insert the mode menu in the viewport menu pmenu = self.menu.item('viewport') pmenu.insertMenu(pmenu.item('background color'),mmenu) ## VIEWS menu and toolbar self.viewsMenu = None if GD.cfg.get('gui/viewmenu',True): self.viewsMenu = widgets.Menu('&Views',parent=self.menu,before='help') views = GD.cfg['gui/builtinviews'] area = GD.cfg['gui/viewbar'] if area: area = self.toolbarArea.get(area,None) if area: self.viewbar = QtGui.QToolBar('Views ToolBar',self) self.addToolBar(area,self.viewbar) else: # default self.viewbar = self.toolbar self.toolbar.addSeparator() else: self.viewbar = None self.viewbtns = widgets.ActionList( views,draw.view, menu=self.viewsMenu, toolbar=self.viewbar, icons=['%sview' % t for t in views] ) # Display the main menubar #self.menu.show() self.resize(*size) self.move(*pos) self.board.resize(*bdsize) self.setcurfile() if GD.options.redirect: sys.stderr = self.board sys.stdout = self.board if GD.options.debug: printsize(self,'Main:') printsize(self.canvas,'Canvas:') printsize(self.board,'Board:')
def __init__(self,windowname,size=(800,600),pos=(0,0),bdsize=(0,0)): """Constructs the GUI. The GUI has a central canvas for drawing, a menubar and a toolbar on top, and a statusbar at the bottom. """ self.on_exit = [fileMenu.askCloseProject] QtGui.QMainWindow.__init__(self) self.setWindowTitle(windowname) # add widgets to the main window # The status bar self.statusbar = self.statusBar() self.curproj = widgets.ButtonBox('Project:',[('None',fileMenu.openProject)]) self.curfile = widgets.ButtonBox('Script:',[('None',fileMenu.openScript)]) self.curdir = widgets.ButtonBox('Cwd:',[('None',draw.askDirname)]) self.canPlay = False # The menu bar self.menu = menu.MenuBar('TopMenu') self.setMenuBar(self.menu) # The toolbar self.toolbar = self.addToolBar('Top ToolBar') self.editor = None # Create a box for the central widget self.box = QtGui.QWidget() self.setCentralWidget(self.box) self.boxlayout = QtGui.QVBoxLayout() self.box.setLayout(self.boxlayout) #self.box.setFrameStyle(qt.QFrame.Sunken | qt.QFrame.Panel) #self.box.setLineWidth(2) # Create a splitter self.splitter = QtGui.QSplitter() self.boxlayout.addWidget(self.splitter) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.show() # self.central is the complete central widget of the main window self.central = QtGui.QWidget() self.central.autoFillBackground() #self.central.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken) self.central.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,QtGui.QSizePolicy.MinimumExpanding) self.central.resize(*pf.cfg['gui/size']) self.viewports = viewport.MultiCanvas(parent=self.central) self.central.setLayout(self.viewports) # Create the message board self.board = Board() #self.board.setPlainText(pf.Version+' started') # Put everything together self.splitter.addWidget(self.central) self.splitter.addWidget(self.board) #self.splitter.setSizes([(800,200),(800,600)]) self.box.setLayout(self.boxlayout) # Create the top menu menudata = menu.createMenuData() self.menu.insertItems(menudata) # ... and the toolbar self.actions = toolbar.addActionButtons(self.toolbar) # timeout button toolbar.addTimeoutButton(self.toolbar) self.menu.show() # Define Toolbars self.camerabar = self.updateToolBar('camerabar','Camera ToolBar') self.modebar = self.updateToolBar('modebar','RenderMode ToolBar') self.viewbar = self.updateToolBar('viewbar','Views ToolBar') self.toolbars = [self.camerabar, self.modebar, self.viewbar] ############### CAMERA menu and toolbar ############# if self.camerabar: toolbar.addCameraButtons(self.camerabar) toolbar.addPerspectiveButton(self.camerabar) ############### RENDERMODE menu and toolbar ############# modes = [ 'wireframe', 'smooth', 'smoothwire', 'flat', 'flatwire' ] if pf.cfg['gui/modemenu']: mmenu = QtGui.QMenu('Render Mode') else: mmenu = None #menutext = '&' + name.capitalize() self.modebtns = menu.ActionList( modes,guifunc.renderMode,menu=mmenu,toolbar=self.modebar) # Add the toggle type buttons if self.modebar: toolbar.addTransparencyButton(self.modebar) if self.modebar and pf.cfg['gui/lightbutton']: toolbar.addLightButton(self.modebar) if self.modebar and pf.cfg['gui/normalsbutton']: toolbar.addNormalsButton(self.modebar) if self.modebar and pf.cfg['gui/shrinkbutton']: toolbar.addShrinkButton(self.modebar) if mmenu: # insert the mode menu in the viewport menu pmenu = self.menu.item('viewport') pmenu.insertMenu(pmenu.item('background color'),mmenu) ############### VIEWS menu ################ if pf.cfg['gui/viewmenu']: if pf.cfg['gui/viewmenu'] == 'main': parent = self.menu before = 'help' else: parent = self.menu.item('camera') before = parent.item('---') self.viewsMenu = menu.Menu('&Views',parent=parent,before=before) else: self.viewsMenu = None defviews = pf.cfg['gui/defviews'] views = [ v[0] for v in defviews ] viewicons = [ v[1] for v in defviews ] self.viewbtns = menu.ActionList( views,self.setView, menu=self.viewsMenu, toolbar=self.viewbar, icons = viewicons ) # Restore previous pos/size self.resize(*size) self.move(*pos) self.board.resize(*bdsize) self.setcurfile() self.setcurdir() if pf.options.redirect: sys.stderr = self.board sys.stdout = self.board if pf.options.debug: printsize(self,'DEBUG: Main:') printsize(self.central,'DEBUG: Canvas:') printsize(self.board,'DEBUG: Board:') # Drawing lock self.drawwait = pf.cfg['draw/wait'] self.drawlock = drawlock.DrawLock()
def __init__(self,windowname,size=(800,600),pos=(0,0),bdsize=(0,0)): """Constructs the GUI. The GUI has a central canvas for drawing, a menubar and a toolbar on top, and a statusbar at the bottom. """ QtGui.QMainWindow.__init__(self) self.setWindowTitle(windowname) # add widgets to the main window self.statusbar = self.statusBar() self.curfile = QtGui.QLabel('No File') self.curfile.setLineWidth(0) self.statusbar.addWidget(self.curfile) self.smiley = QtGui.QLabel() self.statusbar.addWidget(self.smiley) self.menu = widgets.MenuBar() self.setMenuBar(self.menu) self.toolbar = self.addToolBar('Top ToolBar') self.editor = None # Create a box for the central widget self.box = QtGui.QWidget() self.setCentralWidget(self.box) self.boxlayout = QtGui.QVBoxLayout() self.box.setLayout(self.boxlayout) #self.box.setFrameStyle(qt.QFrame.Sunken | qt.QFrame.Panel) #self.box.setLineWidth(2) # Create a splitter self.splitter = QtGui.QSplitter() self.boxlayout.addWidget(self.splitter) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.show() #s.moveSplitter(300,0) #s.moveSplitter(300,1) #s.setLineWidth(0) # Create an OpenGL canvas with a nice frame around it fmt = QtOpenGL.QGLFormat.defaultFormat() if GD.options.dri: fmt.setDirectRendering(True) if GD.options.nodri: fmt.setDirectRendering(False) #fmt.setRgba(False) if GD.options.debug: printFormat(fmt) QtOpenGL.QGLFormat.setDefaultFormat(fmt) self.viewports = MultiCanvas() self.canvas = QtGui.QWidget() #self.canvas.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken) self.canvas.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,QtGui.QSizePolicy.MinimumExpanding) self.canvas.resize(*GD.cfg['gui/size']) self.canvas.setLayout(self.viewports) # Create the message board self.board = Board() #self.board.setPlainText(GD.Version+' started') # Put everything together self.splitter.addWidget(self.canvas) self.splitter.addWidget(self.board) #self.splitter.setSizes([(800,200),(800,600)]) self.box.setLayout(self.boxlayout) # Create the top menu and keep a dict with the main menu items if GD.options.multiview: print "Activating the multiview feature" menu.insertViewportMenu() self.menu.addItems(menu.MenuData) #widgets.addMenuItems(self.menu, menu.MenuData) #self.menus = dict([ [str(a.text()),a] for a in self.menu.actions()]) # ... and the toolbar self.actions = toolbar.addActionButtons(self.toolbar) self.toolbar.addSeparator() if GD.cfg.get('gui/camerabuttons','True'): toolbar.addCameraButtons(self.toolbar) self.menu.show() # Create a menu with standard views # and insert it before the help menu self.viewsMenu = None if GD.cfg.get('gui/viewsmenu',True): self.viewsMenu = QtGui.QMenu('&Views') self.menu.insertMenu(self.viewsMenu) # Install the default canvas views # defviews = self.canvas.views.keys() # NO, these are not sorted, better: defviews = [ 'front', 'back', 'top', 'bottom', 'left', 'right', 'iso' ] if GD.cfg['gui/viewsbar']: tbar = self.toolbar tbar.addSeparator() else: tbar = None self.viewbtns = actionlist.ActionList( defviews,draw.view, menu=self.viewsMenu, toolbar=tbar, iconpath=os.path.join(GD.cfg['icondir'],'%sview')+GD.cfg['gui/icontype']) # Display the main menubar #self.menu.show() self.resize(*size) self.move(*pos) self.board.resize(*bdsize) if GD.options.redirect: sys.stderr = self.board sys.stdout = self.board if GD.options.debug: printsize(self,'Main:') printsize(self.canvas,'Canvas:') printsize(self.board,'Board:')
def __init__(self,windowname,size=(800,600),pos=(0,0),bdsize=(0,0)): """Constructs the GUI. The GUI has a central canvas for drawing, a menubar and a toolbar on top, and a statusbar at the bottom. """ QtGui.QMainWindow.__init__(self) self.setWindowTitle(windowname) # add widgets to the main window # The status bar self.statusbar = self.statusBar() self.curproj = widgets.ButtonBox('Project:',['None'],[fileMenu.openProject]) self.curfile = widgets.ButtonBox('Script:',['None'],[fileMenu.openScript]) self.canPlay = False #cf = QtGui.QWidget() #hl = QtGui.QHBoxLayout() #hl.setSpacing(0) #hl.setMargin(0) #cf.setLayout(hl) #self.curfile = QtGui.QLabel('No File') #self.curfile.setLineWidth(0) #self.smiley = QtGui.QLabel() #hl.addWidget(self.smiley) #hl.addWidget(self.curfile) #self.statusbar.addWidget(cf) # The menu bar self.menu = widgets.MenuBar() self.setMenuBar(self.menu) # The toolbar self.toolbar = self.addToolBar('Top ToolBar') self.editor = None # Create a box for the central widget self.box = QtGui.QWidget() self.setCentralWidget(self.box) self.boxlayout = QtGui.QVBoxLayout() self.box.setLayout(self.boxlayout) #self.box.setFrameStyle(qt.QFrame.Sunken | qt.QFrame.Panel) #self.box.setLineWidth(2) # Create a splitter self.splitter = QtGui.QSplitter() self.boxlayout.addWidget(self.splitter) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.show() #### Do not touch the next line unless you know what you're doing !! self.easter_egg = None #s.moveSplitter(300,0) #s.moveSplitter(300,1) #s.setLineWidth(0) # self.central is the complete central widget of the main window self.central = QtGui.QWidget() self.central.autoFillBackground() #self.central.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken) self.central.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,QtGui.QSizePolicy.MinimumExpanding) self.central.resize(*GD.cfg['gui/size']) # Create an OpenGL canvas with a nice frame around it self.viewports = viewport.MultiCanvas() self.viewports.setDefaults(GD.cfg['canvas']) self.central.setLayout(self.viewports) # Create the message board self.board = Board() #self.board.setPlainText(GD.Version+' started') # Put everything together self.splitter.addWidget(self.central) self.splitter.addWidget(self.board) #self.splitter.setSizes([(800,200),(800,600)]) self.box.setLayout(self.boxlayout) # Create the top menu menu.createMenuData() self.menu.insertItems(menu.MenuData) # ... and the toolbar self.actions = toolbar.addActionButtons(self.toolbar) # timeout button if GD.cfg.get('gui/timeoutbutton',False): toolbar.addTimeoutButton(self.toolbar) # camera buttons if GD.cfg.get('gui/camerabuttons',True): self.toolbar.addSeparator() toolbar.addCameraButtons(self.toolbar) self.menu.show() ## RENDER MODE menu and toolbar ## modes = [ 'wireframe', 'smooth', 'smoothwire', 'flat', 'flatwire' ] if GD.cfg['gui/modemenu']: mmenu = QtGui.QMenu('Render Mode') else: mmenu = None # we add a modebar depending on the config: # modebar = None: forget it # modebar = 'left', 'right', 'top' or 'bottom' : separate toolbar # modebar = 'default' (or anything else): in the default top toolbar area = GD.cfg['gui/modebar'] if area: area = self.toolbarArea.get(area,None) if area: self.modebar = QtGui.QToolBar('Render Mode ToolBar',self) self.addToolBar(area,self.modebar) else: # default self.modebar = self.toolbar self.toolbar.addSeparator() else: self.modebar = None # OK, we know where the actions will go, so create them # Add the perspective button if self.modebar: toolbar.addPerspectiveButton(self.modebar) self.modebtns = widgets.ActionList( modes,draw.renderMode,menu=mmenu,toolbar=self.modebar) # Add the transparency button if self.modebar: toolbar.addTransparencyButton(self.modebar) # Add the lights button if self.modebar and GD.cfg.get('gui/lightbutton',False): toolbar.addLightButton(self.modebar) # Add the normals button if self.modebar and GD.cfg.get('gui/normalsbutton',False): toolbar.addNormalsButton(self.modebar) # Add the shrink button if self.modebar and GD.cfg.get('gui/shrinkbutton',False): toolbar.addShrinkButton(self.modebar) if mmenu: # insert the mode menu in the viewport menu pmenu = self.menu.item('viewport') pmenu.insertMenu(pmenu.item('background color'),mmenu) ## VIEWS menu and toolbar self.viewsMenu = None if GD.cfg.get('gui/viewmenu',True): self.viewsMenu = widgets.Menu('&Views',parent=self.menu,before='help') defviews = GD.cfg['gui/defviews'] views = [ v[0] for v in defviews ] viewicons = [ v[1] for v in defviews ] area = GD.cfg['gui/viewbar'] if area: area = self.toolbarArea.get(area,None) if area: self.viewbar = QtGui.QToolBar('Views ToolBar',self) self.addToolBar(area,self.viewbar) else: # default self.viewbar = self.toolbar self.toolbar.addSeparator() else: self.viewbar = None self.viewbtns = widgets.ActionList( views,draw.view, menu=self.viewsMenu, toolbar=self.viewbar, icons = viewicons ) # Restore previous pos/size self.resize(*size) self.move(*pos) self.board.resize(*bdsize) self.setcurfile() if GD.options.redirect: sys.stderr = self.board sys.stdout = self.board if GD.options.debug: printsize(self,'DEBUG: Main:') printsize(self.central,'DEBUG: Canvas:') printsize(self.board,'DEBUG: Board:') # Drawing lock self.drawwait = GD.cfg['draw/wait'] self.drawlock = drawlock.DrawLock()
def __init__(self,windowname,size=(800,600),pos=(0,0),bdsize=(0,0)): """Constructs the GUI. The GUI has a central canvas for drawing, a menubar and a toolbar on top, and a statusbar at the bottom. """ pf.debug('Creating Main Window',pf.DEBUG.GUI) self.on_exit = [] QtGui.QMainWindow.__init__(self) self.fullscreen = False self.setWindowTitle(windowname) # add widgets to the main window # The status bar pf.debug('Creating Status Bar',pf.DEBUG.GUI) self.statusbar = self.statusBar() #self.statusbar.setSizePolicy(QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Minimum) #self.statusbar.setFixedHeight(32) #self.statusbar.setContentsMargins(0,0,0,0) #widgets.addEffect(self.statusbar,color=(255,0,0)) self.curproj = widgets.ButtonBox('Project:',[('None',fileMenu.openExistingProject)]) self.curfile = widgets.ButtonBox('',[('Script:',toggleAppScript),('None',fileMenu.openScript)]) self.curdir = widgets.ButtonBox('Cwd:',[('None',draw.askDirname)]) self.canPlay = False self.canEdit = False # The menu bar pf.debug('Creating Menu Bar',pf.DEBUG.GUI) self.menu = menu.MenuBar('TopMenu') self.setMenuBar(self.menu) # The toolbar pf.debug('Creating ToolBar',pf.DEBUG.GUI) self.toolbar = self.addToolBar('Top ToolBar') self.editor = None # Create a box for the central widget self.box = QtGui.QWidget() self.setCentralWidget(self.box) self.boxlayout = QtGui.QVBoxLayout() self.boxlayout.setContentsMargins(*pf.cfg['gui/boxmargins']) self.box.setLayout(self.boxlayout) #self.box.setFrameStyle(qt.QFrame.Sunken | qt.QFrame.Panel) #self.box.setLineWidth(2) # Create a splitter self.splitter = QtGui.QSplitter() self.boxlayout.addWidget(self.splitter) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.show() # self.central is the central widget of the main window # self.viewports is its layout, containing multiple viewports pf.debug('Creating Central Widget',pf.DEBUG.GUI) self.central = QtGui.QWidget() self.central.autoFillBackground() #self.central.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Sunken) self.central.setSizePolicy(QtGui.QSizePolicy.MinimumExpanding,QtGui.QSizePolicy.MinimumExpanding) self.central.resize(*pf.cfg['gui/size']) self.viewports = viewport.MultiCanvas(parent=self.central) self.centralgrid = QtGui.QGridLayout() self.centralgrid.addLayout(self.viewports,0,0) self.central.setLayout(self.centralgrid) # Create the message board self.board = Board() #self.board.setPlainText(pf.Version+' started') # Put everything together self.splitter.addWidget(self.central) self.splitter.addWidget(self.board) #self.splitter.setSizes([(800,200),(800,600)]) self.box.setLayout(self.boxlayout) # Create the top menu pf.debug('Creating Menus',pf.DEBUG.GUI) menudata = menu.createMenuData() self.menu.insertItems(menudata) # ... and the toolbar self.actions = toolbar.addActionButtons(self.toolbar) # timeout button toolbar.addTimeoutButton(self.toolbar) self.menu.show() # Define Toolbars pf.debug('Creating Toolbars',pf.DEBUG.GUI) self.camerabar = self.updateToolBar('camerabar','Camera ToolBar') self.modebar = self.updateToolBar('modebar','RenderMode ToolBar') self.viewbar = self.updateToolBar('viewbar','Views ToolBar') self.toolbars = [self.camerabar, self.modebar, self.viewbar] ############### CAMERA menu and toolbar ############# if self.camerabar: toolbar.addCameraButtons(self.camerabar) toolbar.addPerspectiveButton(self.camerabar) ############### RENDERMODE menu and toolbar ############# modes = [ 'wireframe', 'smooth', 'smoothwire', 'flat', 'flatwire' ] if pf.cfg['gui/modemenu']: mmenu = QtGui.QMenu('Render Mode') else: mmenu = None #menutext = '&' + name.capitalize() self.modebtns = menu.ActionList( modes,guifunc.renderMode,menu=mmenu,toolbar=self.modebar) # Add the toggle type buttons if self.modebar: toolbar.addTransparencyButton(self.modebar) if self.modebar and pf.cfg['gui/lightbutton']: toolbar.addLightButton(self.modebar) if self.modebar and pf.cfg['gui/normalsbutton']: toolbar.addNormalsButton(self.modebar) if self.modebar and pf.cfg['gui/shrinkbutton']: toolbar.addShrinkButton(self.modebar) if mmenu: # insert the mode menu in the viewport menu pmenu = self.menu.item('viewport') pmenu.insertMenu(pmenu.item('background color'),mmenu) ############### VIEWS menu ################ if pf.cfg['gui/viewmenu']: if pf.cfg['gui/viewmenu'] == 'main': parent = self.menu before = 'help' else: parent = self.menu.item('camera') before = parent.item('---') self.viewsMenu = menu.Menu('&Views',parent=parent,before=before) else: self.viewsMenu = None defviews = pf.cfg['gui/defviews'] views = [ v[0] for v in defviews ] viewicons = [ v[1] for v in defviews ] self.viewbtns = menu.ActionList( views,self.setView, menu=self.viewsMenu, toolbar=self.viewbar, icons = viewicons ) ## TESTING SAVE CURRENT VIEW ## self.saved_views = {} self.saved_views_name = utils.NameSequence('View') if self.viewsMenu: name = self.saved_views_name.next() self.menu.item('camera').addAction('Save View',self.saveView) # Restore previous pos/size pf.debug('Restore size/pos',pf.DEBUG.GUI) self.resize(*size) self.move(*pos) self.board.resize(*bdsize) pf.debug('Set Curdir',pf.DEBUG.GUI) self.setcurdir() # redirect standard/error output if option set # # TODO: we should redirect it to a buffer and # wait until GUI shown, then show in board # else show on stdout/err #self.board.redirect(pf.cfg['gui/redirect']) if pf.options.debuglevel: s = sizeReport(self,'DEBUG: Main:') + \ sizeReport(self.central,'DEBUG: Canvas:') + \ sizeReport(self.board,'DEBUG: Board:') pf.debug(s,pf.DEBUG.GUI) # Drawing lock self.drawwait = pf.cfg['draw/wait'] self.drawlock = drawlock.DrawLock() # Materials and Lights database self.materials = canvas.createMaterials() ## for m in self.materials: ## print self.materials[m] # Modeless child dialogs self.doc_dialog = None pf.debug('Done initializing GUI',pf.DEBUG.GUI) # Set up signal/slot connections self.signals = signals.Signals() self.signals.FULLSCREEN.connect(self.fullScreen) # Set up hot keys: hitting the key will emit the corresponding signal self.hotkey = { QtCore.Qt.Key_F2: self.signals.SAVE, QtCore.Qt.Key_F5: self.signals.FULLSCREEN, }