Increase the size of the image in the expanded QComboBox list

52 Views Asked by At

there is a small piece of program code. As it has a Combobox that contains a drop-down list. Please help with 2 questions:

  1. how not to display the first picture in the expanded list? that is, you need the first picture to be visible when the list is not disclosed.
  2. how do I increase the size of 2 and 3 images (which are in the drop-down list), for example, by 2 times?

Pictures are not attached, you can attach any other __

from PyQt5 import QtWidgets
from PyQt5.QtWidgets import * 
from PyQt5.QtGui import *     
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QWidget
import sys


app = QApplication([])
tab = QTabWidget()
tab.setGeometry(0, 0, 400, 1000)


class Tabs_tools(QWidget):
    def __init__(self):
        super().__init__() 
        self.combo_box = QComboBox()
        self.combo_box.setStyleSheet("QComboBox::drop-down {""width: 0px;" "border: 0px;" "}")
        self.combo_box.setFixedSize(120, 120)
        self.combo_box.setIconSize(QSize(120, 120))     
        self.combo_box.setView(QListView())
        self.combo_box.view().setRowHidden(0, True)
        self.combo_box.view().setFixedSize(400, 220)

        icon1 = QIcon('App_DB/Images/Load_data.png')
        icon2 = QIcon(QPixmap('App_DB/Images/Load_data_file.png').scaled(QSize(11000, 11000)))
        icon3 = QIcon(QPixmap('App_DB/Images/Load_data_file.png').scaled(QSize(110, 110)))

        self.combo_box.addItem(icon1, '')
        self.combo_box.addItem(icon2, 'From the file')
        self.combo_box.addItem(icon3, 'From the folder')

        self.combo_box.activated[str].connect(self.get_FileNames)
        
        # 
        grid_for_tab_Gemeral = QGridLayout()
        grid_for_tab_Gemeral.setColumnStretch(0, 0)
        grid_for_tab_Gemeral.setAlignment(Qt.AlignmentFlag.AlignLeft)

        grid_for_tab_Gemeral.addWidget(self.combo_box, 0, 0)

        group_box = QGroupBox()
        group_box.setLayout(grid_for_tab_Gemeral)

        # 
        self.tab = QTabWidget()
        self.tab.setFixedSize(1800, 180)
        self.tab.setContentsMargins(-100, 0, 0, 0)

        self.tab.addTab(group_box, 'Main')
        self.tab.addTab(QWidget(), 'Сonvert data')
        self.tab.addTab(QWidget(), 'Add column')

        self.tab.setStyleSheet(
            """QTabBar::tab {
                border: 1px solid #C4C4C3;
                padding: 10px;}""")

        grid = QGridLayout()
        grid.setColumnStretch(0, 0)
        grid.addWidget(self.tab, 0, 0)
        self.setLayout(grid)

    def get_FileNames(self, text):
        file_paths = QFileDialog.getOpenFileNames()[0]

        if file_paths:
            if text == 'From the file"':
                self.processing_excel()

    def processing_excel(self):
        print('f')       


grid = QtWidgets.QGridLayout()
grid.setColumnStretch(1, 0)
grid.setRowStretch(4, 4)
grid.addWidget(Tabs_tools(), 0, 0)
tab.setLayout(grid)


if __name__ == '__main__':
    tab.show()
    sys.exit(app.exec())

I read the documentation and did not find the answer, I asked a chatGPT question, but he also did not give the correct code

I need this as in the picture:

enter image description here

0

There are 0 best solutions below