Пример #1
0
 def __init__(self, parent):
     """Initialization"""
     # Initialize superclass, from which the current class is inherited,
     # THIS MUST BE DONE SO THAT THE SUPERCLASS EXECUTES ITS __init__ !!!!!!
     super().__init__(parent)
     # Set various events and attributes
     # Save parent as a reference
     self._parent = parent
     # Set default font
     self.setFont(data.get_current_font())
     # Initialize the custom tab bar
     self.custom_tab_bar = self.CustomTabBar(self)
     self.setTabBar(self.custom_tab_bar)
     # Enable drag&drop events
     self.setAcceptDrops(True)
     # Add close buttons to tabs
     self.setTabsClosable(True)
     # Set tabs as movable, so that you can move tabs with the mouse
     self.setMovable(True)
     # Add signal for coling a tab to the EVT_tabCloseRequested function
     self.tabCloseRequested.connect(self._signal_editor_tabclose)
     # Connect signal that fires when the tab index changes
     self.currentChanged.connect(self._signal_editor_tabindex_change)
     # Store the default settings
     self.default_tab_font = self.tabBar().font()
     self.default_icon_size = self.tabBar().iconSize()
Пример #2
0
 def __init__(self, parent):
     # Initialize superclass
     super().__init__()
     # Store the reference to the parent
     self._parent = parent
     # Set default font
     self.setFont(data.get_current_font())
Пример #3
0
    def __init__(self, parent):
        """Initialization routine"""
        #Initialize superclass, from which the current class is inherited, THIS MUST BE DONE SO THAT THE SUPERCLASS EXECUTES ITS __init__ !!!!!!
        super().__init__()

        #Initialize the log window
        self.setWindowTitle("LOGGING WINDOW")
        self.resize(500, 300)
        self.setWindowFlags(data.Qt.WindowStaysOnTopHint)
        # Set default font
        self.setFont(data.get_current_font())

        #Initialize the display box
        self.displaybox = MessageLogger.MessageTextBox(self)
        self.displaybox.setReadOnly(True)
        #Make displaybox click/doubleclick event also fire the log window click/doubleclick method
        self.displaybox.mousePressEvent = self._event_mousepress
        self.displaybox.mouseDoubleClickEvent = self._event_mouse_doubleclick
        self.keyPressEvent = self._keypress

        #Initialize layout
        self.layout = data.QGridLayout()
        self.layout.addWidget(self.displaybox)
        self.setLayout(self.layout)

        self.append_message("Ex.Co. debug log window loaded")
        self.append_message("LOGGING Mode is enabled")
        self._parent = parent

        #Set the log window icon
        if os.path.isfile(data.application_icon) == True:
            self.setWindowIcon(data.QIcon(data.application_icon))
Пример #4
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self._id = uuid.uuid4()
     Menu.menu_cache[self._id] = self
     # Set default font
     self.setFont(data.get_current_font())
     # Update style
     self.update_style()
Пример #5
0
 def __init__(self, text, dialog_type=None, parent=None):
     super().__init__(parent)
     # Make the dialog stay on top
     self.setWindowFlags(data.Qt.WindowStaysOnTopHint)
     # Set the dialog icon and title
     self.setWindowIcon(data.QIcon(data.application_icon))
     self.setWindowTitle(dialog_type.title())
     self.init_layout(text, dialog_type)
     # Set default font
     self.setFont(data.get_current_font())
Пример #6
0
 def __init__(self, parent=None):
     """Overridden initialization"""
     #Initialize superclass
     super().__init__()
     #Set the font colors
     self.setFont(data.get_current_font(), 0)
     #Reset autoindentation style
     self.setAutoIndentStyle(0)
     #Set the theme
     self.set_theme(data.theme)
Пример #7
0
 def __init__(self, parent):
     """Initialize the tab bar object"""
     # Initialize superclass
     super().__init__(parent)
     # Store the parent reference
     self._parent = parent
     # Store the main form reference
     self.main_form = self._parent._parent
     # Set style
     self.set_style()
     # Set default font
     self.setFont(data.get_current_font())
Пример #8
0
 def customize_tab_bar(self):
     if data.custom_menu_scale != None and data.custom_menu_font != None:
         components.TheSquid.customize_menu_style(self.tabBar())
         self.tabBar().setFont(data.QFont(*data.custom_menu_font))
         new_icon_size = functions.create_size(data.custom_menu_scale,
                                               data.custom_menu_scale)
         self.setIconSize(new_icon_size)
     else:
         components.TheSquid.customize_menu_style(self.tabBar())
         self.tabBar().setFont(data.get_current_font())
         self.setIconSize(self.default_icon_size)
     self.tabBar().set_style()
Пример #9
0
 def __init__(self, parent=None, main_form=None, offset=(0, 0)):
     # Initialize the superclass
     super().__init__(parent)
     # Store the reference to the parent
     self.setParent(parent)
     # Store the reference to the main form
     self.main_form = main_form
     # Set default font
     self.setFont(data.get_current_font())
     # Store the painting offset
     self.offset = offset
     # Set the background color
     style_sheet = "background-color: transparent;"
     style_sheet += "border: 0 px;"
     self.setStyleSheet(style_sheet)
     # Set the groupbox size
     screen_resolution = data.application.desktop().screenGeometry()
     width, height = screen_resolution.width(), screen_resolution.height()
     self.setGeometry(functions.create_rect(0, 0, width, height))
Пример #10
0
 def __init__(self, parent=None, main_form=None):
     # Initialize the superclass
     super().__init__(parent)
     # Store the reference to the main form
     self.main_form = main_form
     # Set default font
     self.setFont(data.get_current_font())
     # Set the shown property to False
     self.shown = False
     # Initialize button list
     self.buttons = []
     # Initialize the background image
     self._init_background()
     # Position the overlay to the center of the screen
     self.center(functions.create_size(*self.DEFAULT_SIZE))
     # Scale the size if needed
     self._init_scaling()
     # Initialize the display label that will display the various information
     self._init_info_label()
     # Initialize the buttons
     self._init_key_shortcut_buttons()
Пример #11
0
 def __init__(self, parent, interpreter_references, *args, **kwargs):
     super().__init__("Python Interactive Interpreter (REPL)")
     self.setObjectName("REPL_Box")
     self._parent = parent
     self.repl = ReplLineEdit(self,
                              parent,
                              interpreter_references=interpreter_references)
     self.repl.setObjectName("REPL_line")
     self.repl_helper = ReplHelper(self, parent, self.repl)
     self.repl_helper.setObjectName("REPL_multiline")
     # Create layout and children
     repl_layout = data.QVBoxLayout()
     repl_layout.setContentsMargins(4, 4, 4, 4)
     repl_layout.setSpacing(0)
     repl_layout.addWidget(self.repl)
     repl_layout.addWidget(self.repl_helper)
     self.setLayout(repl_layout)
     # Set the defaults
     self.set_repl(data.ReplType.SINGLE_LINE)
     self.indication_reset()
     # Set default font
     self.setFont(data.get_current_font())
Пример #12
0
 def __init__(self, settings_manipulator, parent, main_form):
     """Initialization"""
     #Initialize the superclass
     super().__init__(parent)
     # Initialize components
     self.icon_manipulator = components.IconManipulator(parent=self,
                                                        tab_widget=parent)
     self.add_corner_buttons()
     #Store the reference to the parent TabWidget from the "forms" module
     self._parent = parent
     #Store the reference to the MainWindow form from the "forms" module
     self.main_form = main_form
     # Set default font
     self.setFont(data.get_current_font())
     #Store the reference to the active SettingsManipulator
     self.settings_manipulator = settings_manipulator
     #Set the icon
     self.current_icon = functions.create_icon("tango_icons/sessions.png")
     #Store name of self
     self.name = "Session editing tree display"
     #Enable node expansion on double click
     self.setExpandsOnDoubleClick(True)
     #Set the node icons
     self.node_icon_group = functions.create_icon("tango_icons/folder.png")
     self.node_icon_session = functions.create_icon(
         "tango_icons/sessions.png")
     self.icon_session_add = functions.create_icon(
         "tango_icons/session-add.png")
     self.icon_session_remove = functions.create_icon(
         "tango_icons/session-remove.png")
     self.icon_session_overwrite = functions.create_icon(
         "tango_icons/session-overwrite.png")
     self.icon_group_add = functions.create_icon(
         "tango_icons/folder-add.png")
     self.icon_session_edit = functions.create_icon(
         "tango_icons/session-edit.png")
     #Connect the signals
     self.doubleClicked.connect(self._item_double_clicked)
Пример #13
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     # Set the default font
     self.setFont(data.get_current_font())
     # Restyle
     self.update_style()
Пример #14
0
 def __init__(self, parent, main_form, repl_master):
     #Initialize superclass, from which the current class is inherited, THIS MUST BE DONE SO THAT THE SUPERCLASS EXECUTES ITS __init__ !!!!!!
     super().__init__(parent)
     # Set default font
     self.setFont(data.get_current_font())
     #Save the reference to the parent(main window)
     self._parent = parent
     self.main_form = main_form
     #Save the reference to the REPL object
     self.repl_master = repl_master
     #Hide the horizontal and show the vertical scrollbar
     self.SendScintilla(data.QsciScintillaBase.SCI_SETVSCROLLBAR, True)
     self.SendScintilla(data.QsciScintillaBase.SCI_SETHSCROLLBAR, False)
     #Hide the margin
     self.setMarginWidth(1, 0)
     #Autoindentation enabled when using "Enter" to indent to the same level as the previous line
     self.setAutoIndent(True)
     #Tabs are spaces by default
     self.setIndentationsUseTabs(False)
     #Set tab space indentation width
     self.setTabWidth(settings.Editor.tab_width)
     #Set encoding format to UTF-8 (Unicode)
     self.setUtf8(True)
     #Set brace matching
     self.setBraceMatching(data.QsciScintilla.SloppyBraceMatch)
     self.setMatchedBraceBackgroundColor(data.QColor(255, 153, 0))
     #Tabs are spaces by default
     self.setIndentationsUseTabs(False)
     #Set backspace to delete by tab widths
     self.setBackspaceUnindents(True)
     #Disable drops
     self.setAcceptDrops(False)
     #Set line endings to be Unix style ("\n")
     self.setEolMode(settings.Editor.end_of_line_mode)
     #Set the initial zoom factor
     self.zoomTo(settings.Editor.zoom_factor)
     """
     Functionality copied from the CustomEditor to copy some of 
     the neede editing functionality like commenting, ...
     """
     # Add the attributes needed to implement the line nist
     self.line_list = components.LineList(self, self.text())
     # Add the needed functions assigned from the CustomEditor
     self.set_theme = functools.partial(CustomEditor.set_theme, self)
     self.set_line = functools.partial(CustomEditor.set_line, self)
     self.set_lines = functools.partial(CustomEditor.set_lines, self)
     self.toggle_comment_uncomment = functools.partial(CustomEditor.toggle_comment_uncomment, self)
     self.comment_line = functools.partial(CustomEditor.comment_line, self)
     self.comment_lines = functools.partial(CustomEditor.comment_lines, self)
     self.uncomment_line = functools.partial(CustomEditor.uncomment_line, self)
     self.uncomment_lines = functools.partial(CustomEditor.uncomment_lines, self)
     self.prepend_to_line = functools.partial(CustomEditor.prepend_to_line, self)
     self.prepend_to_lines = functools.partial(CustomEditor.prepend_to_lines, self)
     self.replace_line = functools.partial(CustomEditor.replace_line, self)
     self.get_line = functools.partial(CustomEditor.get_line, self)
     self.check_line_numbering = functools.partial(CustomEditor.check_line_numbering, self)
     self.text_to_list = functools.partial(CustomEditor.text_to_list, self)
     self.list_to_text = functools.partial(CustomEditor.list_to_text, self)
     # Add the function and connect the signal to update the line/column positions
     self.cursorPositionChanged.connect(self._signal_editor_cursor_change)
     #Set the lexer to python
     self.set_lexer()
     #Set the initial autocompletions
     self.update_autocompletions()
     #Setup the LineList object that will hold the custom editor text as a list of lines
     self.line_list = components.LineList(self, self.text())
     self.textChanged.connect(self.text_changed)
Пример #15
0
 def __init__(self,
              parent,
              main_form,
              input_pixmap,
              input_function=None,
              input_function_text="",
              input_font=data.QFont('Courier', 14, weight=data.QFont.Bold),
              input_focus_last_widget=data.HexButtonFocus.NONE,
              input_no_tab_focus_disable=False,
              input_no_document_focus_disable=True,
              input_check_last_tab_type=False,
              input_check_text_differ=False,
              input_tool_tip=None,
              input_scale=(1, 1)):
     #Initialize superclass
     super().__init__(parent)
     #Store the reference to the parent
     self._parent = parent
     #Store the reference to the main form
     self.main_form = main_form
     # Set default font
     self.setFont(data.get_current_font())
     #Store the reference to the group box that holds the parent
     #(the parent of the parent)
     self.group_box_parent = parent.parent
     #Store the main function image
     self.stored_pixmap = input_pixmap
     #Store the hex edge image
     self.stored_hex = data.QPixmap(
         os.path.join(data.resources_directory,
                      "various/hex-button-edge.png"))
     #Store the function that will be executed on the click event
     self.function = input_function
     #Store the function text
     self.function_text = input_function_text
     #Set the attribute that will be check if focus update is needed
     #when the custom button executes its function
     self.focus_last_widget = input_focus_last_widget
     #Set the attribute that checks if any tab is focused
     self.no_tab_focus_disable = input_no_tab_focus_disable
     #Set the attribute that will be check if button will be disabled
     #if there is no focused document tab
     self.no_document_focus_disable = input_no_document_focus_disable
     #Set checking the save state stored in the main form
     self.check_last_tab_type = input_check_last_tab_type
     #Set checking for if the focused tab is a text differer
     self.check_text_differ = input_check_text_differ
     #Set the font that will be used with the button
     self.stored_font = input_font
     #Enable mouse move events
     self.setMouseTracking(True)
     #Set the image for displaying
     #        self.setPixmap(input_pixmap)
     #        #Image should scale to the button size
     #        self.setScaledContents(True)
     #        # Set the button mask, which sets the button area to the shape of
     #        # the button image instead of a rectangle
     #        self.setMask(self.stored_hex.mask())
     #        #Set the initial opacity to low
     #        self._set_opacity_with_hex_edge(self.OPACITY_LOW)
     #Set the tooltip if it was set
     if input_tool_tip != None:
         self.setToolTip(input_tool_tip)
     # Set the scaling
     self.scale = input_scale
Пример #16
0
        def __init__(self,
                     name,
                     picture,
                     scale_factor=1.0,
                     function=None,
                     key_combination=None,
                     starting_position=None,
                     end_position=None,
                     parent=None):
            super().__init__(parent)

            self.name = name
            self.scale_factor = scale_factor
            self.key_combination = key_combination
            self.animating = False
            self.starting_position = starting_position
            self.end_position = end_position
            self.disable()
            self.properties = {}
            # Set default font
            self.setFont(data.get_current_font())
            # Button image
            self.button_image = data.QPixmap(
                os.path.join(data.resources_directory, picture))
            adjusted_size = self.DEFAULT_SIZE * self.scale_factor
            self.button_image = self.button_image.scaled(
                functions.create_size(
                    math.ceil(adjusted_size),
                    math.ceil(adjusted_size),
                ),
                transformMode=data.Qt.SmoothTransformation)

            width, height = components.HexBuilder.get_single_hex_size(
                adjusted_size, 2)

            def create_base_image():
                hex_image = data.QImage(
                    functions.create_size(width, height),
                    data.QImage.Format_ARGB32_Premultiplied)
                hex_image.fill(data.Qt.transparent)
                qpainter = data.QPainter(hex_image)
                qpainter.setRenderHints(data.QPainter.Antialiasing
                                        | data.QPainter.TextAntialiasing
                                        | data.QPainter.SmoothPixmapTransform)
                hb = components.HexBuilder(
                    qpainter,
                    (width / 2, height / 2),
                    self.DEFAULT_SIZE,
                    self.scale_factor,
                    fill_color=data.theme.Settings_Hex_Background,
                    line_width=2,
                    line_color=data.QColor(64, 64, 64),
                )
                hb.create_grid(False)
                qpainter.end()
                return data.QPixmap.fromImage(hex_image)

            self.hex_image = create_base_image()
            self.hex_image = self.hex_image.scaled(
                functions.create_size(
                    math.ceil(self.hex_image.size().width() *
                              self.scale_factor),
                    math.ceil(self.hex_image.size().height() *
                              self.scale_factor),
                ),
                transformMode=data.Qt.SmoothTransformation)

            # Green hex background
            def create_color_image(color):
                hex_image = data.QImage(
                    functions.create_size(width, height),
                    data.QImage.Format_ARGB32_Premultiplied)
                hex_image.fill(data.Qt.transparent)
                qpainter = data.QPainter(hex_image)
                qpainter.setRenderHints(data.QPainter.Antialiasing
                                        | data.QPainter.TextAntialiasing
                                        | data.QPainter.SmoothPixmapTransform)
                hb = components.HexBuilder(
                    qpainter,
                    (width / 2, height / 2),
                    self.DEFAULT_SIZE,
                    self.scale_factor,
                    fill_color=color,
                    line_width=0,
                    line_color=data.QColor(0, 0, 0),
                )
                hb.create_grid(False)
                qpainter.end()
                return data.QPixmap.fromImage(hex_image)

            self.hex_image_green = create_color_image(data.QColor(
                138, 226, 52))
            self.hex_image_green = self.hex_image_green.scaled(
                functions.create_size(
                    math.ceil(self.hex_image_green.size().width() *
                              self.scale_factor) - 1,
                    math.ceil(self.hex_image_green.size().height() *
                              self.scale_factor) - 1,
                ),
                transformMode=data.Qt.SmoothTransformation)
            # Red hex background
            self.hex_image_red = create_color_image(data.QColor(239, 41, 41))
            self.hex_image_red = self.hex_image_red.scaled(
                functions.create_size(
                    math.ceil(self.hex_image_red.size().width() *
                              self.scale_factor) - 1,
                    math.ceil(self.hex_image_red.size().height() *
                              self.scale_factor) - 1,
                ),
                transformMode=data.Qt.SmoothTransformation)

            scaled_size = functions.create_size(
                self.hex_image.size().width(),
                self.hex_image.size().height(),
            )
            image = data.QImage(
                scaled_size,
                data.QImage.Format_ARGB32_Premultiplied,
            )
            image.fill(data.Qt.transparent)
            button_painter = data.QPainter(image)
            button_painter.setCompositionMode(
                data.QPainter.CompositionMode_SourceOver)
            button_painter.setOpacity(1.0)
            # Adjust inner button positioning according to the scale
            x = (self.hex_image.width() - self.button_image.width()) / 2
            y = (self.hex_image.height() - self.button_image.height()) / 2
            button_painter.drawPixmap(0, 0, self.hex_image)

            button_painter.drawPixmap(x, y, self.button_image)
            button_painter.end()

            # Set properites
            self.setParent(parent)
            self.setPixmap(data.QPixmap.fromImage(image))
            self.setGeometry(0, 0, int(image.width() * self.scale_factor),
                             int(image.height() * self.scale_factor))
            self.setMask(self.hex_image.mask())
            self.setScaledContents(True)
            # Set the non-enlarged dimensions
            self.original_size = (self.geometry().width(),
                                  self.geometry().height())

            # Set the initial color state
            self.current_color = "default"