Открыто окно из которого по нажатию на кнопку вызываю метод:
def Settings(self):
ConfigW = QtGui.QWidget()
ConfigW.setGeometry(5, 90, 100, 100)
#ConfigW.__init__(self,None)
ConfigW.show()
def Settings(self):
ConfigW = QtGui.QWidget()
ConfigW.setGeometry(5, 90, 100, 100)
#ConfigW.__init__(self,None)
ConfigW.show()
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui, QtCore
class MainWindow(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowTitle('MainWindow')
self.ConfigW = QtGui.QWidget()
def settingW(self):
self.ConfigW.setWindowTitle('ConfigWindow')
self.ConfigW.setGeometry(5, 90, 100, 100)
self.ConfigW.show()
if __name__=="__main__":
app = QtGui.QApplication(sys.argv)
window = MainWindow()
window.settingW()
window.show()
sys.exit(app.exec_())
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui, QtCore
class MainWindow(QtGui.QWidget): # не QMainWindow !
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowTitle('MainWindow')
self.ConfigW = QtGui.QWidget()
button = QtGui.QPushButton('settingW')
layout = QtGui.QVBoxLayout()
layout.addWidget(button)
self.setLayout(layout)
QtCore.QObject.connect(button,QtCore.SIGNAL("clicked()"),self.settingW)
#### self.ConfigW - для доступа в методах класса ####
def settingW(self):
self.ConfigW.setWindowTitle('ConfigWindow')
self.ConfigW.setGeometry(5, 90, 100, 100)
self.ConfigW.show()
if __name__=="__main__":
app = QtGui.QApplication(sys.argv)
window = MainWindow()
window.show()
sys.exit(app.exec_())