Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/343.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wxpython链接并打开新窗口应用程序_Python_User Interface_Wxpython - Fatal编程技术网

wxpython链接并打开新窗口应用程序

wxpython链接并打开新窗口应用程序,python,user-interface,wxpython,Python,User Interface,Wxpython,我有一个对话框应用程序和一个框架应用程序(两个文件),我希望它们能够相互交互 我想单击对话框应用程序上的按钮,它将关闭对话框应用程序并打开我的框架应用程序。你知道我怎样才能做到这一点吗 我的dialog应用程序非常简单,看起来像这样 class ThisClass(wx.Dialog): def __init__(self, parent, id, title): wx.Dialog.__init__(self, parent, id, title, size=(APP_

我有一个对话框应用程序和一个框架应用程序(两个文件),我希望它们能够相互交互

我想单击对话框应用程序上的按钮,它将关闭对话框应用程序并打开我的框架应用程序。你知道我怎样才能做到这一点吗

我的dialog应用程序非常简单,看起来像这样

class ThisClass(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, size=(APP_SIZE_X, APP_SIZE_Y))

        wx.Button(self, 1, 'Start Monitoring', (50, 20), (120,-1))
        wx.Button(self, 2, 'View Data', (50, 70), (120, -1))
        wx.Button(self, 3, 'Close', (50, 120), (120, -1))


        self.Bind(wx.EVT_BUTTON, self.idk1, id=1)
        self.Bind(wx.EVT_BUTTON, self.idk2, id=2)
        self.Bind(wx.EVT_BUTTON, self.clickClose, id=3)

        self.Centre()
        self.ShowModal()

    def idk1(self,event):
        #i want to launch another app here if 
        #this (Start Monitoring) button is pressed

    def idk2(self, event):
        self.Close(True)

    def clickClose(self, event):
        self.Close(True)

app = wx.App(0)
MyButtons(None, -1, 'buttons.py')
app.MainLoop()

谢谢

您需要在对话框应用程序周围创建一个框架,这样它就不会出现奇怪的行为。没有人说过你必须展示它:

class ThisFrame(wx.Frame):
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(0, 0))
        dlg = ThisClass(self, -1, "buttons.py")

        if dlg.ShowModal() == 1:
            from otherfile import MyFrame
            mf = MyFrame(self, "MyFrame")
            mf.Show()

app = wx.App(0)
frame = ThisFrame(None, 'ThisFrame')
app.MainLoop()

在idk1方法中,调用self.EndModal(1)返回一个已知值。现在,在某个时候,你将不得不想出如何彻底销毁你的应用程序,但我认为你可以从这里得到它

您好,谢谢您的回复。我做了一些和你建议的相似的事情,我设法让我的MyFrame(来自其他文件)弹出,但我无法与它交互。这些小部件在其他文件中不起作用,请创建一个执行app=MyFrame(0)和app.MainLoop()的函数,然后调用该函数。这对我很管用。