Created
October 31, 2012 15:30
-
-
Save benregn/3987693 to your computer and use it in GitHub Desktop.
Panda3D questionnaire GUI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from direct.showbase.ShowBase import ShowBase | |
| import direct.directbase.DirectStart | |
| from direct.gui.OnscreenText import OnscreenText | |
| from direct.gui.DirectGui import * | |
| from panda3d.core import * | |
| class Directs(ShowBase): | |
| # rbuttonFrame = DirectFrame(pos = (-1, 0, 0.40)) | |
| _LABELS = ["Strongly do not want to continue", "Do not want to continue", | |
| "Neither", "Want to continue", "Strongly want to continue"] | |
| _rButtonValue = [0] | |
| _overlayFrame = None | |
| _overlayVisible = False | |
| _buttons = [] | |
| _buttonLabels = [] | |
| _rButtonFrame = None | |
| done = False | |
| hsepp = DirectLabel(text = '-'*100, scale = 0.07, | |
| pos = (0, 0, 0.22), frameColor=(0, 0, 0, 0)) | |
| def __init__(self): | |
| self.accept("shift-o", self.toggleOverlayFrame) | |
| def toggleOverlayFrame(self): | |
| if self._overlayVisible: | |
| print "Toggle off" | |
| self._overlayFrame.destroy() | |
| self._overlayVisible = False | |
| else: | |
| print "Toggle on" | |
| self._overlayFrame = DirectFrame(frameColor=(1, 1, 1, 1), | |
| # (Left,Right,Bottom,Top) | |
| frameSize=(-1.4, 1.4, 1, -1), | |
| pos=(0, 0, 0)) | |
| self._rButtonFrame = DirectFrame(parent=self._overlayFrame, pos=(-0.5, 0, 0.2)) | |
| self.setupButtons() | |
| self._overlayVisible = True | |
| def setupButtons(self): | |
| self._buttons = [] | |
| for i, label in enumerate(self._LABELS): | |
| xOffset = ((i * 15) / 100.0) | |
| # yOffset = 0.01 if int(len(label)/10.0) == 0 else int(len(label)/10.0)/100.0 | |
| xPos = len(label) / 100.0 + 0.02 + xOffset | |
| yPos = len(label)/100.0+0.07 | |
| self._buttonLabels.append(DirectLabel(parent=self._rButtonFrame, text = label, scale = 0.07, hpr=(0, 0, -45.0), | |
| pos = (xPos, 0, yPos), frameColor=(0, 0, 0, 0))) | |
| self._buttons.append(DirectRadioButton(parent=self._rButtonFrame, pos=(xOffset, 0, 0), | |
| variable=self._rButtonValue, value=[i], scale=0.05, | |
| frameColor=(1, 1, 1, 0), indicatorValue=0) | |
| ) | |
| for button in self._buttons: | |
| button['others'] = self._buttons | |
| # Run the tutorial | |
| Directs() | |
| run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment