Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

Invalid syntax

roshanshilimkar3434
Advocate
Advocate

Invalid syntax

roshanshilimkar3434
Advocate
Advocate

Hey, I am new to programming and following a tut for creating a blank window using python, I've started maya 2022 with python2, what am I doing wrong? this is the exact code used in the tutorial

 

from PySide2 import QtCore
from PySide2 import QtWidgets


class TestDialog(QtWidgets.QDialog):
def_init_(self, parent=None):
super(TestDialog, self)._init_(parent)


if_name_ == "_main_":

d = TestDialog()
d.show()

 

thank you.,

 

 

 

 

0 Likes
Reply
Accepted solutions (1)
286 Views
1 Reply
Reply (1)

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

You're missing the spaces after "def" and "if".

 

from PySide2 import QtCore
from PySide2 import QtWidgets


class TestDialog(QtWidgets.QDialog):
    def _init_(self, parent=None):
        super(TestDialog, self)._init_(parent)
        
        
        if _name_ == "_main_":
        
            d = TestDialog()
            d.show()

 

I hope it helps!