Skip to content

Instantly share code, notes, and snippets.

@gyu-don
Created April 17, 2016 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gyu-don/7ec4c21150fce58824becc4fee78881a to your computer and use it in GitHub Desktop.
Save gyu-don/7ec4c21150fce58824becc4fee78881a to your computer and use it in GitHub Desktop.
PyQt4 stackoverflow
import sys
from PyQt4 import QtGui, QtCore
class Window(QtGui.QMainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
widget = QtGui.QWidget()
widget1 = QtGui.QLabel("Page 1", widget)
widget2 = QtGui.QLabel("Page 2", widget)
widget2.setGeometry(50, 10, 70, 10)
btn1 = QtGui.QPushButton("Page 1")
btn1.setCheckable(True)
btn1.setChecked(True)
btn1.toggled.connect(widget1.setShown)
btn2 = QtGui.QPushButton("Page 2")
btn2.setCheckable(True)
btn2.setChecked(True)
btn2.toggled.connect(widget2.setShown)
layout = QtGui.QVBoxLayout()
layout.addWidget(widget)
layout.addWidget(btn1)
layout.addWidget(btn2)
cent_widget = QtGui.QWidget()
cent_widget.setLayout(layout)
self.setCentralWidget(cent_widget)
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment