Exemplo n.º 1
0
class MainWindow(QtGui.QMainWindow):
	def showLabTrigger(self, num):
		return lambda: self.showLab(num)
		
	def __init__(self):
		super(MainWindow, self).__init__()

		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)

		self.aboutDialog = AboutDialog(self)

		self.ui.actionAbout.triggered.connect(self.aboutDialog.open)
		self.ui.tabWidget.tabCloseRequested.connect(self.closeTab)
		self.ui.tabWidget.removeTab(0)
		self.ui.tabWidget.removeTab(0)
		
		for i in range(NUM_OF_LABS):
			getattr(self.ui, 'actionLab%s' % (i + 1)).triggered.connect(self.showLabTrigger(i + 1))

	def showLab(self, num):
		for i in range(self.ui.tabWidget.count()):
			widget = self.ui.tabWidget.widget(i)
			if widget.labNum == num:
				self.ui.tabWidget.setCurrentIndex(i)
				return

		lab = globals()["Lab%s" % num](self)
		self.ui.tabWidget.addTab(lab, u'Лабораторная работа №{0}'.format(num))
		self.ui.tabWidget.setCurrentIndex(self.ui.tabWidget.count() - 1)

	@QtCore.pyqtSlot(int)
	def closeTab(self, index):
		self.ui.tabWidget.removeTab(index)

	def changeState(self, state):
		self.ui.statusLabel.setText(state)
Exemplo n.º 2
0
	def __init__(self):
		super(MainWindow, self).__init__()

		self.ui = Ui_MainWindow()
		self.ui.setupUi(self)

		self.aboutDialog = AboutDialog(self)

		self.ui.actionAbout.triggered.connect(self.aboutDialog.open)
		self.ui.tabWidget.tabCloseRequested.connect(self.closeTab)
		self.ui.tabWidget.removeTab(0)
		self.ui.tabWidget.removeTab(0)
		
		for i in range(NUM_OF_LABS):
			getattr(self.ui, 'actionLab%s' % (i + 1)).triggered.connect(self.showLabTrigger(i + 1))