article

Saturday, May 28, 2016

wxpython dialogs About dialog box

wxpython dialogs About dialog box

In order to create an about dialog box we must create two objects. A wx.AboutDialogInfo and a wx.AboutBox.


 
import wx


class Example(wx.Frame):
    
    def __init__(self, *args, **kwargs):
        super(Example, self).__init__(*args, **kwargs) 
            
        self.InitUI() #call function def InitUI(self):
        
    def InitUI(self):    

        menubar = wx.MenuBar()
        help = wx.Menu()
        help.Append(100, '&About')
        self.Bind(wx.EVT_MENU, self.OnAboutBox, id=100) #bind menu and call function def OnAboutBox(self, e):
        menubar.Append(help, '&Help')
        self.SetMenuBar(menubar)

        self.SetSize((300, 200)) #form size
        self.SetTitle('About dialog box') #form title
        self.Centre() #form center
        self.Show(True) #show form

    def OnAboutBox(self, e):
        
        description = """Neque porro quisquam est qui dolore 
orem ipsum quia dolor sit amet, consectetur, adipisci  
ue porro quisquam est qui dolore 
ipsum quia dolor sit amet, consectetur, adipisci velit..
"""

        licence = """eque porro quisquam est qui do 
em ipsum quia dolor sit amet, consectetur, 
quam est qui dolorem ipsum quia dolor sit amet, consectetur, adipis 
eque porro quisquam est qui dolorem ipsu

uia dolor sit amet, consectetur, adipisci , 
eque porro quisquam est qui dolorem ipsum 
ia dolor sit amet, consectet 
lorem ipsum quia dolor sit amet, consectetur, adi"""

        #The first thing to do is to create a wx.AboutDialogInfo object. The constructor is empty.
        #It does not taky any parameters.
        info = wx.AboutDialogInfo()

        info.SetIcon(wx.Icon('icon_folder.png', wx.BITMAP_TYPE_PNG))
        info.SetName('About dialog box')
        info.SetVersion('1.0')
        info.SetDescription(description)
        info.SetCopyright('(C) 2016 - 2017 tutorial1.101')
        info.SetWebSite('http://tutorial101.blogspot.com/')
        info.SetLicence(licence)
        info.AddDeveloper('Tutorial101')
        info.AddDocWriter('Tutorial101')
        info.AddArtist('Tutorial101')
        info.AddTranslator('Tutorial101')
        #The next thing to do is to call all necessary methods upon the created wx.AboutDialogInfo object. wx.AboutBox(info)
        wx.AboutBox(info)


def main():
    
    ex = wx.App()
    Example(None)
    ex.MainLoop()    


if __name__ == '__main__':
    main()

Related Post