Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - My first wxPython App with Twisted - barebones version

 
Thread Tools Search this Thread
Old 08-05-2009, 02:41 AM   #1
Default My first wxPython App with Twisted - barebones version


Hi,
I am creating the first GUI app (wxPython based) using Twisted.
I am facing an issue which I cannot seem to solve/understand due
to lack of trace or anything.
I had a big app written on twisted and now I am creating a login
screen to the app.
The app used to work without any issues. I added the login screen
and the login screen comes up.
But then everything freezes up. I have to force quit the python
application to get anything back. Can anyone help me solve it?
The code is as follows:

import wx
import os
import logging

from twisted.internet import wxreactor
wxreactor.install()
from twisted.internet import reactor #Called only after
wxreactor.install()
from twisted.internet.task import LoopingCall

import clientapp


def opj(path):
""" Convert paths to the platform-specific separator """
st = apply(os.path.join, tuple(path.split('/')))
if path.startswith('/'):
st = '/' + st
return st


class APPApp(wx.App):
def OnInit(self):
self.frame = APPFrame(None, -1, " APP Login", size=(200, 150))
self.panel = APPPanel(self.frame,-1)
client = clientapp.setup_app()
call = LoopingCall(client.run)
call.start(.51)
return True


def main():
app = APPApp(0)
reactor.registerWxApp(app)
try:
reactor.run()
except StandardError:
raise


class APPFrame(wx.Frame):
def __init__(self, parent, id, title, size=None):
wx.Frame.__init__(self, parent, id, title,
size=size, pos=wx.Point(400, 300))
icon = self.get_icon()
self.SetIcon(icon)
self.Show(True)
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
self.Bind(wx.EVT_ICONIZE, self.OnIconify)

def on_login_click(self, username, password):
self.Hide()

def OnCloseWindow(self, event):
event.Skip()

def OnIconify(self, event):
self.Hide()

def get_image(self):
img= wx.Image(opj('client.ico'), wx.BITMAP_TYPE_ICO)
return img

def get_icon(self):
img = self.get_image()
icon = wx.IconFromBitmap(img.ConvertToBitmap() )
return icon


if __name__ == '__main__':
main()


koranthala
  Reply With Quote
Old 08-05-2009, 03:51 AM   #2
koranthala
 
Posts: n/a
Default Re: My first wxPython App with Twisted - barebones version
On Aug 5, 6:41*am, koranthala <koranth...@gmail.com> wrote:
> Hi,
> * *I am creating the first GUI app (wxPython based) using Twisted.
> * *I am facing an issue which I cannot seem to solve/understand due
> to lack of trace or anything.
> * *I had a big app written on twisted and now I am creating a login
> screen to the app.
> * *The app used to work without any issues. I added the login screen
> and the login screen comes up.
> * * But then everything freezes up. I have to force quit the python
> application to get anything back. Can anyone help me solve it?
> * *The code is as follows:
>
> import wx
> import os
> import logging
>
> from twisted.internet import wxreactor
> wxreactor.install()
> from twisted.internet import reactor #Called only after
> wxreactor.install()
> from twisted.internet.task import LoopingCall
>
> import clientapp
>
> def opj(path):
> * * """ Convert paths to the platform-specific separator """
> * * st = apply(os.path.join, tuple(path.split('/')))
> * * if path.startswith('/'):
> * * * * st = '/' + st
> * * return st
>
> class APPApp(wx.App):
> * * def OnInit(self):
> * * * * self.frame = APPFrame(None, -1, " APP Login", size=(200, 150))
> * * * * self.panel = APPPanel(self.frame,-1)
> * * * * client = clientapp.setup_app()
> * * * * call = LoopingCall(client.run)
> * * * * call.start(.51)
> * * * * return True
>
> def main():
> * * app = APPApp(0)
> * * reactor.registerWxApp(app)
> * * try:
> * * * * reactor.run()
> * * except StandardError:
> * * * * raise
>
> class APPFrame(wx.Frame):
> * * def __init__(self, parent, id, title, size=None):
> * * * * wx.Frame.__init__(self, parent, id, title,
> * * * * * * * * * * * * * size=size, pos=wx..Point(400, 300))
> * * * * icon = self.get_icon()
> * * * * self.SetIcon(icon)
> * * * * self.Show(True)
> * * * * self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
> * * * * self.Bind(wx.EVT_ICONIZE, self.OnIconify)
>
> * * def on_login_click(self, username, password):
> * * * * self.Hide()
>
> * * def OnCloseWindow(self, event):
> * * * * event.Skip()
>
> * * def OnIconify(self, event):
> * * * * self.Hide()
>
> * * def get_image(self):
> * * * * img= wx.Image(opj('client.ico'), wx.BITMAP_TYPE_ICO)
> * * * * return img
>
> * * def get_icon(self):
> * * * * img = self.get_image()
> * * * * icon = wx.IconFromBitmap(img.ConvertToBitmap() )
> * * * * return icon
>
> if __name__ == '__main__':
> * * main()


Sorry for spamming this group.
I found that this was due to a interaction with pyHook and the
wxPython GUI.
I havent solved it, but atleast it is not due to twisted and wxPython.


koranthala
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Specials on Nov with irresistible gift! Find yours and take advantageof Christmas around the corner yafei617@sina.com DVD Video 0 11-28-2007 04:09 PM
Specials on Nov with irresistible gift! Find yours and take advantageof Christmas around the corner aa DVD Video 0 11-27-2007 02:18 PM
ALL NEW TV SHOW MOVIE DVD BOXSETS ONSALE candemo2006@gmail.com DVD Video 1 08-31-2007 04:05 AM
ALL NEW TV SHOW MOVIE DVD BOXSETS ONSALE candemo2006@gmail.com DVD Video 1 08-22-2007 07:05 PM
DUNE Extended edition - is it the same cut that aired on Sci Fi? Joseph S. Powell, III DVD Video 13 01-30-2006 02:47 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46