本文整理汇总了Python中display.Display.write方法的典型用法代码示例。如果您正苦于以下问题:Python Display.write方法的具体用法?Python Display.write怎么用?Python Display.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类display.Display
的用法示例。
在下文中一共展示了Display.write方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Game
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import write [as 别名]
class Game(object):
def __init__(self):
self.logger = Logger(level='debug')
self.logger.debug("Create display")
self.display = Display()
self.logger.debug(" + size: %sx%s" % (self.display.width, self.display.height))
## Config
self.blocks_width = 5
self.aliens_width = 10
self.aliens_height = 4
self.aliens_margin = 2
self.torpedos = []
self.max_speed = 10
self.frame_rate = 25
self.speed_down = 3
self.score = 0
# Build Aliens
self.aliens = self.build_aliens()
# Build Blocks
self.blocks = self.build_blocks()
# Build ship
self.ship = Ship(
logger=self.logger,
display=self.display,
game=self
)
def build_blocks(self):
step = int(self.display.width / self.blocks_width)
blocks = []
start_y = self.display.height - 13
start_x = 0
for x in range(0, self.blocks_width):
block = Block(
logger=self.logger,
display=self.display,
game=self,
x=start_x + x * step,
y=start_y
)
blocks.append(block)
if block:
# Center blocks
offset = (self.blocks_width-1) * step
offset = offset + block.width
offset = self.display.width - offset
offset = offset / 2
for block in blocks:
block.x += offset
return blocks
def build_aliens(self):
# Build level
start_x=2
start_y=1
alien_width = 0
alien_height = 0
aliens = []
for x in range(0, self.aliens_width):
for y in range(0, self.aliens_height):
objAlien = Alien1
if y == 0:
objAlien = Alien2
alien = objAlien(
logger=self.logger,
display=self.display,
game=self,
x=start_x + x * (alien_width + self.aliens_margin),
y=start_y + y * (alien_height + self.aliens_margin),
line=y
)
alien_width = alien.width
alien_height = alien.height
aliens.append(alien)
return aliens
def win(self):
self.display.clear()
self.display.write(
pos=self.display.get_center(you_win),
sprite=you_win
)
#.........这里部分代码省略.........
示例2: Display
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import write [as 别名]
from display import Display
__author__ = 'Dani'
if __name__ == "__main__":
column1 = [18, 23, 4, 17, 27]
column2 = [26, 19, 13, 6, 5]
ports = [column1, column2]
display = Display(5, 2, ports)
text = input('Text: ')
display.write(text)
display.show()
示例3: Clock
# 需要导入模块: from display import Display [as 别名]
# 或者: from display.Display import write [as 别名]
class Clock(object):
"""This is the clock aggregate root.
"""
def __init__(self, configuration):
"""Create a new instance of the clock class.
"""
self._configuration = configuration
self._logger = logging.getLogger(__name__)
self._motor = Motor(self._configuration)
self._blinker = Blinker(self._configuration)
self._display = Display(self._configuration)
self._database = Database(self._configuration)
self._consumer = Consumer(self._configuration, self.on_message)
@property
def blinker(self):
"""The blinker.
"""
return self._blinker
@property
def consumer(self):
"""The RabbitMQ consumer.
"""
return self._consumer
@property
def database(self):
"""The database.
"""
return self._database
@property
def display(self):
"""The display.
"""
return self._display
@property
def ip_address(self):
"""The IP address.
"""
return socket.gethostbyname(socket.gethostname())
@property
def motor(self):
"""The clock motor.
"""
return self._motor
def on_message(self, unused_channel, basic_deliver, properties, body):
"""Invoked when a message is delivered from RabbitMQ. The channel is passed for your convenience. The
basic_deliver object that is passed in carries the exchange, routing key, delivery tag and a redelivered flag
for the message. The properties passed in is an instance of BasicProperties with the message properties and the
body is the message that was sent.
:param pika.channel.Channel unused_channel: The channel object
:param pika.Spec.Basic.Deliver: basic_deliver method
:param pika.Spec.BasicProperties: properties
:param str|unicode body: The message body
"""
self._logger.info('Received message # %s from %s: %s', basic_deliver.delivery_tag, properties.app_id, body)
#if body is not None:
# payload = json.loads(body)
# if payload['Order'] is not None:
# order = payload['Order']
# if order is not None:
# order_date = date_parser.parse(order['OrderDate'])
# self._logger.info('Order date is %s', order_date.strftime("%Y-%m-%d %H:%M:%S"))
# order_year = int(order_date.year)
# self._logger.info('Order year is %i', order_year)
# order_month = int(order_date.month)
# self._logger.info('Order month is %i', order_month)
#self._blinker.blink()
self._motor.turn(15, 50)
self._logger.info('Current order count is %i', self._database.order_count)
order_year = datetime.today().year
order_month = datetime.today().month
self._database.record_order(order_year, order_month)
self._display.write("%i orders" % self._database.order_count)