import PySimpleGUI as sg

"""
    Demo of Base64 Buttons (that have gradients)
    
    These button images are all located at the bottom of the souce file.  
    
    It's very easy to convert any PNG image into a BASE64 button but running one of these PySimpleGUI Demos:
        Demo_Base64_Image_Encoder.py - Converts an entire folder and writes results to output.py
        Demo_Base64_Single_Image_Encoder.py - Converts a single image and puts result onto the clipboard so you can
            paste into your code
            
    These images are not going to win any awards but they get the point across.
                
    Copyright 2020 PySimpleGUI.org
"""

def main():
    # sg.theme('Light Green 6')
    # sg.theme('Dark Red')
    sg.theme('Dark Green 7')
    layout = [  [sg.Text('Some Base64 Buttons', font='Default 16')],
                [sg.Text('The size is modified using the image_subsample parameter')],
                [sg.Text("All of these buttons are contained in this program's source code")],
                [sg.Text('These are not super-attractive buttons... better are coming... perhaps with your help.')],
                [sg.Text('The point is that it is not difficult for you to add button graphics to your GUI')],

                [
                    sg.Button('Rect', image_data=r1,  button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Rect', image_data=g1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Rect', image_data=grey1, button_color=('white', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Rect', image_data=g2, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Rect', image_data=o1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Rect', image_data=y1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Rect', image_data=p1, image_subsample=3, button_color=('black', sg.theme_background_color()), border_width=0),
                    ],
                [sg.Text('These oval buttons are 1/2 of their original size. (image_subsample=2)')],
                [
                    sg.Button('Oval', image_data=bo1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Oval', image_data=ro1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Oval', image_data=go1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Oval', image_data=go2, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Oval', image_data=oo1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Oval', image_data=yo1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Oval', image_data=po1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Oval', image_data=greyo1, image_subsample=2, button_color=('white', sg.theme_background_color()), border_width=0, font='Any 15'),],
                [sg.Text('These square buttons are their original size. (image_subsample=1)')],
                [
                    sg.Button('Sq', image_data=bs1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=rs1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=gs1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=gs2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=os1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=ys1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=grays1, button_color=('white', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=ps1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'), ],
                [
                    sg.Button('Sq', image_data=bs1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=rs1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=gs1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=gs2, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=os1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=ys1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=grays1, image_subsample=2, button_color=('white', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=ps1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'), ],
                [
                    sg.Button('Sq', image_data=bs1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Sq', image_data=bs1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 12'),
                    sg.Button('Sq', image_data=bs1, image_subsample=3, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 10'),
                ],
                [
                    sg.Button('Circle', image_data=bc1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Circle', image_data=rc1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Circle', image_data=gc1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Circle', image_data=gc2, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Circle', image_data=oc1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Circle', image_data=yc1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Circle', image_data=pc1, button_color=('black', sg.theme_background_color()), border_width=0, font='Any 15'),
                    sg.Button('Circle', image_data=grayc1, button_color=('white', sg.theme_background_color()), border_width=0, font='Any 15'),

                ],
                [sg.Button(f'Standard Button'),
                 sg.Button('Exit', image_data=r1, image_subsample=2, button_color=('black', sg.theme_background_color()), border_width=0),],

                  ]

    window = sg.Window('Base64 Buttons', layout)

    while True:             # Event Loop
        event, values = window.read()
        print(event, values)
        if event == sg.WIN_CLOSED or event == 'Exit':
            break
    window.close()


if __name__ == '__main__':
    b1 = b'[encoded data, 13640 characters]'
    bc1 = b'[encoded data, 6400 characters]'
    bo1 = b'[encoded data, 16760 characters]'
    g1 = b'[encoded data, 13376 characters]'
    g2 = b'[encoded data, 13260 characters]'
    gc1 = b'[encoded data, 6512 characters]'
    gc2 = b'[encoded data, 6432 characters]'
    go1 = b'[encoded data, 16756 characters]'
    go2 = b'[encoded data, 16488 characters]'
    grey1 = b'[encoded data, 6512 characters]'
    greyo1 = b'[encoded data, 8508 characters]'
    o1 = b'[encoded data, 12752 characters]'
    oc1 = b'[encoded data, 6376 characters]'
    oo1 = b'[encoded data, 15876 characters]'
    p1 = b'[encoded data, 13048 characters]'
    pc1 = b'[encoded data, 6032 characters]'
    po1 = b'[encoded data, 15944 characters]'
    r1 = b'[encoded data, 13884 characters]'
    rc1 = b'[encoded data, 6132 characters]'
    ro1 = b'[encoded data, 16240 characters]'
    y1 = b'[encoded data, 12916 characters]'
    yc1 = b'[encoded data, 6452 characters]'
    yo1 = b'[encoded data, 15768 characters]'



    bs1 = b'[encoded data, 5884 characters]'
    grays1 = b'iVBORw0KGgoAAAANSUhEUgAAADgAAAA2CAYAAACSjFpuAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAcCSURBVGhDlZpLjhTJEkUjqQIGSGwAISQQEkOWwC4Yg8SEHTBBby1sg0UAI0bMYAgS4v8p6vWJfid085Z7Fs+k025m7m5+LTyykir17vT0dLlz587J8fHxheV/ttvtzoBduPDvksz1Gix9rOM2NGj6jOk7JtifP3/25h0vXrz458WLF0e7+/fvn169enW5d+/e8vv3700szeiPwGaxlnlHRWidG/k5jvxuEu3Pnz9fvn79uuwePnx4evv27eXWrVvDBjFz0jljR/20znWswLYUrnUuR/jn9paXL18ur1+/XnYPHjw4vXHjxnLz5s3l5OTk3JsDbBbr56iNYsVpszjz+Blzg5i5o6Oj5dWrV8ubN2+W9UP169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hk5rSOtTyn54mZRxPN0igPXt3Y+jXBIt5rwJ+B5SGjHGY+9+bnJvNax23q7D1pxF4IYOsNYi2yY81Dsnjm+iHZWDaIn+R6yJqa60bWedZq62cwi+mP4lF+JjTzNOVHQD8bxWePdcl1rbTZXOad227QZPqzXAvQnBOEiw3yCtkgWCv3ZW1izdg5zFfXfBpzezcomUt/hsKSbi7H9sF9WbPr48/0aJ3bGnRs+uDOJwpN0frZZDc3Ius1rWOmHdZXFHKjfucOkaK6GeH19BVNWJtY07Mb512To76ceUV7QW7SlxbWzBoZ5cS6WT/PlNSnP2L7HhQb7mIZz/IpbCT+UGNJ1mrU6dmpAT/1M66vqAvAwuQl55MUpegUnw3NXk/nGLsW5Dn6qQFGOomx7TOYsCCLNs45n2NjEx0nOaffjM7vnL49wPYZNJFkvgtmXhSYwjsH7NPvvZL12x/pneXWBmcLLJjjiFyj8BGu55VkNOc4OitznW/owT70t8/gbFPnPSAZNWG+55NDc9A1GJPWpG9P2Nag4wgL/D+kUJn9kMk9WQNaw0hX5rIfWL8mXJwL3dz50XzSgpNRLvPuGzE6c6YJf2vQjnNBbs5ci0iRI85bk3X+pp56Wptx5hn3XtFemJv1z2MkKunvwo6TUf0RrU/92w3SpUnpjaNck6JaaAvOuVFsLuMRqUuc22swb7E3MnrYTEjPZzy6oV7bZG39UTzCRukJ2/4lM1o8I8V4aPs21nH7SdfuuiNGFwP2td1gL0hmeWlBh+bab5wbrc9xhlq3BvlP/9ovxox/Qx6QBzazPMzmztPTmjH83aNHj06fPXu2Bph/u/SPs4fgwax/9wh/xMwUorimhSc8CPP9UDB6ePz48bL+T+lPnz49+fDhw3abWArrXIuere11GDnOaSMnaRnr55j1GM1du3ZtefLkye6/bczXf5smYBYAAAAASUVORK5CYII='
    grayc1 = b'[encoded data, 4224 characters]'
    gs1 = b'[encoded data, 5360 characters]'
    gs2 = b'[encoded data, 5260 characters]'
    os1 = b'[encoded data, 5312 characters]'
    ps1 = b'[encoded data, 4988 characters]'
    rs1 = b'[encoded data, 5252 characters]'
    ys1 = b'[encoded data, 5024 characters]'
    main()
