0

I'm using qgrid with pyshiny and I would like to detect what rows are selected in qgrid when the user presses a button:

from shiny import App, render, ui, reactive
import pandas as pd
from shinywidgets import *
import qgrid

app_ui = ui.page_fluid(
    output_widget("mytable"),
    ui.input_action_button("doSomething", "Do Something")
    )

def server(input, output, session):
    from pandas_datareader.data import get_data_yahoo
    spy = get_data_yahoo(
        symbols='SPY',
        start=pd.Timestamp('2011-01-01'),
        end=pd.Timestamp('2014-01-01'),
        adjust_price=True,
    )

    @output
    @render_widget
    def mytable():
        return qgrid.show_grid(spy)

    @reactive.Effect
    @reactive.event(input.doSomething)
    def doSomething():
        #do something with selected rows
        print("click")

app = App(app_ui, server)

How do I get the selected rows from mytable?

M--
  • 25,431
  • 8
  • 61
  • 93
michael
  • 245
  • 2
  • 11

0 Answers0