当前位置: 首页>>代码示例>>Python>>正文


Python DirectFrame.show方法代码示例

本文整理汇总了Python中direct.gui.DirectFrame.DirectFrame.show方法的典型用法代码示例。如果您正苦于以下问题:Python DirectFrame.show方法的具体用法?Python DirectFrame.show怎么用?Python DirectFrame.show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在direct.gui.DirectFrame.DirectFrame的用法示例。


在下文中一共展示了DirectFrame.show方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: MessageFrm

# 需要导入模块: from direct.gui.DirectFrame import DirectFrame [as 别名]
# 或者: from direct.gui.DirectFrame.DirectFrame import show [as 别名]
class MessageFrm(GameObject):

    def __init__(self, menu_props):
        GameObject.__init__(self)
        self.eng.log('created message form')
        self.chats = []
        self.curr_chat = None
        self.curr_match_room = None
        self.msg_frm = DirectFrame(
            frameSize=(-.02, .8, 0, .45),
            frameColor=(.2, .2, .2, .5),
            pos=(-.82, 1, .02), parent=base.a2dBottomRight)
        self.presences_sent = []
        self.menu_props = menu_props
        t_a = menu_props.text_args
        t_a['scale'] = .05
        t_a['fg'] = menu_props.text_normal_col
        self.dst_txt = OnscreenText(
            text='', pos=(0, .4), parent=self.msg_frm, align=TextNode.A_left,
            **t_a)
        self.arrow_btn = ImgBtn(
            parent=self.msg_frm, scale=(.024, .024), pos=(.7, 1, .42),
            frame_col=(1, 1, 1, 1),
            frame_texture='assets/images/gui/arrow.txo',
            cmd=self.on_arrow,
            **menu_props.imgbtn_args)
        self.arrow_btn.disable()
        self.close_btn = ImgBtn(
            parent=self.msg_frm, scale=(.024, .024), pos=(.76, 1, .42),
            frame_col=(1, 1, 1, 1),
            frame_texture='assets/images/gui/close.txo',
            cmd=self.on_close,
            **menu_props.imgbtn_args)
        self.close_btn.disable()
        self.ent = Entry(
            scale=.04, pos=(0, .03), entry_font=menu_props.font, width=19.5,
            frame_col=menu_props.btn_col, parent=self.msg_frm,
            initial_text=_('write here your message'),
            cmd=self.on_typed_msg, focus_in_cmd=self.on_focus,
            focus_in_args=['in'], focus_out_cmd=self.on_focus,
            focus_out_args=['out'], text_fg=menu_props.text_active_col)
        self.ent['state'] = DISABLED
        self.txt_frm = DirectScrolledFrame(
            frameSize=(-.02, .76, -.02, .28),
            canvasSize=(-.02, .72, -.02, .28),
            scrollBarWidth=.036,
            verticalScroll_relief=FLAT,
            verticalScroll_frameColor=(.2, .2, .2, .4),
            verticalScroll_thumb_relief=FLAT,
            verticalScroll_thumb_frameColor=(.8, .8, .8, .6),
            verticalScroll_incButton_relief=FLAT,
            verticalScroll_incButton_frameColor=(.8, .8, .8, .6),
            verticalScroll_decButton_relief=FLAT,
            verticalScroll_decButton_frameColor=(.8, .8, .8, .6),
            horizontalScroll_relief=FLAT,
            frameColor=(1, 1, 1, 0),
            pos=(.02, 1, .11), parent=self.msg_frm)
        t_a['scale'] = .046
        self.msg_txt = OnscreenText(
            text='', pos=(0, .24), parent=self.txt_frm.getCanvas(),
            align=TextNode.A_left, wordwrap=14, **t_a)
        lab_args = menu_props.label_args
        lab_args['scale'] = .046
        lab_args['text_fg'] = menu_props.text_normal_col
        self.lab_frm = Btn(
            frame_size=(-.02, .64, -.01, .05),
            frame_col=(1, 1, 1, 0),
            pos=(0, 1, .4), parent=self.msg_frm)
        self.lab_frm.bind(ENTER, self.on_enter)
        self.lab_frm.bind(EXIT, self.on_exit)
        self.tooltip = Label(
            text='', pos=(.78, 1, -.06),
            parent=self.lab_frm, text_wordwrap=16,# text_bg=(.2, .2, .2, .8),
            text_align=TextNode.A_right, **lab_args)
        self.tooltip.set_bin('gui-popup', 10)
        self.tooltip.hide()

    def on_enter(self, pos):
        self.tooltip.show()

    def on_exit(self, pos):
        self.tooltip.hide()

    def show(self):
        self.msg_frm.show()

    def hide(self):
        self.msg_frm.hide()

    def add_msg_txt(self, msg):
        self.msg_txt['text'] += ('\n' if self.msg_txt['text'] else '') + msg
        txt_height = self.msg_txt.textNode.getUpperLeft3d()[2] - \
            self.msg_txt.textNode.getLowerRight3d()[2]
        self.txt_frm['canvasSize'] = (-.02, .72, .28 - txt_height, .28)

    def set_title(self, title):
        ttitle = self.trunc(title, 32)
        fix_name = lambda name: name if '@' not in name else name.split('@')[0] + '\1smaller\[email protected]' + name.split('@')[1] + '\2'
        if title:
            if ',' in ttitle:
#.........这里部分代码省略.........
开发者ID:cflavio,项目名称:yorg,代码行数:103,代码来源:messagefrm.py

示例2: Menu

# 需要导入模块: from direct.gui.DirectFrame import DirectFrame [as 别名]
# 或者: from direct.gui.DirectFrame.DirectFrame import show [as 别名]

#.........这里部分代码省略.........
        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):

        if self.activeEntry == len(self.entries)-1:
            self.activeEntry=0
        else:
            self.activeEntry +=1
        if self.entries[self.activeEntry].isHidden() :
            self.selectUp()
            return
        self.selectFrame.reparentTo(self.entries[self.activeEntry])

    def hideMenu(self):
        self.clearKeys()
        self.main.gui.show()
        seq= Sequence( LerpColorScaleInterval(self.myFrame, 0.4 ,(1,1,1,0)) , Func(self.myFrame.hide) )
        seq.start()
    
    def hideResume(self):
        seq= Sequence( LerpColorScaleInterval(self.resumeButton, .5 ,(1,1,1,0)) , Func(self.resumeButton.hide))
        seq.start()
     
    def showResume(self):
        self.resumeButton.show()
        #seq= Sequence(  LerpColorScaleInterval(self.resumeButton, 1 ,(1,1,1,1)) )
        #seq.start()
        
    def showMenu(self): 
        self.clearKeys()
        base.accept("arrow_up" , self.selectUp )
        base.accept("arrow_down" , self.selectDown )
        base.accept("escape", exit)
        base.accept("enter",self.execSelection)  
        self.myFrame.show()
        self.main.gui.hide()
        seq= Sequence( LerpColorScaleInterval(self.myFrame, .5 ,(1,1,1,1)) )
        seq.start()
开发者ID:eswartz,项目名称:RenderPipeline-Samples,代码行数:104,代码来源:Menu.py


注:本文中的direct.gui.DirectFrame.DirectFrame.show方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。