def setSkipInterval(self, increase=True, sec=None): if sec == None: sec = settings.getSkipInterval()[0] idx = settings.skipInterval.index(sec) if increase == True: if idx < len(settings.skipInterval)-1: settings.setSkipInterval(settings.skipInterval[idx+1]) else: if idx > 0: settings.setSkipInterval(settings.skipInterval[idx-1]) strVal = settings.getSkipInterval()[1] globalVars.app.hMainView.menu.SetMenuLabel("SKIP", strVal+" "+_("進む")) globalVars.app.hMainView.menu.SetMenuLabel("REVERSE_SKIP", strVal+" "+_("戻る")) globalVars.app.hMainView.notification.show(strVal + _("スキップ"), 2) globalVars.app.say(strVal, interrupt=True)
def setSkipInterval(self, increase=True, sec=None): if sec == None: sec = settings.getSkipInterval()[0] idx = settings.skipInterval.index(sec) if increase == True: if idx < len(settings.skipInterval) - 1: settings.setSkipInterval(settings.skipInterval[idx + 1]) else: if idx > 0: settings.setSkipInterval(settings.skipInterval[idx - 1]) strVal = settings.getSkipInterval()[1] globalVars.app.hMainView.menu.hOperationMenu.SetLabel( menuItemsStore.getRef("SKIP"), strVal + " " + _("進む")) globalVars.app.hMainView.menu.hOperationMenu.SetLabel( menuItemsStore.getRef("REVERSE_SKIP"), strVal + " " + _("戻る"))
def OnMenuSelect(self, event): """メニュー項目が選択されたときのイベントハンドら。""" #ショートカットキーが無効状態のときは何もしない if not self.parent.shortcutEnable: event.Skip() return selected = event.GetId() #メニュー識別しの数値が出る if selected == menuItemsStore.getRef("FILE_OPEN"): d = views.mkOpenDialog.Dialog("fileOpenDialog") d.Initialize(0) #0=ファイルダイアログ rtnCode = d.Show() if rtnCode == d.PLAYLIST: listManager.addItems([d.GetValue()], globalVars.app.hMainView.playlistView) elif rtnCode == d.QUEUE: listManager.addItems([d.GetValue()], globalVars.app.hMainView.queueView) else: return elif selected == menuItemsStore.getRef("DIR_OPEN"): d = views.mkOpenDialog.Dialog("directoryOpenDialog") d.Initialize(1) #1=フォルダダイアログ rtnCode = d.Show() if rtnCode == d.PLAYLIST: listManager.addItems([d.GetValue()], globalVars.app.hMainView.playlistView) elif rtnCode == d.QUEUE: listManager.addItems([d.GetValue()], globalVars.app.hMainView.queueView) else: return elif selected == menuItemsStore.getRef("URL_OPEN"): d = views.mkOpenDialog.Dialog("urlOpenDialog") d.Initialize(2) #2=URLダイアログ rtnCode = d.Show() if rtnCode == d.PLAYLIST: listManager.addItems([d.GetValue()], globalVars.app.hMainView.playlistView) elif rtnCode == d.QUEUE: listManager.addItems([d.GetValue()], globalVars.app.hMainView.queueView) else: return elif selected == menuItemsStore.getRef("M3U_OPEN"): m3uManager.loadM3u() elif selected == menuItemsStore.getRef("NEW_M3U8_SAVE"): m3uManager.saveM3u8() elif selected == menuItemsStore.getRef("M3U8_SAVE"): m3uManager.saveM3u8(globalVars.listInfo.playlistFile) elif selected == menuItemsStore.getRef("M3U_ADD"): m3uManager.loadM3u(None, m3uManager.ADD) elif selected == menuItemsStore.getRef("M3U_CLOSE"): m3uManager.closeM3u() elif selected == menuItemsStore.getRef("EXIT"): self.parent.hFrame.Close() #機能メニューのイベント elif selected >= constants.FILTER_LIST_MENU and selected < constants.FILTER_LIST_MENU + 500: globalVars.filter.get(selected - constants.FILTER_LIST_MENU).setEnable( event.IsChecked()) elif selected == menuItemsStore.getRef("FILTER_SETTING"): d = filterSettingDialog.Dialog(*globalVars.filter.getDic()) d.Initialize() if d.Show() == wx.ID_CANCEL: return globalVars.filter.loadDic(*d.GetValue()) elif selected == menuItemsStore.getRef("SET_SLEEPTIMER"): globalVars.sleepTimer.set() elif selected == menuItemsStore.getRef("SET_EFFECTOR"): effector.effector() elif selected == menuItemsStore.getRef("SET_CURSOR_PLAYING"): if globalVars.eventProcess.playingList == constants.PLAYLIST: p = self.parent.playlistView p.Focus(p.getPointer()) p.Select(-1, 0) p.Select(p.getPointer()) else: globalVars.app.hMainView.notification.show( _("プレイリスト上の項目を再生していません。"), 2) elif selected == menuItemsStore.getRef("ABOUT_PLAYING"): if globalVars.eventProcess.playingList == constants.PLAYLIST: listManager.infoDialog(listManager.getTuple( constants.PLAYLIST)) else: listManager.infoDialog(globalVars.listInfo.playingTmp) elif selected == menuItemsStore.getRef("SHOW_NET_CONTROLLER"): globalVars.lampController.showController() elif selected == menuItemsStore.getRef("SHOW_NET_FILE_MANAGER"): netFileManager.run() # 操作メニューのイベント elif selected == menuItemsStore.getRef("PLAY_PAUSE"): globalVars.eventProcess.playButtonControl() elif selected == menuItemsStore.getRef("STOP"): globalVars.eventProcess.stop() elif selected == menuItemsStore.getRef("PREVIOUS_TRACK"): globalVars.eventProcess.previousBtn() elif selected == menuItemsStore.getRef("NEXT_TRACK"): globalVars.eventProcess.nextFile(button=True) elif selected == menuItemsStore.getRef("VOLUME_100"): globalVars.eventProcess.changeVolume(vol=100) elif selected == menuItemsStore.getRef("VOLUME_UP"): globalVars.eventProcess.changeVolume(+1) elif selected == menuItemsStore.getRef("VOLUME_DOWN"): globalVars.eventProcess.changeVolume(-1) elif selected == menuItemsStore.getRef("MUTE"): globalVars.eventProcess.mute() elif selected == menuItemsStore.getRef("FAST_FORWARD"): globalVars.play.fastForward() elif selected == menuItemsStore.getRef("REWIND"): globalVars.play.rewind() elif selected == menuItemsStore.getRef("SAY_TIME"): pos = globalVars.play.getPosition() if pos == -1: time = _("情報がありません") else: hour = pos // 3600 min = (pos - hour * 3600) // 60 sec = int(pos - hour * 3600 - min * 60) if hour == 0: sHour = "" else: sHour = str(int(hour)) + _("時間") + " " if min == 0: sMin = "" else: sMin = str(int(min)) + _("分") + " " time = sHour + sMin + str(int(sec)) + _("秒") globalVars.app.say(time) elif selected == menuItemsStore.getRef("SKIP"): globalVars.eventProcess.skip(settings.getSkipInterval()[0]) elif selected == menuItemsStore.getRef("REVERSE_SKIP"): globalVars.eventProcess.skip(settings.getSkipInterval()[0], False) elif selected == menuItemsStore.getRef("SKIP_INTERVAL_INCREASE"): globalVars.eventProcess.setSkipInterval() elif selected == menuItemsStore.getRef("SKIP_INTERVAL_DECREASE"): globalVars.eventProcess.setSkipInterval(False) elif selected == menuItemsStore.getRef("REPEAT_LOOP"): globalVars.eventProcess.repeatLoopCtrl() elif selected == menuItemsStore.getRef("REPEAT_LOOP_NONE"): globalVars.eventProcess.repeatLoopCtrl(0) elif selected == menuItemsStore.getRef("RL_REPEAT"): globalVars.eventProcess.repeatLoopCtrl(1) elif selected == menuItemsStore.getRef("RL_LOOP"): globalVars.eventProcess.repeatLoopCtrl(2) elif selected == menuItemsStore.getRef("SHUFFLE"): globalVars.eventProcess.shuffleSw() elif selected == menuItemsStore.getRef("MANUAL_SONG_FEED"): globalVars.eventProcess.setSongFeed() elif selected >= constants.DEVICE_LIST_MENU and selected < constants.DEVICE_LIST_MENU + 500: if selected == constants.DEVICE_LIST_MENU: globalVars.play.setDevice(PLAYER_DEFAULT_SPEAKER) else: globalVars.play.setDevice(selected - constants.DEVICE_LIST_MENU) elif selected >= constants.PLAYLIST_HISTORY and selected < constants.PLAYLIST_HISTORY + 20: m3uManager.loadM3u( globalVars.m3uHistory.getList()[selected - constants.PLAYLIST_HISTORY]) elif selected == menuItemsStore.getRef("SET_STARTUPLIST"): startupListSetter.run() elif selected == menuItemsStore.getRef("FILE_ASSOCIATE"): fileAssocDialog.assocDialog() elif selected == menuItemsStore.getRef("SET_SENDTO"): sendToManager.sendToCtrl("LAMP") elif selected == menuItemsStore.getRef("SET_KEYMAP"): if self.setKeymap("MainView", _("ショートカットキーの設定"), filter=keymap.KeyFilter().SetDefault( False, False)): #ショートカットキーの変更適用とメニューバーの再描画 self.parent.menu.InitShortcut() self.parent.menu.ApplyShortcut(self.parent.hFrame) self.parent.menu.Apply(self.parent.hFrame) elif selected == menuItemsStore.getRef("SET_HOTKEY"): if self.setKeymap("HOTKEY", _("グローバルホットキーの設定"), self.parent.hotkey, filter=self.parent.hotkey.filter): #変更適用 self.parent.hotkey.UnSet("HOTKEY", self.parent.hFrame) self.parent.applyHotKey() elif selected == menuItemsStore.getRef("ENVIRONMENT"): d = setting_dialog.settingDialog("environment_dialog") d.Initialize() d.Show() elif selected == menuItemsStore.getRef("HELP"): if os.path.exists("./readme.txt"): subprocess.Popen("start ./readme.txt", shell=True) else: dialog(_("ヘルプ"), _("ヘルプファイルが見つかりません。")) elif selected == menuItemsStore.getRef("CHECK_UPDATE"): update.checkUpdate() elif selected == menuItemsStore.getRef("VERSION_INFO"): versionDialog.versionDialog()
def Apply(self, target): """指定されたウィンドウに、メニューを適用する。""" #メニュー内容をいったんクリア self.hMenuBar = wx.MenuBar() #メニューの大項目を作る self.hFileMenu = wx.Menu() self.hFunctionMenu = wx.Menu() self.hPlaylistMenu = wx.Menu() self.hOperationMenu = wx.Menu() self.hSettingsMenu = wx.Menu() self.hHelpMenu = wx.Menu() #ファイルメニューの中身 self.RegisterMenuCommand(self.hFileMenu, [ "FILE_OPEN", "DIR_OPEN", "URL_OPEN", "M3U_OPEN", "NEW_M3U8_SAVE", "M3U8_SAVE", "M3U_ADD", "M3U_CLOSE", "EXIT" ]) self.hFileMenu.Enable(menuItemsStore.getRef("M3U8_SAVE"), False) self.hFileMenu.Enable(menuItemsStore.getRef("M3U_CLOSE"), False) #機能メニューの中身 #フィルタ設定 self.hFilterSubMenu = wx.Menu() self.RegisterMenuCommand(self.hFilterSubMenu, ["FILTER_SETTING"]) self.RegisterMenuCommand(self.hFunctionMenu, "FILTER_SUB", None, self.hFilterSubMenu) self.RegisterMenuCommand(self.hFunctionMenu, [ "SET_SLEEPTIMER", "SET_EFFECTOR", "SET_CURSOR_PLAYING", "ABOUT_PLAYING", "SHOW_NET_CONTROLLER", "SHOW_NET_FILE_MANAGER" ]) self.hFunctionMenu.Enable(menuItemsStore.getRef("ABOUT_PLAYING"), False) self.hFunctionMenu.Enable(menuItemsStore.getRef("SET_CURSOR_PLAYING"), False) # プレイリストメニューの中身 self.RegisterMenuCommand(self.hPlaylistMenu, ["SET_STARTUPLIST", "PLAYLIST_HISTORY_LABEL"]) self.hPlaylistMenu.Enable( menuItemsStore.getRef("PLAYLIST_HISTORY_LABEL"), False) #操作メニューの中身 self.RegisterMenuCommand( self.hOperationMenu, ["PLAY_PAUSE", "STOP", "PREVIOUS_TRACK", "NEXT_TRACK"]) skipRtn = settings.getSkipInterval() self.RegisterMenuCommand( self.hOperationMenu, { "SKIP": skipRtn[1] + " " + _("進む"), "REVERSE_SKIP": skipRtn[1] + " " + _("戻る") }) #スキップ間隔設定 self.hSkipIntervalSubMenu = wx.Menu() self.RegisterMenuCommand( self.hSkipIntervalSubMenu, ["SKIP_INTERVAL_INCREASE", "SKIP_INTERVAL_DECREASE"]) self.RegisterMenuCommand(self.hOperationMenu, "SET_SKIP_INTERVAL_SUB", None, self.hSkipIntervalSubMenu) #音量 self.hVolumeSubMenu = wx.Menu() self.RegisterMenuCommand( self.hVolumeSubMenu, ["VOLUME_100", "VOLUME_UP", "VOLUME_DOWN", "MUTE"]) self.RegisterMenuCommand(self.hOperationMenu, "SET_VOLUME_SUB", None, self.hVolumeSubMenu) #リピート・ループ self.hRepeatLoopSubMenu = wx.Menu() self.RegisterMenuCommand(self.hOperationMenu, "SET_REPEAT_LOOP_SUB", None, self.hRepeatLoopSubMenu) self.RegisterRadioMenuCommand(self.hRepeatLoopSubMenu, "REPEAT_LOOP_NONE") self.RegisterRadioMenuCommand(self.hRepeatLoopSubMenu, "RL_REPEAT") self.RegisterRadioMenuCommand(self.hRepeatLoopSubMenu, "RL_LOOP") if globalVars.eventProcess.repeatLoopFlag == 1: self.hRepeatLoopSubMenu.Check(menuItemsStore.getRef("RL_REPEAT"), True) elif globalVars.eventProcess.repeatLoopFlag == 2: self.hRepeatLoopSubMenu.Check(menuItemsStore.getRef("RL_LOOP"), True) self.RegisterCheckMenuCommand(self.hOperationMenu, "SHUFFLE") if globalVars.eventProcess.shuffleCtrl != None: self.hOperationMenu.Check(menuItemsStore.getRef("SHUFFLE"), True) self.RegisterCheckMenuCommand(self.hOperationMenu, "MANUAL_SONG_FEED") # 設定メニューの中身 self.hDeviceSubMenu = wx.Menu() self.RegisterMenuCommand(self.hSettingsMenu, "SET_DEVICE_SUB", _("再生出力先の変更"), self.hDeviceSubMenu) self.RegisterMenuCommand(self.hSettingsMenu, [ "FILE_ASSOCIATE", "SET_SENDTO", "SET_KEYMAP", "SET_HOTKEY", "ENVIRONMENT" ]) self.hPlaylistMenu.Enable(menuItemsStore.getRef("SET_STARTUPLIST"), False) #ヘルプメニューの中身 self.RegisterMenuCommand(self.hHelpMenu, ["HELP", "CHECK_UPDATE", "VERSION_INFO"]) #メニューバーの生成 self.hMenuBar.Append(self.hFileMenu, _("ファイル(&F)")) self.hMenuBar.Append(self.hFunctionMenu, _("機能(&U)")) self.hMenuBar.Append(self.hPlaylistMenu, _("プレイリスト(&P)")) self.hMenuBar.Append(self.hOperationMenu, _("操作(&O)")) self.hMenuBar.Append(self.hSettingsMenu, _("設定(&S)")) self.hMenuBar.Append(self.hHelpMenu, _("ヘルプ(&H)")) target.SetMenuBar(self.hMenuBar) # イベント target.Bind(wx.EVT_MENU_OPEN, self.event.OnMenuOpen)
def OnMenuSelect(self, event): """メニュー項目が選択されたときのイベントハンドら。""" #ショートカットキーが無効状態のときは何もしない if not self.parent.shortcutEnable: event.Skip() return selected = event.GetId() #メニュー識別しの数値が出る if selected == menuItemsStore.getRef("FILE_OPEN"): dialog = views.mkOpenDialog.Dialog() dialog.Initialize(0) #0=ファイルダイアログ rtnCode = dialog.Show() if rtnCode == dialog.PLAYLIST: globalVars.playlist.addFiles([dialog.GetValue()]) elif rtnCode == dialog.QUEUE: globalVars.queue.addFiles([dialog.GetValue]) else: return elif selected == menuItemsStore.getRef("DIR_OPEN"): dialog = views.mkOpenDialog.Dialog() dialog.Initialize(1) #1=フォルダダイアログ rtnCode = dialog.Show() if rtnCode == dialog.PLAYLIST: globalVars.playlist.addFiles([dialog.GetValue()]) elif rtnCode == dialog.QUEUE: globalVars.queue.addFiles([dialog.GetValue()]) else: return elif selected == menuItemsStore.getRef("URL_OPEN"): dialog = views.mkOpenDialog.Dialog() dialog.Initialize(2) #2=URLダイアログ rtnCode = dialog.Show() if rtnCode == dialog.PLAYLIST: globalVars.playlist.addFiles([dialog.GetValue()]) elif rtnCode == dialog.QUEUE: globalVars.queue.addFiles([dialog.GetValue()]) else: return elif selected == menuItemsStore.getRef("M3U_OPEN"): m3uManager.loadM3u() elif selected == menuItemsStore.getRef("NEW_M3U8_SAVE"): m3uManager.saveM3u8() elif selected == menuItemsStore.getRef("M3U8_SAVE"): m3uManager.saveM3u8(globalVars.playlist.playlistFile) elif selected == menuItemsStore.getRef("M3U_ADD"): m3uManager.loadM3u(None, m3uManager.ADD) elif selected == menuItemsStore.getRef("M3U_CLOSE"): m3uManager.closeM3u() elif selected == menuItemsStore.getRef("EXIT"): self.Exit() #機能メニューのイベント elif selected == menuItemsStore.getRef("SET_SLEEPTIMER"): globalVars.sleepTimer.set() elif selected == menuItemsStore.getRef("SET_EFFECTOR"): effector.effector() # 操作メニューのイベント elif selected == menuItemsStore.getRef("PLAY_PAUSE"): globalVars.eventProcess.playButtonControl() elif selected == menuItemsStore.getRef("STOP"): globalVars.eventProcess.stop() elif selected == menuItemsStore.getRef("PREVIOUS_TRACK"): globalVars.eventProcess.previousBtn() elif selected == menuItemsStore.getRef("NEXT_TRACK"): globalVars.eventProcess.nextFile() elif selected == menuItemsStore.getRef("VOLUME_DEFAULT"): globalVars.eventProcess.changeVolume(vol=100) elif selected == menuItemsStore.getRef("VOLUME_UP"): globalVars.eventProcess.changeVolume(+5) elif selected == menuItemsStore.getRef("VOLUME_DOWN"): globalVars.eventProcess.changeVolume(-5) elif selected == menuItemsStore.getRef("MUTE"): globalVars.eventProcess.mute() elif selected == menuItemsStore.getRef("FAST_FORWARD"): globalVars.play.fastForward() elif selected == menuItemsStore.getRef("REWIND"): globalVars.play.rewind() elif selected == menuItemsStore.getRef("SKIP"): globalVars.eventProcess.skip(settings.getSkipInterval()[0]) elif selected == menuItemsStore.getRef("REVERSE_SKIP"): globalVars.eventProcess.skip(settings.getSkipInterval()[0], False) elif selected == menuItemsStore.getRef("SKIP_INTERVAL_INCREASE"): globalVars.eventProcess.setSkipInterval() elif selected == menuItemsStore.getRef("SKIP_INTERVAL_DECREASE"): globalVars.eventProcess.setSkipInterval(False) elif selected == menuItemsStore.getRef("REPEAT_LOOP"): globalVars.eventProcess.repeatLoopCtrl() elif selected == menuItemsStore.getRef("REPEAT_LOOP_NONE"): globalVars.eventProcess.repeatLoopCtrl(0) elif selected == menuItemsStore.getRef("RL_REPEAT"): globalVars.eventProcess.repeatLoopCtrl(1) elif selected == menuItemsStore.getRef("RL_LOOP"): globalVars.eventProcess.repeatLoopCtrl(2) elif selected == menuItemsStore.getRef("SHUFFLE"): globalVars.eventProcess.shuffleSw() elif selected == menuItemsStore.getRef("EXAMPLE"): d = mkDialog.Dialog() d.Initialize("テスト", "これはテストです。", ("テ", "ス", "ト")) r = d.Show() print(r)
def Apply(self, target): """指定されたウィンドウに、メニューを適用する。""" #メニューの大項目を作る self.hFileMenu = wx.Menu() self.hFunctionMenu = wx.Menu() self.hOperationMenu = wx.Menu() self.hHelpMenu = wx.Menu() #ファイルメニューの中身 self.RegisterMenuCommand(self.hFileMenu, "FILE_OPEN", _("ファイルを開く")) self.RegisterMenuCommand(self.hFileMenu, "DIR_OPEN", _("フォルダを開く")) self.RegisterMenuCommand(self.hFileMenu, "URL_OPEN", _("URLを開く")) self.RegisterMenuCommand(self.hFileMenu, "M3U_OPEN", _("プレイリストを開く")) self.RegisterMenuCommand(self.hFileMenu, "NEW_M3U8_SAVE", _("名前を付けてプレイリストを保存")) self.RegisterMenuCommand(self.hFileMenu, "M3U8_SAVE", _("プレイリストを上書き保存")) self.hFileMenu.Enable(menuItemsStore.getRef("M3U8_SAVE"), False) self.RegisterMenuCommand(self.hFileMenu, "M3U_ADD", _("プレイリストから読み込む")) self.RegisterMenuCommand(self.hFileMenu, "M3U_CLOSE", _("プレイリストを閉じる")) self.hFileMenu.Enable(menuItemsStore.getRef("M3U_CLOSE"), False) self.RegisterMenuCommand(self.hFileMenu, "EXIT", _("終了")) #機能メニューの中身 self.RegisterMenuCommand(self.hFunctionMenu, "SET_SLEEPTIMER", _("スリープタイマーを設定")) self.RegisterMenuCommand(self.hFunctionMenu, "SET_EFFECTOR", _("エフェクター")) #操作メニューの中身 self.RegisterMenuCommand(self.hOperationMenu, "PLAY_PAUSE", _("再生 / 一時停止")) self.RegisterMenuCommand(self.hOperationMenu, "STOP", _("停止")) self.RegisterMenuCommand(self.hOperationMenu, "PREVIOUS_TRACK", _("前へ / 頭出し")) self.RegisterMenuCommand(self.hOperationMenu, "NEXT_TRACK", _("次へ")) skipRtn = settings.getSkipInterval() self.RegisterMenuCommand(self.hOperationMenu, "SKIP", skipRtn[1] + " " + _("進む")) self.RegisterMenuCommand(self.hOperationMenu, "REVERSE_SKIP", skipRtn[1] + " " + _("戻る")) #スキップ間隔設定 self.hSetSkipIntervalInOperationMenu = wx.Menu() self.hOperationMenu.AppendSubMenu(self.hSetSkipIntervalInOperationMenu, _("スキップ間隔設定")) self.RegisterMenuCommand(self.hSetSkipIntervalInOperationMenu, "SKIP_INTERVAL_INCREASE", _("間隔を大きくする")) self.RegisterMenuCommand(self.hSetSkipIntervalInOperationMenu, "SKIP_INTERVAL_DECREASE", _("間隔を小さくする")) #音量 self.hVolumeInOperationMenu = wx.Menu() self.hOperationMenu.AppendSubMenu(self.hVolumeInOperationMenu, _("音量")) self.RegisterMenuCommand(self.hVolumeInOperationMenu, "VOLUME_DEFAULT", _("音量を100%に設定")) self.RegisterMenuCommand(self.hVolumeInOperationMenu, "VOLUME_UP", _("音量を上げる")) self.RegisterMenuCommand(self.hVolumeInOperationMenu, "VOLUME_DOWN", _("音量を下げる")) self.RegisterMenuCommand(self.hVolumeInOperationMenu, "MUTE", _("消音に設定")) #リピート・ループ self.hRepeatLoopInOperationMenu = wx.Menu() self.hOperationMenu.AppendSubMenu(self.hRepeatLoopInOperationMenu, _("リピート・ループ") + "\tCtrl+R") self.RegisterRadioItemCommand(self.hRepeatLoopInOperationMenu, "REPEAT_LOOP_NONE", _("解除する")) self.RegisterRadioItemCommand(self.hRepeatLoopInOperationMenu, "RL_REPEAT", _("リピート")) self.RegisterRadioItemCommand(self.hRepeatLoopInOperationMenu, "RL_LOOP", _("ループ")) self.RegisterCheckItemCommand(self.hOperationMenu, "SHUFFLE", _("シャッフル再生")) #ヘルプメニューの中身 self.RegisterMenuCommand(self.hHelpMenu, "EXAMPLE", _("テストダイアログを閲覧")) #メニューバーの生成 self.hMenuBar = wx.MenuBar() self.hMenuBar.Append(self.hFileMenu, _("ファイル")) self.hMenuBar.Append(self.hFunctionMenu, _("機能")) self.hMenuBar.Append(self.hOperationMenu, _("操作")) self.hMenuBar.Append(self.hHelpMenu, _("ヘルプ")) target.SetMenuBar(self.hMenuBar)
def OnMenuSelect(self, event): """メニュー項目が選択されたときのイベントハンドら。""" #ショートカットキーが無効状態のときは何もしない if not self.parent.shortcutEnable: event.Skip() return selected = event.GetId() #メニュー識別しの数値が出る if selected == menuItemsStore.getRef("FILE_OPEN"): dialog = views.mkOpenDialog.Dialog() dialog.Initialize(0) #0=ファイルダイアログ rtnCode = dialog.Show() if rtnCode == dialog.PLAYLIST: globalVars.playlist.addFiles([dialog.GetValue()]) elif rtnCode == dialog.QUEUE: globalVars.queue.addFiles([dialog.GetValue]) else: return elif selected == menuItemsStore.getRef("DIR_OPEN"): dialog = views.mkOpenDialog.Dialog() dialog.Initialize(1) #1=フォルダダイアログ rtnCode = dialog.Show() if rtnCode == dialog.PLAYLIST: globalVars.playlist.addFiles([dialog.GetValue()]) elif rtnCode == dialog.QUEUE: globalVars.queue.addFiles([dialog.GetValue()]) else: return elif selected == menuItemsStore.getRef("URL_OPEN"): dialog = views.mkOpenDialog.Dialog() dialog.Initialize(2) #2=URLダイアログ rtnCode = dialog.Show() if rtnCode == dialog.PLAYLIST: globalVars.playlist.addFiles([dialog.GetValue()]) elif rtnCode == dialog.QUEUE: globalVars.queue.addFiles([dialog.GetValue()]) else: return elif selected == menuItemsStore.getRef("M3U_OPEN"): m3uManager.loadM3u() elif selected == menuItemsStore.getRef("NEW_M3U8_SAVE"): m3uManager.saveM3u8() elif selected == menuItemsStore.getRef("M3U8_SAVE"): m3uManager.saveM3u8(globalVars.playlist.playlistFile) elif selected == menuItemsStore.getRef("M3U_ADD"): m3uManager.loadM3u(None, m3uManager.ADD) elif selected == menuItemsStore.getRef("M3U_CLOSE"): m3uManager.closeM3u() elif selected == menuItemsStore.getRef("EXIT"): self.Exit() #機能メニューのイベント elif selected == menuItemsStore.getRef("SET_SLEEPTIMER"): globalVars.sleepTimer.set() elif selected == menuItemsStore.getRef("SET_EFFECTOR"): effector.effector() elif selected == menuItemsStore.getRef("SEND_REGIST"): shortCut = os.environ[ "APPDATA"] + "\\Microsoft\\Windows\\SendTo\\" + _( "lampへ送る.lnk") ws = win32com.client.Dispatch("wscript.shell") scut = ws.CreateShortcut(shortCut) scut.TargetPath = sys.argv[0] scut.Save() dialog(_("送るメニューの登録が完了しました。送るメニューから「SOCで文字認識を開始」で実行できます。"), _("完了")) # 操作メニューのイベント elif selected == menuItemsStore.getRef("PLAY_PAUSE"): globalVars.eventProcess.playButtonControl() elif selected == menuItemsStore.getRef("STOP"): globalVars.eventProcess.stop() elif selected == menuItemsStore.getRef("PREVIOUS_TRACK"): globalVars.eventProcess.previousBtn() elif selected == menuItemsStore.getRef("NEXT_TRACK"): globalVars.eventProcess.nextFile() elif selected == menuItemsStore.getRef("VOLUME_DEFAULT"): globalVars.eventProcess.changeVolume(vol=100) elif selected == menuItemsStore.getRef("VOLUME_UP"): globalVars.eventProcess.changeVolume(+5) elif selected == menuItemsStore.getRef("VOLUME_DOWN"): globalVars.eventProcess.changeVolume(-5) elif selected == menuItemsStore.getRef("MUTE"): globalVars.eventProcess.mute() elif selected == menuItemsStore.getRef("FAST_FORWARD"): globalVars.play.fastForward() elif selected == menuItemsStore.getRef("REWIND"): globalVars.play.rewind() elif selected == menuItemsStore.getRef("SKIP"): globalVars.eventProcess.skip(settings.getSkipInterval()[0]) elif selected == menuItemsStore.getRef("REVERSE_SKIP"): globalVars.eventProcess.skip(settings.getSkipInterval()[0], False) elif selected == menuItemsStore.getRef("SKIP_INTERVAL_INCREASE"): globalVars.eventProcess.setSkipInterval() elif selected == menuItemsStore.getRef("SKIP_INTERVAL_DECREASE"): globalVars.eventProcess.setSkipInterval(False) elif selected == menuItemsStore.getRef("REPEAT_LOOP"): globalVars.eventProcess.repeatLoopCtrl() elif selected == menuItemsStore.getRef("REPEAT_LOOP_NONE"): globalVars.eventProcess.repeatLoopCtrl(0) elif selected == menuItemsStore.getRef("RL_REPEAT"): globalVars.eventProcess.repeatLoopCtrl(1) elif selected == menuItemsStore.getRef("RL_LOOP"): globalVars.eventProcess.repeatLoopCtrl(2) elif selected == menuItemsStore.getRef("SHUFFLE"): globalVars.eventProcess.shuffleSw() elif selected == menuItemsStore.getRef("EXAMPLE"): d = mkDialog.Dialog() d.Initialize("テスト", "これはテストです。", ("テ", "ス", "ト")) r = d.Show()