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

pandasgui shutdown out of interactive cmd, pandasgui.show(df, settings={'block': True}) is needed. #65

Closed
forhonourlx opened this issue Nov 8, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@forhonourlx
Copy link

Hi @adamerose ,

I am trying pandasgui in some python script, unlike in interactive cmd, it shutdown immediately after running.
I find settings={'block': True} is necessary, would you please figure it out in the demo examples?
Thank you and pandasgui is nice tool!

@forhonourlx forhonourlx added the bug Something isn't working label Nov 8, 2020
@adamerose
Copy link
Owner

adamerose commented Nov 8, 2020

It's working properly for me:

image

I have some logic to make it so settings={'block': True} isn't needed in most cases, this is it:

def in_interactive_console():
    # https://stackoverflow.com/a/64523765/3620725
    return hasattr(sys, 'ps1')

if in_interactive_console():
    # Don't block if in an interactive console (so you can view GUI and still continue running commands)
    block = False
else:
    # If in a script, we need to block or the script will continue and finish without allowing GUI interaction
    block = True

How are you running the script? Are you running it from cmd or bash or some IDE? The only test case where it doesn't predict properly is when I run a script from PyCharm with this option checked, otherwise it always blocks properly

image

@forhonourlx
Copy link
Author

Hi,

I am running the following code on win10 anaconda python3.6, pandasgui.show() shutdown immediately without a block.

import pandas as pd
import pandasgui

class Render(object):
    def __init__(self, xlsx):
        self.store = pd.read_excel(xlsx, sheet_name=None)

if __name__ == '__main__':
    cr = Render('aaaa.xlsx')
    pandasgui.show(**cr.store)

@adamerose
Copy link
Owner

adamerose commented Nov 8, 2020

Run pip install --upgrade pandasgui to make sure you have the latest version of PandasGUI.

I am running the following code on win10 anaconda python3.6

But what method are you actually using to run your script, are you typing python myscript.py in Anaconda Prompt or what? I tried your code in a .py file and ran it from both cmd and Anaconda Prompt and it blocked correctly for me.

@henrybzhang
Copy link

I have the same problem in Ubuntu 20.04.1, Python 3.8.5, and pandasgui 0.2.5.1. I am running python myscript.py in a terminal where myscript.py is the basic usage example.

@adamerose
Copy link
Owner

@C0VER

pandasgui 0.2.5.1

I added the terminal detection & automatic blocking in 0.2.6

@LoganKells
Copy link

@C0VER

pandasgui 0.2.5.1

I added the terminal detection & automatic blocking in 0.2.6

Running an upgrade shows the latest available version is 0.2.5.1 FYI.

@adamerose
Copy link
Owner

@C0VER

pandasgui 0.2.5.1

I added the terminal detection & automatic blocking in 0.2.6

Running an upgrade shows the latest available version is 0.2.5.1 FYI.

Oh! Thanks for pointing that out, latest versions are on PyPi now

@LoganKells
Copy link

@C0VER

pandasgui 0.2.5.1

I added the terminal detection & automatic blocking in 0.2.6

Running an upgrade shows the latest available version is 0.2.5.1 FYI.

Oh! Thanks for pointing that out, latest versions are on PyPi now

Awesome v0.2.7 is working now in a .py script! Thank you!

@adamerose
Copy link
Owner

Closing this since it sounds like this was just due to the PyPi release being older than the README... @forhonourlx please reopen if your issue still persists on latest release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants