469,269 Members | 1,006 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,269 developers. It's quick & easy.

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
ul********@yahoo.com.cn
Jul 18 '05 #1
13 8595
ul********@yahoo.com.cn (ulysses) writes:
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.


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

bye

--
William Dode - http://flibuste.net
Jul 18 '05 #2
ul********@yahoo.com.cn (ulysses) writes:
[...]
Python is a really good programming language. But how to do a
small,smart, efficency GUI in win32,it's a big question.
http://venster.sourceforge.net/

[...] 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.
Well, if you hate win32 also, then you won't like venster.

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.


Interesting idea.
John
Jul 18 '05 #3
Wilk <wi******@OUTflibuste.net> writes:
ul********@yahoo.com.cn (ulysses) writes: [...] An solution is to make a web application and use a tiny browser like
kmeleon.


Or MSIE, possibly using HTA.
John
Jul 18 '05 #4
On Wed, 03 Sep 2003 06:32:42 -0700, ulysses wrote:
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. [snip] 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.


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:
http://wiki.wxpython.org/index.cgi/C_2b_2bExtensions
(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
Jul 18 '05 #5
ulysses wrote:
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.


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.riverbankcomputing.co.uk/pyqt/>.

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

Jul 18 '05 #6
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 bk*****@wi.mit.edu
Whitehead Institute for Biomedical Research 617 258-6191

Jul 18 '05 #7
jj*@pobox.com (John J. Lee) writes:
Wilk <wi******@OUTflibuste.net> writes:
ul********@yahoo.com.cn (ulysses) writes:

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


Or MSIE, possibly using HTA.


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

--
William Dode - http://flibuste.net
Jul 18 '05 #8
| What is HTA ?

Wilk ....

HTA ... HTML Application

http://msdn.microsoft.com/workshop/a...bjects/hta.asp

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

http://fastq.com/~sckitching/HTML/Start_Page.hta

--
Cousin Stanley
Human Being
Phoenix, Arizona
Jul 18 '05 #9
| But you can use Python just as easily.
|
| <script language="Python">
| ...
| </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
Jul 18 '05 #10
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.
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 "cancelthe download"

~~~~~ 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:ou***@211.90.187.42:2111/ourbtsetupen.exe

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

Ulysses
Jul 18 '05 #11
On Wednesday 03 September 2003 07:32 am, ulysses wrote:
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.


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.CreateDialogIndirect for more info).

-Dave

Jul 18 '05 #12
I have put up the source code on my projects page. You can find it at
the bottom of the path here:

http://jura.wi.mit.edu/people/kelley/

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(parent, title, pythonscript)
dlg.Destroy()

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

Jul 18 '05 #13
ul********@yahoo.com.cn (ulysses) wrote in message news:<43**************************@posting.google. com>...
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. :(


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 ?
Jul 18 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

467 posts views Thread by mike420 | last post: by
52 posts views Thread by Neuruss | last post: by
114 posts views Thread by Maurice LING | last post: by
9 posts views Thread by Dieter Vanderelst | last post: by
50 posts views Thread by diffuser78 | last post: by
8 posts views Thread by . | last post: by
4 posts views Thread by wang frank | last post: by
reply views Thread by Kurt Mueller | last post: by
2 posts views Thread by mh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.