Hi everyone, Python noob here, im working on an assignment that is Tkinter heavy. Basically the endstate of the program is to display a GUI that allows a user to select upcoming entertainment events from data from an imported live HTML page that displays dates and a names of events using findall to display the dates and name.(like a music concert website for example.
The program also must feature an offline mode that when selected tells the program to gather the "data" from an offline source, in my case a downloaded HTML page from a sitdown comedy club.
So to get to the point of my problem. Im having trouble figuring out how to tell the radio buttons to read from the offline source when offline is selected and read from the online source when the online button is selected.
Ive tried multiple things, using if statements and different commands and functions. But im at the point where I pull my hair out when I stare at it for too long.
In this scenario the online source is there to simulate a live HTML page but they're both downloaded pages.
Below is the code I believe is pertinent to my problem.
The error I get when I run the program now is:
The program also must feature an offline mode that when selected tells the program to gather the "data" from an offline source, in my case a downloaded HTML page from a sitdown comedy club.
So to get to the point of my problem. Im having trouble figuring out how to tell the radio buttons to read from the offline source when offline is selected and read from the online source when the online button is selected.
Ive tried multiple things, using if statements and different commands and functions. But im at the point where I pull my hair out when I stare at it for too long.
In this scenario the online source is there to simulate a live HTML page but they're both downloaded pages.
Below is the code I believe is pertinent to my problem.
The error I get when I run the program now is:
Error:Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\Muzz\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:\Users\Muzz\Documents\Python\Assigment 2\Tkinter\ProtoAssignment2\test1.py", line 65, in comedy_pressed
Comedian1 = findall('">([A-Za-z]+ [A-Za-z]+ [A-Za-z]+) @',Source)
File "C:\Users\Muzz\AppData\Local\Programs\Python\Python37-32\lib\re.py", line 223, in findall
return _compile(pattern, flags).findall(string)
TypeError: expected string or bytes-like object
Thanks in advance to anyone who takes the time to read this and help me. from tkinter import * from re import * #Make the menu entertainment_fix=Tk() #Give menu a name----------------------------------------------------------------------------------# entertainment_fix.title('Entertainment Fix!') #Give the menu a background colour entertainment_fix['bg']='light sea green' #Insert a picture fixpic=PhotoImage(file='entertainment.gif') picture=Label(entertainment_fix, image=fixpic) picture.grid(row=0, column =1) Source = () # Create a Interger Value for the radio buttons On_or_Off = IntVar() # Define a function that when called by the offline radio button, the source HTML page changes------------# def offline(): if On_or_Off.get() == 1: Source = open('OfflineComedy.html').read() # Define a function that when called by the online radio button, the source HTML page changes-------------# def online(): if On_or_Off.get() == 2: Source = open('OnlineComedy.html').read() # Create a radio button for working offline----------------------------------------------# work_offline_button = Radiobutton(entertainment_fix,text='Work Offline',font=('Arial',10), variable = On_or_Off, value = 1, command = offline) work_offline_button.grid(row=0,column=0) # Create a radio button for working offline----------------------------------------------# work_online_button = Radiobutton(entertainment_fix,text='Work Online',font=('Arial',10), variable = On_or_Off, value = 2, command = online) work_online_button.grid(row=0,column=2)