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


Python Event类代码示例

本文整理汇总了Python中Event的典型用法代码示例。如果您正苦于以下问题:Python Event类的具体用法?Python Event怎么用?Python Event使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: start

	def start(self):
		"""
		Start the game engine.
		"""
		lasttime = time()
		curtime = 0
		frames = 0
		# Start the main event loop
		while 1:
			# Process the internal event queue
			Event.handle_events()
			
			# Process the SDL event queue
			for event in SDL.event.get():
				if event.type == SDL.QUIT:
					self.shutdown()
				elif event.type == SDL.VIDEORESIZE:
					self.resize(event.w, event.h)
				elif event.type == SDL.KEYDOWN:
					StateManager.current.key_pressed(event.key)
					self.queue_flip()
				elif event.type == SDL.KEYUP:
					StateManager.current.key_released(event.key)
			
			# Update and draw the current state
			StateManager.update()
			self.draw()
			
			frames += 1
			curtime = time()
			if curtime - lasttime >= 1:
				Log.info("FPS: " + str(frames / (curtime - lasttime)))
				frames = 0
				lasttime = curtime
开发者ID:jasonkotenko,项目名称:Boom-Engine,代码行数:34,代码来源:Interface.py

示例2: process

def process(entry, result, mode="Num"):
    Event.process(entry, result)
    margin = Auction.process(entry, result)
    Auction_Site.process(entry, result)
    Auction_BidRequests.process(margin, entry, result, mode)
    # Response
    result.append(entry["response"])
开发者ID:jche,项目名称:GumGum,代码行数:7,代码来源:Driver.py

示例3: createSocket

def createSocket(addr, port):
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind((addr, port))
    rudpSocket = RudpSocket(sock)
    rudpSocket.addr_src = sock.getsockname()
    rudpSockets.append(rudpSocket)
    Event.eventFd(sock.fileno(), handleDataAvailable, rudpSocket, "DataReceived")
    return rudpSocket
开发者ID:El--Presidente,项目名称:python-rudp,代码行数:8,代码来源:Rudp.py

示例4: received_message

 def received_message(self, m):
     # self.clients is set from within the server
     # and holds the list of all connected servers
     # we can dispatch to
     import json
     msg = json.loads(str(m))
     Event.broadcast(msg['event'], msg['msg'])
     pass
开发者ID:csantosbh,项目名称:Lauen,代码行数:8,代码来源:WSServer.py

示例5: __handleTimeoutFIN

 def __handleTimeoutFIN(self, packetSequenceNumber):
     logger.log(Level.DEBUG, "Handling FIN timeout of:" + str(packetSequenceNumber))
     if self.__incrementRetries():
         Event.eventTimeoutDelete(self.__handleTimeoutFIN, packetSequenceNumber)
         packet = RudpPacket()
         packet.type = RudpPacket.TYPE_FIN
         packet.seqnum = packetSequenceNumber
         self.rudpSocket.sendPacketControl(self.addr, packet)
         Event.eventTimeout(RudpSocket.PARAM_TIMEOUT, self.__handleTimeoutFIN, packet.seqnum, "DATA Timeout")    
开发者ID:El--Presidente,项目名称:python-rudp,代码行数:9,代码来源:Rudp.py

示例6: __emptyBuffer

 def __emptyBuffer(self):
     logger.log(Level.TRACE, "Sending packets, window:" +  str(self.window) + " index:" + str(self.nextSendingPacketSeqNumber))
     if len(self.dataBuffer) > self.nextSendingPacketSeqNumber:
         while self.window > 0 and len(self.dataBuffer) > 0 and len(self.dataBuffer) > self.nextSendingPacketSeqNumber:            
             packet = self.dataBuffer[self.nextSendingPacketSeqNumber]
             self.rudpSocket.sendPacketData(self.addr, packet)
             self.nextSendingPacketSeqNumber = self.nextSendingPacketSeqNumber + 1
             self.window = self.window - 1
             Event.eventTimeout(RudpSocket.PARAM_TIMEOUT, self.__handleTimeoutData, packet.seqnum, "DATA Timeout")
开发者ID:El--Presidente,项目名称:python-rudp,代码行数:9,代码来源:Rudp.py

示例7: __handleTimeoutSYN

 def __handleTimeoutSYN(self, packetSequenceNumber):
     logger.log(Level.DEBUG, "Handling SYN timeout of:" + str(packetSequenceNumber))
     Event.eventTimeoutDelete(self.__handleTimeoutSYN, packetSequenceNumber)
     if self.__incrementRetries():
         packet = self.rudpSocket.generateSynPacket()
         self.nextAckSeqNumber = packet.seqnum + 1
         logger.log(Level.INFO, "Retransmitting SYN")
         self.rudpSocket.sendPacketControl(self.addr, packet)
         Event.eventTimeout(RudpSocket.PARAM_TIMEOUT, self.__handleTimeoutSYN, packet.seqnum, "SYN timeout")
开发者ID:El--Presidente,项目名称:python-rudp,代码行数:9,代码来源:Rudp.py

示例8: fill_insert

		def fill_insert(classe, i):
			classe.name = "C"+str(i)

			classe.planning = Planning()
			# XXX fill planning with normal events ?
			#classe.planning.cb_fill(number)
			# XXX fill planning with course events
			cursus = db.session.query(Cursus).get(i+1)
			if cursus:
				periods = cursus.periods
				import Event
				Event.fill_date = cursus.start
			else:
				periods = []
			for period in periods:
				for course in period.courses:
					from Event import Event
					# XXX move fill event in class
					event = Event()
					event.planning = classe.planning
					event.course = course
					course.c_elearning_rest = course.c_elearning
					course.c_classroom_rest = course.c_classroom
					course.c_practice_rest = course.c_practice
					course.e_oral_rest = course.e_oral
					course.e_practice_rest = course.e_practice
					hours = course.c_elearning
					hours += course.c_classroom
					hours += course.c_practice
					hours += course.e_oral
					hours += course.e_practice
					event.cb_fill(hours / 2)

				if len(period.classes) == 0:
					for course in period.courses:
						event = Event()
						event.planning = period.planning
						event.course = course
						event.cb_fill(event.course.e_exam / 2 + 1)

				import Event
				Event.fill_date = period.end

			classe.periods = periods

			user = User()
			user.manager_class = [classe]
			user.cb_fill(randint(1, number),
			    classe.campus.name + '_' + classe.name +
			    '_manager_user' + str(i))

			user = User()
			user.student_class = classe
			user.cb_fill(randint(10, 30), classe.campus.name+'_'+classe.name+'_student_user'+str(i))

			db.session.add(classe)
开发者ID:SBillion,项目名称:timetableasy,代码行数:56,代码来源:Class.py

示例9: __handleTimeoutData

 def __handleTimeoutData(self, rudpSecNum):
     logger.log(Level.DEBUG, "Handling packet timeout DATA packet seq:" + str(rudpSecNum))
     ''' Here we need to remove all other DATA packet timeouts'''
     for seq in range(rudpSecNum, self.nextSendingPacketSeqNumber):            
         Event.eventTimeoutDelete(self.__handleTimeoutData, seq)
     if self.__incrementRetries():
         ''' Decrease window size, reset packet index to the one we lost'''
         self.window = 1 if self.window - 1 < 1 else self.window - 1
         self.nextSendingPacketSeqNumber = rudpSecNum
         self.__emptyBuffer()
         self.retries = self.retries + 1  
开发者ID:El--Presidente,项目名称:python-rudp,代码行数:11,代码来源:Rudp.py

示例10: createEvents

	def createEvents(self):
		nextDate = next_weekday(datetime.datetime.now().date(),self.day)
		created = []
		skipped = []
		while(nextDate < self.endDate):
			if not Event.getByDate(nextDate):
				Event.create(self.name,self.place,datetime.datetime.combine(nextDate, self.time),self.key)
				created.append(nextDate)
			else:
				skipped.append(nextDate)
			nextDate += datetime.timedelta(days=7)
		return [created,skipped]
开发者ID:ThomasPfeiffer,项目名称:SCWKbot,代码行数:12,代码来源:RepeatingEvent.py

示例11: __checkClose

 def __checkClose(self):
     ''' Send FIN if all packet have been sent - last packet in a buffer was sent and all have been ACK'ed'''
     if self.closePending is True:
         logger.log(Level.DEBUG, str(self.nextBufferPacketSeqNumber) + ">" + str(self.nextSendingPacketSeqNumber) + " >" + str(self.nextAckSeqNumber))
         if  self.nextBufferPacketSeqNumber == self.nextSendingPacketSeqNumber == (self.nextAckSeqNumber - 1):
             logger.log(Level.DEBUG, "Closing peer socket:" + str(self))
             packet = RudpPacket()
             packet.type = RudpPacket.TYPE_FIN
             packet.seqnum = self.dataBuffer[self.nextSendingPacketSeqNumber - 1].seqnum + 1
             self.rudpSocket.sendPacketControl(self.addr, packet)
             Event.eventTimeout(RudpSocket.PARAM_TIMEOUT, self.__handleTimeoutFIN, packet.seqnum, "DATA Timeout")
             self.state = RudpSocket.STATE_CLOSED                
         else:
             logger.log(Level.DEBUG, "Could not close peer socket yet !!!!")
开发者ID:El--Presidente,项目名称:python-rudp,代码行数:14,代码来源:Rudp.py

示例12: process

def process(entry, result, mode="Num"):
    """
    Given a JSON object formatted by Extractor.py, parse each key-value pair in the object.
    :param entry: the JSON object that represents one impression
    :param result: the buffer to store the parsed variables
    :param mode: "Num" or "Bin"; a flag indicating whether to parse bid bloor into binary variables or just keep the numerical value
    :return: a list containing parsed variables of an impression
    """

    Event.process(entry, result)
    margin = Auction.process(entry, result)
    Auction_Site.process(entry, result)
    Auction_BidRequests.process(margin, entry, result, mode)

    # Response
    result.append(entry["response"])
开发者ID:Shurooo,项目名称:gumgum,代码行数:16,代码来源:Driver.py

示例13: old_main

def old_main():
  for line in sys.stdin:
    event = Event.decode_event(line)
     # Common handling
    Global.UpdateThreadState(event)
    # Event-specific handling
    event_handler_map[event.event](event)
开发者ID:EmbeddedAtUM,项目名称:panappticon-tools,代码行数:7,代码来源:ComputeDependencies.py

示例14: main

def main():
    print("Handler Chain #1")
    pipeline = key_handler(mouse_handler(timer_handler()))
    while True:
        event = Event.next()
        if event.kind == Event.TERMINATE:
            break
        pipeline.send(event)

    print("\nHandler Chain #2 (debugging)")
    pipeline = debug_handler(pipeline)
    while True:
        event = Event.next()
        if event.kind == Event.TERMINATE:
            break
        pipeline.send(event)
开发者ID:JamesPei,项目名称:PythonProjects,代码行数:16,代码来源:test2.py

示例15: main

def main():
    print("Handler Chain #1")
    handler1 = TimerHandler(KeyHandler(MouseHandler(NullHandler())))
    # Could pass None or nothing instead of the NullHandler
    while True:
        event = Event.next()
        if event.kind == Event.TERMINATE:
            break
        handler1.handle(event)

    print("\nHandler Chain #2 (debugging)")
    handler2 = DebugHandler(handler1)
    while True:
        event = Event.next()
        if event.kind == Event.TERMINATE:
            break
        handler2.handle(event)
开发者ID:ShuyaMotouchi,项目名称:joke,代码行数:17,代码来源:eventhandler1.py


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