def scale(self, width_scale_factor=1, height_scale_factor=1): """Scale the size of the function wheel and all of its child widgets""" #Scale the function wheel form geo = self.geometry() new_width = int(geo.width() * width_scale_factor) new_height = int(geo.height() * height_scale_factor) rectangle = data.QRect( geo.topLeft(), data.QSize(new_width, new_height) ) self.setGeometry(rectangle) #Scale all of the function wheel child widgets for button in self.children(): geo = button.geometry() new_topLeft = data.QPoint( int(geo.topLeft().x() * width_scale_factor), int(geo.topLeft().y() * height_scale_factor) ) new_width = int(geo.width() * width_scale_factor) new_height = int(geo.height() * height_scale_factor) new_size = data.QSize(new_width, new_height) rectangle = data.QRect(new_topLeft, new_size) button.setGeometry(rectangle) #Center to main form self.center(self.size())
def _set_opacity_with_hex_edge(self, input_opacity): """ Set the opacity of the stored QPixmap image and display it """ # Store the opacity self.stored_opacity = input_opacity # Create and initialize the QImage from the stored QPixmap button_image = self.stored_pixmap # Resize the button image to scale button_image = button_image.scaled( data.QSize( math.ceil(button_image.size().width() * self.scale[0]), math.ceil(button_image.size().height() * self.scale[1]), ), transformMode=data.Qt.SmoothTransformation ) # Scale the hex image hex_image = self.stored_hex scaled_size = data.QSize( math.ceil(hex_image.size().width() * self.scale[0]), math.ceil(hex_image.size().height() * self.scale[1]), ) image = data.QImage( scaled_size, data.QImage.Format_ARGB32_Premultiplied, ) image.fill(data.Qt.transparent) # image.fill(data.theme.Context_Menu_Background) # Create and initialize the QPainter that will manipulate the QImage button_painter = data.QPainter(image) button_painter.setCompositionMode( data.QPainter.CompositionMode_SourceOver ) button_painter.setOpacity(input_opacity) # Resize the hex image to scale hex_image = hex_image.scaled( data.QSize( math.ceil(hex_image.size().width() * self.scale[0]), math.ceil(hex_image.size().height() * self.scale[1]), ), transformMode=data.Qt.SmoothTransformation ) # Adjust inner button positioning according to the scale button_painter.drawPixmap(0, 0, hex_image) x_scaled = math.ceil(self.scale[0] * self.INNER_IMAGE_OFFSET[0]) y_scaled = math.ceil(self.scale[1] * self.INNER_IMAGE_OFFSET[1]) button_painter.drawPixmap(x_scaled, y_scaled, button_image) button_painter.end() # Display the manipulated image self.setPixmap(data.QPixmap.fromImage(image)) # Set the button mask, which sets the button area to the shape of # the button image instead of a rectangle self.setMask(hex_image.mask())
def update_styles(): if TheSquid.main_form == None: # Do not update if the main form is not initialized return TheSquid.update_objects() TheSquid.customize_menu_style(TheSquid.main_form.menubar) if data.custom_menu_font != None: for action in TheSquid.main_form.menubar.stored_actions: action.setFont(data.QFont(*data.custom_menu_font)) TheSquid.customize_menu_style(TheSquid.main_form.sessions_menu) TheSquid.customize_menu_style(TheSquid.main_form.recent_files_menu) TheSquid.customize_menu_style(TheSquid.main_form.save_in_encoding) TheSquid.customize_menu_style(TheSquid.main_form.bookmark_menu) def set_style(menu): if hasattr(menu, "actions"): TheSquid.customize_menu_style(menu) for item in menu.actions(): if item.menu() != None: TheSquid.customize_menu_style(item.menu()) set_style(item) set_style(TheSquid.main_form.sessions_menu) windows = [ TheSquid.main_window, TheSquid.upper_window, TheSquid.lower_window ] for window in windows: window.customize_tab_bar() for i in range(window.count()): if hasattr(window.widget(i), "corner_widget"): TheSquid.customize_menu_style( window.widget(i).corner_widget ) if data.custom_menu_scale != None: window.widget(i).corner_widget.setIconSize( data.QSize( data.custom_menu_scale, data.custom_menu_scale ) ) else: window.widget(i).corner_widget.setIconSize( data.QSize(16, 16) ) if hasattr(window.widget(i), "icon_manipulator"): window.widget(i).icon_manipulator.restyle_corner_button_icons() if isinstance(window.widget(i), gui.TreeDisplay): window.widget(i).update_icon_size()
def init_extra_button(self, parent, main_form, input_extra_pixmap, input_extra_function=None, input_extra_function_text=""): #Store the parent and main form references self._parent = parent self.main_form = main_form #Initialize the extra button self.extra_button = data.QLabel(self) width = int(self.geometry().width() * self.extra_button_size_factor) height = int(self.geometry().height() * self.extra_button_size_factor) self.extra_button_position = data.QPoint( self.geometry().width()*2/3-width, self.geometry().height()*1/4 ) rectangle = data.QRect(self.extra_button_position, data.QSize(width, height)) self.extra_button.setGeometry(rectangle) self.extra_button_stored_pixmap = input_extra_pixmap self.extra_button.setPixmap(input_extra_pixmap) self.extra_button.setScaledContents(True) #Store the function options self.extra_button_function = input_extra_function self.extra_button_function_text = input_extra_function_text #Set the extra button opacity to low self._set_extra_button_opacity(self.OPACITY_LOW) #Overridden the extra buttons events self.extra_button.mousePressEvent = self.extra_button_click self.extra_button.enterEvent = self.extra_button_enter_event self.extra_button.leaveEvent = self.extra_button_leave_event
def restyle_corner_button_icons(self): if self.corner_groupbox == None: return layout = self.corner_groupbox.layout() for i in range(layout.count()): if data.custom_menu_scale != None: layout.itemAt(i).widget().setIconSize( data.QSize(data.custom_menu_scale, data.custom_menu_scale))
def sizeFromContents(self, ct, opt, contentsSize, widget=None): if ct == data.QStyle.CT_MenuItem: scaled_width = self.scale_constant * 1.5 resized_width = self.custom_font_metrics.width( opt.text) + scaled_width result = data.QSize(int(resized_width), int(self.scale_constant)) return result elif ct == data.QStyle.CT_MenuBarItem: base_width = self.custom_font_metrics.width(opt.text) scaled_width = self.scale_constant * 1.5 if base_width < scaled_width: result = data.QSize(scaled_width, self.scale_constant) else: result = data.QSize(base_width, self.scale_constant) return result else: return self._style.sizeFromContents(ct, opt, contentsSize, widget)
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 = data.QSize(data.custom_menu_scale, data.custom_menu_scale) self.setIconSize(new_icon_size) else: components.TheSquid.customize_menu_style(self.tabBar()) self.tabBar().setFont(self.default_tab_font) self.setIconSize(self.default_icon_size)
def update_styles(): if TheSquid.main_form == None: # Do not update if the main form is not initialized return TheSquid.update_objects() TheSquid.customize_menu_style(TheSquid.main_form.menubar) TheSquid.customize_menu_style(TheSquid.main_form.sessions_menu) TheSquid.customize_menu_style(TheSquid.main_form.recent_files_menu) TheSquid.customize_menu_style(TheSquid.main_form.save_in_encoding) def set_style(menu): if hasattr(menu, "actions"): TheSquid.customize_menu_style(menu) for item in menu.actions(): if item.menu() != None: TheSquid.customize_menu_style(item.menu()) set_style(item) set_style(TheSquid.main_form.sessions_menu) windows = [ TheSquid.main_window, TheSquid.upper_window, TheSquid.lower_window ] for window in windows: window.customize_tab_bar() for i in range(window.count()): if hasattr(window.widget(i), "corner_widget"): TheSquid.customize_menu_style( window.widget(i).corner_widget) if data.custom_menu_scale != None: window.widget(i).corner_widget.setIconSize( data.QSize(data.custom_menu_scale, data.custom_menu_scale)) else: window.widget(i).corner_widget.setIconSize( data.QSize(16, 16)) if isinstance(window.widget(i), helper_forms.TreeDisplay): window.widget(i).update_icon_size()
def resizeEvent(self, event): """Overridden resize event""" #Execute the superclass resize function super().resizeEvent(event) #Update the extra button geometry width = int(self.geometry().width() * self.extra_button_size_factor) height = int(self.geometry().height() * self.extra_button_size_factor) rectangle = data.QRect( self.extra_button_position, data.QSize(width, height) ) self.extra_button.setGeometry(rectangle)
def add_corner_button(self, icon, tooltip, function): # Create the group box for buttons if needed if self.corner_groupbox == None: self.corner_groupbox = data.QGroupBox(self._basic_widget) corner_layout = data.QHBoxLayout() corner_layout.setSpacing(0) corner_layout.setContentsMargins(0, 0, 0, 0) self.corner_groupbox.setLayout(corner_layout) self.corner_groupbox.setStyleSheet("QGroupBox{border: 0px;}") self.corner_groupbox.show() # Add the button button = self.create_corner_button(icon, tooltip, function) layout = self.corner_groupbox.layout() layout.addWidget(button) for i in range(layout.count()): if data.custom_menu_scale != None: layout.itemAt(i).widget().setIconSize( data.QSize(data.custom_menu_scale, data.custom_menu_scale))
def _set_wait_animation(self, index, show): tabBar = self.tabBar() if show: lbl = data.QLabel(self) movie = data.QMovie(os.path.join(data.resources_directory, "animations/wait.gif"), parent=lbl) movie.setCacheMode(data.QMovie.CacheAll) if data.custom_menu_scale != None: size = tuple([(x * data.custom_menu_scale / 16) for x in (16, 16)]) else: size = (16, 16) movie.setScaledSize(data.QSize(*size)) lbl.setMovie(movie) movie.start() tabBar.setTabButton(index, data.QTabBar.LeftSide, lbl) else: tabBar.setTabButton(index, data.QTabBar.LeftSide, None)
def check_position_offset(self, inner_buttons=True, outer_buttons=True, horizontal_buttons=False): button_positions = [] if inner_buttons == True: button_positions.extend(ContextMenu.inner_button_positions) if outer_buttons == True: button_positions.extend(ContextMenu.outer_button_positions) if horizontal_buttons == True: button_positions.extend(self.horizontal_button_positions) hex_x_size = self.ContextButton.HEX_IMAGE_SIZE[0] * self.x_scale hex_y_size = self.ContextButton.HEX_IMAGE_SIZE[1] * self.y_scale window_size = self.parent().size() - data.QSize(hex_x_size, hex_y_size) min_x = 0 min_y = 0 max_x = 0 max_y = 0 for b in button_positions: x = self.offset[0] + b[0] * self.x_scale / 0.8 + self.total_offset[ 0] y = self.offset[1] + b[1] * self.y_scale / 0.8 + self.total_offset[ 1] if x < min_x: min_x = x if x > window_size.width(): new_max = x - window_size.width() if new_max > max_x: max_x = new_max if y < min_y: min_y = y if y > window_size.height(): new_max = y - window_size.height() if new_max > max_y: max_y = new_max if min_x != 0: self.offset = (self.offset[0] - min_x, self.offset[1]) if max_x != 0: self.offset = (self.offset[0] - max_x, self.offset[1]) if min_y != 0: self.offset = (self.offset[0], self.offset[1] - min_y) if max_y != 0: self.offset = (self.offset[0], self.offset[1] - max_y)
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 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( data.QSize(*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()
def set_color(self, color): if not(color in self.valid_colors): raise Exception("Invalid EnlargeButton color selected!") elif color == "red": selected_image = self.hex_image_red elif color == "green": selected_image = self.hex_image_green elif color == "default": selected_image = None self.current_color = color scaled_size = data.QSize( 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) if selected_image != None: button_painter.drawPixmap( (5 * (self.scale_factor - 1.0)), (5 * (self.scale_factor - 1.0)), selected_image ) button_painter.drawPixmap(x, y, self.button_image) button_painter.end() # Set the image as the pixmap self.setPixmap(data.QPixmap.fromImage(image))
def create_base_image(): hex_image = data.QImage( data.QSize(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)
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 = {} # 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( data.QSize( 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( data.QSize(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( data.QSize( 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( data.QSize(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( data.QSize( 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( data.QSize( 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 = data.QSize( 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, image.width() * self.scale_factor, 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"
def init_layout(self, text, dialog_type): # Setup the image # First create the background image using the hex builder back_image = data.QImage(data.QSize(246, 211), data.QImage.Format_ARGB32_Premultiplied) back_image.fill(data.Qt.transparent) painter = data.QPainter(back_image) painter.setRenderHints(data.QPainter.Antialiasing | data.QPainter.TextAntialiasing | data.QPainter.SmoothPixmapTransform) hex_builder = components.HexBuilder( painter, (123, 28), 30, 1.0, fill_color=data.theme.YesNoDialog_Background, line_width=3, line_color=data.theme.YesNoDialog_Edge, ) hex_builder.create_grid( False, 2, 2, 3, 4, 0, 5, 3, (3, True), 5, 0, 0, 4, 3 # OkDialog ) painter.end() original_dialog_image = data.QPixmap.fromImage(back_image) # Now add the images according to the type of dialog dialog_image = original_dialog_image.scaled( original_dialog_image.size() * self.scale, transformMode=data.Qt.SmoothTransformation) self.image = data.QLabel(self) self.image.setPixmap(dialog_image) self.image.setGeometry( 0, 0, dialog_image.rect().width() * self.scale, dialog_image.rect().height() * self.scale, ) self.image.setScaledContents(True) # Set the dialog mask to match the image mask self.setMask(dialog_image.mask()) # Setup the image behind the label if dialog_type != None: if dialog_type == "question": type_pixmap = data.QPixmap( os.path.join(data.resources_directory, "various/dialog-question.png")) elif dialog_type == "warning": type_pixmap = data.QPixmap( os.path.join(data.resources_directory, "various/dialog-warning.png")) elif dialog_type == "error": type_pixmap = data.QPixmap( os.path.join(data.resources_directory, "various/dialog-error.png")) else: raise Exception("Wrong dialog type!") image = data.QImage(type_pixmap.size(), data.QImage.Format_ARGB32_Premultiplied) image.fill(data.Qt.transparent) painter = data.QPainter(image) painter.setOpacity(0.2) painter.drawPixmap(0, 0, type_pixmap) painter.end() type_pixmap = data.QPixmap.fromImage(image) type_pixmap = type_pixmap.scaled( type_pixmap.size() * 2.0 * self.scale, transformMode=data.Qt.SmoothTransformation) self.type_label = data.QLabel(self) self.type_label.setPixmap(type_pixmap) type_label_rect = data.QRect( (self.image.rect().width() - type_pixmap.rect().width()) / 2 * self.scale, (self.image.rect().height() - type_pixmap.rect().height()) / 2 * self.scale, type_pixmap.rect().width() * self.scale, type_pixmap.rect().height() * self.scale, ) self.type_label.setGeometry(type_label_rect) # Setup the text label self.text = text self.label = data.QLabel(self) self.label.setFont( data.QFont('Segoe UI', 12 * self.scale, data.QFont.Bold)) self.label.setWordWrap(True) self.label.setAlignment(data.Qt.AlignCenter) self.label.setStyleSheet('color: rgb({}, {}, {})'.format( data.theme.Font.Default.red(), data.theme.Font.Default.green(), data.theme.Font.Default.blue(), )) self.label.setText(text) width_diff = self.image.rect().width() - original_dialog_image.width() height_diff = self.image.rect().height( ) - original_dialog_image.height() x_offset = 20 * (self.scale - 1.0) y_offset = 60 * (self.scale - 1.0) label_rect = data.QRect( dialog_image.rect().x() + 20 + x_offset, dialog_image.rect().y() + 60 + y_offset, dialog_image.rect().width() - (40 * self.scale), dialog_image.rect().height() - (120 * self.scale), ) self.label.setGeometry(label_rect) # Shrink text if needed for i in range(10): label_width = label_rect.width() label_height = label_rect.height() font_metrics = data.QFontMetrics(self.label.font()) bounding_rectangle = font_metrics.boundingRect( data.QRect(0, 0, label_width, label_height), self.label.alignment() | data.Qt.TextWordWrap, text) if (bounding_rectangle.width() > label_width or bounding_rectangle.height() > label_height): self.label.setFont( data.QFont('Segoe UI', (12 - i) * self.scale, data.QFont.Bold)) else: break # Setup the buttons self.button_no = self.Button( self, os.path.join(data.resources_directory, "various/hex-red.png"), "OK", data.QMessageBox.No, self.scale) x_offset = 93 * (self.scale - 1.0) y_offset = 158 * (self.scale - 1.0) self.button_no.setGeometry(93 + x_offset, 158 + y_offset, 59 * self.scale, 50 * self.scale) self.button_no.on_signal.connect(self.update_state_off) self.button_no.off_signal.connect(self.update_state_reset) # Setup the layout self.layout = data.QGridLayout() self.layout.setSpacing(0) self.layout.setContentsMargins(data.QMargins(0, 0, 0, 0)) self.layout.addWidget(self.image) self.setLayout(self.layout) # Setup tranparency and borders if data.on_rpi == True: self.image.setStyleSheet("border:0;" + "background-color:white;") else: self.image.setAttribute(data.Qt.WA_TranslucentBackground) self.image.setStyleSheet("border:0;" + "background-color:transparent;") self.setAttribute(data.Qt.WA_TranslucentBackground) self.setStyleSheet("border:0;" + "background-color:transparent;") self.setGeometry(dialog_image.rect()) self.center() self.setWindowFlags(data.Qt.FramelessWindowHint)
def create_background_image(in_scale=1.0): """ Dinamically create the settings manipulator's background image """ # Check if the QPixmap has been created already if SettingsGuiManipulator.settings_background_image == None: scale = in_scale edge_length = 27 scaled_edge_diff = (edge_length - (edge_length * scale)) / edge_length back_color = data.theme.Settings_Background edge_color = data.QColor(data.theme.Settings_Hex_Edge) SettingsGuiManipulator.theme_name = data.theme.name def add_offset(offset): x_add = 64.0 y_add = 20.0 return (offset[0] + x_add, offset[1] + y_add) settings_background_image = data.QImage( data.QSize(*SettingsGuiManipulator.DEFAULT_SIZE), data.QImage.Format_ARGB32_Premultiplied ) settings_background_image.fill(data.Qt.transparent) # settings_background_image.fill(data.QColor(255,255,255)) qpainter = data.QPainter(settings_background_image) qpainter.setRenderHints( data.QPainter.Antialiasing | data.QPainter.TextAntialiasing | data.QPainter.SmoothPixmapTransform ) # Corner options x = edge_length + 205 y = 1.8 * edge_length + 30 offset = (x, y) hb = components.HexBuilder( qpainter, offset, edge_length, scale, fill_color=back_color, line_width=2, line_color=edge_color, ) grid_list = [ (3, True), (4, True), (4, True), (4, True), (5, True), (1, True), ] hb.create_grid(*grid_list) # Label field last_step = hb.get_last_position() hb = components.HexBuilder( qpainter, offset, edge_length, scale, fill_color=data.theme.Settings_Label_Background, line_width=3, line_color=data.QColor(146,146,146), ) hb.set_first_position(last_step) hb.create_grid( 5,5,0,2,0,2,3,1,0,2,3,4 ) # Editor buttons offset = (90, 280) offset = add_offset(offset) row_length = 6 editor_button_count = 30 hb = components.HexBuilder( qpainter, offset, edge_length, scale, fill_color=back_color, line_width=2, line_color=edge_color, ) grid_list = hb.generate_square_grid_list( row_length, editor_button_count ) hb.create_grid(*grid_list) # Editor edge hb.next_step_move(3) first_edge_hex_position = hb.get_last_position() hb = components.HexBuilder( qpainter, first_edge_hex_position, edge_length, scale, fill_color=back_color, line_width=2, line_color=edge_color, ) grid_list = [ (4, True), (5, True), (4, True), (5, True), (4, True), (5, True), (0, True), (0, True), (0, True), (0, True), (0, True), (1, True), (1, True), (2, True), (1, True), (2, True), (1, True), (2, True), (3, True), (3, True), (3, True), (3, True), (3, True), ] hb.create_grid(*grid_list) # General buttons offset = (offset[0]+(8*hb.horizontal_step), offset[1]-(6*hb.vertical_step)) row_length = 7 general_button_count = 56 hb = components.HexBuilder( qpainter, offset, edge_length, scale, fill_color=back_color, line_width=2, line_color=edge_color, ) grid_list = hb.generate_square_grid_list( row_length, general_button_count ) hb.create_grid(*grid_list) # General edge hb.next_step_move(3) first_edge_hex_position = hb.get_last_position() hb = components.HexBuilder( qpainter, first_edge_hex_position, edge_length, scale, fill_color=back_color, line_width=2, line_color=edge_color, ) grid_list = [ (1, True), (2, True), (1, True), (2, True), (1, True), (2, True), (1, True), (0, True), (0, True), (0, True), (0, True), (0, True), (0, True), (0, True), (0, True), (5, True), (5, True), (4, True), (5, True), (4, True), (5, True), (4, True), (4, True), (3, True), (3, True), (3, True), (3, True), (3, True), (3, True), (3, True), (3, True), ] hb.create_grid(*grid_list) qpainter.end() SettingsGuiManipulator.settings_background_image = data.QPixmap.fromImage(settings_background_image) return SettingsGuiManipulator.settings_background_image