I'm trying to use the How to Create Hospital Management Systems in Python - Full Tutorial as a programming exercise to learn how to define classes. I've followed along making no changes but I get an error (in the video the script runs fine). I'm using Python 3.7.4 (64bit) in Windows 10.
# Import packages
from tkinker import *
from tkinter import ttk
import random
import time;
import datetime
import tkinter.messagebox
# Define interface
class Hospital:
def__init__(self, root):
self.root = root
self.root.title("Hospital Management Systems")
self.root.geometry("1350x750+0+0")
self.root.configure(background='powder blue')
cmbNameTablets = StringVar()
Ref = StringVar()
Dose = StringVar()
NumberTablets = StringVar()
Lot = StringVar()
IssuedDate = StringVar()
ExpDate = StringVar()
DailyDose = StringVar()
PossibleSideEffects = StringVar()
FurtherInformation = StringVar()
StorageAdvice = StringVar()
DrivingUsingMachines = StringVar()
HowtoUseMedication = StringVar()
PatientID = StringVar()
PatientNHSNo = StringVar()
PatientName = StringVar()
DateOfBirth = StringVar()
PatientAddress = StringVar()
Prescription = StringVar()
MainFrame = Frame(self.root)
MainFrame.grid()
TitleFrame = Frame(MainFrame, bd = 20, width = 1350, padx = 20, relief = RIDGE)
TitleFrame.pack(side = TOP)
self.lblTitle = Label(TitleFrame, font = ('arial', 40, 'bold'), text = "Hospital Management Systems", padx = 2)
self.lblTitle.grid()
FrameDetail = Frame(MainFrame, bd = 20, width = 1350, height = 500, padx = 20, relief = RIDGE)
FrameDetail.pack(side = BOTTOM)
if__name__ == '__main__':
root = Tk()
application = Hospital(root)
root.mainloop()
Error message and traceback:
File "<ipython-input-7-e64c65d6c91e>", line 3
def__init__(self, root):
^
SyntaxError: invalid syntax
I expected it to look like it does at 10:36 in the video (a rather bare graphical interface).
I'm new to python and I've never defined classes before so I'm lost. Has the syntax changed since the video was made (August 2018), or is it because the instructor is using a different operating system/version of python?
Thanks for any help!
EDIT: error message and traceback added
Near the top of your source code:
from tkinker import *
You misspelled tkinter
as tkinker
with a k
Remove semi-colon from the line import time;
Put a space between def
and __init__
in def__init__
Put a space between if
and __name__
in if__name__