Python Forum
HTML multi select HTML listbox with Flask/Python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTML multi select HTML listbox with Flask/Python
#1
I have stumbled through creating a python tkinter program which plays multiple video clips (captured by motion surveillance app). Works very well but I will need to convert it to be usable over the internet (private use only) and would like to use Python Flask and HTML.

the current list creation is the following (inRadio being a directory variable passed by a radio Button, orig_import a base directory in case radioButton passage does not work):

def SourceBrowse():
    player.stop()
    global directory
    directory = inRadio.get()
    lbFrame.lift()
    if not directory:
        print("it's empty!")
        directory = orig_import
    populate_lb()

currently populating a listbox with the files:

# for scrolling vertically 
yscrollbar = Scrollbar(lbFrame)
yscrollbar.pack(side = RIGHT, fill = Y )

lb = Listbox(lbFrame, height = 40, width = 50, selectmode = "extended",yscrollcommand = yscrollbar.set,
             bg = '#153549', fg = 'white', selectbackground = 'lime')
lb.bind("<Double-1>", lambda x: viewButton.invoke())
lb.pack(padx = 2, pady = 2, fill = "both")
yscrollbar.config(command = lb.yview)


# Populating listbox: filenames only, then add directory when manipulating files
def populate_lb():
    global directory
    lb.delete(0, END)  #clear listbox
    file_list = [f for f in listdir(directory) if isfile(join(directory,f))]
    sorted_list = sorted(file_list, reverse=True)
    for file in sorted_list:
        lb.insert(0, file)
populate_lb()
the rest of my code allows for single or multiple of these video clips being played successively.

Is it possible to re-create this with Flask and HTML? I did find code allowing for a single file to be played:
<!DOCTYPE html>

<!-- place the charset right after head -->
<meta charset="UTF-8">

<select name="list_box_name[]" size="number_of_options" multiple="multiple">
<option value="option1">Option1</option>
<option value="option2">Option2</option>
<option value="Option3">Option3</option>
</select>

<video controls width="640" height="480"  autoplay muted>
  <source src="videofile.mp4" type="video/mp4">

  <!-- fallback for browsers that don't support mp4 -->
  <source src="/home/rainer/Videos/HouseToCoop-Deer-.20201127_080547_1.mp4" type="video/webm">


  <!-- fallback for browsers that don't support video tag -->
  <a href="videofile.mp4">download video</a>
</video>
but have not found any help with populating a listbox from files of directory and then play the selected files
Reply


Messages In This Thread
HTML multi select HTML listbox with Flask/Python - by rfeyer - Mar-14-2021, 12:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Div Class HTML selector in Python Artur 1 443 10 minutes ago
Last Post: StevenSnyder
  Trying to scrape data from HTML with no identifiers pythonpaul32 2 795 Dec-02-2023, 03:42 AM
Last Post: pythonpaul32
  How to find element in a deeply nested html structure Orientation_group 5 1,177 Oct-09-2023, 10:13 AM
Last Post: Larz60+
  Flask - use bootstrap styles in HTML Krayna 1 1,003 Aug-29-2023, 02:33 PM
Last Post: menator01
  Getting a URL from Amazon using requests-html, or beautifulsoup aaander 1 1,618 Nov-06-2022, 10:59 PM
Last Post: snippsat
  Populating list items to html code and create individualized html code files ChainyDaisy 0 1,560 Sep-21-2022, 07:18 PM
Last Post: ChainyDaisy
  selenium returns junk instead of html klaarnou 5 2,182 Mar-27-2022, 07:20 AM
Last Post: klaarnou
  requests-html + Beautifulsoup klaarnou 0 2,398 Mar-21-2022, 05:31 PM
Last Post: klaarnou
  Post Python to HTML/CSS Extra 3 1,839 Feb-17-2022, 06:07 PM
Last Post: snippsat
Question Python Obstacles | Jeet-Kune-Do | BS4 (Tags > MariaDB) [URL/Local HTML] BrandonKastning 0 1,400 Feb-08-2022, 08:55 PM
Last Post: BrandonKastning

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020