How to Starts PythonCE without the shell

xi huang
  • xi huang
    xi huang

    I wroted some script using tkinter.
    What confued me was that the script always starts with the shell.
    Anybody knows how to close the shell?

    These are from the PythonCE Wiki, but it is not clearly stated. I still don't know how to do it.
    PythonCE Command Line Options

    Starts PythonCE without the graphical shell. This is only useful when also passing a script filename on the command line.
    By default, PythonCE only allows one instance to be running at a time. This option allow you to start a multiple instances.


    • Change the file type with .py to .pyw

    • xi huang
      xi huang

      I tried but it just returned the result in shell:
      Traceback (innermost last):
      <NULL>: <NULL>

      • Can you post your source code here?

    • xi huang
      xi huang

      from tkFileDialog   import askopenfilename        # get standard dialogs
      from tkColorChooser import askcolor               # they live in Lib/lib-tk
      from tkMessageBox   import askquestion, showerror, askokcancel
      from tkSimpleDialog import askfloat
      from Tkinter import *              # get base widget set

      demos = {
          'Open':  askopenfilename,
          'Color': askcolor,
          'Query': lambda: askquestion('Warning', 'You typed "rm *"\nConfirm?'),
          'Error': lambda: showerror('Error!', "He's dead, Jim"),
          'Input': lambda: askfloat('Entry', 'Enter credit card number'),

      class Quitter(Frame):                          # subclass our GUI
          def __init__(self, parent=None):             # constructor method
              Frame.__init__(self, parent)
              self.pack( )
              widget = Button(self, text='Quit', command=self.quit)
          def quit(self):
              ans = askokcancel('Verify exit', "Really quit?")
              if ans: Frame.quit(self)

      class Demo(Frame):
          def __init__(self, parent=None):
              Frame.__init__(self, parent)
              self.pack( )
              Label(self, text="Basic demos").pack( )
              for (key, value) in demos.items( ):
                  Button(self, text=key, command=value).pack(side=TOP, fill=BOTH)
              Quitter(self).pack(side=TOP, fill=BOTH)

      if __name__ == '__main__': Demo().mainloop( )

    • xi huang
      xi huang

      PS: I am running the above code on Windows Mobile 6.0.

  • Just rename your script from .py to .pyw!