0

i'm currently trying to creat a small accounting program where the user should type his earnings and expanses and the program should count it and display the differnt transactions in an secound frame. Im stuck at this point: So far ive created 6 frames where the user can switch between with buttons.

When the user click on the button "first transaction" he can entry a ammount and after he click on validate the ammount is displaying under the button.

But i want that the ammount is display at the frame "transaction overview" After hours spending with searching the web i couln't find a way to display a functions output on a secound frame/window in the App. Thanks for your helf.

class Finanzapp(tk.Tk):

    def get_page(self, classname):

        for page in self.frames.values():
            if str(page.__class__.__name__) == classname:
                return page
        return None

    def __init__(self, *args, **kwargs):

        tk.Tk.__init__(self, *args, **kwargs)

        tk.Tk.wm_title(self, "Finanz Manager V2")
        container = tk.Frame(self)

        container.pack(side="top", fill="both", expand = True)

        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (StartPage, PageOne, PageTwo, PageThree, Pagefour, Pagefive):

            frame = F(container,self)

            self.frames[F] = frame

            frame.grid(row=0, column = 0, sticky="nsew")

        self.show_frame(StartPage)

    def show_frame(self, cont):

        frame = self.frames[cont]
        frame.tkraise()

class StartPage(tk.Frame):

    def __init__(self, parent, controller):
        self.controller = controller
        tk.Frame.__init__(self,parent)
        label = tk.Label(self, text="Start Page", font=LARGE_FONT)
        label.pack(pady=10,padx=10)

        button1 = ttk.Button(self, text="erste Buchung",
                           command=lambda: controller.show_frame(PageOne)) # add a page
        button1.pack()

        button2 = ttk.Button(self, text="Konten",
                           command=lambda: controller.show_frame(PageTwo)) # add a page
        button2.pack()

        button3 = ttk.Button(self, text="neue Buchung",
                           command=lambda: controller.show_frame(PageThree)) # add a page
        button3.pack()

        button4 = ttk.Button(self, text="Kategorien",
                           command=lambda: controller.show_frame(Pagefour)) # add a page
        button4.pack()

        button5 = ttk.Button(self, text="Übersicht",
                           command=lambda: controller.show_frame(Pagefive)) # add a page
        button5.pack()

        button6 = ttk.Button(self, text="Diagramm",
                           command=lambda: controller.show_frame(StartPage)) # add a page
        button6.pack()



class PageOne(tk.Frame):

    def __init__(self, parent, controller):
        self.controller = controller
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="erste Buchung", font=LARGE_FONT)
        label.pack(pady=10,padx=10)

        button1 = ttk.Button(self, text="zurück",
                           command=lambda: controller.show_frame(StartPage)) # add a page
        button1.pack()

        def calc():
            monthly_earning = float(m_earning.get())




            labelresult1 = Label(self, text='gebucht: € %.2f' % monthly_earning).pack()            
            label1 = Label(self, text='Enter the amount').pack()
        m_earning=StringVar()
        earning=Entry(self, textvariable=m_earning).pack()   
        buttoncalc=Button(self,text='Buchen', command=calc).pack() 

class PageTwo(tk.Frame):

    def __init__(self, parent, controller):

        def get_page(self,PageOne):

            def print_it(self):

                page_one = self.controller.get_page("PageOne")
                value = page_one.monthly_m_earning.get()
                labelresult2 = Label(self, text='gebucht: € %.2f' % value).pack()

        self.controller = controller
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Konten", font=LARGE_FONT)
        label.pack(pady=10,padx=10)

        button1 = ttk.Button(self, text="zurück",
                           command=lambda: controller.show_frame(StartPage)) 
        button1.pack()
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Marco
  • 11
  • 3
  • If the problem is about taking data from one frame and showing it in another, we don't need an example with five pages. Please a) fix the indentation, and b) reduce this down to a [minimal, complete, and verifiable example](http://stackoverflow.com/help/mcve) – Bryan Oakley May 06 '17 at 12:37
  • Your are right I only want to display the input of the entry box in another fram. (One Page Two Accounts or Page 5 transaction overview) def calc(): monthly_earning = float(m_earning.get()) labelresult1 = Label(self, text='validated: € %.2f' %monthly_earning).pack() label1 = Label(self, text='Enter the amount').pack() m_earning=StringVar() earning=Entry(self, textvariable=m_earning).pack() buttoncalc=Button(self,text='validate', command=calc).pack() – Marco May 06 '17 at 13:15
  • please don't put code in the comments. Use the [edit](http://stackoverflow.com/posts/43818742/edit) button to edit your question. – Bryan Oakley May 06 '17 at 14:00
  • do either of these links answer your question? http://stackoverflow.com/q/33646605/7432, http://stackoverflow.com/a/32213127/7432 – Bryan Oakley May 06 '17 at 14:02
  • Hallo Bryan thanks for the link, i updated my code with your description "leveraging your controller" from the link. But it doesnt work, what did i wrong? When i click on the button "Konten" there should be the output of the userinput from the pageOne Entry-Button. Can you please check my updated code again? Thanks for your affort! – Marco May 07 '17 at 11:50
  • Hallo Bryan sorry for asking again, but your code rewiev displayes the same output as before. Please tell me what du you have changed. Thanks – Marco May 07 '17 at 15:51
  • I indented all of the code; in the original, some of the code wasn't indented properly. – Bryan Oakley May 07 '17 at 15:58
  • ahh okay thats happened when i copied and paste the code, in my file the code is idented correctly like in your file. Can you please check it another time i really didnt find a way to display results in another frame. Thank you very much again. – Marco May 07 '17 at 16:16

0 Answers0