Active Topics

 


Reply
Thread Tools
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#1
Hi everyone, i spent about 5 hours last night trying to open new windows within pyqt.

Managed to get hildon stackables working fine, but my app is qt ... so i'm trying to be sensible and not mix and match!

I've got to the point where the window loads fine..! Yay! - but on exit of that window, the original' window goes into a loop of hang'y'ness....

So in pseudo my aim is

Load main window
click button
open new window
<allow things to happen>
user clicks exit on that window
close sub window
return to main window...
(Allow user to continue using that window!!!!)


Ok... so in code.....
My button calls this sub
(Note my many attempts to sort out the closing - as the window is full screen at time of pressing exit)
Code:
   
def show_new_window(self):
        appt=QtGui.QApplication(sys.argv)
        win=HelloWindow()
        win.show()
        win.showFullScreen()
        appt.connect(appt, SIGNAL("lastWindowClosed()"),appt, SLOT("quit()"))
        appt.exec_loop()
The class for the new window and exit function are....

Code:
class HelloWindow(QtGui.QMainWindow):

    def __init__(self, *args):
        apply(QtGui.QMainWindow.__init__, (self,) + args)

        self.exitb = QtGui.QPushButton('Exit', self)
        self.exitb.move(10, 210)
        self.connect(self.exitb, QtCore.SIGNAL('clicked()'), self.exitB)

    def exitB(self):
        #win.hide()
        #sys.exit(app.exec_())
        self.showMaximized()
        #MainWindow.show()
        #self.hide()
I'm sure i'm doing this in a non-sensible way and would appreciate someone sorting me out

Hope that is enough info
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#2
... but.... where is this other window you're talking about ? In the code above you just make one. Also, I think what you want to do with the clicked signal is:

self.connect(self.exitb, QtCore.SIGNAL('clicked()'), self.close)

EDIT: So off the top of my head, do you want something like this ?

Code:
class HelloWindow(QtGui.QMainWindow):

    def __init__(self, *args):
        QtGui.QMainWindow.__init__(self, *args)

        self.exitb = QtGui.QPushButton('Exit', self)
        self.exitb.move(10, 210)
        self.connect(self.exitb, QtCore.SIGNAL('clicked()'), self.close)

def show_new_window():
        appt=QtGui.QApplication(sys.argv)
        basewin = QtGui.QMainWindow()
        basewin.show()
        win=HelloWindow(basewin)
        win.showFullScreen()
        sys.exit(appt.exec_())

show_new_window()
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc

Last edited by attila77; 2010-03-24 at 09:31.
 

The Following User Says Thank You to attila77 For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#3
Originally Posted by attila77 View Post
... but.... where is this other window you're talking about ? In the code above you just make one. Also, I think what you want to do with the clicked signal is:

self.connect(self.exitb, QtCore.SIGNAL('clicked()'), self.close)

EDIT: So off the top of my head, do you want something like this ?

Code:
class HelloWindow(QtGui.QMainWindow):

    def __init__(self, *args):
        QtGui.QMainWindow.__init__(self, *args)

        self.exitb = QtGui.QPushButton('Exit', self)
        self.exitb.move(10, 210)
        self.connect(self.exitb, QtCore.SIGNAL('clicked()'), self.close)

def show_new_window():
        appt=QtGui.QApplication(sys.argv)
        basewin = QtGui.QMainWindow()
        basewin.show()
        win=HelloWindow(basewin)
        win.showFullScreen()
        sys.exit(appt.exec_())

show_new_window()
Thankeee very much - getting a segmentation fault with that one at the moment, will take a proper look tonight though

where is this other window you're talking about ?
I've setup a MainWindow earlier, and was just trying to create this new window from within a function.... probably not the best way :|
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
mikec's Avatar
Posts: 1,366 | Thanked: 1,185 times | Joined on Jan 2006
#4
@noobmonkey

maybe you are confusing hildon stackable windows with qt windows.

if you parent your second window to your main window then Maemo will convert your second window to a hildon stackable for you, and you dont need to mess with close window events, bringing windows to the top etc. just hit the back button at the top left of second window and it will close and de-stack.

as per my code in this thread

http://talk.maemo.org/showpost.php?p=577316&postcount=9

As there is no hildon specific code I am assuming come PR1.2 this will continue to work.
__________________
N900_Email_Options Wiki Page
 

The Following User Says Thank You to mikec For This Useful Post:
krk969's Avatar
Posts: 754 | Thanked: 630 times | Joined on Sep 2009 @ London
#5
Originally Posted by mikec View Post
@noobmonkey

...... just hit the back button at the top leftright of second window and it will close and de-stack.
corrected that for you ...

*EDIT* QT4.6
set the folllowing attribute Qt::WA_Maemo5StackedWindow as well on both windows to see that nice back button else you will see a cross
__________________
Developer of :
Buddy - budget/expense manager ( website )
Showtime - a telly channel listing viewer/reminder ( website )
Travelapp - london underground status/planner ( website )
Batlevel - desktop widget for battery level ( website )

“I hear and I forget. I see and I remember. I do and I understand.”
 

The Following 2 Users Say Thank You to krk969 For This Useful Post:
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#6
Originally Posted by mikec View Post
@noobmonkey

maybe you are confusing hildon stackable windows with qt windows.

if you parent your second window to your main window then Maemo will convert your second window to a hildon stackable for you, and you dont need to mess with close window events, bringing windows to the top etc. just hit the back button at the top left of second window and it will close and de-stack.

as per my code in this thread

http://talk.maemo.org/showpost.php?p=577316&postcount=9

As there is no hildon specific code I am assuming come PR1.2 this will continue to work.
heya, nope got hildon and gtk working, removed them to use qt

As i'm setting it as full screen (to test dead pixels) there is no back button, but i have a normal movable button the screen that i am using to close it... (That also works fine) - but the program hangs once the window closes


Tried your code - also didn't work
was telling me that i was passing an invalid variable (My Main window...... )

(Argument 1 has unexpected type)
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#7
Originally Posted by krk969 View Post
corrected that for you ...

*EDIT* QT4.6
set the folllowing attribute Qt::WA_Maemo5StackedWindow as well on both windows to see that nice back button else you will see a cross
erm, that looks c code? - tried searching for that in python with no luck :| :|
but still, dont want the back button as i have it full screen
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#8
screenshot.....
when i close it falls back to app list screen.
healthcheck still running. but hanging.........
Attached Images
   
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#9
ok sorted it i think.......... fresh mind and all

Well, i was calling it all from the def function.
Moved the window setup etc down to main initialisation (Where my other window is called....... Made more sense) - and then just ran window.show.....

Doesnt hang, no cpu spikes and all back to normal
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 3,319 | Thanked: 5,610 times | Joined on Aug 2008 @ Finland
#10
Originally Posted by krk969 View Post
corrected that for you ...

*EDIT* QT4.6
set the folllowing attribute Qt::WA_Maemo5StackedWindow as well on both windows to see that nice back button else you will see a cross
One teenzy note, the Maemo5 symbols (and well, general Qt4.6) support will appear in PyQt *after* the PR1.2 release. Just saying this so people using PyQt from pre-PR1.2 Extras don't wonder why this doesn't work for them.
__________________
Blogging about mobile linux - The Penguin Moves!
Maintainer of PyQt (see introduction and docs), AppWatch, QuickBrownFox, etc
 

The Following User Says Thank You to attila77 For This Useful Post:
Reply

Tags
fullscreen, pyqt, stackable, window


 
Forum Jump


All times are GMT. The time now is 22:45.