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
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():
    global directory
    directory = inRadio.get()
    if not directory:
        print("it's empty!")
        directory = orig_import

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)
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>

<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>
but have not found any help with populating a listbox from files of directory and then play the selected files

Possibly Related Threads…
Thread Author Replies Views Last Post
  cleaning HTML pages using lxml and XPath wenkos 2 300 Aug-25-2021, 10:54 AM
Last Post: wenkos
  Python Web Scraping can not getting all HTML content yqqwe123 0 200 Aug-02-2021, 08:56 AM
Last Post: yqqwe123
  show csv file in flask template.html rr28rizal 8 27,020 Apr-12-2021, 09:24 AM
Last Post: adamabusamra
Lightbulb Hypertag. New language for HTML templating w/ Django support mwojnars 0 474 Apr-06-2021, 12:53 PM
Last Post: mwojnars
Sad web scraping HTML - :( Kingoman 22 1,487 Apr-05-2021, 09:50 AM
Last Post: snippsat
  Cleaning HTML data using Jupyter Notebook jacob1986 7 1,077 Mar-05-2021, 10:44 PM
Last Post: snippsat
  Parsing html page and working with checkbox (on a captcha) straannick 17 2,923 Feb-04-2021, 02:54 PM
Last Post: snippsat
  Saving html page and reloading into selenium while developing all xpaths Larz60+ 4 1,951 Feb-04-2021, 07:01 AM
Last Post: jonathanwhite1
Smile Extracting the Address tag from multiple HTML files using BeautifulSoup Dredd 8 1,247 Jan-25-2021, 12:16 PM
Last Post: Dredd
  Scrape for html based on url string and output into csv dana 13 1,478 Jan-13-2021, 03:52 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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