commit
7be47240fc
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/python
|
||||
#-*- coding: utf-8 -*-
|
||||
from PySide import QtGui, QtCore
|
||||
from PySide.QtGui import QScrollArea, QLabel
|
||||
from leftmenu import LeftMenu
|
||||
|
||||
class Check(QtGui.QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super(Check, self).__init__()
|
||||
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
|
||||
self.lbl = QtGui.QLabel("Ubuntu", self)
|
||||
combo = QtGui.QComboBox(self)
|
||||
combo.addItem("Ubuntu")
|
||||
combo.addItem("Mandriva")
|
||||
combo.addItem("Fedora")
|
||||
combo.addItem("Red Hat")
|
||||
combo.addItem("Gentoo")
|
||||
|
||||
combo.move(50, 50)
|
||||
self.lbl.move(50, 150)
|
||||
|
||||
combo.activated[str].connect(self.onActivated)
|
||||
|
||||
self.setGeometry(0, 0, 150, 180)
|
||||
self.setWindowTitle('QtGui.QComboBox')
|
||||
self.show()
|
||||
|
||||
def onActivated(self, text):
|
||||
if text == 'Gentoo':
|
||||
if hasattr (self, 'lbl'): #if 'lbl' in self:
|
||||
self.lbl.hide()
|
||||
del self.lbl
|
||||
else:
|
||||
if not hasattr (self, 'lbl'):
|
||||
self.lbl = QtGui.QLabel(text, self)
|
||||
self.lbl.move(50, 150)
|
||||
self.lbl.show()
|
||||
self.lbl.setText(text)
|
||||
self.lbl.adjustSize()
|
||||
|
||||
class Example(QtGui.QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super(Example, self).__init__()
|
||||
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
|
||||
hbox = QtGui.QHBoxLayout(self)
|
||||
|
||||
# левое верхнее меню
|
||||
topleft = LeftMenu(self)
|
||||
# верхнее правое
|
||||
check2 = Check()
|
||||
self.scrollArea2 = QtGui.QScrollArea()
|
||||
self.scrollArea2.setWidget(check2)
|
||||
|
||||
# создание нижнего фрейма
|
||||
bottom = QtGui.QFrame(self)
|
||||
# bottom.setFrameShape(QLabel.Panel)
|
||||
|
||||
tempbox3 = QtGui.QHBoxLayout(self)
|
||||
check3 = Check()
|
||||
self.scrollArea3 = QtGui.QScrollArea()
|
||||
self.scrollArea3.horizontalScrollBar().hide()
|
||||
self.scrollArea3.setWidget(check3)
|
||||
|
||||
tempbox3.addWidget(self.scrollArea3)
|
||||
bottom.setLayout(tempbox3)
|
||||
|
||||
# объединение в один виджет
|
||||
splitter1 = QtGui.QSplitter(QtCore.Qt.Horizontal)
|
||||
splitter1.addWidget(topleft)
|
||||
splitter1.addWidget(self.scrollArea2)
|
||||
splitter1.setGeometry(0, 0, 0, 140)
|
||||
|
||||
splitter2 = QtGui.QSplitter(QtCore.Qt.Vertical)
|
||||
splitter2.addWidget(splitter1)
|
||||
splitter2.addWidget(bottom)
|
||||
|
||||
|
||||
hbox.addWidget(splitter2)
|
||||
self.setLayout(hbox)
|
||||
QtGui.QApplication.setStyle(QtGui.QStyleFactory.create('Cleanlooks'))
|
||||
|
||||
self.setGeometry(200, 200, 800, 800)
|
||||
self.setWindowTitle('QtGui.QSplitter')
|
||||
|
||||
def onChanged(self, text):
|
||||
|
||||
self.lbl.setText(text)
|
||||
self.lbl.adjustSize()
|
||||
|
||||
#def closeEvent(self, event):
|
||||
#reply = QtGui.QMessageBox.question(self, 'Message',
|
||||
#"Are you sure to quit?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No)
|
||||
|
||||
#if reply == QtGui.QMessageBox.Yes:
|
||||
#event.accept()
|
||||
#else:
|
||||
#event.ignore()
|
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/python
|
||||
# messagebox.py
|
||||
|
||||
import sys
|
||||
from PySide import QtGui
|
||||
from Box import Example
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
#qb = MessageBox()
|
||||
#qb.show()
|
||||
|
||||
ex = Example()
|
||||
ex.show()
|
||||
|
||||
sys.exit(app.exec_())
|
@ -0,0 +1,60 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from PySide import QtGui
|
||||
|
||||
class Checkbox(QtGui.QWidget):
|
||||
|
||||
def __init__(self):
|
||||
super(Checkbox, self).__init__()
|
||||
|
||||
self.initUI()
|
||||
|
||||
def initUI(self):
|
||||
|
||||
self.lbl = QtGui.QLabel("Moscow", self)
|
||||
combo = QtGui.QComboBox(self)
|
||||
combo.addItem("Moscow")
|
||||
combo.addItem("Piter")
|
||||
combo.addItem("London")
|
||||
combo.addItem("New York")
|
||||
combo.addItem("Brazilia")
|
||||
|
||||
combo.move(50, 50)
|
||||
self.lbl.move(50, 150)
|
||||
|
||||
combo.activated[str].connect(self.onActivated)
|
||||
|
||||
self.setGeometry(0, 0, 150, 180)
|
||||
self.setWindowTitle('QtGui.QComboBox')
|
||||
self.show()
|
||||
|
||||
def onActivated(self, text):
|
||||
if text == 'Brazilia':
|
||||
if hasattr (self, 'lbl'): #if 'lbl' in self:
|
||||
self.lbl.hide()
|
||||
del self.lbl
|
||||
else:
|
||||
if not hasattr (self, 'lbl'):
|
||||
self.lbl = QtGui.QLabel(text, self)
|
||||
self.lbl.move(50, 150)
|
||||
self.lbl.show()
|
||||
self.lbl.setText(text)
|
||||
self.lbl.adjustSize()
|
||||
|
||||
|
||||
class LeftMenu(QtGui.QFrame):
|
||||
def __init__(self, parent):
|
||||
QtGui.QFrame.__init__(self)
|
||||
# верхнее левое меню
|
||||
topleft = QtGui.QFrame(self)
|
||||
topleft.setFrameShape(QtGui.QFrame.NoFrame)
|
||||
topleft.setGeometry(0, 0, 100, 20)
|
||||
|
||||
check1 = Checkbox()
|
||||
|
||||
tempbox = QtGui.QHBoxLayout(self)
|
||||
self.scrollArea1 = QtGui.QScrollArea()
|
||||
self.scrollArea1.setWidget(check1)
|
||||
|
||||
tempbox.addWidget(self.scrollArea1)
|
||||
topleft.setLayout(tempbox)
|
Loading…
Reference in new issue