我正在尝试打印到 wxpython 中的特定选项卡式面板,但我下面的代码似乎只是打印到第三个(运行作业)选项卡面板窗口,我不知道为什么。我想打印第二个(QueueList)TAB 面板。
import wx
import sys
global queueList
queueList = []
class ScrolledWindow(wx.Frame):
def __init__(self, parent, id, title):
#global panel1
wx.Frame.__init__(self, parent, id, title, size=(800, 700))
self.tabbed = wx.Notebook(self, -1, style=(wx.NB_TOP))
self.panel1 = wx.Panel(self.tabbed, -1)
self.panel2 = wx.Panel(self.tabbed, -1)
self.panel3 = wx.Panel(self.tabbed, -1)
self.tabbed.AddPage(self.panel1, "Submit Job")
self.tabbed.AddPage(self.panel2, "Queue")
self.tabbed.AddPage(self.panel3, "Running Jobs")
self.CreateStatusBar()
menuBar = wx.MenuBar()
menu = wx.Menu()
self.SetMenuBar(menuBar)
self.Centre()
self.submit(self)
self.queue(self)
self.running(self)
def submit(self, event):
self.Show()
dt1 = MyFileDropTarget(self)
self.tc_files = wx.TextCtrl(self.panel1, wx.ID_ANY, pos=(42, 120), size=(500, 25))
self.tc_files.SetDropTarget(dt1)
self.buttonGo = wx.Button(self.panel1, -1, "Submit", pos=(90,530))
self.buttonGo.Bind(wx.EVT_BUTTON, self.submit1)
self.buttonClose = wx.Button(self.panel1, -1, "Quit", pos=(195,530))
self.buttonClose.Bind(wx.EVT_BUTTON, self.OnClose)
outputtxt3 = '''Drag & Drop Folder of Packages to Verify'''
wx.StaticText(self.panel1, -1, outputtxt3, (33, 64), style=wx.ALIGN_CENTRE)
def notify(self, indir):
"""Update file in testcontrol after drag and drop"""
self.tc_files.SetValue(indir[0])
global indirTemp
indirTemp = indir
def submit1(self, edit):
list1 = '\n'.join(indirTemp)
queueList.append(list1)
print queueList
wx.MessageBox('Job Submitted')
def queue(self, event):
self.Show()
self.buttonClose2 = wx.Button(self.panel2, -1, "Quit", pos=(195,170))
self.buttonClose2.Bind(wx.EVT_BUTTON, self.OnClose)
global log2
log2 = wx.TextCtrl(self.panel2, -1, pos=(35, 210), size=(720,400),
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self.redir2=RedirectText(log2)
sys.stdout=self.redir2
def showQueue(self, edit):
global queueList
print queueList
def running(self, event):
self.Show()
self.buttonClose3 = wx.Button(self.panel3, -1, "Quit", pos=(195,170))
self.buttonClose3.Bind(wx.EVT_BUTTON, self.OnClose)
global log3
log3 = wx.TextCtrl(self.panel3, -1, pos=(35, 210), size=(720,400),
style = wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
self.redir3=RedirectText(log3)
sys.stdout=self.redir3
def go3(self, edit):
print "do something"
def OnClose(self, e):
self.Close(True)
class MyFileDropTarget(wx.FileDropTarget):
""""""
def __init__(self, window):
wx.FileDropTarget.__init__(self)
self.window = window
def OnDropFiles(self, x, y, filenames):
self.window.notify(filenames)
class RedirectText:
def __init__(self,aWxTextCtrl):
self.out=aWxTextCtrl
def write(self,string):
self.out.WriteText(string)
app = wx.App()
ScrolledWindow(None, -1, 'Application')
app.MainLoop()