How to execute a python script from another python script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • somialis
    New Member
    • Mar 2007
    • 32

    #16
    Originally posted by bartonc
    I've added CODE tags to your post. Please read "REPLY GUIDELINES" to learn how to do this.

    So how is the class MyApp defined?

    Class MyaApp is as follows:

    Code:
    class MyApp(wx.App):
        # wxWindows calls this method to initialize the application
        def OnInit(self, operator=None):
            
            # Create an instance of our customized Frame class
            frame = MyFrame(None, -1, "PetShopTest")
            frame.Show(1)
            # and let wxWindows know that is our main window...
            self.SetTopWindow(frame)
            
            # we need to return a success flag (to keep wxWindows happy)...
            return 1

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #17
      Originally posted by somialis
      Class MyaApp is as follows:

      Code:
      class MyApp(wx.App):
          # wxWindows calls this method to initialize the application
          def OnInit(self, operator=None):
              
              # Create an instance of our customized Frame class
              frame = MyFrame(None, -1, "PetShopTest")
              frame.Show(1)
              # and let wxWindows know that is our main window...
              self.SetTopWindow(frame)
              
              # we need to return a success flag (to keep wxWindows happy)...
              return 1
      Awesome! Your GUI Toolkit is wxPython. It's the best in my opinion.
      Since this should work, there can be only one reson why it doesn't:
      Python doesn't know how to find your program (you've been calling it "filename.p y). You probably need to specify the entire path in the command. Use raw strings for path names on windows:
      Code:
      r"D:\Python24\Lib\filename.py"
      Or you can add the path to the environment variable called PYTHONPATH in the operating system. Or you can put path into a file with any name (say) testpath.pth into the D:\Python24\Lib \site-packages (on my system) directory. The .pth extention tells python to add whaterver is in that file to sys.path.

      Comment

      • sandeepyadav147
        New Member
        • Nov 2019
        • 1

        #18
        bro use 'py' in cmd instead of 'python'.if it works or you may need to setup path.
        its just an assumption. :))

        Comment

        Working...