How to accelerate python application GUI speed

D

Dave Brueck

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
 
U

ulysses

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
(e-mail address removed)
 
W

Wilk

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
 
J

John J. Lee

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
 
J

John J. Lee

Wilk said:
(e-mail address removed) (ulysses) writes: [...]
An solution is to make a web application and use a tiny browser like
kmeleon.

Or MSIE, possibly using HTA.


John
 
M

Mark Roach

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
 
J

Jim Dabell

ulysses said:
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.
 
B

Brian Kelley

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).
 
W

Wilk

Wilk said:
(e-mail address removed) (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.
 
C

Cousin Stanley

| 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 ....
 
U

ulysses

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.
~~~~~ 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:eek:[email protected]:2111/ourbtsetupen.exe

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

Ulysses
 
B

Brian Kelley

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.
 
L

Lothar Scholz

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 ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top