Re: [Ubuntu] PyQt5

2015-11-09 Thread Terry Reedy

On 11/8/2015 9:41 PM, Laura Creighton wrote:

In a message of Sun, 08 Nov 2015 18:05:32 -0500, Terry Reedy writes:



I just read somewhere that the issue could be because I was trying to
run these examples from within Idle.


First let me note that a) IDLE is meant for learning Python and 
developing Python programs, and b) IDLE using tkinter/tcl/tk and 
programs that introspect too deeply or interact with hardware can 
interfere with each other.  I recently added

https://docs.python.org/3/library/idle.html#idle-console-differences
to document some differences from console python.

Can IDLE be used for developing GUI programs?  In the case of tkinter, 
yes.  For 3.x, at least, I believe there are advantages over plain 
editors.  For other gui packages, I would like to know what limitations 
or problems there are so I can warn people against trying to do things 
that will not work.  Hence the questions below.



I am an IDLE maintainer.  Am I to take it that everything ran fine
before you tried to quit?  If not, I would want to know why and try to fix.

If you run tut.py from an IDLE editor, IDLE tries to run it the same as
if you ran it at a console in the tut.py directory with 'python3 -i
tut.py'.  I can imagine that there might be a problem with the
transition from gui mode to interactive shell mode, though it works for
tkinter apps.  You said 'python3 tut.py' works.  What happens if you add
the '-i' option?  I'd like to know if the transition problem is in
(Py)qt5 or in IDLE's simulation of '-i'.



I suspect that Qt and Idle are disagreeing as to who gets to have the
main thread around here.


I doubt this is the specific problem because user code, here invoking 
pyqt and qt, are run in a separate process.  While it is running, I 
believe the only Idle code that would run is in the substitute 
stdin/out/err, which are only used if the user code calls input, print, 
or .write() or raises.  Instead of


> python3 -i mypyqt.py

at a console prompt, IDLE starts a subprocess with

> python -m idlelib.run mypyqt.py

The latter sets up socket communication, a locals namespace that 
imitates __main__, and a few other things and then runs

   exec(open(mypyqt.py).read(), locals).

I can imagine a few different ways things could get messed up, which is 
why I asked the specific questions I did.  For instance, if a program 
rebinds the standard stream but does not restore them, because it 
assumes that exiting the program mean exiting the process (as would 
normally be the case with a gui program), then the '-i' option and the 
IDLE simulation thereof may not work.


In thinking about this, I realized that I could test that idlelib.run at 
least works with all stdlib modules by running the entire CPython test 
suite in the execution process.  I already run idle tests in IDLE while 
developing them, but had never thought about the fact that I was testing 
the run module also.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: [Ubuntu] PyQt5

2015-11-08 Thread Laura Creighton
In a message of Sun, 08 Nov 2015 18:05:32 -0500, Terry Reedy writes:
>On 11/8/2015 11:03 AM, Andrew Diamond wrote:
>> On Saturday, November 7, 2015 at 10:13:25 PM UTC-5, Andrew Diamond
>> wrote:
>>> Hi!
>>>
>>> I'm fairly new to Python, and installed pyqt5 and began working
>>> through the examples at http://zetcode.com/gui/pyqt5/menustoolbars/
>>> However, whenever I click one of the buttons or menus in the
>>> example apps I run that is supposed to quit the application, it
>>> locks up.
>
>What is 'it'?  And what does 'lock up' mean?  Did the gui freeze and not 
>disappear?  Or did IDLE itself freeze, and even the menu quit working?
>
>>> This happens with all the examples I installed that
>>> handle code to quit the app.
>>>
>>> Running Ubuntu 15.10, and installed pyqt5 via:
>>>
>>> sudo apt-get install python3-pyqt5 sudo apt-get install qtcreator
>
>> I just read somewhere that the issue could be because I was trying to
>> run these examples from within Idle.
>
>I am an IDLE maintainer.  Am I to take it that everything ran fine 
>before you tried to quit?  If not, I would want to know why and try to fix.
>
>If you run tut.py from an IDLE editor, IDLE tries to run it the same as 
>if you ran it at a console in the tut.py directory with 'python3 -i 
>tut.py'.  I can imagine that there might be a problem with the 
>transition from gui mode to interactive shell mode, though it works for 
>tkinter apps.  You said 'python3 tut.py' works.  What happens if you add 
>the '-i' option?  I'd like to know if the transition problem is in 
>(Py)qt5 or in IDLE's simulation of '-i'.
>
>-- 
>Terry Jan Reedy

I suspect that Qt and Idle are disagreeing as to who gets to have the
main thread around here.

Laura

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Ubuntu] PyQt5

2015-11-08 Thread Terry Reedy

On 11/8/2015 11:03 AM, Andrew Diamond wrote:

On Saturday, November 7, 2015 at 10:13:25 PM UTC-5, Andrew Diamond
wrote:

Hi!

I'm fairly new to Python, and installed pyqt5 and began working
through the examples at http://zetcode.com/gui/pyqt5/menustoolbars/
However, whenever I click one of the buttons or menus in the
example apps I run that is supposed to quit the application, it
locks up.


What is 'it'?  And what does 'lock up' mean?  Did the gui freeze and not 
disappear?  Or did IDLE itself freeze, and even the menu quit working?



This happens with all the examples I installed that
handle code to quit the app.

Running Ubuntu 15.10, and installed pyqt5 via:

sudo apt-get install python3-pyqt5 sudo apt-get install qtcreator



I just read somewhere that the issue could be because I was trying to
run these examples from within Idle.


I am an IDLE maintainer.  Am I to take it that everything ran fine 
before you tried to quit?  If not, I would want to know why and try to fix.


If you run tut.py from an IDLE editor, IDLE tries to run it the same as 
if you ran it at a console in the tut.py directory with 'python3 -i 
tut.py'.  I can imagine that there might be a problem with the 
transition from gui mode to interactive shell mode, though it works for 
tkinter apps.  You said 'python3 tut.py' works.  What happens if you add 
the '-i' option?  I'd like to know if the transition problem is in 
(Py)qt5 or in IDLE's simulation of '-i'.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: [Ubuntu] PyQt5

2015-11-08 Thread Andrew Diamond
On Sunday, November 8, 2015 at 11:22:30 AM UTC-5, Chris Angelico wrote:
> On Mon, Nov 9, 2015 at 3:03 AM, Andrew Diamond  wrote:
> > On Saturday, November 7, 2015 at 10:13:25 PM UTC-5, Andrew Diamond wrote:
> >> Hi!
> >>
> >> I'm fairly new to Python, and installed pyqt5 and began working through 
> >> the examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, 
> >> whenever I click one of the buttons or menus in the example apps I run 
> >> that is supposed to quit the application, it locks up.  This happens with 
> >> all the examples I installed that handle code to quit the app.
> >>
> >> Running Ubuntu 15.10, and installed pyqt5 via:
> >>
> >> sudo apt-get install python3-pyqt5
> >> sudo apt-get install qtcreator
> >>
> >> Thank you in advance for any assistance!
> >
> > I just read somewhere that the issue could be because I was trying to run 
> > these examples from within Idle.  However, when I try to run them from the 
> > terminal, I run into another snag:
> >
> > andrew@andrew-Satellite-P755:~/Programming/Python$ python tut8.py
> > Traceback (most recent call last):
> >   File "tut8.py", line 16, in 
> > from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
> > ImportError: No module named PyQt5.QtWidgets
> >
> > ...a path issue?
> 
> If you installed "python3-pyqt5", you probably want to run "python3
> tut8.py". There are potentially two completely separate Python
> interpreters installed - version 2.7, and the latest available version
> 3.x (probably 3.4 or 3.5). You've installed a package for Python 3,
> but haven't installed the corresponding Python 2 package, so it won't
> run under the Python 2 interpreter. Compare these:
> 
> $ python --version
> $ python3 --version
> 
> I suspect that "python3 tut8.py" should work. If it doesn't, post some
> more info about your Idle installation; it might give a hint as to
> what's going on.
> 
> ChrisA

You were absolutely correct!

$ python3 tut8.py 

...worked great, thanks!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Ubuntu] PyQt5

2015-11-08 Thread Chris Angelico
On Mon, Nov 9, 2015 at 3:03 AM, Andrew Diamond  wrote:
> On Saturday, November 7, 2015 at 10:13:25 PM UTC-5, Andrew Diamond wrote:
>> Hi!
>>
>> I'm fairly new to Python, and installed pyqt5 and began working through the 
>> examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, whenever I 
>> click one of the buttons or menus in the example apps I run that is supposed 
>> to quit the application, it locks up.  This happens with all the examples I 
>> installed that handle code to quit the app.
>>
>> Running Ubuntu 15.10, and installed pyqt5 via:
>>
>> sudo apt-get install python3-pyqt5
>> sudo apt-get install qtcreator
>>
>> Thank you in advance for any assistance!
>
> I just read somewhere that the issue could be because I was trying to run 
> these examples from within Idle.  However, when I try to run them from the 
> terminal, I run into another snag:
>
> andrew@andrew-Satellite-P755:~/Programming/Python$ python tut8.py
> Traceback (most recent call last):
>   File "tut8.py", line 16, in 
> from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
> ImportError: No module named PyQt5.QtWidgets
>
> ...a path issue?

If you installed "python3-pyqt5", you probably want to run "python3
tut8.py". There are potentially two completely separate Python
interpreters installed - version 2.7, and the latest available version
3.x (probably 3.4 or 3.5). You've installed a package for Python 3,
but haven't installed the corresponding Python 2 package, so it won't
run under the Python 2 interpreter. Compare these:

$ python --version
$ python3 --version

I suspect that "python3 tut8.py" should work. If it doesn't, post some
more info about your Idle installation; it might give a hint as to
what's going on.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Ubuntu] PyQt5

2015-11-08 Thread Andrew Diamond
On Saturday, November 7, 2015 at 10:13:25 PM UTC-5, Andrew Diamond wrote:
> Hi!
> 
> I'm fairly new to Python, and installed pyqt5 and began working through the 
> examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, whenever I 
> click one of the buttons or menus in the example apps I run that is supposed 
> to quit the application, it locks up.  This happens with all the examples I 
> installed that handle code to quit the app.
> 
> Running Ubuntu 15.10, and installed pyqt5 via:
> 
> sudo apt-get install python3-pyqt5
> sudo apt-get install qtcreator
> 
> Thank you in advance for any assistance!

I just read somewhere that the issue could be because I was trying to run these 
examples from within Idle.  However, when I try to run them from the terminal, 
I run into another snag:

andrew@andrew-Satellite-P755:~/Programming/Python$ python tut8.py 
Traceback (most recent call last):
  File "tut8.py", line 16, in 
from PyQt5.QtWidgets import QMainWindow, QAction, qApp, QApplication
ImportError: No module named PyQt5.QtWidgets

...a path issue?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Ubuntu] PyQt5

2015-11-08 Thread Laura Creighton
In a message of Sun, 08 Nov 2015 06:36:26 +0100, Vincent Vande Vyvre writes:
>Le 08/11/2015 04:13, Andrew Diamond a écrit :
>> Hi!
>>
>> I'm fairly new to Python, and installed pyqt5 and began working through the 
>> examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, whenever I 
>> click one of the buttons or menus in the example apps I run that is supposed 
>> to quit the application, it locks up.  This happens with all the examples I 
>> installed that handle code to quit the app.
>>
>> Running Ubuntu 15.10, and installed pyqt5 via:
>>
>> sudo apt-get install python3-pyqt5
>> sudo apt-get install qtcreator
>>
>> Thank you in advance for any assistance!
>Works fine for me on 15.04.
>
>I've tested the first example with the menuBar.
>
>Have you a message into the terminal? Maybe an error?
>
>Vincent

A suggestion:

When I get the 'it locks up when I want to quit' behaviour
in PyQt4 it is because I have messed up something with my threading.
PyQt4 wants there to be one, main control thread (that handles, among
other things, shutting down) and lots of worker threads which do the
gui-stuff, i.e. all the work that the program really needs to do.

If you manage to structure things so that your control ends up in
a worker thread, then when it is told to quit, your app sits around
and waits for the main control thread to come back and deal with things,
but your main control thread is dead, and therefore isn't coming.

I assume you can get problems like this with Qt5 as well.

Did quitting work properly with the earlier exercises of this tutorial,
or did you try to start learning from the middle?

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [Ubuntu] PyQt5

2015-11-07 Thread Vincent Vande Vyvre

Le 08/11/2015 04:13, Andrew Diamond a écrit :

Hi!

I'm fairly new to Python, and installed pyqt5 and began working through the 
examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, whenever I 
click one of the buttons or menus in the example apps I run that is supposed to 
quit the application, it locks up.  This happens with all the examples I 
installed that handle code to quit the app.

Running Ubuntu 15.10, and installed pyqt5 via:

sudo apt-get install python3-pyqt5
sudo apt-get install qtcreator

Thank you in advance for any assistance!

Works fine for me on 15.04.

I've tested the first example with the menuBar.

Have you a message into the terminal? Maybe an error?

Vincent
--
https://mail.python.org/mailman/listinfo/python-list


[Ubuntu] PyQt5

2015-11-07 Thread Andrew Diamond
Hi!

I'm fairly new to Python, and installed pyqt5 and began working through the 
examples at http://zetcode.com/gui/pyqt5/menustoolbars/  However, whenever I 
click one of the buttons or menus in the example apps I run that is supposed to 
quit the application, it locks up.  This happens with all the examples I 
installed that handle code to quit the app.

Running Ubuntu 15.10, and installed pyqt5 via:

sudo apt-get install python3-pyqt5
sudo apt-get install qtcreator

Thank you in advance for any assistance!
-- 
https://mail.python.org/mailman/listinfo/python-list