Reputation: 71
I was wondering if there is a way how to implement the rendered "webview" into customTkinter frame?
import customtkinter
import webview
from customtkinter import CTk, CTkFrame
def Get_Main_Frame(Frame: CTk|CTkFrame) -> CTkFrame:
Frame_NonScrolable = CTkFrame(
master = Frame,
width = 1700,
height = 500,
corner_radius = 6,
border_width = 1,
border_color = "#111219",
bg_color = "transparent",
fg_color = "transparent")
return Frame_NonScrolable
def Get_Button_Frame(Frame: CTk|CTkFrame) -> CTkFrame:
Frame_NonScrolable = CTkFrame(
master = Frame,
width = 1700,
height = 90,
corner_radius = 6,
border_width = 1,
border_color = "#111219",
bg_color = "transparent",
fg_color = "transparent")
return Frame_NonScrolable
def Get_Chart_Frame(Frame: CTk|CTkFrame) -> CTkFrame:
Frame_NonScrolable = CTkFrame(
master = Frame,
width = 1700,
height = 410,
corner_radius = 6,
border_width = 1,
border_color = "#111219",
bg_color = "transparent",
fg_color = "transparent")
return Frame_NonScrolable
# Create the main window
root = customtkinter.CTk()
root.geometry("1700x550")
# Function to create and embed the webview window
def DashBoard_Project():
#! How to render webvie into "Frame_Chart_Area" Frame?
webview.create_window(title="", width=1645, height=410, url=f"Operational\\DashBoard_Project_Dark.html", frameless=True, easy_drag=True)
webview.start()
def DashBoard_Activity():
#! How to render webvie into "Frame_Chart_Area" Frame?
webview.create_window(title="", width=1645, height=410, url=f"Operational\\DashBoard_Activity_Dark.html", frameless=True, easy_drag=True)
webview.start()
def DashBoard_Utilization():
#! How to render webvie into "Frame_Chart_Area" Frame?
webview.create_window(title="", width=1645, height=410, url=f"Operational\\DashBoard_Utilization_Dark.html", frameless=True, easy_drag=True)
webview.start()
Frame_Background = Get_Main_Frame(Frame=root)
Frame_Background.pack(side="top", fill="x", expand=True)
Frame_Button_Area = Get_Button_Frame(Frame=Frame_Background)
Frame_Button_Area.pack(side="top", fill="x", expand=True)
Frame_Chart_Area = Get_Chart_Frame(Frame=Frame_Background)
Frame_Chart_Area.pack(side="top", fill="x", expand=True)
# Create a button to load the webview
load_button = customtkinter.CTkButton(master=Frame_Button_Area, text="Project", command=DashBoard_Project)
load_button.pack(side="left", pady=10, expand=True)
load_button = customtkinter.CTkButton(master=Frame_Button_Area, text="Activity", command=DashBoard_Activity)
load_button.pack(side="left", pady=10, expand=True)
load_button = customtkinter.CTkButton(master=Frame_Button_Area, text="Utilization", command=DashBoard_Utilization)
load_button.pack(side="left", pady=10, expand=True)
# Run the application
root.mainloop()
You can add any web page instead of mine, I can provide them in case of request, just don't know hot wo provide them now.
The aim of my request is to build an dashboard containing charts (generated by python + bokeh lib).
Upvotes: 0
Views: 67