Ejemplo n.º 1
0
 def setup_message_box_layout(self):
     container_layout = QtWidgets.QHBoxLayout()
     text_area_layout = QtWidgets.QVBoxLayout()
     if self.chat_window.user["username"] == self.username:
         text_area_layout.addWidget(self.messageBox)
         self.textArea.setLayout(text_area_layout)
         container_layout.addStretch()
         container_layout.addWidget(self.textArea)
     else:
         username_label = QtWidgets.QLabel(f"{self.username}")
         username_label.setContentsMargins(5, 5, 5, 0)
         label_font = QtGui.QFont()
         label_font.setBold(True)
         username_label.setFont(label_font)
         text_area_layout.addWidget(username_label)
         text_area_layout.addWidget(self.messageBox)
         self.textArea.setLayout(text_area_layout)
         container_layout.addWidget(self.textArea)
         container_layout.addStretch()
     for reply in self.replies:
         self.add_message_reply(reply)
     self.textArea.layout().setSpacing(0)
     self.textArea.layout().setContentsMargins(0, 0, 0, 0)
     container_layout.setSpacing(0)
     container_layout.setContentsMargins(5, 5, 5, 5)
     self.set_message_style()
     self.setLayout(container_layout)
Ejemplo n.º 2
0
    def __init__(self, parent=None):
        # initialization of Qt MainWindow widget
        super(MplWidget, self).__init__(parent)

        # set the canvas to the Matplotlib widget
        self.canvas = MplCanvas()

        # create a vertical box layout
        self.vbl = QtWidgets.QVBoxLayout()

        # add mpl widget to vertical box
        self.vbl.addWidget(self.canvas)

        # set the layout to th vertical box
        self.setLayout(self.vbl)
Ejemplo n.º 3
0
 def setup_message_text(self):
     self.messageText.setAcceptRichText(False)
     self.messageText.setTextInteractionFlags(
         QtCore.Qt.LinksAccessibleByKeyboard
         | QtCore.Qt.LinksAccessibleByMouse
         | QtCore.Qt.TextBrowserInteraction | QtCore.Qt.TextEditable
         | QtCore.Qt.TextEditorInteraction
         | QtCore.Qt.TextSelectableByKeyboard
         | QtCore.Qt.TextSelectableByMouse)
     self.messageText.setPlaceholderText(
         "Enter message here.\nPress enter to send.\nShift+Enter to add a new line."
     )
     self.messageText.setObjectName("messageText")
     vbox_layout = QtWidgets.QVBoxLayout()
     vbox_layout.addWidget(self.messageText)
     vbox_layout.setSpacing(0)
     vbox_layout.setContentsMargins(0, 0, 0, 0)
     self.messageTextContainer.setLayout(vbox_layout)
Ejemplo n.º 4
0
    def __init__(self, sideview=False, parent=None, canvas=None):
        # initialization of Qt MainWindow widget
        super(MplNavBarWidget, self).__init__(parent)

        # set the canvas to the Matplotlib widget
        if canvas:
            self.canvas = canvas
        else:
            self.canvas = MplCanvas()

        # instantiate the navigation toolbar
        self.navbar = NavigationToolbar(self.canvas, self, sideview)

        # create a vertical box layout
        self.vbl = QtWidgets.QVBoxLayout()

        # add mpl widget to vertical box
        self.vbl.addWidget(self.navbar)
        self.vbl.addWidget(self.canvas)

        # set the layout to th vertical box
        self.setLayout(self.vbl)
Ejemplo n.º 5
0
    def __init__(self, parent=None):
        super(EditorMainWindow, self).__init__(parent)
        self.path = None

        self.file_content = None
        self.layout = QtWidgets.QVBoxLayout()
        # Could also use a QTextEdit and set self.editor.setAcceptRichText(False)
        self.editor = QtWidgets.QPlainTextEdit()

        # Setup the QTextEdit editor configuration
        fixedfont = QtGui.QFontDatabase.systemFont(
            QtGui.QFontDatabase.FixedFont)
        fixedfont.setPointSize(12)
        self.editor.setFont(fixedfont)

        # self.path holds the path of the currently open file.
        # If none, we haven't got a file open yet (or creating new).
        self.path = constants.MSS_CONFIG_PATH
        self.layout.addWidget(self.editor)

        self.container = QtWidgets.QWidget()
        self.container.setLayout(self.layout)
        self.setCentralWidget(self.container)

        self.status = QtWidgets.QStatusBar()
        self.setStatusBar(self.status)

        self.file_toolbar = QtWidgets.QToolBar("File")
        self.file_toolbar.setIconSize(QtCore.QSize(14, 14))
        self.addToolBar(self.file_toolbar)
        self.file_menu = self.menuBar().addMenu("&File")

        self.open_file_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Folder-new.svg')),
            "Open file...", self)
        self.open_file_action.setStatusTip("Open file")
        self.open_file_action.triggered.connect(self.file_open)
        self.file_menu.addAction(self.open_file_action)
        self.file_toolbar.addAction(self.open_file_action)

        self.save_file_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Document-save.svg')), "Save",
            self)
        self.save_file_action.setStatusTip("Save current page")
        self.save_file_action.triggered.connect(self.file_save)
        self.file_menu.addAction(self.save_file_action)
        self.file_toolbar.addAction(self.save_file_action)

        self.saveas_file_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Document-save-as.svg')),
            "Save As...", self)
        self.saveas_file_action.setStatusTip(
            "Save current page to specified file")
        self.saveas_file_action.triggered.connect(self.file_saveas)
        self.file_menu.addAction(self.saveas_file_action)
        self.file_toolbar.addAction(self.saveas_file_action)

        self.print_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Document-print.svg')),
            "Print...", self)
        self.print_action.setStatusTip("Print current page")
        self.print_action.triggered.connect(self.file_print)
        self.file_menu.addAction(self.print_action)
        self.file_toolbar.addAction(self.print_action)

        self.edit_toolbar = QtWidgets.QToolBar("Edit")
        self.edit_toolbar.setIconSize(QtCore.QSize(16, 16))
        self.addToolBar(self.edit_toolbar)
        self.edit_menu = self.menuBar().addMenu("&Edit")

        self.undo_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Edit-undo.svg')), "Undo", self)
        self.undo_action.setStatusTip("Undo last change")
        self.undo_action.triggered.connect(self.editor.undo)
        self.edit_menu.addAction(self.undo_action)

        self.redo_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Edit-redo.svg')), "Redo", self)
        self.redo_action.setStatusTip("Redo last change")
        self.redo_action.triggered.connect(self.editor.redo)
        self.edit_toolbar.addAction(self.redo_action)
        self.edit_menu.addAction(self.redo_action)

        self.edit_menu.addSeparator()

        self.cut_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Edit-cut.svg')), "Cut", self)
        self.cut_action.setStatusTip("Cut selected text")
        self.cut_action.triggered.connect(self.editor.cut)
        self.edit_toolbar.addAction(self.cut_action)
        self.edit_menu.addAction(self.cut_action)

        self.copy_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Edit-copy.svg')), "Copy", self)
        self.copy_action.setStatusTip("Copy selected text")
        self.copy_action.triggered.connect(self.editor.copy)
        self.edit_toolbar.addAction(self.copy_action)
        self.edit_menu.addAction(self.copy_action)

        self.paste_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Edit-paste.svg')), "Paste",
            self)
        self.paste_action.setStatusTip("Paste from clipboard")
        self.paste_action.triggered.connect(self.editor.paste)
        self.edit_toolbar.addAction(self.paste_action)
        self.edit_menu.addAction(self.paste_action)

        self.select_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Edit-select-all.svg')),
            "Select all", self)
        self.select_action.setStatusTip("Select all text")
        self.select_action.triggered.connect(self.editor.selectAll)
        self.edit_menu.addAction(self.select_action)

        self.edit_menu.addSeparator()

        self.wrap_action = QtWidgets.QAction(
            QtGui.QIcon(icons('config_editor', 'Go-next.svg')),
            "Wrap text to window", self)
        self.wrap_action.setStatusTip("Toggle wrap text to window")
        self.wrap_action.setCheckable(True)
        self.wrap_action.setChecked(True)
        self.wrap_action.triggered.connect(self.edit_toggle_wrap)
        self.edit_menu.addAction(self.wrap_action)
        self.update_title()
        self.show()