Demo — Generating GUI Files for YT Transcript Scrawler Using PySimpleGUI v1 Demo Part 3

Posted by


In this tutorial, we will continue working on our YouTube transcript scrawler generation files GUI using PySimpleGUI. This is part 3 of the demo, where we will focus on creating a GUI interface for the user to select the output location for the generated files.

To begin, we need to have PySimpleGUI installed in our Python environment. If you haven’t installed it yet, you can do so by running the following command:

pip install PySimpleGUI

Once PySimpleGUI is installed, we can start creating our GUI interface. First, let’s import the necessary modules:

import PySimpleGUI as sg

Next, we will define the layout of our GUI. In this part of the demo, we will add a file selection field for the user to choose the output location for the generated files:

layout = [
    [sg.Text('Select Output Location:')],
    [sg.InputText(), sg.FolderBrowse()],
    [sg.Button('Generate Files')]
]

In the layout above, we have a text label for the user to see what they need to do, an input field for the user to input the file location, a folder browse button for the user to select the folder, and a button for the user to start the file generation process.

Now, let’s create the window using the layout we defined:

window = sg.Window('Transcript Scrawler Generation Files GUI', layout)

Next, we will add the event loop to keep the window open and handle user input:

while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED:
        break
    if event == 'Generate Files':
        output_location = values[0]
        # Call the function to generate the files with the specified output location

In the event loop, we are checking for two events: if the user closes the window, we break out of the loop, and if the user clicks the "Generate Files" button, we get the output location from the input field and call a function (which we will define later) to generate the files.

Finally, don’t forget to close the window at the end of the script:

window.close()

That’s it for part 3 of the demo! In the next part, we will create the function to generate the files with the specified output location. Stay tuned for more!

0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x