473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

[twisted+wxPython] widgets do not work?


Hi

Anybody used wxPython with twisted?

I started putting together a Twisted-based app with wx GUI, and the widgets
just don't work - some controls do not show up etc. - at least on my
system.

For example, if I just take the wxdemo.py shipped with Twisted, and add to
it a static text, it doesn't show - while if I change
reactor.registerWxApp(app)
reactor.run(0)
into
app.MainLoop(0)
the text is there. What the heck is wrong with this? Or am I doing something
wrong? Does the same work at yours?

Bartek

--
#!/usr/bin/env python
print 'sygnatura'
Jul 18 '05 #1
2 1786
On Tue, 2004-10-12 at 19:58 +0200, Taki Jeden wrote:
Hi

Anybody used wxPython with twisted?

I started putting together a Twisted-based app with wx GUI, and the widgets
just don't work - some controls do not show up etc. - at least on my
system.

For example, if I just take the wxdemo.py shipped with Twisted, and add to
it a static text, it doesn't show - while if I change
reactor.registerWxApp(app)
reactor.run(0)
into
app.MainLoop(0)
the text is there. What the heck is wrong with this? Or am I doing something
wrong? Does the same work at yours?


The method I use to mix the two is to poll Twisted during wxPython's
idle event:

class SomeTwistedStuff:
def fetch(self, ...):
reactor.startRunning()
# do stuff here, i.e. set up Deferreds, etc

def poll(self):
if reactor.running:
reactor.runUntilCurrent()
reactor.doIteration(0)
return reactor.running

def pending(self):
return reactor.running

class Frame(wx.Frame):
def __init__(self, ...):
...
self.twistedthing = SomeTwistedStuff(...)
self.Bind(wx.EVT_IDLE, self.OnIdle)
self.twistedthing.fetch(...)

def OnIdle(self, event):
if self.twistedthing.poll():
event.RequestMore()
event.Skip()
I yanked this out of a working app, so hopefully I didn't omit anything
important. You'll of course probably want to pass callbacks/errbacks
from your wxPython portion of the app to the Twisted portion so that the
GUI can be synchronized with the Twisted backend.

I've also seen examples of doing the polling using a wx.Timer, but this
does a lot of unnecessary polling if Twisted doesn't have anything
available. Probably not a lot of overhead, but certainly unnecessary
overhead in most cases.

Note that I tried using the wxPython reactor but found that so much time
was spent in Twisted that the GUI became unacceptably slow.

Regards,
Cliff

--
Cliff Wells <cl************@comcast.net>

Jul 18 '05 #2
Cliff Wells wrote:
On Tue, 2004-10-12 at 19:58 +0200, Taki Jeden wrote:
Hi

Anybody used wxPython with twisted?

I started putting together a Twisted-based app with wx GUI, and the
widgets just don't work - some controls do not show up etc. - at least on
my system.
The method I use to mix the two is to poll Twisted during wxPython's
idle event:


Works like a charm! Thanks a lot, Cliff.

Bartek

--
#!/usr/bin/env python
print 'sygnatura'
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: jblazi | last post by:
I am having this problem: I use Python for my teaching and right now we are trying to implement some sort of very simple graphical game the pupils can play across the Internet. For this, we use...
1
by: marchew | last post by:
hi, i have a problem integrating wxPython and Twisted under Win32. my application consumes 40-50% of CPU resources when wxFrame is visible and reactor (twisted) is running. i looked at...
3
by: flupke | last post by:
Hi, previously i made an application that used sockets to do some network based processing. My next app is again going to be a client/server app and i wanted to see if i can't find an easier...
2
by: Daniel Bickett | last post by:
Hello, I am writing an application using two event-driven libraries: wxPython, and twisted. The first problem I encountered in the program is the confliction between the two all-consuming...
12
by: Tom | last post by:
1) Portable to Windows, Unix-like platforms, and the Macintosh; 2) Powerful, GUI is very beautiful ; 3) Efficiency of development is high; What's the best, Tkinter, wxPython, QT, GTK or other? ...
6
by: Zunbeltz Izaola | last post by:
Hi, I have the following problem. I'm developing a GUI program (wxPython). This program has to comunicate (TCP) whit other program that controls a laboratory machine to do a measurement. I...
9
by: perchef | last post by:
Hi, I have several files to download and a GUI to update. I know this is a frequently asked question but i can't find an appropriate solution. My Downloader extends threading.Thread and update a...
1
by: PeterG | last post by:
Hi, I am relatively new to Python, and am learning it as part of a university module... Im currently undertaking a project to create an IM server and IM gui client. I have a very basic...
12
by: bullockbefriending bard | last post by:
I am a complete ignoramus and newbie when it comes to designing and coding networked clients (or servers for that matter). I have a copy of Goerzen (Foundations of Python Network Programming) and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.