How to accelerate python application GUI speed

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ulysses

    How to accelerate python application GUI speed

    Hi,all

    I use wxPython make a bittorrent client. I find wxPython very slow and
    use many many memory.
    When app start, it need 19MB memory. I only use common GUI components.
    Python is a really good
    programming language. But how to do a small,smart, efficency GUI in
    win32,it's a big question.

    I need make GUI,core code is bittorrent code. I can't change it.it's
    really good code.

    I read book 'Python Programming on Win32' ,I get following idea. I
    test it.

    1. Use wxpython ,it's successful,but very slow .

    2. use python for delphi. I test it, but it need embed python code to
    delphi. So need
    change original code.Actually I don't know how to change .it's big
    project.

    3. User win32com, make a com server by delphi. com server have form.
    make python code
    as com client. I make a com server and invoke the server by
    pythonwin. but the form
    can't show. :( anyone do it ,could you share you code to world.

    4. use pythonwin. mfc or win32gui framework. I check the demo code,
    it's very complex.
    you know I hate MFC. it's a joke. i like VCL so much.

    5. I have a another idea. use wxWindows (c lan) build a GUI. embed
    python code .
    or embed wxWindows code to python by SWIG. I have't test it. if you
    have do it.
    Please tell us.

    Thanks.

    Ulysses
    ulysses_dm@yaho o.com.cn
  • Wilk

    #2
    Re: How to accelerate python application GUI speed

    ulysses_dm@yaho o.com.cn (ulysses) writes:
    [color=blue]
    > Hi,all
    >
    > I use wxPython make a bittorrent client. I find wxPython very slow and
    > use many many memory.
    > When app start, it need 19MB memory. I only use common GUI components.
    > Python is a really good
    > programming language. But how to do a small,smart, efficency GUI in
    > win32,it's a big question.[/color]

    An solution is to make a web application and use a tiny browser like
    kmeleon.

    bye

    --
    William Dode - http://flibuste.net

    Comment

    • John J. Lee

      #3
      Re: How to accelerate python application GUI speed

      ulysses_dm@yaho o.com.cn (ulysses) writes:
      [...][color=blue]
      > Python is a really good programming language. But how to do a
      > small,smart, efficency GUI in win32,it's a big question.[/color]



      [...][color=blue]
      > 4. use pythonwin. mfc or win32gui framework. I check the demo code,
      > it's very complex. you know I hate MFC. it's a joke. i like VCL so
      > much.[/color]

      Well, if you hate win32 also, then you won't like venster.

      [color=blue]
      > 5. I have a another idea. use wxWindows (c lan) build a GUI. embed
      > python code . or embed wxWindows code to python by SWIG. I have't
      > test it. if you have do it. Please tell us.[/color]

      Interesting idea.


      John

      Comment

      • John J. Lee

        #4
        Re: How to accelerate python application GUI speed

        Wilk <wilkSPAM@OUTfl ibuste.net> writes:
        [color=blue]
        > ulysses_dm@yaho o.com.cn (ulysses) writes:[/color]
        [...][color=blue]
        > An solution is to make a web application and use a tiny browser like
        > kmeleon.[/color]

        Or MSIE, possibly using HTA.


        John

        Comment

        • Mark Roach

          #5
          Re: How to accelerate python application GUI speed

          On Wed, 03 Sep 2003 06:32:42 -0700, ulysses wrote:
          [color=blue]
          > Hi,all
          >
          > I use wxPython make a bittorrent client. I find wxPython very slow and
          > use many many memory.
          > When app start, it need 19MB memory. I only use common GUI components.
          > Python is a really good
          > programming language. But how to do a small,smart, efficency GUI in
          > win32,it's a big question.[/color]
          [snip][color=blue]
          > 5. I have a another idea. use wxWindows (c lan) build a GUI. embed
          > python code .
          > or embed wxWindows code to python by SWIG. I have't test it. if you
          > have do it.
          > Please tell us.[/color]

          Swig is how wxPython works already. If you wanted to do the whole gui in
          C++, and just have python launch the code, you can do an extension pretty
          easily, see my wiki entry here:

          (I'm not sure that this will make any difference wrt memory usage though.)


          I think that letting C++ "drive" your code will be a significantly greater
          time investment, I'm not sure how much of an effort it is to get the
          python mainloop and the wxWin mainloop to work together, but since it is
          already done for me with wxPython, I don't think I'll go trying to find
          out either :-)

          -Mark

          Comment

          • Jim Dabell

            #6
            Re: How to accelerate python application GUI speed

            ulysses wrote:
            [color=blue]
            > I use wxPython make a bittorrent client. I find wxPython very slow and
            > use many many memory.
            > When app start, it need 19MB memory. I only use common GUI components.
            > Python is a really good programming language. But how to do a small,smart,
            > efficency GUI in win32,it's a big question.[/color]

            In my opinion, the Qt toolkit is far better in terms of quality and speed
            than wx/tk/whatever. It's also dead simple to code for. The Python
            bindings are here: <URL:http://www.riverbankco mputing.co.uk/pyqt/>.

            Check out the license first, some people don't like any of the choices
            available.


            --
            Jim Dabell

            Comment

            • Brian Kelley

              #7
              Re: How to accelerate python application GUI speed

              You will always take a hit using threading and a gui. I agree with your
              complaints about wxPython's size though. I'm not quite sure what you
              mean by wxPython is "slow" though. Do you mean that running your code
              inside wxPython is slow?

              Qualitatively, when using wxPython and QT I've encountered about a 30%
              speed hit when using threads.

              I'll assume that your bit-torrent code has a pretty simple interface,
              such as "download this file to here", "I'm X percent done" and "cancel
              the download"

              If this is the case, you might be interested in using wxProcess to spawn
              a new python process and then monitor the new processes stdout to update
              a progress bar or a dialog box.

              The benefits are as follows:
              1) Easy to kill a process.
              2) The process doesn't get blocked by the GIL and can run with (just
              about) full CPU power.

              Downsides:
              1) python needs to be in your path and the python path has to be
              set up correctly to load your code.
              2) wxProcess doesn't work on OS X yet.

              My code is pretty ugly, but I am using it in a production environment.
              Let me know if you want me to post it here (it comes with an example).

              --
              Brian Kelley bkelley@wi.mit. edu
              Whitehead Institute for Biomedical Research 617 258-6191

              Comment

              • Wilk

                #8
                Re: How to accelerate python application GUI speed

                jjl@pobox.com (John J. Lee) writes:
                [color=blue]
                > Wilk <wilkSPAM@OUTfl ibuste.net> writes:
                >[color=green]
                >> ulysses_dm@yaho o.com.cn (ulysses) writes:[/color]
                > [...][color=green]
                >> An solution is to make a web application and use a tiny browser like
                >> kmeleon.[/color]
                >
                > Or MSIE, possibly using HTA.[/color]

                What is HTA ? I thought about an HTTPServer that could work with any
                browser.

                --
                William Dode - http://flibuste.net

                Comment

                • Cousin Stanley

                  #9
                  Re: How to accelerate python application GUI speed

                  | What is HTA ?

                  Wilk ....

                  HTA ... HTML Application

                  Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


                  Example containing a bit of VBScript
                  to access some common applications
                  under Windows ...



                  --
                  Cousin Stanley
                  Human Being
                  Phoenix, Arizona


                  Comment

                  • Cousin Stanley

                    #10
                    Re: How to accelerate python application GUI speed

                    | But you can use Python just as easily.
                    |
                    | <script language="Pytho n">
                    | ...
                    | </script>

                    John ....

                    I did that example HTA using VBScript about 3 years ago
                    before I even knew that Python existed and just posted it
                    as a handy example to illustrate basically what a local
                    HTA could do ....

                    It would be WAY cooler to do it in Python,
                    and now that I know it's possible I'll try it ....

                    --
                    Cousin Stanley
                    Human Being
                    Phoenix, Arizona


                    Comment

                    • ulysses

                      #11
                      Re: How to accelerate python application GUI speed

                      Thanks to all.

                      To:John J.Lee
                      I download 'venster' and test a small samples. I think it's good idea
                      for python GUI.
                      I has use MFC, but I don't like MFC framework. but I like VENSTER's
                      way. I only need
                      make GUI by VC. and write code in python . that code very clear and
                      obvious. I'll test
                      for complete project. anyone has make project to do it? thank you.

                      To: Mark Roach

                      I has read this article. It's same as my idea. But the code sample is
                      make a foo button
                      in wxWindows ,use swig link to wxpython. I don't know if I make a frame
                      in wxWindows.
                      Can I use it in wxPython. Who test it? thank you.

                      To:Jim Dabell

                      I download pyQt ,But I hasn't test it. QT is C++ GUI framework. It's
                      very cool too.

                      To:Brian Kelley

                      sorry about my poor english.
                      I say 'slow'. It's mean wxPython application start up very slow and use
                      big memory.
                      core python code very quick. I use thread. Because Bit-torrent is a P2P
                      program.
                      it's have many intercurrent internet connection for download and
                      upload.
                      [color=blue][color=green]
                      >>I'll assume that your bit-torrent code has a pretty simple interface,
                      >>such as "download this file to here", "I'm X percent done" and[/color][/color]
                      "cancel[color=blue][color=green]
                      >>the download"[/color][/color]
                      ~~~~~ you are right. I only need get these information from bit-torrent
                      ..
                      It's use a function to communicate with GUI and core program.

                      If you should post you code . I very thank you. I like study with you.
                      thank you.

                      To:Harobed
                      I didn't test pyGTK. thank you.
                      You know I very care speed and use in WIN32,I hear GTK very slow.

                      my BitTorrent client (ourbt) download address

                      ftp://ourbt:ourbt@211.90.187.42:2111/ourbtsetupen.exe

                      After you use it,you will know what i need. :)

                      Ulysses

                      Comment

                      • Dave Brueck

                        #12
                        Re: How to accelerate python application GUI speed

                        On Wednesday 03 September 2003 07:32 am, ulysses wrote:[color=blue]
                        > Hi,all
                        >
                        > I use wxPython make a bittorrent client. I find wxPython very slow and
                        > use many many memory.
                        > When app start, it need 19MB memory. I only use common GUI components.
                        > Python is a really good
                        > programming language. But how to do a small,smart, efficency GUI in
                        > win32,it's a big question.[/color]

                        Another option is to use Venster, which is based on ctypes. It'll have a
                        pretty small memory and disk footprint (relatively speaking). It's not as
                        mature or high-level as wx though, but if you're more or less familiar with
                        Win32 GUI programming it's pretty straightforward .

                        If the GUI is pretty simple (a few dialog boxes) then you could just build the
                        dialogs in something like Visual Studio and store them in a resource DLL, and
                        then use Win32 calls to display them. You could also build the dialogs on the
                        fly using Win32 calls (ctypes or win32all, although win32all has some nice
                        helper routines - look at win32ui.CreateD ialogIndirect for more info).

                        -Dave

                        Comment

                        • Brian Kelley

                          #13
                          Re: How to accelerate python application GUI speed

                          I have put up the source code on my projects page. You can find it at
                          the bottom of the path here:



                          Here is a bit of the description:

                          Are you annoyed that using python threads slows down your progam by
                          about 30% because of the GIL (Global Interpreter Lock)?

                          The code described here give you another option! You can run and
                          monitor a python script running in a seperate process. This is very
                          coarse grained threading but the spawned process can run at (just about)
                          full speed. You can also kill the process as well.

                          The process can also send rudimentary data back to the monitoring
                          application. This includes raw python datatypes and pickled items can
                          be transferred back to the monitoring application.

                          The usage is fairly simple:
                          pythonscript a python script in a text string.

                          dlg = ProcessDlg(pare nt, title, pythonscript)
                          dlg.Destroy()

                          Warning, the code hasn't been tested under linux/unix.
                          Enjoy.

                          Comment

                          • Lothar Scholz

                            #14
                            Re: How to accelerate python application GUI speed

                            ulysses_dm@yaho o.com.cn (ulysses) wrote in message news:<43e3984e. 0309130401.5543 9c14@posting.go ogle.com>...[color=blue]
                            > Finally. I use PyQt build my new GUI. PyQt is good framework.
                            > But It isn't free. Anybody give QT education version. I can't
                            > download it from trolltech. QT non commercial version have some
                            > restriction. I build freeware why I can only get the limit non
                            > commercial version. :([/color]

                            This is not supported. If you don't work for an university forget about QT.
                            Pay or use something else - so is life. Why should they give away there
                            work for free, just because you want to do the same ?

                            Comment

                            Working...