私はwxPythonサウンドボードを作成していて、About Boxを実装する方法が不思議でした。目的は、wxPythonの[ファイル]メニューの[バージョン情報]ボタンを押してAboutボックスを生成することです。wxPython:aboutボックスを追加する。
これは、これまでの私のコードです:
import wx
import os
import pygame
pygame.init()
##SOUNDS##
goliathwav = pygame.mixer.Sound("goliath.wav")
channelopen = pygame.mixer.Sound("channelopen.wav")
##SOUNDS##
class windowClass(wx.Frame):
def __init__(self, *args, **kwargs):
super(windowClass,self).__init__(*args,**kwargs)
self.__basicGUI()
def __basicGUI(self):
panel = wx.Panel(self)
menuBar = wx.MenuBar()
fileButton = wx.Menu()
editButton = wx.Menu()
aboutBox = wx.MessageDialog(None, "Created by Kommander000(cyrex)")
answer=aboutBox.ShowModal()
aboutBox.Destroy()
aboutButton = wx.Menu()
exitItem = fileButton.Append(wx.ID_EXIT, 'Exit','status msg...')
aboutItem = aboutButton.Append(wx.ID_ABOUT, "About")
menuBar.Append(fileButton, 'File')
menuBar.Append(editButton, 'Edit')
menuBar.Append(aboutButton, 'About this program')
self.SetMenuBar(menuBar)
self.Bind(wx.EVT_MENU, self.__quit, exitItem)
self.Bind(wx.EVT_MENU, self.OnMenuHelpAbout, aboutBox)
self.__sound_dict = { "Goliath" : "goliath.wav",
"Goliath2" : "channelopen.wav"
}
self.__sound_list = sorted(self.__sound_dict.keys())
self.__list = wx.ListBox(panel,pos=(20,20), size=(250,150))
for i in self.__sound_list:
self.__list.Append(i)
self.__list.Bind(wx.EVT_LISTBOX,self.__on_click)
#wx.TextCtrl(panel,pos=(10,10), size=(250,150))
self.SetTitle("Soundboard")
self.Show(True)
def __on_click(self,event):
event.Skip()
name = self.__sound_list[self.__list.GetSelection()]
filename = self.__sound_dict[name]
if filename == "goliath.wav":
print "[ NOW PLAYING ] ... %s" % filename
pygame.mixer.Sound.play(goliathwav)
if filename == "channelopen.wav":
print "[ NOW PLAYING ] ... %s" % filename
pygame.mixer.Sound.play(channelopen)
def __quit(self, e):
self.Close()
def main():
app = wx.App()
windowClass(None, -1, style=wx.MAXIMIZE_BOX | wx.CAPTION | wx.CENTRE)
app.MainLoop()
main()
は、これは私が受けていますエラーです:
self.Bind(wx.EVT_MENU, self.OnMenuHelpAbout, aboutBox)
AttributeError: 'windowClass' object has no attribute 'OnMenuHelpAbout'
任意の提案ですか?再びいつものように
おかげで、
kommander000
をちょっとちょっと支援のための私の男のおかげで。私は助けが必要なときに誰に電話するか知っています。ありがとう、もう一度男、 – kommander0000
私は良いpythonの本やチュートリアルをお勧めしたいと思います。私はいつも周りにいるわけではありません。 –