Re: [PyQt] Mac OS X Problem: PyQT applications not focusing on launch

2009-09-28 Thread Holger Rapp


Am 25.09.2009 um 18:24 schrieb Alexei Puzikov:


hello = HelloWorld()
hello.show()
hello.raise_() # this will raise the window on Mac OS X
sys.exit(app.exec_())
This was a mighty useful advice. The internet doesn't seem to be aware  
of this
solution (as mentioned, I only found the clue to pack things together  
via
py2app). Is there a possibility to make this more prominent in the  
docs or add a

page with Mac OS X notes to some wiki?

Cheers,
Holger



Given it's a Mac-only problem, which wasn't reproducible with Qt, only
PyQt, for me it looks like a PyQt bug. But the fix is quite easy.

A.

On Fri, Sep 25, 2009 at 5:16 PM, Holger Rapp r...@mrt.uka.de wrote:

Hi,

Every pyqt example I start under Mac OS X (PyQt 4.5.4, Python 2.6  
from

Python.org, Mac OS X 10.5.8), no matter which (I tried the delivered
examples
in the source distribution and also the examples from the python  
book [1], I
also tried the eric IDE and spyder) fail to receive the focus when  
launched.
A click is needed to raise the application. Sometimes the newly  
opened

window
is hidden under others.

I am aware that I have to use pythonw (instead of python) for GUI  
scripts,

but
this doesn't change anything. After googling I read that I just  
have to

bundle
my scripts in .app packages because the issues is all Apples fault.  
I feel

this is
unelegant and most importantly: all wxpython applications RECEIVE  
the focus
when launched (no matter if with python or pythonw), therefore  
there IS a

way
to make scripts open up GUI applications with focus. I give code  
examples

for
pyqt (no focus) and WXPython (receives focus) below my message.

Maybe someone with more insight can shed some light on this problem.

[1] http://www.qtrac.eu/pyqtbook.tar.gz

Greetings,
Holger

--- SNIP ---
# encoding: utf-8
# wxPython example. This receives focus on launch.
# Launch with
# $ python hello_world_wx.py
# File: hello_world_wx.py

import wx
app = wx.PySimpleApp()
frame = wx.Frame(None, wx.ID_ANY, Hello World)
frame.Show(True)
app.MainLoop()
--- SNAP ---

--- SNIP ---
# encoding: utf-8
# pyqt example. This DOES NOT receives focus on launch.
# Launch with
# $ python hello_world_qt.py
# or
# $ pythonw hello_world_qt.py
# Doesn't make a difference on my computer.
# File: hello_world_qt.py

from PyQt4 import QtCore, QtGui
import sys

class HelloWorld(QtGui.QWidget):
  def __init__(self, parent=None):
  super(HelloWorld, self).__init__(parent)

  self.setWindowTitle(Hello World)

app = QtGui.QApplication(sys.argv)
hello = HelloWorld()
hello.show()
sys.exit(app.exec_())
--- SNAP ---


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt



___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Mac OS X Problem: PyQT applications not focusing on launch

2009-09-28 Thread David Boddie
On Mon Sep 28 11:37:27 BST 2009, Holger Rapp wrote:
 Am 25.09.2009 um 18:24 schrieb Alexei Puzikov:
  hello = HelloWorld()
  hello.show()
  hello.raise_() # this will raise the window on Mac OS X
  sys.exit(app.exec_())

 This was a mighty useful advice. The internet doesn't seem to be aware
 of this solution (as mentioned, I only found the clue to pack things
 together via py2app). Is there a possibility to make this more prominent
 in the docs or add a page with Mac OS X notes to some wiki?

Maybe somewhere in the PyQt Wiki:

  http://www.diotavelli.net/PyQtWiki/StartPage

Perhaps create a Platform Specific Notes page and add a link to it in the
list under Developing with PyQt and PyKDE on the main page.

David
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Mac OS X Problem: PyQT applications not focusing on launch

2009-09-25 Thread Alexei Puzikov
hello = HelloWorld()
hello.show()
hello.raise_() # this will raise the window on Mac OS X
sys.exit(app.exec_())


Given it's a Mac-only problem, which wasn't reproducible with Qt, only
PyQt, for me it looks like a PyQt bug. But the fix is quite easy.

A.

On Fri, Sep 25, 2009 at 5:16 PM, Holger Rapp r...@mrt.uka.de wrote:
 Hi,

 Every pyqt example I start under Mac OS X (PyQt 4.5.4, Python 2.6 from
 Python.org, Mac OS X 10.5.8), no matter which (I tried the delivered
 examples
 in the source distribution and also the examples from the python book [1], I
 also tried the eric IDE and spyder) fail to receive the focus when launched.
 A click is needed to raise the application. Sometimes the newly opened
 window
 is hidden under others.

 I am aware that I have to use pythonw (instead of python) for GUI scripts,
 but
 this doesn't change anything. After googling I read that I just have to
 bundle
 my scripts in .app packages because the issues is all Apples fault. I feel
 this is
 unelegant and most importantly: all wxpython applications RECEIVE the focus
 when launched (no matter if with python or pythonw), therefore there IS a
 way
 to make scripts open up GUI applications with focus. I give code examples
 for
 pyqt (no focus) and WXPython (receives focus) below my message.

 Maybe someone with more insight can shed some light on this problem.

 [1] http://www.qtrac.eu/pyqtbook.tar.gz

 Greetings,
 Holger

 --- SNIP ---
 # encoding: utf-8
 # wxPython example. This receives focus on launch.
 # Launch with
 # $ python hello_world_wx.py
 # File: hello_world_wx.py

 import wx
 app = wx.PySimpleApp()
 frame = wx.Frame(None, wx.ID_ANY, Hello World)
 frame.Show(True)
 app.MainLoop()
 --- SNAP ---

 --- SNIP ---
 # encoding: utf-8
 # pyqt example. This DOES NOT receives focus on launch.
 # Launch with
 # $ python hello_world_qt.py
 # or
 # $ pythonw hello_world_qt.py
 # Doesn't make a difference on my computer.
 # File: hello_world_qt.py

 from PyQt4 import QtCore, QtGui
 import sys

 class HelloWorld(QtGui.QWidget):
def __init__(self, parent=None):
super(HelloWorld, self).__init__(parent)

self.setWindowTitle(Hello World)

 app = QtGui.QApplication(sys.argv)
 hello = HelloWorld()
 hello.show()
 sys.exit(app.exec_())
 --- SNAP ---


 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Mac OS X Problem: PyQT applications not focusing on launch

2009-09-25 Thread Hans-Peter Jansen
Am Freitag 25 September 2009 schrieb Alexei Puzikov:
 hello = HelloWorld()
 hello.show()
 hello.raise_() # this will raise the window on Mac OS X
 sys.exit(app.exec_())


 Given it's a Mac-only problem, which wasn't reproducible with Qt, only
 PyQt, for me it looks like a PyQt bug. But the fix is quite easy.

No, it's not a PyQt issue, it's about Qt being compliant with Apple design 
guidelines.. (red that in some Qt developer blog, but didn't remember the 
address..)

I bet, wxpython does ignore these guides and implicitely raises the window. 
Now imagine, you try to respect them with wx.. Calling raise_() is a small 
price to pay, doesn't it?

Pete

 A.

 On Fri, Sep 25, 2009 at 5:16 PM, Holger Rapp r...@mrt.uka.de wrote:
  Hi,
 
  Every pyqt example I start under Mac OS X (PyQt 4.5.4, Python 2.6 from
  Python.org, Mac OS X 10.5.8), no matter which (I tried the delivered
  examples
  in the source distribution and also the examples from the python book
  [1], I also tried the eric IDE and spyder) fail to receive the focus
  when launched. A click is needed to raise the application. Sometimes
  the newly opened window
  is hidden under others.
 
  I am aware that I have to use pythonw (instead of python) for GUI
  scripts, but
  this doesn't change anything. After googling I read that I just have to
  bundle
  my scripts in .app packages because the issues is all Apples fault. I
  feel this is
  unelegant and most importantly: all wxpython applications RECEIVE the
  focus when launched (no matter if with python or pythonw), therefore
  there IS a way
  to make scripts open up GUI applications with focus. I give code
  examples for
  pyqt (no focus) and WXPython (receives focus) below my message.
 
  Maybe someone with more insight can shed some light on this problem.
 
  [1] http://www.qtrac.eu/pyqtbook.tar.gz
 
  Greetings,
  Holger
 
  --- SNIP ---
  # encoding: utf-8
  # wxPython example. This receives focus on launch.
  # Launch with
  # $ python hello_world_wx.py
  # File: hello_world_wx.py
 
  import wx
  app = wx.PySimpleApp()
  frame = wx.Frame(None, wx.ID_ANY, Hello World)
  frame.Show(True)
  app.MainLoop()
  --- SNAP ---
 
  --- SNIP ---
  # encoding: utf-8
  # pyqt example. This DOES NOT receives focus on launch.
  # Launch with
  # $ python hello_world_qt.py
  # or
  # $ pythonw hello_world_qt.py
  # Doesn't make a difference on my computer.
  # File: hello_world_qt.py
 
  from PyQt4 import QtCore, QtGui
  import sys
 
  class HelloWorld(QtGui.QWidget):
 def __init__(self, parent=None):
 super(HelloWorld, self).__init__(parent)
 
 self.setWindowTitle(Hello World)
 
  app = QtGui.QApplication(sys.argv)
  hello = HelloWorld()
  hello.show()
  sys.exit(app.exec_())
  --- SNAP ---
 
 
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt

 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt