MWCam.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:MechWarfareScoring 作者: artanz 项目源码 文件源码
def OnPaint( self, event ):

        dc = wx.BufferedPaintDC( self )

        # Draw the camera image
        if self.Camera.Connected:
            try:
                stream = self.Camera.Update()
                if stream != None:
                    img = wx.ImageFromStream( stream )
                    bmp = wx.BitmapFromImage( img )
                    dc.DrawBitmap( bmp, 0, 0, True )
            except:
                pass

        # If camera not connected draw blank white screen
        else:
            dc.SetBrush( wx.WHITE_BRUSH )
            dc.DrawRectangle( -1, -1, CAMERA_SIZE_WIDTH, CAMERA_SIZE_HEIGHT )

        # Draw the SocketClient match data
        if self.SocketClient != None:
            dc.SetTextForeground( HUD_COLOR )

            # Clock
            min = self.SocketClient.MatchTime / 600
            sec = int((self.SocketClient.MatchTime -(min * 600)) * .1)

            dc.DrawText( str(min).rjust(2, "0") + ":" + str(sec).rjust(2, "0"), TIME_POSITION_X, TIME_POSITION_Y )

            # Scores
            for m in xrange(self.SocketClient.NumMechs):
                dc.DrawText( self.SocketClient.MechNames[m], SCORE_POSITION_X, SCORE_POSITION_Y1+(40*m) )
                dc.DrawText( str(self.SocketClient.MechHP[m]), SCORE_POSITION_X, SCORE_POSITION_Y2+(40*m) )

        # Draw the crosshairs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号