def __init__(self, master, controller, tip, cnf, **args):
"""Initialise MyButton.
Args:
master (tk.widget): Master widget to which MyButton (slave)
instance will belong. The master widget is part of
the WeatherApp object.
controller (Controller): controller object which will store
all the data required by each segment of the
application.
tip (str): Tooltip text to display in the status_bar_label.
cnf (dict): Dictionary with the configuration for MyButton.
**args: Keyword arguments to further initialise the button.
:Attributes:
:system (str): Platform on which application is run.
:cur_bg (str): Current background color of the button.
:tip (str): Text to display in the status_bar_label of the app.
:controller (Controller): controller object which will store all
the data required by each segment of the application.
This has to be the same Controller as for the WeatherApp.
:v_link (dict): Link to access variables in controller.
"""
super().__init__(master, cnf, **args)
self.system = platform.system()
self.cur_bg = self["bg"]
self.controller = controller
self.v_link = self.controller.app_data
self.tip = tip
# Action on entering the button with mouse.
self.bind("<Enter>", lambda e: self.enter_button())
# Action on leaving the button with mouse.
self.bind("<Leave>", lambda e: self.leave_button())
评论列表
文章目录