0

I have developed a plugin where I am filling my GUI Control like (Drop down) in initGui Event. But the problem is that if I open my plugin it's only exectures Run events. Its initGui event doesn't fire and my control are not updating with data. As you can see in my initGui Event I also print a message which is also not showing as my plugin start.

  def initGui(self):
        """Create the menu entries and toolbar icons inside the QGIS GUI."""

        icon_path = ':/plugins/TaskAutomation/icon.png'

        self.add_action(
            icon_path,
            text=self.tr(u'TLL Task Automation'),
            callback=self.run,
            parent=self.iface.mainWindow())
        self.AttachBtnClicked()
        self.AllCBLayersFill()
        self.AttachCBLayersIndexChange()
        print 'initGui  method' #this message is not showing when plugin start


    def unload(self):
        """Removes the plugin menu item and icon from QGIS GUI."""
        for action in self.actions:
            self.iface.removePluginMenu(
                self.tr(u'&TLL QGIS Task Automation'),
                action)
            self.iface.removeToolBarIcon(action)
        # remove the toolbar
        del self.toolbar
        print 'unload  method'

    def run(self):

        """Run method that performs all the real work"""
        print 'run  method 123'
        # show the dialog
        self.dlg.show()
        # Run the dialog event loop
        result = self.dlg.exec_()
        # See if OK was pressed
        if result:
            # Do something useful here - delete the line containing pass and
            # substitute with your code.
            pass
1

Don't know you still interested, but your code is fine for me. InitGui method launchs only, while plugin is loading, not starting\opening. According to that, your message will show, e.g. when you open qgis (you will not see this message, cuz console is hidden), when you uncheck and check plugin in repository or when you reload a plugin.

In this case more appropriate will be putting message bar instead of print function.

  • I am still intereseted but you did not mention the solution – Muhammad Faizan Khan Dec 27 '16 at 7:45
  • Cuz you didn't ask a question actually. What's your main problem? – DIV Dec 27 '16 at 10:29
  • why initi GUI is not executing. I have to run my logic at that event – Muhammad Faizan Khan Dec 27 '16 at 10:31
  • but it's executing, when it should (I listed all cases). What kind of stuff you wanna put there? – DIV Dec 27 '16 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.