0
from images import mainwindow
from PyQt4.QtGui import QWidget, QMainWindow

class mainwindow_ui(QMainWindow):
      def __init__(self):
          QMainWindow.__init__(self)
          self.ui = uic.loadUi('mainwindow.ui',self)
          button = self.ui.exitBtn
          self.ui.show()

How to interactive with button object on Python console?

Tab completion work. After tab press, there is no mainwindow_ui.exitBtn - or mainwindow.button why?

Adam Ł.
  • 1
  • 2
  • Use the uic utility to convert the file from .ui to .py as described here: http://stackoverflow.com/questions/18429452/convert-pyqt-ui-to-python. Then you'll be able to import the .py file directly instead (which will allow code completion). – 101 Dec 23 '15 at 10:42
  • Oh, then you shouldn't need to load mainwindow.ui at all. I'd recommend looking at some basic PyQt tutorials. – 101 Jan 04 '16 at 00:15

1 Answers1

0

uic.loadUi essentially loading the widget name into the classes namespace.

if you named the widget "foo" from within Qdesigner then you can access it via self.foo

Naib
  • 999
  • 7
  • 20