欢迎光临散文网 会员登陆 & 注册

wxpython多个窗口调用(II)-简单粗暴,可行但有问题

2020-03-24 18:40 作者:一心想当网红的李老师  | 我要投稿

首先设计两个窗口

###winmain.py

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):

        os.system("python wininput.py")  

###简单粗暴的调用wininput,可以出界面,但是又黑框

        

if __name__=='__main__':

    app = wx.App()

    SiteFrame = mainframe(parent=None)

    SiteFrame.Show()

    app.MainLoop()


####wininput.py

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()


wxpython多个窗口调用(II)-简单粗暴,可行但有问题的评论 (共 条)

分享到微博请遵守国家法律