Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images on buttons #9

Closed
MikeTheWatchGuy opened this issue Jul 23, 2018 · 2 comments
Closed

Images on buttons #9

MikeTheWatchGuy opened this issue Jul 23, 2018 · 2 comments
Labels
enhancement New feature or request
Milestone

Comments

@MikeTheWatchGuy
Copy link
Collaborator

The next new feature.

Images as buttons will help the overall look of these GUI interfaces in a big way.

Should be a straightforward interface for the caller. A few more optional parameters to the Button Element call should do the trick.

Expect this in version 2.4

@MikeTheWatchGuy MikeTheWatchGuy added the enhancement New feature or request label Jul 23, 2018
@MikeTheWatchGuy MikeTheWatchGuy added this to the 2.4 milestone Jul 23, 2018
@MikeTheWatchGuy
Copy link
Collaborator Author

snap0124

It's coming along really well! Just about done with the coding. Need to test and then it'll be ready for release 2.4

@MikeTheWatchGuy
Copy link
Collaborator Author

media file player

Done with version 2.4... uploaded to PyPI. Enjoy!

    import PySimpleGUI as sg

    # Images are located in a subfolder in the Demo Media Player.py folder
    image_pause = './ButtonGraphics/Pause.png'
    image_restart = './ButtonGraphics/Restart.png'
    image_next = './ButtonGraphics/Next.png'
    image_exit = './ButtonGraphics/Exit.png'

    # A text element that will be changed to display messages in the GUI
    TextElem = sg.Text('', size=(15, 3), font=("Helvetica", 14))

    # Open a form, note that context manager can't be used generally speaking for async forms
    form = sg.FlexForm('Media File Player', auto_size_text=True, default_element_size=(20, 1),
                       font=("Helvetica", 25))
    # define layout of the rows
    layout= [[sg.Text('Media File Player',size=(17,1), font=("Helvetica", 25))],
            [TextElem],
             [sg.ReadFormButton('Restart Song', button_color=sg.TRANSPARENT_BUTTON,
                                image_filename=image_restart, image_size=(50, 50), image_subsample=2, border_width=0),
                                sg.Text(' ' * 2),
              sg.ReadFormButton('Pause', button_color=sg.TRANSPARENT_BUTTON,
                                image_filename=image_pause, image_size=(50, 50), image_subsample=2, border_width=0),
                                sg.Text(' ' * 2),
              sg.ReadFormButton('Next', button_color=sg.TRANSPARENT_BUTTON,
                                image_filename=image_next, image_size=(50, 50), image_subsample=2, border_width=0),
                                sg.Text(' ' * 2),
              sg.Text(' ' * 2), sg.SimpleButton('Exit', button_color=sg.TRANSPARENT_BUTTON,
                                                image_filename=image_exit, image_size=(50, 50), image_subsample=2, border_width=0)],
            [sg.Text('Treble', font=("Helvetica", 15), size=(6, 1)),
             sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15)),
             sg.Text(' ' * 5),
             sg.Text('Volume', font=("Helvetica", 15), size=(7, 1)),
             sg.Slider(range=(-10, 10), default_value=0, size=(10, 20), orientation='vertical', font=("Helvetica", 15))],
         ]

    # Call the same LayoutAndRead but indicate the form is non-blocking
    form.LayoutAndRead(layout, non_blocking=True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant