krystosan
11th December 2013, 18:30
I managed to animate open a window on startup, but I want to open a different window from already open window by pressing the button, in my case already open window is open in fullscreen mode with window.raise_()
Not sure but is this why the window I am trying to animate open by pressing a button is not opening
from PyQt4 import QtCore,QtGui
import sys
class WindLauncher(QtGui.QMainWindow):
""" docstring for WindLauncher
"""
def __init__(self):
super(WindLauncher, self).__init__()
self.btn = QtGui.QPushButton("Launch")
self.btn.clicked.connect(self.launchWin)
self.setCentralWidget(self.btn)
def launchWin(self):
main = MyTableView()
sw = QtGui.QDesktopWidget().screenGeometry(main).width( )
sh = QtGui.QDesktopWidget().screenGeometry(main).height ()
animation = QtCore.QPropertyAnimation(main, "geometry")
animation.setDuration(500);
animation.setStartValue(QtCore.QRect(0, -(sh), sw, sh));
animation.setEndValue(QtCore.QRect(0, 0, sw, sh));
animation.start();
self.show()
self.raise_()
class MyTableView(QtGui.QTableView):
"""docstring for MyTableView"""
def __init__(self, parent=None):
super(MyTableView, self).__init__(parent)
if __name__ == "__main__":
application = QtGui.QApplication(sys.argv)
main = WindLauncher()
main.show()
main.raise_()
sys.exit(application.exec_())
Not sure but is this why the window I am trying to animate open by pressing a button is not opening
from PyQt4 import QtCore,QtGui
import sys
class WindLauncher(QtGui.QMainWindow):
""" docstring for WindLauncher
"""
def __init__(self):
super(WindLauncher, self).__init__()
self.btn = QtGui.QPushButton("Launch")
self.btn.clicked.connect(self.launchWin)
self.setCentralWidget(self.btn)
def launchWin(self):
main = MyTableView()
sw = QtGui.QDesktopWidget().screenGeometry(main).width( )
sh = QtGui.QDesktopWidget().screenGeometry(main).height ()
animation = QtCore.QPropertyAnimation(main, "geometry")
animation.setDuration(500);
animation.setStartValue(QtCore.QRect(0, -(sh), sw, sh));
animation.setEndValue(QtCore.QRect(0, 0, sw, sh));
animation.start();
self.show()
self.raise_()
class MyTableView(QtGui.QTableView):
"""docstring for MyTableView"""
def __init__(self, parent=None):
super(MyTableView, self).__init__(parent)
if __name__ == "__main__":
application = QtGui.QApplication(sys.argv)
main = WindLauncher()
main.show()
main.raise_()
sys.exit(application.exec_())