wxpython多窗口调用import模式
打扰了一下办公室大神。需要学习import模式调用。
子窗口程序:(和上次变化不大,还没有扩展)
import wx
import os
import CV2
class inputframe(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self,parent,title='输入信息',size=(480,320))
if __name__=='__main__':
app = wx.App()
SiteFrame = inputframe(parent=None)
SiteFrame.Show()
app.MainLoop()
主窗口程序:采用import
import wx
import os
import CV2
import wininput ####先开头引用
class mainframe(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self,parent,title='主界面',size=(480,320))
self.BeginBtn = wx.Button(self,label='开始',pos=(5,5),size=(80,25))
self.BeginBtn.Bind(wx.EVT_BUTTON,self.openfile)
self.inputBtn= wx.Button(self,label='输入',pos=(105,5),size=(80,25))
self.inputBtn.Bind(wx.EVT_BUTTON,self.inputmsg)
def openfile(self,event):
wildcard = 'All files(*.*)|*.*'
dialog = wx.FileDialog(None,'select',os.getcwd(),'',wildcard,wx.FD_OPEN) #####这个部分新旧版本有变化
if dialog.ShowModal() == wx.ID_OK:
self.FileName.SetValue(dialog.GetPath())
def inputmsg(self,event):
dlg=wininput.inputframe(self)
dlg.Show()
####这边可以调用子窗口内部函数。成功,没有黑框框。
if __name__=='__main__':
app = wx.App()
SiteFrame = mainframe(parent=None)
SiteFrame.Show()
app.MainLoop()