Reply
Thread Tools
Posts: 1,086 | Thanked: 2,964 times | Joined on Jan 2010
#1
Im trying to set the orientation of a simple test Gui to portrait and I thought by adding

self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientati on, True)

to the main.py file that would do it. Unfortunately it doesn't seem to be that simple. Once things go past being dead simple then Im in trouble, could someone more familiar point me to the problem and how I can correct it? Many thanks

Code:
#!/usr/bin/python2.5
import sys
from PyQt4 import QtGui,QtCore
from portraitTest import *

class MyForm(QtGui.QMainWindow):
        def __init__(self, parent=None):
                #build parent user interface
                QtGui.QWidget.__init__(self, parent)
                self.ui = Ui_MainWindow()
                self.ui.setupUi(self)
                try : self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientation, True)
                except:print("Cannot set orientation to portrait")
                        

if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
        myapp = MyForm()
        myapp.show()
        sys.exit(app.exec_())
__________________
Follow me on my neglected twitter @kojacker

Cybot950 - Control a robot with your N9/N950
SMSPetFeeder - Build a Bluetooth/SMS dog feeder with Qt, N950, and arduino
Nerf950 - Use your N9/N950 to fire a Nerf gun
 
mece's Avatar
Posts: 1,111 | Thanked: 1,985 times | Joined on Aug 2009 @ Åbo, Finland
#2
Originally Posted by kojacker View Post
Im trying to set the orientation of a simple test Gui to portrait and I thought by adding

self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientati on, True)

to the main.py file that would do it. Unfortunately it doesn't seem to be that simple. Once things go past being dead simple then Im in trouble, could someone more familiar point me to the problem and how I can correct it? Many thanks

Code:
#!/usr/bin/python2.5
import sys
from PyQt4 import QtGui,QtCore
from portraitTest import *

class MyForm(QtGui.QMainWindow):
        def __init__(self, parent=None):
                #build parent user interface
                QtGui.QWidget.__init__(self, parent)
                self.ui = Ui_MainWindow()
                self.ui.setupUi(self)
                try : self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientation, True)
                except:print("Cannot set orientation to portrait")
                        

if __name__ == "__main__":
        app = QtGui.QApplication(sys.argv)
        myapp = MyForm()
        myapp.show()
        sys.exit(app.exec_())

hmm.. I import differently, because I don't feel like typing QtGui and such everywhere. This seems to work:
Code:
#!/usr/bin/python2.5
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
# from portraitTest import *

class MyForm(QMainWindow):
        def __init__(self, parent=None):
                #build parent user interface
                QWidget.__init__(self, parent)
#                self.ui = Ui_MainWindow()
#                self.ui.setupUi(self)
                try : self.setAttribute(Qt.WA_Maemo5PortraitOrientation, True)
                except:print("Cannot set orientation to portrait")
                        

if __name__ == "__main__":
        app = QApplication(sys.argv)
        myapp = MyForm()
        myapp.show()
        sys.exit(app.exec_())
(I didn't have your other stuff so I quoted them out)
__________________
Class .. : Meddler, Thread watcher, Developer, Helper
Humor .. : [********--] Alignment: Pacifist
Patience : [*****-----] Weapon(s): N900, N950, Metal music
Agro ... : [----------] Relic(s) : N95, NGage, Tamyia Wild One

Try Tweed Suit for your hardcore twittering needs
http://twitter.com/mece66
I like my coffee black, like my metal.
 

The Following 2 Users Say Thank You to mece For This Useful Post:
Posts: 1,086 | Thanked: 2,964 times | Joined on Jan 2010
#3
Thank you for your help Mece

I finally got it working by removing the "ui" from self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientati on, True), so it now reads self.setAttribute.......

One thing that kinda irritates me is that when I minimize the application window, to see the multitasking view, it goes back into trying to display the form in landscape view so it looks wrong in the small preview pane. Once I click on it again, it expands and goes back into portrait. Is this normal behaviour?
__________________
Follow me on my neglected twitter @kojacker

Cybot950 - Control a robot with your N9/N950
SMSPetFeeder - Build a Bluetooth/SMS dog feeder with Qt, N950, and arduino
Nerf950 - Use your N9/N950 to fire a Nerf gun
 
mece's Avatar
Posts: 1,111 | Thanked: 1,985 times | Joined on Aug 2009 @ Åbo, Finland
#4
Originally Posted by kojacker View Post
Thank you for your help Mece

I finally got it working by removing the "ui" from self.ui.setAttribute(Qt.WA_Maemo5PortraitOrientati on, True), so it now reads self.setAttribute.......

One thing that kinda irritates me is that when I minimize the application window, to see the multitasking view, it goes back into trying to display the form in landscape view so it looks wrong in the small preview pane. Once I click on it again, it expands and goes back into portrait. Is this normal behaviour?
It's normal. The dashboard doesn't support portrait.
__________________
Class .. : Meddler, Thread watcher, Developer, Helper
Humor .. : [********--] Alignment: Pacifist
Patience : [*****-----] Weapon(s): N900, N950, Metal music
Agro ... : [----------] Relic(s) : N95, NGage, Tamyia Wild One

Try Tweed Suit for your hardcore twittering needs
http://twitter.com/mece66
I like my coffee black, like my metal.
 

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


 
Forum Jump


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