self.Bind(wx.EVT_MENU, self.OnPopupProperty, id = self.popupPropery)
# 创建菜单
menu = wx.Menu()
itemStop = wx.MenuItem(menu, self.popupStop, "Stop")
itemProperty = wx.MenuItem(menu, self.popupPropery, 'Property')
menu.AppendItem(itemStop)
menu.AppendItem(itemProperty)
itemProperty.Enable(False)#默认让属性按钮变成无效状态
if itemid == -1:#如果没有选中任何项
itemStop.Enable(False)
else:
itemStop.Enable(False)
itemProperty.Enable(True)
#到这里才弹出菜单
self.PopupMenu(menu)
#最后注意销毁前面创建的菜单
menu.Destroy()
5. 选择文件对话框(FileDialog)
使用起来非常简单:
dlg = wx.FileDialog(self,
message="Yes, select a place ",
wildcard="PNG(*.png)|*.png" ,
style=wx.SAVE
)
savefile = ''
if dlg.ShowModal() == wx.ID_OK:
savefile = dlg.GetPath()
try:
os.remove(self.filename)
except:
pass
self.img.SaveFile(savefile, wx.BITMAP_TYPE_PNG)
self.filename = savefile










