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

1.1.0 - Pausing & playing with same button / caching musics directory / cross-platform paths #2

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gustavo-bordin
Copy link

@gustavo-bordin gustavo-bordin commented Jun 5, 2021

Before reading...

  • In order to work on linux (Ubuntu 20), i had to install tkinter, every linux users may also need
  • These changes includes a compatibility with unix-based systems, so as i'm a linux user, i could not test it on Windows, even though i think it will not break anything, but would be nice to be tested before merging.

This MR is going to...

  • Change the play/pause button in order to use a single button

    • To do this i created a variable which holds the state of paused, then, if the button was clicked and is playing -> pause, if it was clicked and it is not playing and it is paused -> unpause. If it was clicked and it is not playing and it is not paused -> play
  • Add a cache file for caching the musics directory

    • Everytime the app ran, it asked the musics directory, in order to avoid asking multiple times, this cache functionality was added. Now it asks a single time and then write it in a file called user.txt inside a new directory which i called /tmp, so everytime the app rans, it checks if there is already a directory information in /tmp/user.txt, if so, it avoid asking the directory again.
  • Fix paths in order to be cross-platform.

    • Some paths were not working on linux, it is because window's path is different from unix-based ones.
  • Refactor all the code.

    • All the functionalities were inside a single file, which is not good for maintaining, so i added multiple classes in different files for organizing the functionalities. There are two common files; something_events and something_utilities. _events handles every events that can happen in the app, while _utilities is called to create the context of the _events, for example; music_events.py handles every events that can happen with the musics (play, stop, pause, etc), while music_utilities load the musics, holds the current_music, the states, etc, everything that music_events may use.
  • Resize the play_button image

    • Now the name of this image is just "play", but i resized it because now the app turns between pause and play buttons (because of the first mentioned change), and the play button was breaking the layout 'cause it is bigger than the other buttons.
  • Change gitignore

    • It was being used just one or two ignores, so i placed only the major ones.
  • Back to first/last song when there is no more song while request previous/next


How is it working now?

There is a Core class inside app.py, which is the entrypoint class. It calls interface_utilities to create every UI component and also the main window. This window is passed as parameters to MusicEvents, which passes it to InterfaceEvents (window is used here to update images or texts). The Core class also has a function named _start, which starts the app's events reading, the events are sent to MusicEvents, which uses MusicUtilities for managing the musics and the music's states.

@Jhonatan-de-Souza Could you review these changes? Please test it on Windows as you did in your video (i don't want to break everything 😄

also renaming play_button to play, in order to keep a pattern
features: pausing and playing with the same button, caching musics directory, changing paths to work on unix systems.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant