module.py 1.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Apr 18 18:34:40 2018

@author: Antoine Lima, Leo Reynaert, Domitille Jehenne
"""

import logging

from PyQt5 import QtWidgets
12 13
from PyQt5.QtCore import QTime, QTimer, Qt
from PyQt5.QtWidgets import QTableWidgetItem, QComboBox, QApplication
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

from modules import *

class Module(QtWidgets.QWidget):
	def __init__(self, parent=None, widget=None):
		# UI Setup
		QtWidgets.QWidget.__init__(self, parent)
		self.parent_win = parent
		self.ui = widget
		self.ui.setupUi(self)

	def switchModule(self, new_type):
		panel_idx = self.parent_win.modules.index(new_type)
		
		if panel_idx<0:
			logging.error('Error: unknown panel {}'.format(new_type))
		else:
31 32 33
			self.parent_win.ui.panels.currentWidget().releaseKeyboard()
			if QApplication.focusWidget() != None:
				QApplication.focusWidget().clearFocus()
34
			self.parent_win.ui.panels.currentWidget().unload()
35
			
36
			self.parent_win.ui.panels.setCurrentIndex(panel_idx)
37
			
38
			self.parent_win.ui.panels.currentWidget().load()
39 40 41 42
			# Select first element of the Module
			self.parent_win.ui.panels.currentWidget().focusNextChild()
			self.parent_win.ui.panels.currentWidget().focusPreviousChild()
			self.parent_win.ui.panels.currentWidget().grabKeyboard()
43 44 45 46 47 48 49 50 51

	def load(self):
		logging.warning('Unimplemented method "load" for {}'.format(self.__class__))

	def unload(self):
		logging.warning('Unimplemented method "unload" for {}'.format(self.__class__))

	def other(self, **kwargs):
		logging.warning('Unimplemented method "other" for {}'.format(self.__class__))