Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileBrowser args #707

Open
kirillantonov2901 opened this issue Sep 9, 2021 · 1 comment
Open

FileBrowser args #707

kirillantonov2901 opened this issue Sep 9, 2021 · 1 comment

Comments

@kirillantonov2901
Copy link

kirillantonov2901 commented Sep 9, 2021

import xlwings as xw
from flexx import flx
class FileViewer(flx.FileBrowserWidget):
    @flx.reaction("selected")
    def fileSelected(self, *events):
        ev = events[-1]
        print(ev)

class NewLabel(flx.Label):
    @flx.action
    def new_text(self):
        self.text('')

class Pstat(flx.PyWidget):
    def init(self):

        super().init()

        with flx.VBox():
            with flx.HBox():
                self.label_sheet_name = flx.Label(flex = 0.2 , text = "Excel Sheet :")
                self.input_sheet_name = flx.LineEdit( placeholder_text = "Enter number" )
            with flx.HBox():
                self.faq_btn = flx.Button(flex = 0.45 , text = "Data1")
                self.calcs_btn = flx.Button(flex = 0.45 , text = "Calcs")

    @flx.action
    def read_pd(self):
        xw.view(self.info)

    @flx.reaction("calcs_btn.pointer_click","faq_btn.pointer_click")
    def info(self,*events):
        if events[-1].source.text == self.faq_btn.text:
            file_in = flx.App(FileViewer).launch()
        else:
            file_in = None
        return file_in

app = flx.App(Pstat)
app.launch()
flx.run()

I need on touch "faq_btn" to open FileBrowser, choose excel file open it in xlwings and create new Label with pass to excel file.
The only way that i manage to create fileBrowser is to launch FileViewer in new session. How can i do it in one session? How can pass the path from FileBrowser to Label and read_pd function?

@almarklein
Copy link
Member

You'll need to reserve a space for the file widget to be in, e.g. in a splitter or hbox. Then you can instantiate the widget and set its parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants