コード例 #1
0
ファイル: homework03.py プロジェクト: daishumao/homework-03
 def __init__(self, parent, title):
     wx.Frame.__init__(self, parent, title=title)
     self.timer = wx.Timer(self)
     self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
     self.timer.Start(1000)
     self.CreateStatusBar()
     filemenu = wx.Menu()
     menuClose = filemenu.Append(-1, "&Close", " Close the tab you are looking now")
     filemenu.AppendSeparator()
     menuExit = filemenu.Append(-1, "E&xit", " Terminate the program")
     menuBar = wx.MenuBar()
     menuBar.Append(filemenu, "&File")
     self.Bind(wx.EVT_MENU, self.OnClose, menuClose)
     self.Bind(wx.EVT_MENU, self.OnExit, menuExit)
     self.SetMenuBar(menuBar)
     self.nb = wx.Notebook(self)
     self.filesize = os.path.getsize("data")
     alldata = open("data", "r")
     for i in alldata.readlines():
         sys.argv = i.encode("utf-8")[:-1].split(" ")
         temparg = daishumao.main()
         if_h, if_v = False, False
         if "\\h" in sys.argv:
             if_h = True
         if "\\v" in sys.argv:
             if_v = True
         self.nb.AddPage(cjlists(self.nb, temparg[1], temparg[2], if_h, if_v), "Table 1")
         daishumao.setglobalvar()
     alldata.close()
コード例 #2
0
ファイル: homework03.py プロジェクト: daishumao/homework-03
 def OnTimer(self, event):    # 计时器,定时检查data中是否有新内容,如果有就更新主界面
     tempsize = os.path.getsize("data")
     if tempsize != self.filesize:
         self.filesize = tempsize
         alldata = open("data", "r")
         count = 1
         lastselect = self.nb.GetSelection()
         self.nb.DeleteAllPages()
         for i in alldata.readlines():
             sys.argv = i.encode("utf-8")[:-1].split(" ")
             temparg = daishumao.main()
             if_h, if_v = False, False
             if "\\h" in sys.argv:
                 if_h = True
             if "\\v" in sys.argv:
                 if_v = True
             daishumao.setglobalvar()
             self.nb.AddPage(cjlists(self.nb, temparg[1], temparg[2], if_h, if_v), "Table %d" % (count))
             count += 1
         alldata.close()
         self.nb.SetSelection(lastselect)