weather_gui.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:Weather-App 作者: Tomasz-Kluczkowski 项目源码 文件源码
def __init__(self):
        """Initializes WeatherApp class.

        :Attributes:
        :system (str): Platform on which application is run.
        :controller (Controller): Controller class object used for
            passing data between the View (weather_gui) and the Model
            (weather_backend).
        :v_link (dict): Link to access variables in controller.
        :paper (str): color definition in hex number.
        :title (str): Main window title displayed when using
            application.
        :displays (dict) dictionary storing all displays.
        """
        super().__init__()

        self.system = platform.system()
        # Add Controller to the WeatherApp class instance.
        controller = Controller()
        self.controller = controller
        self.v_link = self.controller.app_data
        # Add main application instance as a View to the Controller.
        self.controller.add_view(self)

        # Create a Report object for backend operations.
        report = Report(self.controller)
        # Add it as a Model to the Controller class object.
        self.controller.add_model(report)

        # Configure main window.
        self.paper = "#D5D5D5"
        self.title("The Weather App")
        self.config(bg=self.paper, bd=2, relief="flat")
        # Prevent resizing.
        self.resizable(width=tk.FALSE, height=tk.FALSE)

        # Create set of displays.
        self.displays = {}
        """:type : dict[str, DisplayShort]"""
        keys = ["title", "metric", "imperial"]
        for key in keys:
            self.displays[key] = DisplayShort(self, controller)
            self.displays[key].grid(row=0, column=0, sticky=tk.NSEW)
        self.update_buttons()
        self.update_geometry()

        # Application icon. Linux does not display it at all.
        if self.system == "Windows":

            self.iconbitmap("Data/Icons/app_icon/app_icon48x48.ico")
        # img_icon = ImageTk.PhotoImage(file="app_icon48x48.ico")
        # self.tk.call("wm", "iconphoto", self._w, img_icon)
        self.show_display("title")
        self.displays["title"].loc_combobox.focus()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号