def _createGUI(self): # initiaslise CEGUI Renderer self.guiRenderer = cegui.OgreCEGUIRenderer(self.renderWindow,ogre.RENDER_QUEUE_OVERLAY, False, self.sceneManager) self.system = cegui.System(self.guiRenderer) cegui.Logger.getSingleton().loggingLevel = cegui.Insane # load WindowsLook Cegui Scheme cegui.SchemeManager.getSingleton().loadScheme("WindowsLookSkin.scheme") self.system.defaultMouseCursor=("WindowsLook", "MouseArrow") cegui.FontManager.getSingleton().createFont("Iconified-12.font") # load layout sheet = cegui.WindowManager.getSingleton().createWindow("DefaultWindow", "root_wnd") self.system.guiSheet = sheet # control colours blue = cegui.colour(0.0, 0.0, 1.0, 0.5) red = cegui.colour(1.0, 0.0, 0.0, 0.5) green = cegui.colour(0.0, 1.0, 0.0, 1.0) blue_back = cegui.colour(0.0, 0.0, 1.0, 1.0) red_back = cegui.colour(1.0, 0.0, 0.0, 1.0) # Tab Control tabControl= CreateControl("WindowsLook/TabControl" , "TabControl" ,sheet ,[0.40,0.50],[0.55,0.40],[0.01,0.01],[1.0,1.0],"a TabControl") tabControl.tabHeight=0.15 page1= CreateControl("WindowsLook/TabPane" , "Page1" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Radio Button") page2= CreateControl("WindowsLook/TabPane" , "Page2" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Combo Box") page3= CreateControl("WindowsLook/TabPane" , "Page3" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"List Box") page4= CreateControl("WindowsLook/TabPane" , "Page4" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Static") page5= CreateControl("WindowsLook/TabPane" , "Page5" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Spinner") page6= CreateControl("WindowsLook/TabPane" , "Page6" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"ScrolledPane") # Page 1 button = CreateControl("WindowsLook/RadioButton" , "Button1",page1 ,[0.10,0.20],[0.30,0.10],[0.01,0.01],[1.0,1.0],"Option1") button.groupID=1 button = CreateControl("WindowsLook/RadioButton" , "Button2",page1 ,[0.10,0.30],[0.30,0.10],[0.01,0.01],[1.0,1.0],"Option2") button.groupID=1 button.selected = True # Page 2 combobox=CreateControl("WindowsLook/Combobox" , "A Combo Box" ,page2 ,[0.05,0.15],[0.8,0.5],[0.01,0.01],[1.0,1.0],"a Combo Box") # Page 3 List Box CreateControl("WindowsLook/StaticText" , "List label" ,page3 ,[0.05,0.05],[0.80,0.15],[0.01,0.01],[1.0,1.0],"Editless ListBox",0) listbox = CreateControl("WindowsLook/Listbox", "a List Box" ,page3 ,[0.05,0.20],[0.80,0.70],[0.01,0.01],[1.0,1.0],"ListBox",1) # Page 5, cant use createcontrol text is numeric CreateControl("WindowsLook/StaticText" , "Label2s" ,page5 ,[0.10,0.10],[0.40,0.15],[0.01,0.01],[1.0,1.0],"Float Pt") spinner = cegui.WindowManager.getSingleton().createWindow("WindowsLook/Spinner", "Test2") page5.addChildWindow(spinner) spinner.position = cegui.Point(0.5,0.1) spinner.size = cegui.Size(0.20,0.15) # ---------------------- Events Test Change Tab ------------------------ page1.id = 1 page2.id = 3 page3.id = 5 page4.id = 7 page5.id = 9 page6.id = 11 self.ec1= tabControl.subscribeEvent(tabControl.EventSelectionChanged, onTabSelection) # Set Tab Selection by Index OK tabControl.selectedTabIndex =2 #OK # Set Tab Selection by ID, Name OK tabControl.setSelectedTab("Page6") # OK tabControl.setSelectedTab(9) # OK win = tabControl.getTabContents(9) # OK print win.name #win = tabControl.getTabContents("Page6") # OK print win.name
def _createGUI(self): # initiaslise CEGUI Renderer self.guiRenderer = cegui.OgreCEGUIRenderer(self.renderWindow,ogre.RENDER_QUEUE_OVERLAY, False, self.sceneManager) self.system = cegui.System(self.guiRenderer) cegui.Logger.getSingleton().loggingLevel = cegui.Insane # load Cegui WindowsLook Skin Scheme cegui.SchemeManager.getSingleton().loadScheme("WindowsLookSkin.scheme") self.system.defaultMouseCursor=("WindowsLook", "MouseArrow") # load an image to use as a background cegui.ImagesetManager.getSingleton().createImagesetFromImageFile("BackgroundImage", "GPN-2000-001437.tga") # here we will use a StaticImage as the root and use it to place a background image background = cegui.WindowManager.getSingleton().createWindow("WindowsLook/StaticImage", "BackgroundImage") # set area rectangle background.rect=(cegui.Relative, cegui.Rect(0, 0, 1, 1)) background.setFormatting(background.HorzStretched,background.VertStretched) background.frameEnabled =False # disable frame and standard background background.backgroundEnabled=False # set the background image background.image=("BackgroundImage", "full_image") # install this as the root GUI sheet cegui.System.getSingleton().guiSheet=background cegui.FontManager.getSingleton().createFont("Iconified-12.font") # load some demo windows and attach to the background 'root' background.addChildWindow(cegui.WindowManager.getSingleton().loadWindowLayout("WindowsLookBackground.layout")) background.activate() # load ogre tga textures in listbox red = cegui.colour(1.0, 0.0, 0.0, 0.5) listbox = cegui.WindowManager.getSingleton().getWindow("Demo7/Window2/Listbox") imageList = ogre.ResourceGroupManager.getSingleton().findResourceNames("General", "*.png") iterator = imageList.get() images = [ iterator.__getitem__(j) for j in range(iterator.size()) ] black = cegui.colour(0.0, 0.0, 0.0, 1.0) for i, v in enumerate(images): item = cegui.ListboxTextItem(v,i) self.img.append(item) item.selectionColours=red item.textColours=black item.selectionBrushImage=("WindowsLook", "Background") listbox.addItem(item) # set image viewer characteristics frame = cegui.WindowManager.getSingleton().getWindow("Demo/ImageViewer") frame.alpha = 0.8 staticimage = cegui.WindowManager.getSingleton().getWindow("Demo/ImageViewer/area2") staticimage.frameColours=(cegui.colour(0.0, 1.0, 0.0, 1.0)) staticimage.frameEnabled = True # set image list frame characteristics frame = cegui.WindowManager.getSingleton().getWindow("Demo/NewNode") frame.alpha = 0.8 # set image viewer characteristics cegui.ImagesetManager.getSingleton().createImagesetFromImageFile("BackgroundImage2", "GPN-2000-001437.tga") staticimage.image=("BackgroundImage2", "full_image") # suscribe show image event addButton = cegui.WindowManager.getSingleton().getWindow("Demo/NewNode/Okay") addButton.alpha = 0.5 self.ec = addButton.subscribeEvent(str(addButton.EventClicked), onShowImage)
def _createGUI(self): # Initiaslise CEGUI Renderer #self.guiRenderer = cegui.OgreCEGUIRenderer(self.renderWindow) self.guiRenderer = cegui.OgreCEGUIRenderer(self.renderWindow,ogre.RENDER_QUEUE_OVERLAY, False, self.sceneManager) self.system = cegui.System(self.guiRenderer) cegui.Logger.getSingleton().loggingLevel = cegui.Insane # Load Cegui Scheme cegui.SchemeManager.getSingleton().loadScheme("TaharezLookSkin.scheme") self.system.defaultMouseCursor = ("TaharezLook", "MouseArrow") cegui.FontManager.getSingleton().createFont("Iconified-12.font") # Load Default CEGUI Window sheet = cegui.WindowManager.getSingleton().createWindow("DefaultWindow", "root_wnd") self.system.guiSheet = sheet # Control Colours blue = cegui.colour(0.0, 0.0, 1.0, 0.5) red = cegui.colour(1.0, 0.0, 0.0, 0.5) green = cegui.colour(0.0, 1.0, 0.0, 1.0) blue_back = cegui.colour(0.0, 0.0, 1.0, 1.0) red_back = cegui.colour(1.0, 0.0, 0.0, 1.0) #Create Control # ----------------- # type,name,parent,pos[x,y],size[x,y],min[x,y],max[x,y],text,border=0 # ----------------- # Push Buttons / Labels quitButton = CreateControl("TaharezLook/Button" , "QuitButton" ,sheet ,[0.85,0.05],[0.1,0.036],[0.01,0.01],[1.0,1.0],"Quit") printButton = CreateControl("TaharezLook/Button" , "PrintButton" ,sheet ,[0.75 ,0.05],[0.1,0.036],[0.01,0.01],[1.0,1.0],"Print") CreateControl("TaharezLook/StaticText" , "Multi label" ,sheet ,[0.45,0.10],[0.45,0.05],[0.01,0.01],[1.0,1.0],"MultiLineEditBox") # ProgressBar CreateControl("TaharezLook/ProgressBar", "a Progress Bar" ,sheet ,[0.1,0.95],[0.60,0.02],[0.01,0.01],[1.0,1.0],"ProgressBar",0).step = 0.05 # Multi Line Edit Box editBox = CreateControl("TaharezLook/MultiLineEditbox", "an edit control",sheet,[0.45,0.15],[0.45,0.35],[0.01,0.01],[1.0,1.0],'') editBox.id = 1 editBox.maxTextLength = 10 editBox.wordwrapped = True editBox.text = '' # Multi Column List multi = CreateControl("TaharezLook/MultiColumnList", "a MultiColumn List",sheet,[0.05,0.1],[0.35,0.3],[0.01,0.01],[1.0,1.0],'') multi.addColumn('Column1',0,0.5) #name,id,width (%widget) multi.addColumn('Column2',1,0.5) #name,id,width (%widget) multi.showVertScrollbar = True # Vertical Scroll Bar CreateControl("TaharezLook/VerticalScrollbar", "a Vertical Scroll Bar",sheet,[0.00,0.02],[0.02,1.0],[0.01,0.01],[1.0,1.0],'') # Frame with Children frame = CreateControl("TaharezLook/FrameWindow", "a Frame Window",sheet,[0.05,0.5],[0.35,0.3],[0.01,0.01],[1.0,1.0],'Test Frame',1) CreateControl("TaharezLook/Checkbox" , "Checkbox1",frame ,[0.10,0.30],[0.30,0.10],[0.01,0.01],[1.0,1.0],"Check Box").enabled=True CreateControl("TaharezLook/Editbox", "an edit box",frame,[0.35,0.45],[0.55,0.15],[0.01,0.01],[1.0,1.0],'') CreateControl("TaharezLook/StaticText" , "Edit label" ,frame ,[0.10,0.45],[0.25,0.15],[0.01,0.01],[1.0,1.0],"Edit Me") # Tab Control tabControl= CreateControl("TaharezLook/TabControl" , "TabControl" ,sheet ,[0.40,0.50],[0.55,0.40],[0.01,0.01],[1.0,1.0],"a TabControl") tabControl.tabHeight = 0.15 page1= CreateControl("TaharezLook/TabPane" , "Page1" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Radio Button") page2= CreateControl("TaharezLook/TabPane" , "Page2" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Combo Box") page3= CreateControl("TaharezLook/TabPane" , "Page3" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"List Box") page4= CreateControl("TaharezLook/TabPane" , "Page4" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Static") page5= CreateControl("TaharezLook/TabPane" , "Page5" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"Spinner") page6= CreateControl("TaharezLook/TabPane" , "Page6" ,tabControl ,[0.01,0.01],[0.99,0.99],[0.01,0.01],[1.0,1.0],"ScrolledPane") # Page 1 button = CreateControl("TaharezLook/RadioButton" , "Button1",page1 ,[0.10,0.20],[0.30,0.10],[0.01,0.01],[1.0,1.0],"Option1") button.groupID=1 button = CreateControl("TaharezLook/RadioButton" , "Button2",page1 ,[0.10,0.30],[0.30,0.10],[0.01,0.01],[1.0,1.0],"Option2") button.groupID=1 button.selected = True # Page 2 combobox=CreateControl("TaharezLook/Combobox" , "A Combo Box" ,page2 ,[0.05,0.15],[0.8,0.5],[0.01,0.01],[1.0,1.0],"a Combo Box") CreateControl("TaharezLook/ComboEditbox" , "Combo Edit Box" ,page2 ,[0.05,0.55],[0.8,0.15],[0.01,0.01],[1.0,1.0],"a Combo Edit Box") # Page 3 List Box CreateControl("TaharezLook/StaticText" , "List label" ,page3 ,[0.05,0.05],[0.80,0.15],[0.01,0.01],[1.0,1.0],"Editless ListBox",0) listbox = CreateControl("TaharezLook/Listbox", "a List Box" ,page3 ,[0.05,0.20],[0.80,0.70],[0.01,0.01],[1.0,1.0],"ListBox",1) # Page 4 Static Text / Static Image # Static Text Background / Horiz Bars staticText=CreateControl("TaharezLook/StaticText", "TestLabel" ,page4 ,[0.50,0.50],[0.4,0.35],[0.01,0.01],[1.0,1.0],"Test Horizontal Bar on Static Text") staticText.frameColours = green staticText.frameEnabled = True img = cegui.ImagesetManager.getSingleton().getImageset("TaharezLook").getImage("ListboxSelectionBrush") staticText.backgroundImage = img staticText.backgroundColours = cegui.ColourRect(blue,red,blue,red) #colrect staticText.horizontalScrollbarEnabled = True staticText.textColours= cegui.colour(1.0,0.0,0.0) # red Text staticText.requestRedraw # Static Image staticImage=CreateControl("TaharezLook/StaticImage", "TestImage" ,page4 ,[0.10,0.10],[0.3,0.85],[0.01,0.01],[1.0,1.0],"Test Image") staticImage.frameColours = green staticImage.frameEnabled = True img = cegui.ImagesetManager.getSingleton().getImageset("TaharezLook").getImage("ListboxSelectionBrush") staticImage.image = img staticImage.imageColours = blue_back # Static Image Alignment LeftAligned,RightAligned,Centred,Justified staticImage.horizontalFormatting=cegui.Centred #OK staticImage.requestRedraw # Page 5, cant use createcontrol text is numeric CreateControl("TaharezLook/StaticText" , "Label2s" ,page5 ,[0.10,0.10],[0.40,0.15],[0.01,0.01],[1.0,1.0],"Float Pt") spinner = cegui.WindowManager.getSingleton().createWindow("TaharezLook/Spinner", "Test2") page5.addChildWindow(spinner) spinner.position = cegui.Point(0.5,0.1) spinner.size = cegui.Size(0.20,0.15) colourframe= CreateControl("TaharezLook/FrameWindow" , "colour_Frame" ,page6 ,[0.15 ,0.15],[5.8,5.86],[0.01,0.01],[1.0,1.0],"Colours",1) scrolledPanel = CreateControl("TaharezLook/ScrollablePane" , "ScrolledPanel" ,page6 ,[0.20,0.40],[0.50,0.50],[0.01,0.01],[1.0,1.0],"Test",1) scrolledPanel.vertScrollBars=True scrolledPanel.horzScrollBars=True scrolledPanel.addChildWindow(colourframe) scrolledPanel.contentPaneAutoSized = True scrolledPanel.horzStepSize=2.0 scrolledPanel.autoSize=False # Should this be self.item, self.item2 etc ? # Add items to Listbox item = cegui.ListboxTextItem("Test",1) item.selectionColours = blue item.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" listbox.addItem(item) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item = item item2 = cegui.ListboxTextItem("Test2",2) item2.selectionColours = blue item2.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" listbox.addItem(item2) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item2 = item2 listbox.showHorzScrollbar=True # Add items to the combobox item3 = cegui.ListboxTextItem("Combo Test1",1) item3.selectionColours = red item3.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" combobox.addItem(item3) combobox.subscribeEvent("ListSelectionAccepted", OnObjectSelection) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item3 = item3 item4 = cegui.ListboxTextItem("Combo Test1",2) item4.selectionColours = red item4.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" combobox.addItem(item4) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item4 = item4 # Add items to the MultiCoulumList item5 = cegui.ListboxTextItem("Multi Col 1") item5.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" item5.selectionColours = red row = multi.addRow(item5,0) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item5 = item5 item6 = cegui.ListboxTextItem("Multi Col 2") item6.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" item6.selectionColours = blue multi.setItem(item6, 1, row) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item6 = item6 item7 = cegui.ListboxTextItem("Next Row ") item7.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" item7.selectionColours = red row = multi.addRow(item7,0) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item7 = item7 item8 = cegui.ListboxTextItem("Next Col") item8.selectionBrushImage = "TaharezLook", "ListboxSelectionBrush" item8.selectionColours = blue multi.setItem(item8, 1, row) # you must hold a copy of this so it isn't destroyed while CEGUI uses it self.item8 = item8 #Event Handling # Which one should it be? self.ec= quitButton.subscribeEvent(quitButton.EventClicked, onQuit)