Refactored main window creation

The main window was created in a somewhat stupid way, that required
multiple steps to be taken from the main module.

Now it's all in one call.
master
Salvo 'LtWorf' Tomaselli 2015-09-29 12:47:20 +07:00
parent 7d0dee2b30
commit f5ef1027d0
2 changed files with 35 additions and 29 deletions

@ -81,14 +81,14 @@ if __name__ == "__main__":
x11 = False
if x11:
import sip # needed on windows
from PyQt5 import QtGui, QtWidgets
try:
from relational_gui import maingui, guihandler, about, surveyForm, resources
from relational_gui import guihandler, about, surveyForm
except:
print (
"Module relational_gui is missing.\nPlease install relational package.",
"Module relational_gui is missing.\n"
"Please install relational package.",
file=sys.stderr
)
sys.exit(3)
@ -102,28 +102,7 @@ if __name__ == "__main__":
app.setApplicationName('relational')
app.setOrganizationDomain("None")
ui = maingui.Ui_MainWindow()
form = guihandler.relForm(ui)
ui.setupUi(form)
f = QtGui.QFont()
size = f.pointSize()
if sys.platform.startswith('win'):
winFont = 'Cambria'
symbolFont = 'Segoe UI Symbol'
increment = 4
else:
winFont = f.family()
symbolFont = f.family()
increment = 2
ui.lstHistory.setFont(QtGui.QFont(winFont, size + increment))
ui.txtMultiQuery.setFont(QtGui.QFont(winFont, size + increment))
ui.txtQuery.setFont(QtGui.QFont(winFont, size + increment))
ui.groupOperators.setFont(QtGui.QFont(winFont, size + increment))
ui.cmdClearMultilineQuery.setFont(QtGui.QFont(symbolFont))
ui.cmdClearQuery.setFont(QtGui.QFont(symbolFont))
form.restore_settings()
form = guihandler.relForm()
m = enumerate(map(os.path.isfile, files))
invalid = ' '.join(

@ -15,7 +15,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
from PyQt5 import QtCore, QtWidgets, QtWidgets
import sys
from PyQt5 import QtCore, QtWidgets, QtWidgets, QtGui
from relational import relation, parser, optimizer, rtypes
from relational.maintenance import UserInterface
@ -28,17 +30,42 @@ from relational_gui import maingui
class relForm(QtWidgets.QMainWindow):
def __init__(self, ui):
def __init__(self):
QtWidgets.QMainWindow.__init__(self)
self.About = None
self.Survey = None
self.undo = None # UndoQueue for queries
self.selectedRelation = None
self.ui = ui
self.ui = maingui.Ui_MainWindow()
self.qcounter = 1 # Query counter
self.user_interface = UserInterface()
# Creates the UI
self.ui.setupUi(self)
#Setting fonts for symbols
f = QtGui.QFont()
size = f.pointSize()
if sys.platform.startswith('win'):
winFont = 'Cambria'
symbolFont = 'Segoe UI Symbol'
increment = 4
else:
winFont = f.family()
symbolFont = f.family()
increment = 2
font = QtGui.QFont(winFont, size + increment)
sfont = QtGui.QFont(symbolFont)
self.ui.lstHistory.setFont(font)
self.ui.txtMultiQuery.setFont(font)
self.ui.txtQuery.setFont(font)
self.ui.groupOperators.setFont(font)
self.ui.cmdClearMultilineQuery.setFont(sfont)
self.ui.cmdClearQuery.setFont(sfont)
self.settings = QtCore.QSettings()
self._restore_settings()
def checkVersion(self):
from relational import maintenance
@ -263,7 +290,7 @@ class relForm(QtWidgets.QMainWindow):
self.settings.setValue('maingui/splitter', self.ui.splitter.saveState())
self.settings.setValue('maingui/relations', self.user_interface.session_dump())
def restore_settings(self):
def _restore_settings(self):
self.user_interface.session_restore(self.settings.value('maingui/relations'))
self.updateRelations()