运行时没有错误。除了初始化之外,没有其他 DEF 工作
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()
运行时没有错误。除了初始化之外,没有其他 DEF 工作。我想我遗漏了一些明显的东西。单击按钮时,'int' 不可调用错误。