как мне сделать так чтобы после выбора опции в менб-кнопке надпись: "write here your monthly salary " менялась в соответствии с выбранной опцией?

main.py:

from tkinter import *
from tkinter.ttk import Notebook, Progressbar
from time import *
from settings import Settings
from menu_button import MenuButton
from tkinter import messagebox as mb


class App:
    def __init__(self):
        self.exit_btn = None
        self.theme_button = None
        self.root = None
        self.tk = None
        self.tabs_control = None
        self.tab1 = None
        self.tab2 = None
        self.tab3 = None
        self.tab4 = None
        self.pb = None
        self.p = None
        self.sb = None
        self.salary_lbl_frame = None
        self.salary_input = None
        self.month = 0
        self.day = self.month // 30
        self.year = self.month * 12
        self.week = self.day * 7
        self.send_res = None
        self.year_res = Label()
        self.month_res = Label()
        self.week_res = Label()
        self.day_res = Label()
        self.res1 = (f""
                     f"monthly salary is\t{self.month}")
        self.res2 = f"yearly salary is\t{self.year}"
        self.res3 = f"weekly salary is\t{self.week}"
        self.res4 = f"daily salary is\t{self.day}"
        self.results = None
        self.res_control = True

        self.label = True

        self.set = Settings()

        self.check_theme_lbl = None

        self.error = None
        self.iserror = False

        self.theme = 'light'

        self.menu = MenuButton()

        self.deside = None

    def change_theme(self):

        if self.theme == 'light':
            self.theme = 'dark'
            self.tab1['bg'] = self.set.themes[self.theme]["tab_color"]
            self.tab2['bg'] = self.set.themes[self.theme]["tab_color"]
            self.tab3['bg'] = self.set.themes[self.theme]["tab_color"]
            self.tab4['bg'] = self.set.themes[self.theme]["tab_color"]
            self.salary_lbl_frame['bg'] = self.set.themes[self.theme]['lbl-frame_color']
            self.salary_input['bg'] = self.set.themes[self.theme]["etr_color"]
            self.year_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.month_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.week_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.day_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.theme_button['bg'] = self.set.themes[self.theme]["theme_button"]
            self.exit_btn['bg'] = self.set.themes[self.theme]["exit_button"]
        else:
            self.theme = 'light'
            self.tab1['bg'] = self.set.themes[self.theme]["tab_color"]
            self.tab2['bg'] = self.set.themes[self.theme]["tab_color"]
            self.tab3['bg'] = self.set.themes[self.theme]["tab_color"]
            self.tab4['bg'] = self.set.themes[self.theme]["tab_color"]
            self.salary_lbl_frame['bg'] = self.set.themes[self.theme]['lbl-frame_color']
            self.salary_input['bg'] = self.set.themes[self.theme]["etr_color"]
            self.year_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.month_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.week_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.day_res['bg'] = self.set.themes[self.theme]["tab_color"]
            self.theme_button['bg'] = self.set.themes[self.theme]["theme_button"]
            self.exit_btn['bg'] = self.set.themes[self.theme]["exit_button"]

    def notebook_code(self):

        # setup Notebook

        self.tabs_control = Notebook(self.tk, padding=(20,))
        self.tabs_control.enable_traversal()

        self.tab1 = Frame(self.tabs_control, bg=self.set.themes[self.theme]["tab_color"])
        self.tab2 = Frame(self.tabs_control, bg=self.set.themes[self.theme]["tab_color"])
        self.tab3 = Frame(self.tabs_control, bg=self.set.themes[self.theme]["tab_color"])
        self.tab4 = Frame(self.tabs_control, bg=self.set.themes[self.theme]["tab_color"])

        self.tabs_control.add(self.tab1, text='Input', underline=0)
        self.tabs_control.add(self.tab2, text='Output', underline=0)
        self.tabs_control.add(self.tab3, text="Settings", underline=0)
        self.tabs_control.add(self.tab4, text="About me", underline=0)

        self.tabs_control.select(self.tab1)

    def widgets(self):
        # title
        title = Label(
            self.tk,
            text='                              salary calculator                              ',
            bg='black',
            fg='white',
            font='Arial 20 bold')

        title.place(rely=0.0399, relx=0.5, anchor=CENTER)

        # Notebook widgets

        self.tabs_control.pack(pady=20, fill=BOTH, expand=True)

        # first tab

        self.salary_lbl_frame = LabelFrame(self.tab1, text=f'write here your {self.menu.solution} salary',
                                           padx=20,
                                           pady=20,
                                           font="Arial 12 bold",
                                           highlightthickness=0,
                                           bg=self.set.themes[self.theme]['lbl-frame_color'])

        self.salary_input = Entry(self.salary_lbl_frame, bg=self.set.themes[self.theme]["etr_color"])
        self.send_res = Button(
            self.salary_lbl_frame,
            text="send",
            command=self.send_results,
            padx=45,
            bg=self.set.themes[self.theme]['send-btn_color'],

        )

        self.salary_lbl_frame.pack(pady=30)
        self.salary_input.pack()
        self.send_res.pack()

        # second tab

        self.results = Label(
            self.tab2,
            text='                                                                        results                    '
                 '                                                    ',
            bg='black', fg='white')

        # third tab

        self.theme_button = Button(self.tab3, text='swich theme', command=self.change_theme)
        self.theme_button.pack()

        self.exit_btn = Button(
            self.tab3,
            text='Exit',
            fg='black',
            font='Arial 8 bold',
            command=self.exit,
            pady=5,
            padx=1000,
            bg=self.set.themes[self.theme]['exit_button']
        )
        self.exit_btn.place(rely=0.96, relx=0.5, anchor=CENTER)

        self.menu.widget(self.tab3)

    def send_results(self):

        try:
            self.salary_input.update()
            self.month = float(self.salary_input.get())
            self.year = self.month * 12
            self.day = self.month // 30
            self.week = self.day * 7

            self.res1 = f"\r\nmonthly salary is\t{self.month}"
            self.res2 = f" yearly salary is\t{self.year}"
            self.res3 = f"weekly salary is\t{self.week}"
            self.res4 = f"daily salary is\t{self.day}"

            self.results.pack()

            if self.label:
                self.year_res['bg'] = self.set.themes[self.theme]["tab_color"]
                self.month_res['bg'] = self.set.themes[self.theme]["tab_color"]
                self.week_res['bg'] = self.set.themes[self.theme]["tab_color"]
                self.day_res['bg'] = self.set.themes[self.theme]["tab_color"]

                self.month_res = Label(self.tab2, text=self.res1, font='Arial 14 bold',
                                       bg=self.set.themes[self.theme]['output_color'])
                self.year_res = Label(self.tab2, text=self.res2, font='Arial 14 bold',
                                      bg=self.set.themes[self.theme]['output_color'])
                self.week_res = Label(self.tab2, text=self.res3, font='Arial 14 bold',
                                      bg=self.set.themes[self.theme]['output_color'])
                self.day_res = Label(self.tab2, text=self.res4, font='Arial 14 bold',
                                     bg=self.set.themes[self.theme]["output_color"])

                self.month_res.pack()
                self.year_res.pack()
                self.week_res.pack()
                self.day_res.pack()
                self.label = False
            else:

                self.month_res['text'] = self.res1
                self.year_res['text'] = self.res2
                self.week_res['text'] = self.res3
                self.day_res['text'] = self.res4

        except ValueError:
            mb.showerror(title='ValueError', message='ValueError')

    def open(self):
        self.root = Tk()

        self.root.geometry("+820+400")

        Label(self.root, text='Loading', font="Arial 15 bold").pack()

        self.pb = Progressbar(self.root, orient=HORIZONTAL, mode="determinate", length=400)

        self.pb.pack(pady=20)

        for i in range(101):
            self.pb.configure(value=i)
            self.pb.update()
            sleep(0.005)

        self.root.destroy()

    @staticmethod
    def exit():
        exit()

    def run(self):
        self.open()
        self.tk = Tk()
        self.tk.title('Salary calculator 1.6')
        self.tk.geometry('500x500+720+225')
        self.tk.resizable(False, False)
        self.notebook_code()
        self.tk.protocol("WM_DELETE_WINDOW", self.exit)
        self.widgets()
        self.tk.mainloop()
        self.exit()


app = App()
app.run()

settings.py:

class Settings:
    def __init__(self):
        self.daily = True
        self.weekly = True
        self.monthly = True
        self.yearly = True
        self.themes = {
            'dark': {
                'tab_color': 'grey50',
                'send-btn_color': 'grey70',
                'etr_color': 'grey50',
                'lbl-frame_color': 'grey60',
                'output_color': 'grey50',
                'theme_button': 'grey40',
                'exit_button': 'maroon'

            },
            'light': {
                'tab_color': 'grey90',
                'send-btn_color': 'grey80',
                'etr_color': 'grey90',
                'lbl-frame_color': 'grey80',
                'output_color': "grey90",
                'theme_button': 'grey70',
                'exit_button': 'pink'
            }
        }

menu_button.py:

from tkinter import *


class MenuButton:

    def __init__(self):
        self.inside_menu = None
        self.my_menu = None
        self.lbl = None
        self.win = None
        self.item_var = StringVar()
        self.solution = 'monthly'

    def widget(self, window):
        self.win = window
        self.lbl = Label(self.win, text='')
        self.lbl.pack()
        self.my_menu = Menubutton(self.win, text='things')
        self.my_menu.pack(pady=50)
        self.inside_menu = Menu(self.my_menu)
        self.my_menu['menu'] = self.inside_menu

        for i in ['daily', 'weekly', 'monthly', 'yearly']:
            self.inside_menu.add_radiobutton(label=i, variable=self.item_var, command=lambda x=i: self.stuff(x))

    def stuff(self, x):
        self.lbl.config(text=f'You selected {x}')
        self.solution = x

        

Ответы (0 шт):