I implemented whole UI and logic into one py file now I thing it would be good if I separate the UI file from the logic, and to run the UI I shoud run the file that contains logic that inturn loads the UI...

I have RenderUI.py module that contains everything now, I have made another file named Render.pyfrom which I want to launch the UI file
both the above files are in folder Batch that I made package by including __init__.py

the RenderUI.py file contains the class Window,

but since I made a PyQt4 app i have this code in the end outside of Window Class ,

if __name__ =='__main__':
   app = QtGui.QApplication(sys.argv)
   app.setStyle("cleanlooks")
   win = Window()
   win.show()
   sys.exit(app.exec_())

which means in Render.py file I should have from RenderUI.py import * but this isnt working strangely when I try typing from RenderUI i get option like from RenderUI.RenderUI while their is not such sub file with same name..

so how should I call the RenderUI from Render.py ?

The first thing to do is to avoid import *. Import only specific names. What you could do in this case is a function

# file RenderUI.py

def main():
   app = QtGui.QApplication(sys.argv)
   app.setStyle("cleanlooks")
   win = Window()
   win.show()
   sys.exit(app.exec_())

and in the other file

# file Render.py
from RenderUI import main

if __name__ == "__main__":
    main()

how about doing this way ?

import RenderUI,sys
from PyQt4 import QtCore,QtGui



#class Actions():




if __name__ =='__main__':
   app = QtGui.QApplication(sys.argv)
   app.setStyle("cleanlooks")
   win = RenderUI.Window()
   win.show()
   sys.exit(app.exec_())
else:
     win = Window()
     win.show()

and no need of main() function in RenderUI.py

i defined a class in Render.py but if i define its constructor __init__ i get error in the RenderUI.py while instantiating this class saying

Message File Name   Line    Position    
Traceback               
    <module> \Render.py  39      
    __init__    \RenderUI.py    26      
TypeError: __init__() takes no arguments (1 given)  

please help out !!

__init__'s minimal signature is def __init__(self):...

i shoudl have implemented UI separate from logic now it is such a pain...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.