<reponame>nbilbo/services_manager<gh_stars>0
"""Frame to show all service\'s register\'s.
"""

import tkinter.ttk

from src.view import constants
from src.view.services_page import ServicesPage


class ServicesReadPage(ServicesPage):
    def __init__(self, parent, controller, *args, **kwargs):
        super(ServicesReadPage, self).__init__(parent, *args, **kwargs)
        self.handler = Handler(self, controller)
        self.create_treeview()
        self.create_crud_buttons()
        self.create_binds()
        self.set_title("Services")

    def create_treeview(self):
        """Create treeview to show data.
        """
        self.treeview = tkinter.ttk.Treeview(self)
        self.treeview.pack(side="top", fill="both", expand=True, padx=constants.PADX, pady=constants.PADY)

    def create_crud_buttons(self):
        """Create crud buttons.
        """
        container = tkinter.ttk.Frame(self)
        container.pack(side="top", fill="both")
        
        self.add_button = tkinter.ttk.Button(
                container,
                text="Add")

        self.update_button = tkinter.ttk.Button(
                container,
                text="update")

        self.delete_button = tkinter.ttk.Button(
                container,
                text="delete")

        for button in (
                self.add_button,
                self.update_button,
                self.delete_button):

            button.pack(
                    side="left", 
                    fill="both", 
                    expand=True,
                    padx=constants.PADX,
                    pady=constants.PADY)
    
    def create_binds(self):
        """Connect events and handler.
        """
        self.back_button["command"] = self.handler.inicialize_home_page
        self.add_button["command"] = self.handler.inicialize_services_add_page
        self.delete_button["command"] = self.handler.inicialize_services_delete_page
        self.update_button["command"] = self.handler.inicialize_services_update_page

    def get_add_button(self):
        """
        return
            tkinter.ttk.Button
        """
        return self.add_button

    def get_update_button(self):
        """
        return
            tkinter.ttk.Button
        """
        return self.update_button

    def get_delete_button(self):
        """
        return
            tkinter.ttk.Button
        """
        return self.delete_button

    def get_treeview(self):
        """
        return
            tkinter.ttk.Treeview
        """
        return self.treeview



class Handler(object):
    def __init__(self, widget, controller):
        super(Handler).__init__()
        self.widget = widget
        self.controller = controller
    
    def inicialize_home_page(self):
        self.controller.inicialize_home_page()
    
    def inicialize_services_add_page(self):
        self.controller.inicialize_services_add_page()
    
    def inicialize_services_delete_page(self):
        self.controller.inicialize_services_delete_page()
    
    def inicialize_services_update_page(self):
        self.controller.inicialize_services_update_page()

"""Frame to show all service\'s register\'s.
"""

import tkinter.ttk

from src.view import constants
from src.view.services_page import ServicesPage


class ServicesReadPage(ServicesPage):
    def __init__(self, parent, controller, *args, **kwargs):
        super(ServicesReadPage, self).__init__(parent, *args, **kwargs)
        self.handler = Handler(self, controller)
        self.create_treeview()
        self.create_crud_buttons()
        self.create_binds()
        self.set_title("Services")

    def create_treeview(self):
        """Create treeview to show data.
        """
        self.treeview = tkinter.ttk.Treeview(self)
        self.treeview.pack(side="top", fill="both", expand=True, padx=constants.PADX, pady=constants.PADY)

    def create_crud_buttons(self):
        """Create crud buttons.
        """
        container = tkinter.ttk.Frame(self)
        container.pack(side="top", fill="both")
        
        self.add_button = tkinter.ttk.Button(
                container,
                text="Add")

        self.update_button = tkinter.ttk.Button(
                container,
                text="update")

        self.delete_button = tkinter.ttk.Button(
                container,
                text="delete")

        for button in (
                self.add_button,
                self.update_button,
                self.delete_button):

            button.pack(
                    side="left", 
                    fill="both", 
                    expand=True,
                    padx=constants.PADX,
                    pady=constants.PADY)
    
    def create_binds(self):
        """Connect events and handler.
        """
        self.back_button["command"] = self.handler.inicialize_home_page
        self.add_button["command"] = self.handler.inicialize_services_add_page
        self.delete_button["command"] = self.handler.inicialize_services_delete_page
        self.update_button["command"] = self.handler.inicialize_services_update_page

    def get_add_button(self):
        """
        return
            tkinter.ttk.Button
        """
        return self.add_button

    def get_update_button(self):
        """
        return
            tkinter.ttk.Button
        """
        return self.update_button

    def get_delete_button(self):
        """
        return
            tkinter.ttk.Button
        """
        return self.delete_button

    def get_treeview(self):
        """
        return
            tkinter.ttk.Treeview
        """
        return self.treeview



class Handler(object):
    def __init__(self, widget, controller):
        super(Handler).__init__()
        self.widget = widget
        self.controller = controller
    
    def inicialize_home_page(self):
        self.controller.inicialize_home_page()
    
    def inicialize_services_add_page(self):
        self.controller.inicialize_services_add_page()
    
    def inicialize_services_delete_page(self):
        self.controller.inicialize_services_delete_page()
    
    def inicialize_services_update_page(self):
        self.controller.inicialize_services_update_page()
Frame to show all service\'s register\'s. Create treeview to show data. Create crud buttons. Connect events and handler. return             tkinter.ttk.Button return             tkinter.ttk.Button return             tkinter.ttk.Button return             tkinter.ttk.Treeview