错误运行TIME.NO其他DEF工作除 INIT
import wx
import os
from spectral import *
class Frame(wx.Frame):
def __init__(self, title):
wx.Frame.__init__(self, None, title=title, size=(1000,70),style=wx.MINIMIZE_BOX|wx.CLOSE_BOX|wx.RESIZE_BORDER|wx.SYSTEM_MENU|wx.CAPTION|wx.CLIP_CHILDREN)
self.Bind(wx.EVT_CLOSE, self.OnClose)
panel=wx.Panel(self,-1)
self.button=wx.Button(panel,label="Open",pos=(0,0),size=(50,30))
self.button1=wx.Button(panel,label="Save",pos=(51,0),size=(50,30))
self.button2=wx.Button(panel,label="ROI",pos=(102,0),size=(50,30))
self.button3=wx.Button(panel,label="Tone",pos=(153,0),size=(50,30))
self.slider=wx.Slider(panel,pos=(204,0))
self.button4=wx.Button(panel,label="Header",pos=(305,0),size=(50,30))
self.SetBackgroundColour((11, 11, 11))
self.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver)
self.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave)
self.Bind(wx.EVT_BUTTON, self.OnButtonClick,self.button)
self.filename=""
def OnButtonClick(self,event):
dlg=wx.FileDialog(self,message="Choose a file", defaultDir="",defaultFile="", wildcard="*.*", style=wx.OPEN)
if dlg.ShowModal==wx.ID_OK:
dlg.Destroy()
def onMouseOver(self, event):
self.SetBackgroundColor((179, 179, 179))
self.Refresh()
def onMouseLeave(self, event):
self.SetBackgroundColor((11, 11, 11))
self.Refresh()
def OnClose(self, event):
dlg = wx.MessageDialog(self,
"Do you really want to close BBvw ?",
"Confirm Exit", wx.OK|wx.CANCEL|wx.ICON_QUESTION)
result = dlg.ShowModal()
dlg.Destroy()
if result == wx.ID_OK:
self.Destroy()
app = wx.App(redirect=True)
top = Frame("BBvw")
top.Show()
app.MainLoop()
错误运行TIME.NO其他DEF工作除了INIT.I我认为我遗漏了一些明显的东西。'点'按钮被点击时无法调用错误。
答案 0 :(得分:0)
OnButtonClick()方法正在调用,但您没有正确调用ShowModal。你需要在括号上加上:括号:ShowModal()
那就行了。 OnClose()适合我。鼠标没有,但我不知道为什么。您应该在wxPython邮件列表中询问这些内容。