本文整理汇总了Python中direct.gui.DirectFrame.DirectFrame.reparentTo方法的典型用法代码示例。如果您正苦于以下问题:Python DirectFrame.reparentTo方法的具体用法?Python DirectFrame.reparentTo怎么用?Python DirectFrame.reparentTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类direct.gui.DirectFrame.DirectFrame
的用法示例。
在下文中一共展示了DirectFrame.reparentTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PiratesDownloadWatcher
# 需要导入模块: from direct.gui.DirectFrame import DirectFrame [as 别名]
# 或者: from direct.gui.DirectFrame.DirectFrame import reparentTo [as 别名]
class PiratesDownloadWatcher(DownloadWatcher.DownloadWatcher):
positions = [
(Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
(Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002)),
(Point3(1, 0, 0.90000000000000002), Point3(1, 0, 0.90000000000000002))]
def __init__(self, phaseNames):
self.phaseNames = phaseNames
self.model = loader.loadModel('models/gui/pir_m_gui_gen_loadingBar')
bar = self.model.findTexture('pir_t_gui_gen_loadingBar')
self.model.find('**/loading_bar').hide()
self.topFrame = DirectFrame(parent = base.a2dTopRight, pos = (-0.80000000000000004, 0, -0.10000000000000001), sortOrder = NO_FADE_SORT_INDEX + 1)
self.text = DirectLabel(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherText', pos = (0, 0, 0), text = ' ', text_fg = (1, 1, 1, 1), text_shadow = (0, 0, 0, 1), text_scale = 0.040000000000000001, textMayChange = 1, text_align = TextNode.ARight, text_pos = (0.17000000000000001, 0), sortOrder = 2)
self.bar = DirectWaitBar(relief = None, parent = self.topFrame, guiId = 'DownloadWatcherBar', pos = (0, 0, 0), frameSize = (-0.40000000000000002, 0.38, -0.044999999999999998, 0.065000000000000002), borderWidth = (0.02, 0.02), range = 100, frameColor = (1, 1, 1, 1), barColor = (0, 0.29999999999999999, 0, 1), barTexture = bar, geom = self.model, geom_scale = 0.089999999999999997, geom_pos = (-0.014, 0, 0.01), text = '0%', text_scale = 0.040000000000000001, text_fg = (1, 1, 1, 1), text_align = TextNode.ALeft, text_pos = (0.19, 0), sortOrder = 1)
self.bgFrame = DirectFrame(relief = DGG.FLAT, parent = self.topFrame, pos = (0, 0, 0), frameColor = (0.5, 0.27000000000000002, 0.35999999999999999, 0.20000000000000001), frameSize = (-0.44, 0.39000000000000001, -0.035999999999999997, 0.056000000000000001), borderWidth = (0.02, 0.02), scale = 0.90000000000000002, sortOrder = 0)
self.accept('launcherPercentPhaseComplete', self.update)
def update(self, phase, percent, reqByteRate, actualByteRate):
phaseName = self.phaseNames[phase]
self.text['text'] = OTPLocalizer.DownloadWatcherUpdate % phaseName + ' -'
self.bar['text'] = '%s %%' % percent
self.bar['value'] = percent
def foreground(self):
self.topFrame.reparentTo(base.a2dpTopRight)
self.topFrame.setBin('gui-fixed', 55)
self.topFrame['sortOrder'] = NO_FADE_SORT_INDEX + 1
def background(self):
self.topFrame.reparentTo(base.a2dTopRight)
self.topFrame.setBin('unsorted', 49)
self.topFrame['sortOrder'] = -1
def cleanup(self):
self.text.destroy()
self.bar.destroy()
self.bgFrame.destroy()
self.topFrame.destroy()
self.ignoreAll()
示例2: load
# 需要导入模块: from direct.gui.DirectFrame import DirectFrame [as 别名]
# 或者: from direct.gui.DirectFrame.DirectFrame import reparentTo [as 别名]
def load(args):
"""Sets up the GUI for the main menu.
Arguments:
This takes no arguments.
"""
global backFrame
global menuFrame
global pauseText
global backButton
font_digital = loader.loadFont('digital.egg')
backFrame = DirectFrame()
backFrame['frameColor'] = (0, 0, 0, .5)
backFrame['frameSize'] = (2, -2, 2, -2)
backFrame.setPos(0, 0, 0)
menuFrame = DirectFrame()
menuFrame.reparentTo(backFrame)
menuFrame['frameColor'] = (1, 1, 1, .5)
menuFrame['frameSize'] = (.5, -.5, .5, -.5)
menuFrame.setPos(0, 0, 0)
pauseText = OnscreenText()
pauseText['text'] = ('PAUSED')
pauseText['scale'] = (.1)
pauseText['font'] = (font_digital)
pauseText['fg'] = (1, 1, 1, 1)
pauseText.setPos(0, .9)
backButton = DirectButton()
backButton.reparentTo(menuFrame)
backButton['text'] = ('Back')
backButton['text_scale'] = (.1)
backButton['text_pos'] = (0, -0.03)
backButton['frameVisibleScale'] = (2, 0.5, 0)
backButton['frameColor'] = (1, 1, 1, 0)
backButton['command'] = (messenger.send)
backButton['extraArgs'] = ("switch_gui", [gui.menu.pause_options, gui.menu.pause])
backButton.setPos(0, 0, 0)
示例3: load
# 需要导入模块: from direct.gui.DirectFrame import DirectFrame [as 别名]
# 或者: from direct.gui.DirectFrame.DirectFrame import reparentTo [as 别名]
def load(args):
"""Sets up the GUI for the in game pause menu.
Arguments:
args[0] -- The function for the 'resume' button.
args[1] -- The function for the 'settings' button.
args[2] -- The function for the 'exit' button.
"""
# GUI should do what they are told, they should get data sent to them, not request it.
global pauseText
global backFrame
global menuFrame
global resumeButton
font_digital = loader.loadFont("digital.egg")
backFrame = DirectFrame()
backFrame["frameSize"] = (2, -2, 2, -2)
backFrame.setPos(0, 0, 0)
backFrame["frameColor"] = (0, 0, 0, 0.5)
menuFrame = DirectFrame()
menuFrame.reparentTo(backFrame)
menuFrame["frameColor"] = (1, 1, 1, 0.5)
menuFrame["frameSize"] = (0.5, -0.5, 0.5, -0.5)
menuFrame.setPos(0, 0, 0)
buttonClickSound = loader.loadSfx("sound/buttonClick.wav")
buttonRollSound = loader.loadSfx("sound/buttonRoll.wav")
resumeButton = DirectButton()
resumeButton.reparentTo(menuFrame)
resumeButton["text"] = "Resume"
resumeButton["text_scale"] = 0.1
resumeButton["text_pos"] = (0, -0.03)
resumeButton["frameVisibleScale"] = (2, 0.5, 0)
resumeButton["frameColor"] = (1, 1, 1, 0)
resumeButton["command"] = resume
resumeButton["rolloverSound"] = buttonRollSound
resumeButton["clickSound"] = buttonClickSound
resumeButton.setPos(0, 0, 0.4)
settingsButton = DirectButton()
settingsButton.reparentTo(menuFrame)
settingsButton["text"] = "Settings"
settingsButton["text_scale"] = 0.1
settingsButton["text_pos"] = (0, -0.03)
settingsButton["frameVisibleScale"] = (2, 0.5, 0)
settingsButton["frameColor"] = (1, 1, 1, 0)
settingsButton["rolloverSound"] = buttonRollSound
settingsButton["clickSound"] = buttonClickSound
settingsButton["command"] = messenger.send # Command to run
settingsButton["extraArgs"] = ("switch_gui", [gui.menu.pause, gui.menu.pause_options]) # Args to send
settingsButton.setPos(0, 0, 0.2)
exitButton = DirectButton()
exitButton.reparentTo(menuFrame)
exitButton["text"] = "Exit"
exitButton["text_scale"] = 0.1
exitButton["text_pos"] = (0, -0.03)
exitButton["frameVisibleScale"] = (2, 0.5, 0)
exitButton["frameColor"] = (1, 1, 1, 0)
exitButton["rolloverSound"] = buttonRollSound
exitButton["clickSound"] = buttonClickSound
exitButton["command"] = exit
exitButton.setPos(0, 0, 0)
pauseText = OnscreenText()
pauseText["text"] = "PAUSED"
pauseText["scale"] = 0.1
pauseText["font"] = font_digital
pauseText["fg"] = (1, 1, 1, 1)
pauseText.setPos(0, 0.9)
示例4: Menu
# 需要导入模块: from direct.gui.DirectFrame import DirectFrame [as 别名]
# 或者: from direct.gui.DirectFrame.DirectFrame import reparentTo [as 别名]
class Menu(object):
def __init__(self,main):
self.main=main
wx = base.win.get_x_size()
wy = base.win.get_y_size()
kx = 1920
ky = 1080
self.myFrame = DirectFrame(frameColor=(1,1,1,1),
frameSize=(0, kx,0, ky))
menu_tex = loader.loadTexture("res/menu.png")
menu_tex.set_minfilter(SamplerState.FT_nearest)
menu_tex.set_magfilter(SamplerState.FT_linear)
self.myFrame["frameTexture"] = menu_tex
self.myFrame.reparentTo(base.pixel2d)
self.myFrame.set_pos( (wx-kx) / 2, 0, -(wy+ky) / 2)
self.myFrame.set_transparency(True)
self.startButton = DirectButton(
text = "",
text_scale=1.0,
text_fg=(0.2,0.2,0.2,1),
frameTexture="res/start_game.png",
frameColor=(1,1,1,1),
frameSize=(-64, 64, -20, 20),
command=self.main.startGame,
relief=DGG.FLAT,
rolloverSound=None,
clickSound=None,
parent=self.myFrame,
scale=2.0,
pos=(wx/2 + 160, 0, wy/2 + 50)
)
self.startButton.setTransparency(1)
self.exitButton = DirectButton(
text = ("Exit Game"),
pos=(0,0,-.8),
text_scale=.1,
frameColor=(0,0,0,0),
relief=1,
frameVisibleScale=(2,3),
command=exit,
rolloverSound=None,
clickSound=None,
parent=self.myFrame,
)
self.exitButton.setTransparency(1)
self.resumeButton = DirectButton(
text = ("Resume"),
pos=(.0,0,.3),
text_scale=.1,
frameColor=(0,0,0,0),
relief=1,
frameVisibleScale=(2,3),
command=self.main.resumeGame,
rolloverSound=None,
clickSound=None,
parent=self.myFrame,
)
self.resumeButton.setTransparency(1)
self.resumeButton.hide()
self.selectFrame= DirectFrame( frameColor=(1,1,1,1) , frameSize=(-64, 64, -20, 20) , frameTexture="res/select.png")
self.selectFrame.setTransparency(1)
self.selectFrame.reparentTo(self.startButton)
self.entries = [self.exitButton,self.startButton,self.resumeButton]
self.activeEntry = 1
def clearKeys(self):
base.ignore("arrow_up")
base.ignore("arrow_down")
base.ignore("arrow_left")
base.ignore("arrow_right")
base.ignore("escape")
base.ignore("enter")
def execSelection(self):
self.entries[self.activeEntry]["command"]()
def selectDown(self):
if self.activeEntry == 0:
self.activeEntry = len(self.entries)-1
else:
self.activeEntry -=1
if self.entries[self.activeEntry].isHidden():
self.selectDown()
return
self.selectFrame.reparentTo(self.entries[self.activeEntry])
def selectUp(self):
#.........这里部分代码省略.........