Problem showing a widget (not Window)

Heads up! You've already completed this tutorial.

Sourabh_Desai | 2020-05-07 14:18:42 UTC | #1

Hello Martin, I am currently facing a problem where I am trying to show-up a WIDGET not a WINDOW. For this I have a seaparate UI file say Ui.py. Now, in order to provide functionality to the GUI, I need to create a class, right? - I did. Now, I am not able to get the UI show-up please help me. I think I am missing the basics. Please find my code below.

python
import PySide2
import os
import sys
from smoky_UI import Ui_Form
from PySide2 import QtWidgets

dirname = os.path.dirname(PySide2.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path

class MyQtApp(Ui_Form,):
    def  __int__ (self):
        super().__init__()
        self.setupUi(self)

if  __name__  == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    qt_app = MyQtApp()
    qt_app.show()
    sys.exit(app.exec_())

1:1 Coaching & Tutoring for your Python GUIs project
Martin Fitzpatrick Python GUIs Coaching & Training
60 mins ($195) Book Now

1:1 Python GUIs Coaching & Training

Comprehensive code reviewBugfixes & improvements • Maintainability advice and architecture improvements • Design and usability assessment • Suggestions and tips to expand your knowledgePackaging and distribution help for Windows, Mac & Linux • Find out more.

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

Problem showing a widget (not Window) was written by Martin Fitzpatrick .

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular Python books on the subject.