2 番目のパネルで情報を展開しようとしています (ニュースを見ているときに画面の下部または上部にどのように表示されるかなど、情報は常にスムーズに展開されます)。それを除いて、私のコードでは、この別のパネルが出てきて、さまざまな情報を展開する複数の行が必要です。これを行う効率的な方法はありますか?私のコードは機能しますが、文字がスムーズに表示されず、最終的に一部の文字がちらつき始めます。
import time
import wx
class MainFrame(wx.Frame):
def __init__(self,parent):
wx.Frame.__init__(self,parent, title = 'Main Frame', size = (680,330))
self.Center()
self.panel = wx.Panel(self,size = (680,330))
self.pnl1 = wx.Panel(self.panel, size = (680,330))
self.pnl1.Show()
self.pnl1.SetBackgroundColour(wx.Colour(red= 150, green= 0, blue= 0))
my_label = wx.StaticText(self.pnl1, label = 'Click on this')
font = wx.Font(14, wx.MODERN, wx.NORMAL, wx.BOLD)
my_label.SetFont(font)
my_label.Center()
my_label.Bind(wx.EVT_LEFT_UP, self.func)
#----------------------------------------------------------------------
self.count1 = 0
self.count2 = 0
self.count3 = 0
self.count4 = 0
self.pnl2 = wx.Panel(self.panel, size=(800,300))
self.pnl2.Hide()
self.pnl2.SetBackgroundColour(wx.Colour(red= 0, green= 190, blue= 0))
self.lbl1 = ' Data ' * 10
self.my_str1 = ''
self.lbl2 = ' Info ' * 10
self.my_str2 = ''
self.lbl3 = ' bla bla ' * 10
self.my_str3 = ''
self.lbl4 = ' names ' * 10
self.my_str4 = ''
self.count1 = len(self.lbl1) - 1
self.count2 = len(self.lbl2) - 1
self.count3 = len(self.lbl3) - 1
self.count4 = len(self.lbl4) - 1
self.timer1 = wx.Timer(self)
self.timer1.Start(200)
self.Bind(wx.EVT_TIMER, self.OnTimer1, self.timer1)
self.timer2 = wx.Timer(self)
self.timer2.Start(200)
self.Bind(wx.EVT_TIMER, self.OnTimer2, self.timer2)
self.timer3 = wx.Timer(self)
self.timer3.Start(200)
self.Bind(wx.EVT_TIMER, self.OnTimer3, self.timer3)
self.timer4 = wx.Timer(self)
self.timer4.Start(200)
self.Bind(wx.EVT_TIMER, self.OnTimer4, self.timer4)
self.font = wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL)
#----------------------------------------------------------------------
def func(self, event):
self.pnl1.Hide()
self.pnl2.Show()
def OnTimer1(self,event):
if self.count1 < 0:
self.count1 = len(self.lbl1) - 1
self.my_str1 = ''
if self.count1 >= 0:
self.my_str1 = self.lbl1[self.count1] + self.my_str1
self.my_label1 = wx.StaticText(self.pnl2, label = self.my_str1, pos = (0,0))
self.my_label1.SetFont(self.font)
self.count1 = self.count1 - 1
def OnTimer2(self,event):
if self.count2 < 0:
self.count2 = len(self.lbl2) - 1
self.my_str2 = ''
if self.count2 >= 0:
self.my_str2 = self.lbl2[self.count2] + self.my_str2
self.my_label2 = wx.StaticText(self.pnl2, label = self.my_str2 , pos=(0,40))
self.my_label2.SetFont(self.font)
self.count2 = self.count2 - 1
def OnTimer3(self,event):
if self.count3 < 0:
self.count3 = len(self.lbl3) - 1
self.my_str3 = ''
if self.count3 >= 0:
self.my_str3 = self.lbl3[self.count3] + self.my_str3
self.my_label3 = wx.StaticText(self.pnl2, label = self.my_str3 , pos=(0,80))
self.my_label3.SetFont(self.font)
self.count3 = self.count3 - 1
def OnTimer4(self,event):
if self.count4 < 0:
self.count4 = len(self.lbl4) - 1
self.my_str4 = ''
if self.count4 >= 0:
self.my_str4 = self.lbl4[self.count4] + self.my_str4
self.my_label4 = wx.StaticText(self.pnl2, label = self.my_str4 , pos=(0,120))
self.my_label4.SetFont(self.font)
self.count4 = self.count4 - 1
#----------------------------------------------------------------------
#run code
if __name__ == '__main__':
app = wx.App(False)
frame = MainFrame(None)
frame.Show(True)
app.MainLoop()