How to hide python cmd "black" window (wxpython)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • luke14free
    New Member
    • Apr 2007
    • 79

    How to hide python cmd "black" window (wxpython)

    Hello guys,
    I've been searching for a method to hide the console (as c/c++ user would say) under windows, but i found nothing really helpful.
    What I found is:
    1) I need to rename file as pyw. But when I do so, code just doesn't give any output or open windows, it just close itself...
    2) I need to create a "python" service...But how?
    Is there another simpler method to tell python that my main window is the frame and not the console? I'm working with boa, and my app code is that:
    Code:
    import wx
    
    import fatturefr1
    
    modules ={'fatturefr1': [1, 'Main frame of Application', 'fatturefr1.py']}
    
    class BoaApp(wx.App):
        def OnInit(self):
            self.main = fatturefr1.create(None)
            self.main.Show()
            self.SetTopWindow(self.main)
            return True
    
    def main():
        application = BoaApp(0)
        application.MainLoop()
    
    if __name__ == '__main__':
        main()
    Thanks and greetings,
    Luke
  • KaezarRex
    New Member
    • Sep 2007
    • 52

    #2
    The only way that I've been able to hide the console window was to use PyInstaller to convert my python script into an executable. It has an option to keep the console from opening when you run the program (and many other options, like packing everything into a single file). This is probably not the kind of solution you are looking for, but maybe you can use it as a last resort if it's necessary that there's no console window.

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Originally posted by luke14free
      Hello guys,
      I've been searching for a method to hide the console (as c/c++ user would say) under windows, but i found nothing really helpful.
      What I found is:
      1) I need to rename file as pyw. But when I do so, code just doesn't give any output or open windows, it just close itself...
      2) I need to create a "python" service...But how?
      Is there another simpler method to tell python that my main window is the frame and not the console? I'm working with boa, and my app code is that:
      Code:
      import wx
      
      import fatturefr1
      
      modules ={'fatturefr1': [1, 'Main frame of Application', 'fatturefr1.py']}
      
      class BoaApp(wx.App):
          def OnInit(self):
              self.main = fatturefr1.create(None)
              self.main.Show()
              self.SetTopWindow(self.main)
              return True
      
      def main():
          application = BoaApp(0)
          application.MainLoop()
      
      if __name__ == '__main__':
          main()
      Thanks and greetings,
      Luke
      1. I use the .pyw (python - no console window) trick all the time.
      2. I don't know where you get that "create a python process" from.
      3. Boa Constructor will consume the output intended for the output. Make sure that you have split the editor window to show (Traceback) (Output), etc. tabs.
      4. Play with [CODE=python]application = BoaApp(redirect =False) # True[/CODE]while using .pyw. Due to #3, do this from the command-line.
      ??? This is windows, right ???
      Last edited by bartonc; Oct 25 '07, 08:01 PM.

      Comment

      Working...