[pygtk] TypeError when trying to destroy a window

2004-08-23 Thread Bruno Dusausoy
Hi,

I have some lines that cause this error message:

TypeError: descriptor 'destroy' requires a 'gtk.Widget' object but
received a 'NoneType'

The lines incriminated are:

...
self.cancel_button = self.wtree.get_widget ("package_add_cancel_button")
self.cancel_button.connect_object
("clicked", 
gtk.Widget.destroy, self.window)   
 gtk.Widget.destroy,

All i want is to destroy (close) "self.window"

Can somebody tell me what i'm doing wrong ? 
-- 
bdusauso (ASCII 64) beeznest (ASCII 46) net

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] ANNOUNCE: PyScintilla-1.99.4 released

2004-08-23 Thread Roberto Cavada
On Fri, 2004-08-20 at 15:17 -0300, Christian Robottom Reis wrote:
> On Wed, Aug 18, 2004 at 04:05:29PM +0200, Roberto Cavada wrote:
> > What is new
> > ---
> > With respect to previous versions, PyScintilla-1.99.4:
> > - is a stand-alone module, no longer based on GtkScintilla. 
> 
> This is excellent news. Does it implement all the syntax highlighting in
> itself then?
All lexers should be embedded in the scintilla's library. Actually their
are both on my linux box, and on the binary distribution I prepared for
MS Windows. 

Underneath there is a short example of syntax hl + folding.
A screenshot of the running example can be found at:


Most of the code deals with the setting of properties and colours. 
rob


# -- CODE STARTS HERE -- #
import gtk
import scintilla

def set_syntax_hl(sci):
sci.SetLexer(scintilla.SCLEX_PYTHON)

# sets attributes:
sci.SetKeyWords(0, "return for while class def import self " \
"pass try except finally")

fore_cols = ((scintilla.SCE_P_COMMENTLINE, 0xa0),
 (scintilla.SCE_P_TRIPLEDOUBLE, 0xA05080),
 (scintilla.SCE_P_STRING, 0xA000A0),
 (scintilla.SCE_P_CLASSNAME, 0x008cdc),
 (scintilla.SCE_P_DEFNAME, 0x007000),
 (scintilla.SCE_P_WORD, 0xA0))

for fore in fore_cols: sci.StyleSetFore(*fore)

# other settings:
sci.StyleSetSize(scintilla.SCE_P_TRIPLEDOUBLE, 9)
sci.StyleSetBold(scintilla.SCE_P_DEFNAME, 1)
sci.StyleSetBold(scintilla.SCE_P_WORD, 2)
sci.StyleSetUnderline(scintilla.SCE_P_WORD, 1)
sci.StyleSetFont(scintilla.SCE_P_WORD, "!courier")
sci.StyleSetSize(scintilla.SCE_P_WORD, 10)
return


def set_folding(sci):
sci.SetProperty("fold", "1")
sci.SetMarginWidthN(2, 20)
sci.SetMarginMaskN(2, scintilla.SC_MASK_FOLDERS)
sci.SetMarginSensitiveN(2, 1)
sci.SetFoldFlags(16)
sci.SetIndentationGuides(1)
sci.SetTabIndents(1)
sci.SetIndent(3)

mdefs = ((scintilla.SC_MARKNUM_FOLDER, scintilla.SC_MARK_PLUS),
 (scintilla.SC_MARKNUM_FOLDEROPEN, scintilla.SC_MARK_MINUS),
 (scintilla.SC_MARKNUM_FOLDERSUB, scintilla.SC_MARK_EMPTY),
 (scintilla.SC_MARKNUM_FOLDERTAIL, scintilla.SC_MARK_EMPTY),
 (scintilla.SC_MARKNUM_FOLDEREND, scintilla.SC_MARK_EMPTY),
 (scintilla.SC_MARKNUM_FOLDERMIDTAIL, scintilla.
SC_MARK_EMPTY),
 (scintilla.SC_MARKNUM_FOLDEROPENMID, scintilla.
SC_MARK_EMPTY))

for mdef in mdefs: sci.MarkerDefine(*mdef)
return

def margin_click(sci, modifiers, position, margin):
"""Callback from signal MarginClick"""
if margin == 2:
line = sci.LineFromPosition(position)
sci.ToggleFold(line)
pass
return


def main():
w = gtk.Window()
w.set_size_request(200,300)
s = scintilla.Scintilla()
w.add(s)

set_syntax_hl(s)
set_folding(s)

s.connect("MarginClick", margin_click)
w.connect("destroy", gtk.mainquit)

w.show_all()
gtk.mainloop()
return


if __name__ == "__main__": main()
# -- CODE ENDS HERE -- #


___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] threading

2004-08-23 Thread Steve McClure
On Mon, 2004-08-23 at 06:30, Le Boulanger Yann wrote:
> Le Boulanger Yann wrote:
> > Hi all,
> > 
> > I've a probleme with pygtk used in a thread.
> > My application can be presented like that : I have a main thread that do 
> > some things and that can lunch plugins. Plugins are lunched in a new 
> > thread thanks to threading module.
> > one of these plugins is a pygtk plugin :
> > it starts gtk with gtk.gdk.threads_init(), gtk.main(), show windows, etc.
> > Now the probleme is when I want to close this plugin : I close the main 
> > window, then do a gtk.main_quit(), but the windows opened don't close. 
> > GTK is no more active : I cannot do anything in them, but they are 
> > always here ...
> > Is it my Job to close them all before the gtk.main_quit() ?
> > 
> > Asterix
> 
> I come back with the same pb not resolved, but this time I have a little 
> program that shows the problem :
> If you want to try it, lAunch ( ;) ) core.py : it prints "core" every 2 
> seconds and launch a thread that use GTK and open 2 windows. When we 
> close the main one (named Gajim), the other doesn't close :(
> 
> Any help would be greatly appreciated.

Your main program doesn't have any way to exit.  The thread running the
GUI quits properly since it handles the destroy signal, but you need
your main program to occasionally to a thr.join() to see if the thread
has exited, then exit itself. Assuming that is the behavior you want.

Something like this:

thr = GajimThread('gt')
thr.start()
while thr.isAlive()
thr.join(timeout=0.1)
time.sleep(2)
print "core"


> 
> Asterix
> ___
> pygtk mailing list   [EMAIL PROTECTED]
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
-- 
Steve McClure <[EMAIL PROTECTED]>

___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/


Re: [pygtk] threading

2004-08-23 Thread Le Boulanger Yann
Le Boulanger Yann wrote:
Hi all,
I've a probleme with pygtk used in a thread.
My application can be presented like that : I have a main thread that do 
some things and that can lunch plugins. Plugins are lunched in a new 
thread thanks to threading module.
one of these plugins is a pygtk plugin :
it starts gtk with gtk.gdk.threads_init(), gtk.main(), show windows, etc.
Now the probleme is when I want to close this plugin : I close the main 
window, then do a gtk.main_quit(), but the windows opened don't close. 
GTK is no more active : I cannot do anything in them, but they are 
always here ...
Is it my Job to close them all before the gtk.main_quit() ?

Asterix
I come back with the same pb not resolved, but this time I have a little 
program that shows the problem :
If you want to try it, lAunch ( ;) ) core.py : it prints "core" every 2 
seconds and launch a thread that use GTK and open 2 windows. When we 
close the main one (named Gajim), the other doesn't close :(

Any help would be greatly appreciated.
Asterix
#!/usr/bin/env python

import threading, time

class GajimThread(threading.Thread):
	def __init__(self, name = None):
		threading.Thread.__init__(self, target = self.run, name = name)
	# END __init__

	def run(self):
		mod = compile("import %s" % self.getName(), self.getName(), "exec")
		res = eval(mod)
		mod = compile("%s.plugin()" % self.getName(), self.getName(), "exec")
		res = eval(mod)
	# END run

thr = GajimThread('gt')
thr.start()
while 1:
	time.sleep(2)
	print "core"
 
http://glade.gnome.org/glade-2.0.dtd";>




  True
  Gajim
  GTK_WINDOW_TOPLEVEL
  GTK_WIN_POS_NONE
  False
  150
  400
  True
  False
  True
  False
  False
  GDK_WINDOW_TYPE_HINT_NORMAL
  GDK_GRAVITY_NORTH_WEST
  

  

  True
  False
  0

  
	
	  True
	  GTK_SHADOW_OUT
	  GTK_POS_LEFT
	  GTK_POS_TOP

	  
	
	  True

	  
		
		  True
		  _Menu
		  True

		  
		
		  True
		  gtk-convert
		  1
		  0.5
		  0.5
		  0
		  0
		
		  

		  
		

		  
			
			  True
			  _Preferences
			  True
			  

			  
			
			  True
			  gtk-preferences
			  1
			  0.5
			  0.5
			  0
			  0
			
			  
			
		  

		  
			
			  True
			  A_ccounts
			  True
			  

			  
			
			  True
			  gtk-select-color
			  1
			  0.5
			  0.5
			  0
			  0
			
			  
			
		  

		  
			
			  True
			  _Browse agents
			  True
			  

			  
			
			  True
			  gtk-find
			  1
			  0.5
			  0.5
			  0
			  0
			
			  
			
		  

		  
			
			  True
			
		  

		  
			
			  True
			  Add
			  True

			  
			
			  True
			  gtk-add
			  1
			  0.5
			  0.5
			  0
			  0
			
			  
			
		  

		  
			
			  True
			  Show Offline
			  True
			  False
			  
			
		  

		  
			
			  True
			  _Join Groupchat
			  True
			  
			
		  

		  
			
			  True
			
		  

		  
			
			  True
			  _About
			  True
			  

			  
			
			  True
			  gtk-help
			  1
			  0.5
			  0.5
			  0
			  0
			
			  
			
		  

		  
			
			  True
			  _Quit
			  True
			  
			  

			  
			
			  True
			  gtk-quit
			  1
			  0.5
			  0.5
			  0
			  0
			
			  
			
		  
		
		  
		
	  
	
	  
	
	
	  0
	  False
	  True
	
  

  
	
	  2
	  True
	  True
	  GTK_POLICY_AUTOMATIC
	  GTK_POLICY_AUTOMATIC
	  GTK_SHADOW_NONE
	  GTK_CORNER_TOP_LEFT

	  
	
	  True
	  True
	  False
	  False
	  True
	  True
	  
	  
	  
	  
	  
	
	  
	
	
	  0
	  True
	  True
	
  

  
	
	  True
	  True
	  0
	  

	  
	

	  
		
		  True
		  Online
		  True
		
	  

	  
		
		  True
		  Away
		  True
		
	  

	  
		
		  True
		  NA
		  True
		
	  

	  
		
		  True
		  DND
		  True
		
	  

	  
		
		  True
		  Invisible
		  True
		
	  

	  
		
		  True
		
	  

	  
		
		  True
		  Offline
		  True
		
	  
	
	  
	
	
	  0
	  False
	  False
	
  

  



  True
  Chat
  GTK_WINDOW_TOPLEVEL
  GTK_WIN_POS_NONE
  False
  400
  300
  True
  False
  True
  False
  False
  GDK_WINDOW_TYPE_HINT_NORMAL
  GDK_GRAVITY_NORTH_WEST
  

  

  5
  True
  False
  0

  
	
	  5
	  True
	  False
	  5

	  
	
	  True
	  True
	  GTK_RELIEF_NORMAL
	  True
	  

	  
		
		  True
		  0.5
		  0.5
		  0
		  0
		  0
		  0
		  0
		  0

		  
		
		  True
		  False
		  2

		  
			
			  True
			  gtk-justify-fill
			  4
			  0.5
			  0.5
			  0
			  0
			
			
			  0
			  False
			  False
			
		  

		  
			
			  True
			  History
			  True
			  False
			  GTK_JUSTIFY_LEFT
			  False
			  False
			  0.5
			  0.5
			  0
			  0
			
			
			  0
			  False
			  False