class FAI(wx.Frame):
.... init stuff ....
self.viewer = wx.ScrolledCanvas(self)
self.viewer.SetScrollbars(1, 1, 500, 500)
self.CreateStatusBar()
self.inside_view = wx.BoxSizer()
self.viewer.SetSizer(self.inside_view)
def im_load(self, event): # wxGlade: MyFrame.<event_handler>
dlg = wx.FileDialog(None)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
print("%s" % dlg.GetPath())
image = wx.StaticBitmap(
self.viewer, wx.ID_ANY, wx.Bitmap(path, wx.BITMAP_TYPE_ANY)
)
self.inside_view.Add(image)
self.Refresh()
dlg.Destroy()
class MyApp(wx.App):
......
答案 0 :(得分:0)
从我这边回答: 使用
固定 self.inside_view.Clear(delete_windows=True)
self.inside_view.Add(image)
delete_windows必须为True