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


Python Adafruit_Thermal.underlineOn方法代码示例

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


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

示例1:

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import underlineOn [as 别名]
   'User-Agent'      : agent,
   'Accept-Encoding' : 'gzip',
   'Authorization'   : 'Bearer ' + token})


# Display results. ---------------------------------------------------------

maxId = data['search_metadata']['max_id_str']

for tweet in data['statuses']:

  printer.inverseOn()
  printer.print(' ' + '{:<31}'.format(tweet['user']['screen_name']))
  printer.inverseOff()

  printer.underlineOn()
  printer.print('{:<32}'.format(tweet['created_at']))
  printer.underlineOff()

  # max_id_str is not always present, so check tweet IDs as fallback
  id = tweet['id_str']
  if(id > maxId): maxId = id # String compare is OK for this

  # Remove HTML escape sequences
  # and remap Unicode values to nearest ASCII equivalents
  printer.print(unidecode(
    HTMLParser.HTMLParser().unescape(tweet['text'])))

  printer.feed(3)

print(maxId) # Piped back to calling process
开发者ID:anoved,项目名称:atp,代码行数:33,代码来源:twitter.py

示例2: main

# 需要导入模块: import Adafruit_Thermal [as 别名]
# 或者: from Adafruit_Thermal import underlineOn [as 别名]
def main():
  printer = Adafruit_Thermal("/dev/ttyAMA0", 19200, timeout=5)
  deg     = chr(0xf8) # Degree symbol on thermal printer
  events = get_events()

  # Print heading
  printer.setSize('M')
  printer.justify('C')
  printer.println( datetime.datetime.today().date().strftime("%A, %B %-d, %Y") )
  printer.justify('L')
  printer.setSize('S')

  # Print schedule
  printer.boldOn()
  printer.underlineOn()
  printer.justify('C')
  printer.println("Today's Schedule")
  printer.justify('L')
  printer.underlineOff()
  printer.boldOff()

  printer.feed(1)

  if not events:
    printer.println('No scheduled events today.')
    printer.feed(1)
  for event in events:
    start = dateutil.parser.parse(event['start'].get('dateTime', event['start'].get('date'))).strftime("%-I:%M%p")
    end = dateutil.parser.parse(event['end'].get('dateTime', event['end'].get('date'))).strftime("%-I:%M%p")
    location = event.get('location', '')
    printer.println(event['summary'])
    if start == end:
      if location:
        printer.println(start + ", " + location)
      else:
        printer.println(start)
    else:
      if location == "":
        printer.println(start + " - " + end)
      else:
        printer.println(start + " - " + end + ", " + location)
    printer.feed(1)

  printer.feed(1)

  # Print weather
  weather = get_weather()

  printer.boldOn()
  printer.underlineOn()
  printer.justify('C')
  printer.println("Today's Weather")
  printer.justify('L')
  printer.underlineOff()
  printer.boldOff()

  printer.feed(1)

  printer.println("Temperature: " + str(weather.temp_now) + ". Feels like " + str(weather.feels_like_now))
  printer.feed(1)

  printer.println("Today: " + weather.weather_today)
  printer.feed(1)

  printer.println("Tonight: " + weather.weather_tonight)
  printer.feed(1)

  downcase_first = lambda s: s[:1].lower() + s[1:] if s else ''
  printer.println("Tomorrow: " + weather.weather_tomorrow + " Tomorrow night, " + downcase_first(weather.weather_tomorrow_night))
  printer.feed(1)

  printer.feed(2)
开发者ID:zeiv,项目名称:Python-Thermal-Printer,代码行数:74,代码来源:schedule.py


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