def __init__(self): """ The initialiser is used to "instantiate" attributes of the class. We cannot create the GUI here as we need to return a reference to the frame created. Hence, we need to implement a 'normal' function to do this e.g. create_gui() Parameters (apart from self): None Return: None """ # Instantiate a data access object # Contains methods to access the database self.vhc_dao = VehicleDAO() # Form fields # Instantiate stringvars/intvars to hold the data entered on the form self.reorder_level = tk.IntVar() # Checkbox self.lead_time_days = tk.IntVar() # Checkbox self.unit_price = tk.IntVar() # Checkbox # Set the default value to reorder_level # i.e. the reorder_level check box is checked # With checkboxes, any number of them can be checked # Thus all 3 boxes can be checked self.reorder_level.set(1) # Messagebox title self.mb_title_bar = "Vehicle Report" pass
def test_find_ids(): session = get_db_session() vhc = VehicleDAO() result = vhc.find_ids(session) print(result) session.close()
def test_find_by_id(): session = get_db_session() vhc = VehicleDAO() vehicle_id = 1 result = vhc.find_by_id(session, vehicle_id) print(result) session.close()
def test_delete(): session = get_db_session() vhc = VehicleDAO() vehicle_id = 1 result = vhc.delete(session, vehicle_id) print(result) session.close()
def __init__(self): """ The initialiser is used to "instantiate" attributes of the class. The attributes are the "variables" that have been declared "outside" of the methods of the class. Some attributes may have not been declared as they may be created any where in the class methods (python allows this). Attributes are like global variables for the class, as they are available to any method in the class. And, to use them, they must be prefixed with "self." This differentiates them from "local" variables which are defined/created and used within a single method If you need to pass the value of a local variable from one method to another, then you must pass "parameters" to the method We cannot create the GUI here as we need to return a reference to the frame created. Hence, we need to implement a 'normal' function to do this e.g. create_gui() Parameters (apart from self): None Return: None """ # Instantiate a data access object # Contains methods to access the database self.vhc_dao = VehicleDAO() # Instantiate a validation object # Contains methods to validate input fields self.validator = Validation() # Form fields # Instantiate stringvars - hold data entered in fields of form self.vehicle_id = tk.StringVar() self.vehicle_make = tk.StringVar() self.vehicle_model = tk.StringVar() self.year_manu = tk.StringVar() self.vehicle_price = tk.StringVar() # List of vehicle ids - lb for listbox self.lb_ids = None # Messagebox title self.mb_title_bar = "Vehicle CRUD" pass
def test_create(): session = get_db_session() vhc = VehicleDAO() data = {} data['vehicle_make'] = "Toyota" data['vehicle_model'] = "Camry" data['year_manu'] = "2008" data['vehicle_price'] = "8999" result = vhc.create(session, data) print(result) session.close()
def test_update(): session = get_db_session() vhc = VehicleDAO() vehicle_id = 1 data = {} data['vehicle_make'] = "Holden" data['vehicle_model'] = "Commodore" data['year_manu'] = "2014" data['vehicle_price'] = "13000" result = vhc.update(session, vehicle_id, data) print(result) session.close()
def __init__(self): """ The initialiser is used to "instantiate" attributes of the class. We cannot create the GUI here as we need to return a reference to the frame created. Hence, we need to implement a 'normal' function to do this e.g. create_gui() Parameters (apart from self): None Return: None """ # Instantiate a data access object # Contains methods to access the database self.vhc_dao = VehicleDAO() # Form fields # Instantiate stringvars/intvars to hold the data entered on the form # All the radio buttons point to the single intvar # And the value will be 1, 2, 3 or 4 depending which radio button was selected # And the value= option assigned to each radio button # Unlike check boxes where any number can be selected, # only one option can be selected with radio buttons self.radio_button_choice = tk.IntVar() # Radiobutton # Set the default value to 1 self.radio_button_choice.set(1) # Messagebox title self.mb_title_bar = "Category Report" # Frame containing the canvas for displaying the matplotlib chart self.canvas_frame = None pass