Exemplo n.º 1
0
 def __init__(self, master, image, position, state='normal'):
     """Create category button of month window."""
     self.text = None
     self.font = font.Font(font=('Lucida Sans', 22, 'normal'))
     self.position = tuple(position)
     self.tk_image = ImageTk.PhotoImage(image, master=master)
     self.widget = Canvas(master,
                          width=60,
                          height=60,
                          bd=0,
                          highlightthickness=0,
                          bg='#e2ddec')
     self.widget_image = self.widget.create_image(0,
                                                  0,
                                                  image=self.tk_image,
                                                  anchor='nw',
                                                  state=state)
     self.widget_text = self.widget.create_text(30,
                                                30,
                                                font=self.font,
                                                text=self.text,
                                                state=state,
                                                justify=tk.CENTER)
     self.widget.grid(row=position[0],
                      column=position[1],
                      sticky=tk.NSEW,
                      padx=25,
                      pady=25)
     config_widget(self.widget)
Exemplo n.º 2
0
    def change_position(self, position):
        """
        Сhange the button position in the category grid.

        :param position: new button position
        :type position: Tuple[int, int]
        """
        self.position = tuple(position)
        self.widget.grid(row=position[0],
                         column=position[1],
                         sticky=tk.NSEW,
                         padx=20,
                         pady=20)
        config_widget(self.widget)
Exemplo n.º 3
0
 def __init__(self, master=None, title=_('Finance management app')):
     """Create main window of application with widgets."""
     if not master:
         master = tk.Tk()
     super().__init__(master=master,
                      relief='ridge',
                      bg='white',
                      takefocus=1)
     self.master.title(title)
     self.master.minsize(width=1265, height=755)
     self.font = font.Font(font=('Lucida Sans', 12, 'normal'))
     self._create_widgets()
     self.grid(sticky=tk.NSEW, row=0, column=0)
     config_widget(self.master)
     config_widget(self)
Exemplo n.º 4
0
    def _create_widgets(self):
        """Create all basic widgets of the main window."""
        self.months_frame = tk.Frame(self, borderwidth=5, bg='#3e3362')
        self.months_frame.grid(sticky=tk.NSEW, row=0, column=0, columnspan=1)

        self.months_names = [
            _('January'),
            _('February'),
            _('March'),
            _('April'),
            _('May'),
            _('June'),
            _('July'),
            _('August'),
            _('September'),
            _('October'),
            _('November'),
            _('December')
        ]

        self.months_buttons = {}
        for i in range(12):
            month_button = tk.Button(self.months_frame,
                                     text=self.months_names[i],
                                     font=self.font,
                                     bg='#f0f4f9',
                                     relief='flat',
                                     height=2,
                                     width=12,
                                     border=5)
            month_button.grid(row=i, column=0, sticky=tk.NSEW, padx=3, pady=3)
            month_button.configure(
                command=lambda obj=month_button: self._change_month(obj))
            month_button.bind('<Double-Button-1>', self._draw_month_stats(i))
            self.months_buttons[i] = month_button

        self.groups_frame = tk.Frame(self, borderwidth=5, bg='#e2ddec')
        self.groups_frame.grid(sticky=tk.NSEW, row=0, column=1, columnspan=4)
        config_widget(self.months_frame)

        self.months_groups = {}
        for month in range(12):
            self.months_groups[month] = MonthWindow(self.groups_frame)
        config_widget(self.groups_frame)
        self.current_month = 0
        self._change_month(self.months_buttons[self.current_month])
Exemplo n.º 5
0
    def _create_widgets(self):
        """Create all widgets of statistic window."""
        self.buttons_frame = tk.Frame(master=self, bg='#e2ddec')
        self.buttons_frame.grid(row=1, column=0, columnspan=2)

        for idx in range(2):
            self.widgets[idx] = {}
            widget = self.widgets[idx]
            widget['canvas'] = tk.Canvas(self,
                                         bd=0,
                                         highlightthickness=0,
                                         bg='#e2ddec')
            widget['canvas'].bind('<Configure>', self.resize_plot(idx))
            widget['canvas'].grid(sticky=tk.NSEW,
                                  row=0,
                                  column=idx,
                                  padx=5,
                                  pady=5)
            widget['widget_img'] = widget['canvas'].create_image(0,
                                                                 0,
                                                                 anchor='nw')
            config_widget(self.widgets[idx]['canvas'])

        if self.data_type == 'month':
            self.draw_year_button = tk.Button(master=self.buttons_frame,
                                              text=_('Show year statistics'),
                                              bg='#f0f4f9')
        else:
            self.draw_year_button = tk.Button(master=self.buttons_frame,
                                              text=_('Show month statistics'),
                                              bg='#f0f4f9')
        self.draw_year_button.grid(sticky=tk.NS,
                                   row=0,
                                   column=0,
                                   columnspan=2,
                                   padx=5,
                                   pady=5)
        self.draw_year_button.configure(command=self.show_yearly_stats)

        config_widget(self.buttons_frame)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)
        self.columnconfigure(1, weight=1)
Exemplo n.º 6
0
    def __init__(self, master):
        """Create month information window."""
        self.label_font = font.Font(font=('Lucida Sans', 13, 'normal'))
        self.widget_font = font.Font(font=('Lucida Sans', 12, 'normal'))
        self.control_frame = tk.Frame(master,
                                      relief='ridge',
                                      bg='#e2ddec',
                                      takefocus=1)
        self.information_frame = tk.Frame(master,
                                          relief='ridge',
                                          bg='#e2ddec',
                                          takefocus=1)
        self.control_frame.grid(sticky=tk.NSEW, row=0, column=0)
        self.information_frame.grid(sticky=tk.NSEW, row=0, column=1)
        state = 'disabled'

        self.control_widgets = {}
        for i, (name, text) in enumerate(
                zip(('add', 'remove', 'change', 'delete'),
                    (_('Add field'), _('Remove field'), _('Change field'),
                     _('Delete category')))):
            widget = tk.Button(self.control_frame,
                               text=text,
                               font=self.label_font,
                               highlightbackground='#e2ddec',
                               relief='solid',
                               width=17,
                               state=state)
            widget.grid(row=i + 1, column=0)
            self.control_widgets[name] = {'widget': widget}

        self.list_widgets = {}
        for i, (name, text) in enumerate(
                zip(('amount', 'date', 'description', 'subcategory'),
                    (_('amount'), _('date'), _('description'),
                     _('subcategory')))):
            label = tk.Label(self.information_frame,
                             text=text.capitalize(),
                             font=self.label_font,
                             bg='#e2ddec',
                             relief='flat',
                             state=state)
            label.grid(row=0, column=i)
            widget = tk.Listbox(self.information_frame,
                                relief='solid',
                                highlightthickness=0,
                                bg='#f0f4f9',
                                font=self.widget_font,
                                width=25,
                                height=5,
                                state=state,
                                selectmode=tk.BROWSE,
                                exportselection=False)
            widget.grid(row=1, column=i, padx=5, pady=5)
            widget.bind("<<ListboxSelect>>", self._select_row)
            self.list_widgets[name] = {
                'widget': widget,
                'label': label,
                'length': 0
            }

        config_widget(master)
        config_widget(self.control_frame)
        config_widget(self.information_frame)