Add some think in tab #2790
Unanswered
Ajsjsjkznz
asked this question in
Q&A
Replies: 1 comment
-
import flet as ft
import sympy as sp
def main(page: ft.Page):
page.bgcolor="#789461"
page.window_height=800
page.window_width=400
tf=ft.TextField(label="please enter your eq",value="sin(x)**2 + cos(x)**2=(x**3 + x**2 - x - 1)/(x**2 + 2 * x + 1)",width=360,bgcolor="#DBE7C9",border_radius=35,border_color="#294B29",border_width=5,color="",focused_bgcolor="#50623A",selection_color="#789461",)
def solve_equation(equation):
# Define supported variables
variables = ['x', 'a', 'b', 'd', 'z', 'y']
var_count = {var: 1 for var in variables}
# Replace '*' with multiplication sign
equation = str(tf.value).replace('*', ' * ')
# Split the equation into left and right sides
left, right = equation.split('=')
# Parse the expressions on the left and right sides and simplify them
left_expr = sp.simplify(sp.sympify(left))
right_expr = sp.simplify(sp.sympify(right))
print(left_expr,right_expr)
# Solve the equation
solutions = [sp.solve(left_expr - right_expr, variables)]
s1=solutions[0]
s2=s1[0]
return s2
btn=ft.ElevatedButton(text="solve",color="#DBE7C9",height=55,width=360,bgcolor="#50623A",on_click=solve_equation)
btn_1=ft.ElevatedButton(text="solve",color="#DBE7C9",height=55,width=360,bgcolor="#50623A")
tf_1=ft.TextField(label="please enter your algebraic",width=360,bgcolor="#DBE7C9",border_radius=35,border_color="#294B29",border_width=5,color="",focused_bgcolor="#50623A",selection_color="#789461",)
t = ft.Tabs(
selected_index=1,
animation_duration=300,
tabs=[
ft.Tab(
text="Eq",
icon=ft.icons.BOOK,
content=ft.Column([tf,btn],)
),
ft.Tab(
text="analyz algebraic expession",
icon=ft.icons.BOOK,
content=ft.Column([tf_1,btn_1])
),
],
expand=1,
)
examp01:str=solve_equation(tf.value)
page.add(t,ft.Text(value=f"s2={examp01}",size=24,weight=ft.FontWeight.BOLD))
ft.app(target=main) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Question
this is my problem
I have two tabs that don't have any name there is a text box and a button in the tab. It is stored somewhere called s2, I just want to know how to display that s2 on the first tab page
Code sample
Error message
No response
------------------------------------------------------
Beta Was this translation helpful? Give feedback.
All reactions