def build_gui(self): """Initialize the GUI elements""" self.setWindowTitle(u"Quiedit %s" % libquiedit.version) self.setWindowIcon(QtGui.QIcon(self.get_resource(u"quiedit.png"))) # Status widget, visible in all components self.status = QtGui.QLabel(u"Press Control+H for help") self.status.setAlignment(QtCore.Qt.AlignHCenter) # Editor component self.editor = quieditor.quieditor(self) self.editor.setFrameStyle(QtGui.QFrame.NoFrame) # Search widget, visible in editor component self.search_edit = search_edit.search_edit(self) self.search_edit.returnPressed.connect(self.editor.perform_search) self.search_label = QtGui.QLabel(u"Search:") self.search_layout = QtGui.QHBoxLayout() self.search_layout.addWidget(self.search_label) self.search_layout.addWidget(self.search_edit) self.search_layout.setContentsMargins(8, 8, 8, 8) self.search_box = QtGui.QFrame() self.search_box.setLayout(self.search_layout) self.search_box.hide() # Command widget, visible in editor component self.command_edit = command_edit.command_edit(self) self.command_label = QtGui.QLabel(u"$") self.command_layout = QtGui.QHBoxLayout() self.command_layout.addWidget(self.command_label) self.command_layout.addWidget(self.command_edit) self.command_layout.setContentsMargins(8, 8, 8, 8) self.command_box = QtGui.QFrame() self.command_box.setLayout(self.command_layout) self.command_box.hide() # Help component self.help = quieditor.quieditor(self, readonly=True) self.help.setFrameStyle(QtGui.QFrame.NoFrame) self.help.set_text(open(self.get_resource(u'keybindings.conf')) \ .read()) self.help.hide() # Preferences component self.prefs = prefs.prefs(self) self.prefs.hide() # Markdown component self._markdown = _markdown._markdown(self) self._markdown.setFrameStyle(QtGui.QFrame.NoFrame) self._markdown.hide() # Layout for all components, only one of which is visible at a time self.editor_layout = QtGui.QVBoxLayout() self.editor_layout.setContentsMargins(0, 0, 0, 0) self.editor_layout.addWidget(self.editor) self.editor_layout.addWidget(self.help) self.editor_layout.addWidget(self.prefs) self.editor_layout.addWidget(self.search_box) self.editor_layout.addWidget(self.command_box) self.editor_layout.addWidget(self._markdown) self.editor_layout.setSpacing(0) self.editor_frame = QtGui.QFrame() self.editor_frame.setFrameStyle(QtGui.QFrame.Box) self.editor_frame.setLayout(self.editor_layout) # Central widget to contain all central widgets, i.e. everything except # the padding around the window self.central_vbox = QtGui.QVBoxLayout() self.central_vbox.addWidget(QtGui.QLabel()) self.central_vbox.addWidget(self.editor_frame) self.central_vbox.addWidget(self.status) self.central_widget = QtGui.QWidget() self.central_widget.setLayout(self.central_vbox) # Main widget that contains everything, i.e. the central widget plus # padding self.main_hbox = QtGui.QHBoxLayout() self.main_hbox.addStretch() self.main_hbox.addWidget(self.central_widget) self.main_hbox.addStretch() self.main_widget = QtGui.QWidget() self.main_widget.setLayout(self.main_hbox) self.setCentralWidget(self.main_widget)
def build_gui(self): """Initialize the GUI elements""" self.setWindowTitle("Quiedit %s" % self.version) self.setWindowIcon(QtGui.QIcon(self.get_resource("quiedit.png"))) self.editor = quieditor.quieditor(self) self.editor.setFrameStyle(QtGui.QFrame.NoFrame) self.status = QtGui.QLabel("Press Control+H for help") self.status.setAlignment(QtCore.Qt.AlignHCenter) self.help = quieditor.quieditor(self, readonly=True) self.help.setFrameStyle(QtGui.QFrame.NoFrame) self.help.hide() self.prefs = prefs.prefs(self) self.prefs.hide() self.navigator = navigator.navigator(self) self.navigator.setFrameStyle(QtGui.QFrame.NoFrame) self.navigator.hide() self.search_edit = search_edit.search_edit(self) self.search_edit.returnPressed.connect(self.editor.perform_search) self.search_label = QtGui.QLabel("Search:") self.search_layout = QtGui.QHBoxLayout() self.search_layout.addWidget(self.search_label) self.search_layout.addWidget(self.search_edit) self.search_layout.setContentsMargins(8, 8, 8, 8) self.search_box = QtGui.QFrame() self.search_box.setLayout(self.search_layout) self.search_box.hide() self.editor_layout = QtGui.QVBoxLayout() self.editor_layout.setContentsMargins(0, 0, 0, 0) self.editor_layout.addWidget(self.editor) self.editor_layout.addWidget(self.help) self.editor_layout.addWidget(self.prefs) self.editor_layout.addWidget(self.navigator) self.editor_layout.addWidget(self.search_box) self.editor_layout.setSpacing(0) self.editor_frame = QtGui.QFrame() self.editor_frame.setFrameStyle(QtGui.QFrame.Box) self.editor_frame.setLayout(self.editor_layout) self.central_vbox = QtGui.QVBoxLayout() self.central_vbox.addWidget(QtGui.QLabel()) self.central_vbox.addWidget(self.editor_frame) self.central_vbox.addWidget(self.status) self.central_widget = QtGui.QWidget() self.central_widget.setLayout(self.central_vbox) self.main_hbox = QtGui.QHBoxLayout() self.main_hbox.addStretch() self.main_hbox.addWidget(self.central_widget) self.main_hbox.addStretch() self.main_widget = QtGui.QWidget() self.main_widget.setLayout(self.main_hbox) self.setCentralWidget(self.main_widget)