#๐Ÿ”’ toolbar dublicates litterly everything!! why?

14 messages ยท Page 1 of 1 (latest)

urban gust
#

salutations lads. im a fellow beginner and need your aid for my script. i have following problem. i wanna make an application. what its supposed to do is that it should show a subtoolbar (which i had to make an invidual toolbar) if i select an action in the "maintoolbar". Ok it shows, yipee. HOW EVER!! everytime i add a new subtoolbar for the other actions it somehow dublicates everything, i supose its only dublicating everythin that is a part of the maintoolbar (images that change position if maintoolbar changes selected action). i will share the code with you.

lavish mesaBOT
#

@urban gust

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

urban gust
#

here is the code(method) i use to make new toolbars:

                                                                #SUBTOOLBAR DATA
        # Create and customize the Sub_Toolbar_DATA
        self.toolbar2 = QToolBar("Sub_Toolbar_DATA")
        self.toolbar2.setFloatable(False)  # Prevent docking
        self.toolbar2.setMovable(False)    # Prevent user from moving it
        self.toolbar2.setParent(self)      # Detach from the QMainWindow toolbar system

        # Make the toolbar transparent by setting its attribute
        self.toolbar2.setAttribute(Qt.WA_OpaquePaintEvent, False)

        # Set the background of the toolbar to transparent
        self.toolbar2.setStyleSheet(
            """
            QToolBar{ 
                background-color: transparent; 
                border: 0px;
                opacity: 0;
                spacing: 0px;
            } 
            QToolButton{ 
                margin: 0px;
                background-color: transparent;
                opacity: 0;
                color: rgb(0, 255, 0); 
                font-size: 30px;
                margin-left: -15px;
            }
            """
        )

        # Add actions to the Sub_Toolbar_DATA
        self.actions2 = []
        self.add_toolbar2_action("SCRAP")
        self.add_toolbar2_action("SHIT")
        self.add_toolbar2_action("GADGETS")

        self.toolbar2.setGeometry(100, 20, 790, 100)
        
    def add_toolbar2_action(self, name):
        action = QAction(name, self)
        action.triggered.connect(lambda checked, option=name: self.change_image_position(option))
        self.toolbar2.addAction(action)
        self.actions2.append(action)
#

here is the code (method i used for the main toolbar:

        # Create and customize the toolbar
        self.toolbar = QToolBar("Main_Toolbar")
        self.toolbar.setFloatable(False)  # Prevent docking
        self.toolbar.setMovable(False)    # Prevent user from moving it
        self.toolbar.setParent(self)      # Detach from the QMainWindow toolbar system

        # Make the toolbar transparent by setting its attribute
        self.toolbar.setAttribute(Qt.WA_OpaquePaintEvent, False)

        # Set the background of the toolbar to transparent
        self.toolbar.setStyleSheet(
            """
            QToolBar{ 
                background-color: transparent; 
                border: 0px;
                opacity: 0;
            } 
            QToolButton{ 
                margin: 0px;
                background-color: transparent;
                opacity: 0;
                color: rgb(0, 255, 0); 
                font-size: 40px;
            }
            """
        )

        # Add actions to the toolbar
        self.actions = []
        self.add_toolbar_action("STAT")
        self.add_toolbar_action("INV")
        self.add_toolbar_action("DATA")
        self.add_toolbar_action("NAVI")
        self.add_toolbar_action("RADIO")

        self.toolbar.setGeometry(80, -20, 790, 100)
        self.toolbar.show()

        # Initialize pygame mixer
        pygame.mixer.init()

    def add_toolbar_action(self, name):
        action = QAction(name, self)
        action.triggered.connect(lambda checked, option=name: self.change_image_position(option))
        self.toolbar.addAction(action)
        self.actions.append(action)
#

Here is a pic. Of the current application. U can see that the test is massivly thick which isnt supposed to be like that. Also the little image that floats in the middle is also not supposed to be like that. If i remove the aditional toolbars it works. But i need the toolbars. Also i realized everytime i add a new toolbar the text gets bigger.

#

Forgot to mention. The code uses PyQt5

lunar slate
#

ok

#

dm me well figure it out

urban gust
#

Aight

lunar slate
#

we'll

normal wing
# lunar slate dm me well figure it out

@urban gust please note that DMs are not standard way of helping in this server. Normally help would be given in the channel.
We've had cases of bad people trying to infect newbies via DMs (telling people to install something or sending over some file or weird code to run).

I'm not accusing @lunar slate of anything, of course, they're quite new in the server so they might not know how help in this server usually works.

urban gust
#

Noted

lavish mesaBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.