473,386 Members | 1,720 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.

New to Python, WxPython etc, etc

I am totally new to Python and WxPython and need to write an
application which can open up an external windows from a plug-in within
GAIM (using pyGAIM). I have managed to hack some code together from
what little I have covered so far, however GAIM refuses to open until I
have closed the extra window. I appreciate this is probably a simple
point but I would be grateful for any advice people can offer on how I
can make them both appear so that people can interact with either GAIM
and/or the contents of the window. I am using Python 2.3.5, and GAIM 2
(beta).

I have attached the hacked code below which is based on a merging some
samples from WxPython and pyGaim. I have tried moving the bit below to
within def plug_in load but to no avail.

"app = MyApp(0)
app.MainLoop()"

Thanks in advance,

Rod
----

import _gaim
import wx

from wxPython.wx import *

ID_ABOUT = 101
ID_EXIT = 102

class MyFrame(wxFrame):
def __init__(self, parent, ID, title):
wxFrame.__init__(self, parent, ID, title,
wxDefaultPosition, wxSize(200, 150))

self.CreateStatusBar()
self.SetStatusText("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ABOUT, "&About",
"More information about this program")
menu.AppendSeparator()
menu.Append(ID_EXIT, "E&xit", "Terminate the program")
menuBar = wxMenuBar()
menuBar.Append(menu, "&File");
self.SetMenuBar(menuBar)

EVT_MENU(self, ID_ABOUT, self.OnAbout)
EVT_MENU(self, ID_EXIT, self.TimeToQuit)

def OnAbout(self, event):
dlg = wxMessageDialog(self, "This sample program shows off\n"
"frames, menus, statusbars, and this\n"
"message dialog.",
"About Me", wxOK | wxICON_INFORMATION)
dlg.ShowModal()
dlg.Destroy()
def TimeToQuit(self, event):
self.Close(true)

class MyApp(wxApp):
def OnInit(self):
frame = MyFrame(NULL, -1, "Hello from wxPython")
frame.Show(true)
self.SetTopWindow(frame)
return true
PLUGIN_INFO = {
'python_api_version' : 2,
'name' : "A Simple Test Plug-in",
'version' : "0.3",
'summary' : "This simply does nothing",
'description' : "Cheese",
'author' : "Si***@silly.com",
'url' : "http://www.xxx.com/",
'load' : "plugin_load",
'unload' : "plugin_unload"
}
def timeout0(anObject):
print 'py:timeout0',anObject
return False

def timeout1(anObject):
print 'py:timeout1',anObject
## return True
return False

def signed_on_cb1(data,account,conv,msgText):
print 'p2:signed_on_cb1'
print 'Data',data
print 'account',account
print 'conversation',conv
print 'msgText',msgText
print 'account.gc',account.gc

blist = gaim.gaim_get_blist()
print blist.root

print conv.name,conv.title,conv.history

buddy = gaim.gaim_find_buddy(account,conv.name)
print buddy,buddy.name,buddy.alias

group = gaim.gaim_find_buddys_group(buddy)
print group,group.name,group.totalsize

return {'r':True,'a3':'this is my text:'+msgText}

def menu_item_activate_cb(node,data):
pass

def blist_node_extended_menu_cb(data,node,menu):
print 'node',node
print 'menu',menu

## if (!GAIM_BLIST_NODE_IS_BUDDY(node))
## return;

## buddy = (GaimBuddy *)node;
## act = gaim.gaim_blist_node_action_new("Send message",
## menu_item_activate_cb,None)
## print act
## *menu = g_list_append(*menu,act);

def plugin_load(plugin):

print 'py:plugin_load'
accs = gaim.gaim_accounts_get_all()
print accs
for account in accs:
print account
if account:
print account.username,account.alias
print 'New:',gaim._GaimAccount()
gaim.gaim_python_timeout_add(plugin,2000,timeout0, "this is timeout
0")
gaim.gaim_python_timeout_add(plugin,1000,timeout1, "this is timeout
1")

handle = gaim.gaim_conversations_get_handle()
gaim.gaim_python_signal_connect(plugin,handle,"wri ting-im-msg",
signed_on_cb1,"abc")
gaim.gaim_python_signal_connect(plugin,gaim.gaim_b list_get_handle(),
"blist-node-extended-menu",
blist_node_extended_menu_cb,None);
print 'py:after plugin load'

def plugin_unload(plugin):
print 'py:plugin_unload'

app = MyApp(0)
app.MainLoop()

Jan 3 '06 #1
2 1692
rodmc wrote:
I am totally new to Python and WxPython and need to write an
application which can open up an external windows from a plug-in within
GAIM (using pyGAIM).

<snip>

"app = MyApp(0)
app.MainLoop()"


You're trying to merge to event loops. GAIM uses the GTK2+ based loop,
whereas WxPython uses its own event loop. As you're starting the WxPython
main loop to service your program, no GUI events (such as displaying a
window) can get processed for GAIM. This is exactly what you're seeing.

I don't know how to patch into GAIM's event loop, but you should look for
some place where integration of pygtk and pygaim is discussed. wxPython
won't get you very far here.

--- Heiko.
Jan 3 '06 #2
"rodmc" <ro***@userpro.com> wrote in news:1136299565.613252.202670
@g44g2000cwa.googlegroups.com:

import _gaim
import wx

from wxPython.wx import *

ID_ABOUT = 101
ID_EXIT = 102

class MyFrame(wxFrame):
def __init__(self, parent, ID, title):


I don't have an answer to your question, but as an aside, you should
think about using the wx namespace if you move forward with wxPython.
Basically, you would just eliminate 'from wxPython.wx import *' as you
are already importing wx. Then, instead of referring to wxFrame, you
would refer to wx.Frame.

See:
http://www.wxpython.org/MigrationGui...e-wx-namespace

for more information about this.

Max

Jan 3 '06 #3

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

Similar topics

37
by: Ubaidullah Nubar | last post by:
Hi, How well is Python suited for developing database based applications? I am new to Python so please bear with me if some of the questions are too simple. I specifically have the following...
4
by: Logan | last post by:
Several people asked me for the following HOWTO, so I decided to post it here (though it is still very 'alpha' and might contain many (?) mistakes; didn't test what I wrote, but wrote it - more or...
3
by: Equis Uno | last post by:
Hi, I'm trying to run some Python software I downloaded off of sf.net. It's called Boa. It uses wxPython. It appears my install of Python cannot see my install of wxPython.
8
by: flupke | last post by:
Hi, i'm trying to get boa constructor working with Python 2.3.4 At first i tried with boa 0.2.3 but that gave me an error. After searching the web, it appeared that it's best to work with the...
3
by: Kenneth McDonald | last post by:
If this is not an appropriate newsgroup for this type of posting, please let me know and (if possible) suggest an alternative. I've done a fair bit of research on the net, but information is...
4
by: Sathyaish | last post by:
My question will sound daft to the good old craftsmen, but they will excuse my nescience on the subject. I come new to the Pythonic world from the land of .NET languages, VB6 and some familiarity...
22
by: Glurt Wuntal | last post by:
I am a newbie with Python. It's a great language, but I would like to be able to present a simple gui menu for some of my scripts; something better than using 'raw_input' prompts. Any...
13
by: filippo | last post by:
Hello, I coded my +10k lines app using Perl/Tk. It is something like a hotel software manager, it has a bunch of windows to manage the arrivals, bills etc etc. I want to port this on...
4
by: 7stud | last post by:
Hi, I'm using an intel imac which came with python 2.3.5 pre-intstalled on OS 10.4.7. I was able run a hello world wxPython script in Terminal by typing: $pythonw wxPythonTest.py ...
20
by: Thorsten Kampe | last post by:
Hi, I've already sent this to the Komodo mailing list (which seemed to me the more appropriate place) but unfortunately I got no response. I'd like to build a Python GUI app. Neither Tkinter...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.