查看: 1541|回复: 0
收起左侧

[求助] 有大神能帮忙看看Win10上好好的代码在树莓为什么运行不了?

2017-4-12 14:09:27 | 显示全部楼层 |阅读模式
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-

  3. __author__ = 'Azir Zhang'

  4. #import
  5. #-------------------------------------------------------------------------------------------
  6. import time
  7. import wx
  8. import sys

  9. #time module
  10. #-------------------------------------------------------------------------------------------
  11. class ClockWindow(wx.Window):
  12.     def __init__(self, parent):
  13.         wx.Window.__init__(self, parent )
  14.         self.Bind(wx.EVT_PAINT, self.OnPaint)
  15.         self.timer = wx.Timer(self)#创建定时器
  16.         self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)#绑定一个定时器事件
  17.         self.timer.Start(1000)#设定时间间隔
  18.         self.SetBackgroundColour('black')

  19.     def Draw(self, dc):#绘制当前时间
  20.         t = time.localtime(time.time())
  21.         dt = time.strftime("%m/%d/%Y %a", t)
  22.         tt = time.strftime("%H:%M:%S",t)
  23.         w, h = self.GetClientSize()
  24.         dc.Clear()
  25.         dc.SetBackground(wx.Brush(self.GetBackgroundColour()))
  26.         dc.SetFont(wx.Font(24, wx.ROMAN, wx.NORMAL, wx.NORMAL))
  27.         dw, dh = dc.GetTextExtent(dt)
  28.         tw, th = dc.GetTextExtent(tt)
  29.         dc.SetTextForeground('white')
  30.         dc.DrawText(dt, (w-dw)/2, (h)/3 - dh/2)
  31.         dc.DrawText(tt, (w-tw)/2, (h)/2 - th/2)

  32.     def OnTimer(self, evt):#显示时间事件处理函数
  33.         dc = wx.BufferedDC(wx.ClientDC(self))
  34.         self.Draw(dc)

  35.     def OnPaint(self, evt):
  36.         dc = wx.BufferedPaintDC(self)
  37.         self.Draw(dc)


  38. #Weather API module
  39. #-------------------------------------------------------------------------------------------

  40. #Home module
  41. #-------------------------------------------------------------------------------------------
  42. def Start():
  43.         print ('AQWics is waking......')

  44. Start()

  45. #Main Loop
  46. #-------------------------------------------------------------------------------------------
  47. class AQWics(wx.Frame):
  48.     def __init__(self):

  49.         wx.Frame.__init__(self, None, title="AQWics")

  50.         self.SetBackgroundColour('black')

  51.         ClockWindow(self)


  52. app = wx.App()
  53. frame = AQWics()
  54. frame.Show()
  55. app.MainLoop()
复制代码
这个代码,写的个始终的脚本,在树莓派上出现的纯白窗口。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热点推荐

关注我们,了解更多

官方微信

服务时间:10:00-16:00

13714503811

公司地址:深圳市龙岗区南湾街道东门头路8号

Copyright © 2012-2020 Powered by 树莓派论坛 2019.4  粤ICP备15075382号-1
快速回复 返回列表 返回顶部