Hi everyone!
I’m new using dash but I think it awesome and has a lot of potential.
Recently I’ve tried to create an application that get information from a Windows application (SAP) and show this information with graphs to users.
I tried a test but I can’t connect with the program correctly with “win32com.client.GetObject(“SAPGUI”)” as I usually do. Here is my example where I link the function to the callback of the button and performance a simply task. It seems that when I run the server, the function of win32com is blocked.
import dash
import dash_html_components as html
import dash_core_components as dcc
import win32com.client
import sys
# Function to return to the initial page for ARP
def SAP_VolverInicio():
try:
# Conectamos
SapGuiAuto = win32com.client.GetObject("SAPGUI")
if not type(SapGuiAuto) == win32com.client.CDispatch:
return
SapGuiAuto = win32com.client.GetObject("SAPGUI")
application = SapGuiAuto.GetScriptingEngine
connection = application.Children(0)
session = connection.Children(0)
cabecera = session.findById("wnd[0]").Text.strip()
while cabecera[:15] != "SAP Easy Access":
session.findById("wnd[0]").sendVKey(15)
cabecera = session.findById("wnd[0]").Text.strip()
if session.Children.count > 1:
session.findById("wnd[1]").Close
except:
print(sys.exc_info())
finally:
session = None
connection = None
application = None
SapGuiAuto = None
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Div(dcc.Input(id='input-box', type='text')),
html.Button('Submit', id='button',n_clicks=0),
html.Div(id='container-button-basic',
children='Enter a value and press submit')
])
@app.callback(
dash.dependencies.Output('container-button-basic', 'children'),
[dash.dependencies.Input('button', 'n_clicks')])
def update_output(n_clicks):
if n_clicks>0:
SAP_VolverInicio()
return 'Test'
if __name__ == '__main__':
app.run_server(debug=True, threaded=True)
Any help or idea would be very helpful.
Thank you very much.