Looking at the example in the manual for creating a DirectButton:
import direct.directbase.DirectStart from direct.gui.OnscreenText import OnscreenText from direct.gui.DirectGui import * #add some text bk_text = "This is my Demo" textObject = OnscreenText(text = bk_text, pos = (0.95,-0.95), scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1) #callback function to set text def setText(): bk_text = "Button Clicked" textObject.setText(bk_text) #add button b = DirectButton(text = ("OK", "click!", "rolling over", "disabled"),scale=.05,command=setText) #run the tutorial run()
It’s very painful to design a complex gui and translate coordinates by hand to the 2.6x2.0 aspect3d coordinate system.
Would it be possible to create some code to change the aspect3d coordinate system to use 800x600 screen coordinates?
I design my GUIs with gimp using guides then i translate by hand. It would be easier to setup a transformation in advance then use the same values i used in gimp to layout gui elements:
... #add some text bk_text = "This is my Demo" ( Code to change the aspect2d coordinate system to use 800x600 with (0,0) position on top-left corner) # from now on pass coordinates for the new system textObject = OnscreenText(text = bk_text, pos = (685,585), ... ...
Gui objects are NodePaths (acording to the manual) so would this be possible and how? Thanks in advance.