wxpython 链接并打开新窗口应用程序
我有一个对话框应用程序和一个框架应用程序(两个文件),我希望它们彼此交互。
我想单击对话框应用程序上的按钮,它将关闭对话框应用程序并打开我的框架应用程序。知道我该如何实现这一目标吗?
我的对话框应用程序非常简单,看起来像这样
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()
谢谢
I have one dialog app and one frame app (two files) and I want them to interact with each other.
I would like to to click a button on my dialog app and it will close the dialog app and open my frame app. Any idea how I can achieve this?
my dialog app is very simple and looks something like this
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()
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在 Dialog 应用程序周围创建一个框架,这样它就不会表现得很奇怪。没有人说过您必须显示它:
在 idk1 方法中,调用 self.EndModal(1) 以返回已知值。现在,在某些时候,您必须弄清楚如何彻底销毁您的应用程序,但我认为您可以从这里获得它!
You'll want to create a frame around your Dialog app so it doesn't act strangely. No one ever said you have to Show it:
In your idk1 method, call self.EndModal(1) to return a known value. Now at some point you'll have to figure out how to cleanly Destroy your apps, but I think you can get it from here!