I wanted to create a buttons using tkinter with line of code below
from tkinter import *
import webbrowser
import numpy as np
course = []
course_link = []
fh = open(r'D:\E-Learning\IBM Data Science.txt')
i=1
for line in fh:
f=line.rstrip()
if not line.startswith("https:"):
course.append( "Course " + str(i) + ": " + str(f))
i+=1
else:
course_link.append(str(f))
window = Tk()
for i in range(0,2):
course[i] = Button(window,text=str(course[i]))
course[i].config(command=webbrowser.open(str(course_link[i])))
course[i].pack()
window.mainloop()
Thanks guys Im new to this module so it's amazing if you can help me out! Edit: Pressing the buttons won't do the command too.