Re: [pygtk] How to draw in a DrawingArea?

2003-02-21 Thread Andreas Kostyrka
Am Freitag, 21. Februar 2003 01:17 schrieb Dan Christian:
 This seems like an obvious question, but I've found the answer quite
 elusive.

 How do you draw in a DrawingArea with PyGtk2?
Bind to the expose-event, and then use
gtk.gdk.*

Andreas
-- 
Andreas Kostyrka
Josef-Mayer-Strasse 5
83043 Bad Aibling
___
pygtk mailing list   [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/



[pygtk] PyScintilla wrapper [WAS: Porting of wrapper from pygtk1 to pygtk2]

2003-02-21 Thread Roberto Cavada
Roberto Cavada wrote:
   I am currently trying to port the python wrapper for a gtk
   widget (gtkscintilla2).

I got it!
As soon as I get the time to provide some missing code, as well as 
configuration/building stuff, I'll release PyScintilla-1.99.0.
rob

--
(What follows a report that might be useful in the future for other 
users. Also, contains suggestion about possible improvement of codegen).

Generated code imports from gtk the widget base class, for Scintilla 
the gtk.Frame type:

_PyGtkFrame_Type = (PyTypeObject *)PyDict_GetItemString(moddict,
  Frame);

Where 'moddict' is of course the gtk module.
Notice that this function does not raise an exception if the given key 
is not found in the dictionary. In this case returned value is simply 
NULL.

* My claim here is that codegen should generate code to check the 
returned value, and if this is NULL, to raise an exception. *


Returned value is used when registering the widget class, as base type:

pygobject_register_class(d, GtkScintilla, GTK_TYPE_SCINTILLA,
  PyGtkScintilla_Type, Py_BuildValue((O), PyGtkFrame_Type));


Again, notice that Py_BuildValue assumes that if the given object is 
NULL, an error occurred before it is called, so the corresponding 
exception has been already handled.
Python documentation states that in this case it returns NULL, without 
raising an exception. Moreover, if there are not previously set 
exceptions, it sets PyExc_SystemError.


IN CONCLUSION:
If - as happened in my case - someone specifies a wrong name for the 
base class type in the override file, the resulting (wrong) behaviour 
can be really hard to understand.

To complete the report, this was the wrong line in the 
scintilla.override file:
  import gtk.GtkFrame as PyGtkFrame_Type

The fixed version is obviously:
  import gtk.Frame as PyGtkFrame_Type


rob

--
--
Roberto Cavada
ITC-irst Institute for Scientific and Technological Research
Automated Reasoning Systems - Formal Methods Group
Via Sommarive, 18 - 38050 Povo (TN) - Italy
Tel: +39 0461 314 321   Fax: +39 0461 302 040
[EMAIL PROTECTED]  http://sra.itc.it/people/cavada/
--

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


[pygtk] RE: How to draw in a DrawingArea?

2003-02-21 Thread Stephen Kennedy

 This seems like an obvious question, but I've found the answer quite
 elusive.

Try window.draw_line window.draw_polygon etc. You can see some code at
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/meld/meld/filediff.py?rev=1.18c
ontent-type=text/vnd.viewcvs-markup starting at def on_linkmap_expose_event

Stephen.

---
/s { 70 mul add } def 0 45 360 { /r exch def 288 r sin s 396 r cos neg s 250 r
dup 45 add arc } for fill /c { setlinewidth /r exch def 1 .5 0 setrgbcolor 288
396 r 0 361 arc stroke } def 145 55 c 8 20 c /Times findfont 32 scalefont
setfont 100 100 moveto ([EMAIL PROTECTED]) 0 setgray show showpage

___
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] position in scrolled window

2003-02-21 Thread Dan Christian
 I want it to display always the 
 lowest part of the widget inside it (a gtk.textview)

I found this to be more difficult that it looked.

The way that I did it for a scrolling text window is to set a Mark at 
the end of the buffer like this:

self.endMark = self.msgBuffer.create_mark (
end, self.msgBuffer.get_end_iter(), gtk.FALSE)

Then (after every text addition), I tell it to scroll to the end, like 
this:

self.msgPanel.scroll_to_mark (self.endMark, 0.05,
  gtk.TRUE, 0.0, 1.0)

The Mark will do the right thing about where it is in the buffer and 
how the idle task works.

How not to do it: scroll_to_iter looks like it will do the right 
thing, but there is a odd timing issue.  The new size of the text 
window won't be computed until all the drawing is done (it's an idle 
task).  However, get_end_iter and scroll_to_iter, happen 
immediately.  So you would tend to scroll near the end, but not quite 
to it (very frustrating).

Hope this helps,
-Dan
___
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] position in scrolled window

2003-02-21 Thread Johan Dahlin
fre 2003-02-21 klockan 14.21 skrev Dan Christian:
  I want it to display always the 
  lowest part of the widget inside it (a gtk.textview)
 
 I found this to be more difficult that it looked.
 
 The way that I did it for a scrolling text window is to set a Mark at 
 the end of the buffer like this:

Added as section 13.24. in the FAQ

-- 
Johan Dahlin [EMAIL PROTECTED]
Async Open Source

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



[pygtk] gtk.glade.XML signal unconnect

2003-02-21 Thread John Hunter

I have a class that implements some handlers for my glade file

The function get_handler_dict returns a dictionary of signal strings
to function handlers that are bound to the class instance self.

class SomeDialog_CohstatExport:

def __init__(self, widgets):
widgets.signal_autoconnect(self.get_handler_dict())

def get_handler_dict(self):
m = {}
for name in dir(self):
if name.find('on_')==0 and callable(getattr(self, name)):
m[name] = getattr(self, name)
return m

def on_button_clicked(self, event):
#do something with self

The problem comes in if I construct this dialog twice, then when the
signal is emitted, the handlers for both the original instance and the
new instance are called.

Is there a way to disconnect the signals from the previous instance?

Thanks,
John Hunter

pygtk-1.99.14
___
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] position in scrolled window

2003-02-21 Thread Abraham Egnor
I prefer the solution I posted (watching the vertical adjustment), as
that'll work with any widget, not just a text one.

Abe

On 21 Feb 2003, Johan Dahlin wrote:

 fre 2003-02-21 klockan 14.21 skrev Dan Christian:
   I want it to display always the 
   lowest part of the widget inside it (a gtk.textview)
  
  I found this to be more difficult that it looked.
  
  The way that I did it for a scrolling text window is to set a Mark at 
  the end of the buffer like this:
 
 Added as section 13.24. in the FAQ
 
 -- 
 Johan Dahlin [EMAIL PROTECTED]
 Async Open Source
 
 ___
 pygtk mailing list   [EMAIL PROTECTED]
 http://www.daa.com.au/mailman/listinfo/pygtk
 Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
 

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


[pygtk] g_object_set

2003-02-21 Thread Haran Shivanan
How do I call g_object_set() from pygtk?
It doesn't seem to be in gtk, or gobject module.

I need to set the weight property of a GtkCellRendererText object.
To do so , I guess I need to do g_object_set(renderer,weight,2)
or something like that.
Is this correct?

-- 
Patriotism is not a flag on your antenna

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