jaredks / rumps

Ridiculously Uncomplicated macOS Python Statusbar apps
BSD 3-Clause "New" or "Revised" License
3.09k stars 179 forks source link

Can't type any string in windows and doesn't display on top. #84

Closed grtfou closed 5 years ago

grtfou commented 6 years ago

I design a simple pop window. But..

@rumps.clicked("Setting")
def area_setting(self, sender):
    setting_window = rumps.Window(
        message='msg',
        title='Preferences',
        default_text="input in here",
        ok="Submit",
        cancel='Cancel',
        dimensions=(100, 20)
    )
    resp = setting_window.run()
    if resp.clicked:
        print(resp.text) 

Thanks.

ghost commented 5 years ago

+1

daredoes commented 5 years ago

Hello @zbot473 @grtfou !

I'm not sure what the solution to the problem is for execution in an IDE, but I do know a workaround.

The workaround is to export the code using py2app, and test it out there. The information for how to do that can be found on the README.

Definitely a hassle, but @jaredks and I are now aware of this issue. If anyone has insights on a solution to this problem, pull requests and discussions are appreciated!

jaredks commented 5 years ago

It looks like this is a problem with virtualenv. It isn't mentioned here, but I'm assuming that is what @grtfou was using (I was also).

So something like this will as leave the window behind others and not allow certain UI interactions,

virtualenv env --python=python3

If you instead use venv packaged with Python 3,

python3 -m venv env

it works. It looks like the reason for this is how virtualenv copies the executable. It is explained well here https://github.com/pypa/virtualenv/issues/322.

When already created, I'm not sure there will be any clean way to get it to function properly.

grtfou commented 5 years ago

Yes. I use pyenv to build my virtual environment.

About py2app solution. I can't try it because setup py2app fail in my computer (maybe some reason). So I followed @jaredks's idea, try to fix virtualenv problem.

Then...It's work. The issue is virtualenv problem. :)

# Build a new virtualenv
$ CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" \
    PYTHON_CONFIGURE_OPTS="--enable-unicode=ucs2 --enable-framework" \
    pyenv install -v 3.7.3

$ python -V
3.7.3
$ pip install rumps
$ python myapp.py            # It's work (MacOS version 10.14.4)

Thanks for @daredoes and @jaredks help.

ref:

jaredks commented 5 years ago

@grtfou Are you able to test https://github.com/jaredks/rumps/pull/117? It's an ugly hack but it does allow interaction for me.

grtfou commented 5 years ago

Sure. 🤔

I test it. It's work for me.

### Test use venv  ###
$ python3 -m venv myenv
$ source myenv/bin/activate
$ (myenv) git clone https://github.com/jaredks/rumps.git
$ (myenv) cd rumps
$ (myenv) git checkout e4d48c0
$ (myenv) python setup install
$ (myenv) pip freeze
pyobjc-core==5.2
pyobjc-framework-Cocoa==5.2
rumps==0.3.0.dev0

$ (myenv) which python
/Users/<my_path>/myenv/bin/python
$ (myenv) python -V         # Python 3.7.0
$ (myenv) python my_app.py  # it's work
jaredks commented 5 years ago

@grtfou Thanks!