= How to create a gen bitmap text button (Phoenix) =
'''Keywords :''' GenBitmapTextButton. <<TableOfContents>>

--------
= Introduction : =
{{{
wx.GenBitmapTextButton(parent, ID=-1, bitmap=wx.NullBitmap, label='', 
                       pos=wx.DefaultPosition, size=wx.DefaultSize,
                       style=0, validator=wx.DefaultValidator, name='genbutton')
}}}
This class is found under wx.lib.buttons.

(info by '''ZetCode / Jan Bodnar''').
--------
= Demonstrating : =
__'''''Tested''' py3.x, wx4.x and Win10. ''__

Are you ready to use some samples ? ;)

Test, modify, correct, complete, improve and share your discoveries ! (!)

--------
== Sample one ==
{{attachment:img_sample_one.png}}

In our example we show a possible use for this class.

{{{#!python
# sample_one.py

"""

Author : Jan Bodnar
Website : zetcode.com

"""

import wx
from wx.lib.buttons import GenBitmapTextButton

# class MyDialog
# class MyApp

#---------------------------------------------------------------------------

class MyDialog(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, size=(300, 260))

        self.SetIcon(wx.Icon('./icons/wxwin.ico', wx.BITMAP_TYPE_ICO))

        #------------

        panel = wx.Panel(self, -1)

        #------------

        email = GenBitmapTextButton(self, 1,
                                    wx.Bitmap('./bitmaps/email.png'),
                                    'Mail', (25, 20), (235, -1))
        email.SetBezelWidth(1)
        email.SetBackgroundColour('#c2e6f8')

        calendar = GenBitmapTextButton(self, 2,
                                       wx.Bitmap('./bitmaps/calendar.png'),
                                       'Calendar', (25, 56), (235, -1))
        calendar.SetBezelWidth(1)
        calendar.SetBackgroundColour('#c2e6f8')

        contacts = GenBitmapTextButton(self, 3,
                                       wx.Bitmap('./bitmaps/contacts.png'),
                                       'Contacts', (25, 92), (235, -1))
        contacts.SetBezelWidth(1)
        contacts.SetBackgroundColour('#c2e6f8')

        tasks = GenBitmapTextButton(self, 4,
                                    wx.Bitmap('./bitmaps/tasks.png'),
                                    'Tasks', (25, 128), (235, -1))
        tasks.SetBezelWidth(1)
        tasks.SetBackgroundColour('#c2e6f8')

        notes = GenBitmapTextButton(self, 5,
                                    wx.Bitmap('./bitmaps/notes.png'),
                                    'Notes', (25, 164), (235, -1))
        notes.SetBezelWidth(1)
        notes.SetBackgroundColour('#c2e6f8')

        #------------

        email.Bind(wx.EVT_ENTER_WINDOW, self.OnButtonEnter)
        email.Bind(wx.EVT_LEAVE_WINDOW, self.OnButtonLeave)
        calendar.Bind(wx.EVT_ENTER_WINDOW, self.OnButtonEnter)
        calendar.Bind(wx.EVT_LEAVE_WINDOW, self.OnButtonLeave)
        contacts.Bind(wx.EVT_ENTER_WINDOW, self.OnButtonEnter)
        contacts.Bind(wx.EVT_LEAVE_WINDOW, self.OnButtonLeave)
        tasks.Bind(wx.EVT_ENTER_WINDOW, self.OnButtonEnter)
        tasks.Bind(wx.EVT_LEAVE_WINDOW, self.OnButtonLeave)
        notes.Bind(wx.EVT_ENTER_WINDOW, self.OnButtonEnter)
        notes.Bind(wx.EVT_LEAVE_WINDOW, self.OnButtonLeave)

        #------------

        self.Centre()

    #-----------------------------------------------------------------------

    def OnButtonEnter(self, event):
        obj =  event.GetEventObject()
        obj.SetBackgroundColour('#ffdf85')
        obj.Refresh()


    def OnButtonLeave(self, event):
        obj =  event.GetEventObject()
        obj.SetBackgroundColour('#c2e6f8')
        obj.Refresh()

#---------------------------------------------------------------------------

class MyApp(wx.App):
    def OnInit(self):
        dlg = MyDialog(None, -1, 'wx.lib.buttons (GenBitmapTextButton)')
        dlg.ShowModal()
        dlg.Destroy()

        return True

#---------------------------------------------------------------------------

def main():
    app = MyApp(redirect=False)
    app.MainLoop()

#---------------------------------------------------------------------------

if __name__ == "__main__" :
    main()
}}}
--------
= Download source =
[[attachment:source.zip]]

--------
= Additional Information =
'''Link :'''

- - - - -

https://wiki.wxpython.org/TitleIndex

https://docs.wxpython.org/

--------
= Thanks to =
Jan Bodnar (sample_one.py coding), the wxPython community...

--------
= About this page =
Date(d/m/y)     Person (bot)    Comments :

30/12/20 - Ecco (Created page for wxPython Phoenix).

--------
= Comments =
- blah, blah, blah....