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


Python File.write方法代码示例

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


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

示例1: __init__

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import write [as 别名]
class Plugin:

	def __init__(self):
		self.windowsManager = WM.WindowsManager(self)
		self.coqManager = CM.CoqManager(self.windowsManager)
		self.instance = None
		self.launched = False

	def launch(self): 
		# Don't relaunched if it is already running !
		if self.launched == True:
			return False
		self.launched = True
		vim.command(":call MapVcoq()")
		self.windowsManager.setupWindows()
		self.coqManager.launchCoqtopProcess()
		self.instance = File(self, (self.windowsManager.windowBuffers['__Edit__'],
			self.windowsManager.windowBuffers['__Compiled__']))
		self.windowsManager.focusWindow("__Edit__")
	
	def shutdown(self):
		self.launched = False
		error("Stopping vcoq ...")
		vim.command('windo bd') # Close every windows

	def next(self):
		if self.instance != None:
			self.instance.next()

	def prev(self):
		if self.instance != None:
			self.instance.prev()

	################
	## Vim events ##
	################

	def onBufferFocus(self, entered, buffer):
		""" This function is called when the user enter or leave a buffer.
		It setups (and removes) the special maps for this buffer.
		It also perform extra actions, depending on the buffer. """
		if self.launched == False:
			return 0
		if buffer == '__Input__':
			cmd = 'imap <buffer> <CR> <Esc>:py vcoq.main.coqManager.sendQueryCommand()<CR>a' if entered else 'mapclear <buffer>'
			vim.command(cmd)
		return 1

	def onVimResized(self):
		if self.launched == False: return 0
		self.windowsManager.updateWindows()
		return 0

	def onEnter(self, buffer):
		if self.launched == False: return 0
		self.windowsManager.onEnter(buffer)
		return 0

	def onWrite(self, filename):
		if self.launched == False: 
			error("Vcoq isn't running", prompt=False)
			return 0
		self.instance.write(filename)
		return 0

	def onOpen(self, filename):
		if self.launched == False: 
			error("Vcoq isn't running", prompt=False)
			return 0
		self.instance.open(filename)
		return 0
开发者ID:QuanticPotato,项目名称:vcoq,代码行数:73,代码来源:vcoq.py

示例2: main

# 需要导入模块: from file import File [as 别名]
# 或者: from file.File import write [as 别名]
def main():
    #Really important values
    showFPS = True
    TOTAL_OBJECTS = 1

    #Import modules
    import pygame, sys, os
    from pygame.locals import *

    #import custom classes
    import background, button, toolbar, selectGun, selectTool, person, powerups, baddieAI
    from background import Level_1
    from button import Button
    from toolbar import Toolbar
    from selectGun import selectGunMenu
    from selectTool import selectToolMenu
    from person import Person
    from powerups import Powerups
    from baddieAI import AI
    from l1 import L1
    import load
    from screen import Screen
    from file import File

    #Setup game data
    getFiles = File()
    highscore, totalscore, firstRun, lockedGuns = getFiles.read()

    #Show Important information if program is run for first time
    if firstRun:
        from installer import Install
        firstRun = False
    #Setup the main screen display and clock
    pygame.init()

    os.environ ['SDL_VIDEO_WINDOW_POS'] = 'center'
    WINDOWWIDTH = 1200
    WINDOWHIEGHT = 600
    windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHIEGHT), 0, 32)
    icon = pygame.image.load('files\\icon.png')
    pygame.display.set_caption('The Taco Chronicles')
    pygame.display.set_icon(icon)
    mainClock = pygame.time.Clock()
    load.Credits(windowSurface)
    #Setup Colors
    BLUE = (0,0,255)
    SKY_BLUE = (0, 255, 255)

    windowSurface.fill(SKY_BLUE)

    lockedTools = {'crowbar':False, 'rope':True, 'key':True, 'TNT':True, 'jetpack':True}
    sound = True
    gameData = {'sound':sound, 'lockedGuns':lockedGuns, 'lockedTools':lockedTools}
    restart = True

    start = Screen(windowSurface)
    clicked = False
    windowSurface.fill((255, 255, 255))
    pygame.mixer.music.load('files//sound//gameTheme.mp3')
    exit = False

    while True:        
        restart = True
        clicked = False
        pygame.mixer.music.play(-1, 0.0)
        windowSurface.fill((255, 255, 255))
        while True:
            if exit:
                getFiles.write(highscore, totalscore, firstRun, lockedGuns)
                pygame.quit()
                sys.exit()
            clicked, exit = start.startScreen(highscore, clicked)
            if clicked:
                break
        
        pygame.mixer.music.stop()

        load.Load(windowSurface)
    
        #Run the gameplay
        count = 0
        while True:
            level = L1(windowSurface, mainClock, SKY_BLUE, gameData, showFPS)
            restart, goBack, highscore, totalscore, exit = level.play(highscore, totalscore)
            if goBack:
                break
            if exit:
                break

        if totalscore > 10000:
            lockedGuns['shotgun'] = False
        if totalscore > 15000:
            lockedGuns['AK-47'] = False
        if totalscore > 30000:
            lockedGuns['bazooka'] = False
        if totalscore > 35000:
            lockedGuns['flamethrower'] = False
开发者ID:victormanakkat,项目名称:Taco-Chronicles,代码行数:99,代码来源:main.py


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