Browse Source

integrated Backend and started Personframe

master
Eddie 2 years ago
parent
commit
564a945fc0
  1. 32
      api.py
  2. 11
      app.py
  3. 22
      frames.py

32
api.py

@ -0,0 +1,32 @@
#from requests.auth import HTTPBasicAuth
import requests, os
from dotenv import load_dotenv
load_dotenv()
# get .env vars
url = os.getenv('URL')
key = os.getenv('API_KEY')
header = {"Authorization": "Bearer " + key}
def get_person_all():
endpoint = url + 'budget-py-personens'
r = requests.get(url=endpoint, headers=header)
data = r.json()
return data
def get_endpoint(endpoint):
endpoint = url + endpoint
r = requests.get(url=endpoint, headers=header)
data = r.json()
return data
def post_endpoint(endpoint, data):
endpoint = url + endpoint
r = requests.post(url = endpoint, data = data, headers=header)
return r.text
#print(get_person_all())
#print(get_endpoint('budget-py-personens'))
#print(post_endpoint('budget-py-personens', {'Name':'Eddie'}))

11
app.py

@ -2,21 +2,22 @@ import tkinter
import customtkinter import customtkinter
from frames import (SidebarFrame, PersonFrame, VermögenFrame, from frames import (SidebarFrame, PersonFrame, VermögenFrame,
ProjekteFrame, KategorieFrame, EinträgeFrame, ProjekteFrame, KategorieFrame, EinträgeFrame,
ÜbersichtFrame, ExportFrame) ÜbersichtFrame, ExportFrame, ExampleFrame)
# Main application # Main application
class App(customtkinter.CTk): class App(customtkinter.CTk):
def __init__(self): def __init__(self):
super().__init__() super().__init__()
#container to pack different windows of the app into # Container to pack different windows of the app into
container = customtkinter.CTkFrame(self) container = customtkinter.CTkFrame(self)
container.pack(expand=True, fill='both') container.pack(expand=True, fill='both')
container.grid_rowconfigure(0, weight=1) container.grid_rowconfigure(0, weight=1)
container.grid_columnconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1)
# Sidebar Creation
self.sidebar = SidebarFrame(container, self) self.sidebar = SidebarFrame(container, self)
self.sidebar.grid(row=0, column=0, padx=20, pady=20) self.sidebar.grid(row=0, column=0, padx=20, pady=20)
# Frame Creation
self.frames = {} self.frames = {}
self.frames['personFrame'] = PersonFrame(container, self) self.frames['personFrame'] = PersonFrame(container, self)
self.frames['vermögenFrame'] = VermögenFrame(container, self) self.frames['vermögenFrame'] = VermögenFrame(container, self)
@ -25,9 +26,9 @@ class App(customtkinter.CTk):
self.frames['einträgeFrame'] = EinträgeFrame(container, self) self.frames['einträgeFrame'] = EinträgeFrame(container, self)
self.frames['übersichtFrame'] = ÜbersichtFrame(container, self) self.frames['übersichtFrame'] = ÜbersichtFrame(container, self)
self.frames['exportFrame'] = ExportFrame(container, self) self.frames['exportFrame'] = ExportFrame(container, self)
self.frames['exampleFrame'] = ExampleFrame(container, self)
for F in ('personFrame', 'vermögenFrame', 'projekteFrame', for F in (self.frames):
'kategorieFrame', 'einträgeFrame', 'übersichtFrame', 'exportFrame'):
self.frames[F].grid(row = 0, column = 1, sticky='nsew') self.frames[F].grid(row = 0, column = 1, sticky='nsew')

22
frames.py

@ -1,6 +1,7 @@
import tkinter import tkinter
import tkinter.messagebox import tkinter.messagebox
import customtkinter import customtkinter
from api import get_person_all
@ -63,6 +64,9 @@ class ÜbersichtFrame(customtkinter.CTkFrame):
self.textbox = customtkinter.CTkTextbox(self, width=600, height=100) self.textbox = customtkinter.CTkTextbox(self, width=600, height=100)
self.textbox.grid(row=0, column=0, padx=(20, 0), pady=(20, 0), sticky="nsew") self.textbox.grid(row=0, column=0, padx=(20, 0), pady=(20, 0), sticky="nsew")
# set default values # set default values
self.textbox.insert("0.0", "Übersicht\n\n" + 'Hier kanst du dir eine Übersicht über deine Ausgaben und Einnahmen verschaffen. Alle eingetragenen Daten werden hier für dich einfach nachvollziehbar angezeigt.') self.textbox.insert("0.0", "Übersicht\n\n" + 'Hier kanst du dir eine Übersicht über deine Ausgaben und Einnahmen verschaffen. Alle eingetragenen Daten werden hier für dich einfach nachvollziehbar angezeigt.')
self.textbox.configure(state='disabled') self.textbox.configure(state='disabled')
@ -84,12 +88,24 @@ class PersonFrame(customtkinter.CTkFrame):
customtkinter.CTkFrame.__init__(self, parent) customtkinter.CTkFrame.__init__(self, parent)
#super().__init__(*args, **kwargs) #super().__init__(*args, **kwargs)
# create textbox # create textbox
persons = get_person_all()
personNames = []
for person in persons:
personNames.append(person['Name'])
self.textbox = customtkinter.CTkTextbox(self, width=600, height=100) self.textbox = customtkinter.CTkTextbox(self, width=600, height=100)
self.textbox.grid(row=0, column=0, padx=(20, 0), pady=(20, 0), sticky="nsew") self.textbox.grid(row=0, column=0, padx=(20, 0), pady=(20, 0), sticky="nsew")
self.activePersonLabel = customtkinter.CTkLabel(self, text='Aktive Person')
self.activePersonLabel.grid(row=1,column=0, padx=(20, 0), pady=(20,0), sticky="nw")
self.optionMenu = customtkinter.CTkOptionMenu(self,values=personNames, command=self.optionmenu_callback)
self.optionMenu.grid(row=2, column=0, padx=(20, 0), sticky="nw")
# set default values # set default values
self.textbox.insert("0.0", "Person\n\n" + 'Hier kannst du neue Personen erstellen, und die aktuell aktive Person') self.textbox.insert("0.0", "Person\n\n" + 'Hier kannst du neue Personen erstellen, und die aktuell aktive Person auswählen')
self.textbox.configure(state='disabled') self.textbox.configure(state='disabled')
def optionmenu_callback(self, choice):
print("optionmenu dropdown clicked:", choice)
class ExampleFrame(customtkinter.CTkFrame): class ExampleFrame(customtkinter.CTkFrame):
def __init__(self, parent, controller): def __init__(self, parent, controller):
@ -222,6 +238,10 @@ class SidebarFrame(customtkinter.CTkFrame):
# Button Export # Button Export
self.sidebar_button_6 = customtkinter.CTkButton(self.sidebar_frame, text="Export", command=lambda: controller.show_frame('exportFrame')) self.sidebar_button_6 = customtkinter.CTkButton(self.sidebar_frame, text="Export", command=lambda: controller.show_frame('exportFrame'))
self.sidebar_button_6.grid(row=8, column=0, padx=20, pady=10) self.sidebar_button_6.grid(row=8, column=0, padx=20, pady=10)
# Example Frame
self.sidebar_button_7 = customtkinter.CTkButton(self.sidebar_frame, text="Example", command=lambda: controller.show_frame('exampleFrame'))
self.sidebar_button_7.grid(row=9, column=0, padx=20, pady=10)
# Apperance Mode Label # Apperance Mode Label
self.appearance_mode_label = customtkinter.CTkLabel(self.sidebar_frame, text="Theme:", anchor="w") self.appearance_mode_label = customtkinter.CTkLabel(self.sidebar_frame, text="Theme:", anchor="w")

Loading…
Cancel
Save