As the title implies, what I want to do is create main.py and have it open a window.
after the window is open, I want to edit main.py, and when finished editing, hit File -> Reload in the window's menu bar.

what's expected is for the window to update with the (working) code.
if the code contains errors, somply show the error in the console and continue.

how could I pull this off??

hmm, not sure how I'd use that to reload...
could I get a quick example >.>

perhaps with this:

class main(QtGui.QMainWindow):
    def __init__(this, parent=None):
        super(main, this).__init__(parent)

        ### Menu ###############################################################################
        # --- init ---
        fileMenu = QtGui.QMenu("&File", this)
        templateMenu = QtGui.QMenu("&New", this)
        scriptMenu = QtGui.QMenu("&Open Script", this)
        editMenu = QtGui.QMenu("&Edit", this)
        helpMenu = QtGui.QMenu("&Help", this)

        # --- display ---
        this.menuBar().addMenu(fileMenu) # [File]
        fileMenu.addMenu(templateMenu) # New
        this.templates = {'Model':0,'Animation':1,'Image':2,'Compression':3,'Archive':4}
        for t in this.templates: # > *template* Script
            tA = QtGui.QAction(this, visible=False, triggered=this.action_newScript)
            tA.setText('%s Script'%t); tA.setData(t); tA.setVisible(True)
            templateMenu.addAction(tA)
        #fileMenu.addSeparator()
        fileMenu.addMenu(scriptMenu) # Open
        for s in [_script for _script in os.listdir('scripts') if _script.endswith('py')]: # > *script*
            sA = QtGui.QAction(this, visible=False, triggered=this.action_openScript)
            sA.setText(s); sA.setData('scripts/%s'%s); sA.setVisible(True)
            scriptMenu.addAction(sA)
        #TODO: libs and mods (later, scripts are the primary focus)
        fileMenu.addAction('&Open Other', this.action_openOther) # Open Other
        fileMenu.addSeparator() # -----
        fileMenu.addAction('&Exit', this.action_exit) # Exit
        fileMenu.addAction('&Reload', this.action_reload) # Reload
        this.menuBar().addMenu(editMenu) # [Edit]
        this.menuBar().addMenu(helpMenu) # [Help]
        helpMenu.addAction("&About", this.action_about) # About
        ########################################################################################

        this.MainSplitter = QtGui.QSplitter()
        this.MainSplitter.setOrientation(QtCore.Qt.Horizontal)

    def action_newScript(this,template): pass
    def action_openScript(this,script): pass
    def action_openOther(this): pass
    def action_exit(this): QtGui.qApp.quit()

    def action_reload(this): reload(main) # error

    def action_about(this): pass

if __name__ == '__main__':
    import sys

    app = QtGui.QApplication(sys.argv)
    window = main()
    window.resize(640, 512)
    window.show()
    sys.exit(app.exec_())

much appreciated :)
replace the reload(main) as that was just some idiocy... lol

cool, I just ported the code from your function into mine and kept it simple :)

it somewhat works as expected :)
should probably test everything for errors before restarting to make it work as fully expected.

I can do that with a try containing an exec on the main file ;)
(and of course an except to cancel the restart process if any errors are found and log it in the console)

thanks for your help grib :)

EDIT:
@grib: man I hope you stick around for as long as possible,
seeing what you do, you're much more help alone than Stack Overflow! =D

Edited 1 Year Ago by Tcll

This question has already been answered. Start a new discussion instead.