add close confirm memu and another way to stop music playing after close

master
hnu202111020428 3 years ago
parent ac2c0d1bf4
commit 6cfb5e8484

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 MiB

After

Width:  |  Height:  |  Size: 204 KiB

@ -72,20 +72,12 @@ class MainFrame(wx.Frame):
self.music = pygame.mixer.music self.music = pygame.mixer.music
self.SONG_FINISHED = pygame.USEREVENT + 1 self.SONG_FINISHED = pygame.USEREVENT + 1
if hasattr(sys, "frozen") and getattr(sys, "frozen") == "windows_exe":
exeName = win32api.GetModuleFileName(win32api.GetModuleHandle(None))
icon = wx.Icon(exeName, wx.BITMAP_TYPE_ANY)
else :
icon = wx.Icon('resources/music.png', wx.BITMAP_TYPE_ANY) icon = wx.Icon('resources/music.png', wx.BITMAP_TYPE_ANY)
self.SetIcon(icon) # 以下可以添加各类控件 self.SetIcon(icon)
pass
''' # 下载音乐面板 self.Bind(wx.EVT_CLOSE, self.OnClose)
self.down_music_panel = None
self.input_url_text_ctrl = None # 输入的下载路径
self.down_button = None # 下载按钮
self.draw_down_music_panel()'''
def get_path_by_name(self, file_name): def get_path_by_name(self, file_name):
''' '''
@ -427,10 +419,17 @@ class MainFrame(wx.Frame):
with open(write_path, 'wb') as img: with open(write_path, 'wb') as img:
img.write(cover) img.write(cover)
def OnClose(self, evt):
'''关闭窗口事件函数'''
dlg = wx.MessageDialog(None, u'确定要关闭本窗口?', u'操作提示', wx.YES_NO | wx.ICON_QUESTION)
if(dlg.ShowModal() == wx.ID_YES):
self.Destroy()
self.music.stop()
if __name__ == "__main__": if __name__ == "__main__":
app = wx.App() app = wx.App()
frame = MainFrame() frame = MainFrame()
frame.Show(True) frame.Show(True)
app.MainLoop() app.MainLoop()
wx.Exit() #wx.Exit()
Loading…
Cancel
Save