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,
wxDefaultPositi on, wxSize(200, 150))
self.CreateStat usBar()
self.SetStatusT ext("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ ABOUT, "&About",
"More information about this program")
menu.AppendSepa rator()
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_INFORMAT ION)
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.SetTopWind ow(frame)
return true
PLUGIN_INFO = {
'python_api_ver sion' : 2,
'name' : "A Simple Test Plug-in",
'version' : "0.3",
'summary' : "This simply does nothing",
'description' : "Cheese",
'author' : "Silly@silly.co m",
'url' : "http://www.xxx.com/",
'load' : "plugin_loa d",
'unload' : "plugin_unl oad"
}
def timeout0(anObje ct):
print 'py:timeout0',a nObject
return False
def timeout1(anObje ct):
print 'py:timeout1',a nObject
## return True
return False
def signed_on_cb1(d ata,account,con v,msgText):
print 'p2:signed_on_c b1'
print 'Data',data
print 'account',accou nt
print 'conversation', conv
print 'msgText',msgTe xt
print 'account.gc',ac count.gc
blist = gaim.gaim_get_b list()
print blist.root
print conv.name,conv. title,conv.hist ory
buddy = gaim.gaim_find_ buddy(account,c onv.name)
print buddy,buddy.nam e,buddy.alias
group = gaim.gaim_find_ buddys_group(bu ddy)
print group,group.nam e,group.totalsi ze
return {'r':True,'a3': 'this is my text:'+msgText}
def menu_item_activ ate_cb(node,dat a):
pass
def blist_node_exte nded_menu_cb(da ta,node,menu):
print 'node',node
print 'menu',menu
## if (!GAIM_BLIST_NO DE_IS_BUDDY(nod e))
## return;
## buddy = (GaimBuddy *)node;
## act = gaim.gaim_blist _node_action_ne w("Send message",
## menu_item_activ ate_cb,None)
## print act
## *menu = g_list_append(* menu,act);
def plugin_load(plu gin):
print 'py:plugin_load '
accs = gaim.gaim_accou nts_get_all()
print accs
for account in accs:
print account
if account:
print account.usernam e,account.alias
print 'New:',gaim._Ga imAccount()
gaim.gaim_pytho n_timeout_add(p lugin,2000,time out0,"this is timeout
0")
gaim.gaim_pytho n_timeout_add(p lugin,1000,time out1,"this is timeout
1")
handle = gaim.gaim_conve rsations_get_ha ndle()
gaim.gaim_pytho n_signal_connec t(plugin,handle ,"writing-im-msg",
signed_on_cb1," abc")
gaim.gaim_pytho n_signal_connec t(plugin,gaim.g aim_blist_get_h andle(),
"blist-node-extended-menu",
blist_node_exte nded_menu_cb,No ne);
print 'py:after plugin load'
def plugin_unload(p lugin):
print 'py:plugin_unlo ad'
app = MyApp(0)
app.MainLoop()
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,
wxDefaultPositi on, wxSize(200, 150))
self.CreateStat usBar()
self.SetStatusT ext("This is the statusbar")
menu = wxMenu()
menu.Append(ID_ ABOUT, "&About",
"More information about this program")
menu.AppendSepa rator()
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_INFORMAT ION)
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.SetTopWind ow(frame)
return true
PLUGIN_INFO = {
'python_api_ver sion' : 2,
'name' : "A Simple Test Plug-in",
'version' : "0.3",
'summary' : "This simply does nothing",
'description' : "Cheese",
'author' : "Silly@silly.co m",
'url' : "http://www.xxx.com/",
'load' : "plugin_loa d",
'unload' : "plugin_unl oad"
}
def timeout0(anObje ct):
print 'py:timeout0',a nObject
return False
def timeout1(anObje ct):
print 'py:timeout1',a nObject
## return True
return False
def signed_on_cb1(d ata,account,con v,msgText):
print 'p2:signed_on_c b1'
print 'Data',data
print 'account',accou nt
print 'conversation', conv
print 'msgText',msgTe xt
print 'account.gc',ac count.gc
blist = gaim.gaim_get_b list()
print blist.root
print conv.name,conv. title,conv.hist ory
buddy = gaim.gaim_find_ buddy(account,c onv.name)
print buddy,buddy.nam e,buddy.alias
group = gaim.gaim_find_ buddys_group(bu ddy)
print group,group.nam e,group.totalsi ze
return {'r':True,'a3': 'this is my text:'+msgText}
def menu_item_activ ate_cb(node,dat a):
pass
def blist_node_exte nded_menu_cb(da ta,node,menu):
print 'node',node
print 'menu',menu
## if (!GAIM_BLIST_NO DE_IS_BUDDY(nod e))
## return;
## buddy = (GaimBuddy *)node;
## act = gaim.gaim_blist _node_action_ne w("Send message",
## menu_item_activ ate_cb,None)
## print act
## *menu = g_list_append(* menu,act);
def plugin_load(plu gin):
print 'py:plugin_load '
accs = gaim.gaim_accou nts_get_all()
print accs
for account in accs:
print account
if account:
print account.usernam e,account.alias
print 'New:',gaim._Ga imAccount()
gaim.gaim_pytho n_timeout_add(p lugin,2000,time out0,"this is timeout
0")
gaim.gaim_pytho n_timeout_add(p lugin,1000,time out1,"this is timeout
1")
handle = gaim.gaim_conve rsations_get_ha ndle()
gaim.gaim_pytho n_signal_connec t(plugin,handle ,"writing-im-msg",
signed_on_cb1," abc")
gaim.gaim_pytho n_signal_connec t(plugin,gaim.g aim_blist_get_h andle(),
"blist-node-extended-menu",
blist_node_exte nded_menu_cb,No ne);
print 'py:after plugin load'
def plugin_unload(p lugin):
print 'py:plugin_unlo ad'
app = MyApp(0)
app.MainLoop()
Comment