return gobject.idle_add(_callback_wrapper, func, *args, **kw)
def timeout_add_lock(milliseconds, func, *args, **kw):
return gobject.timeout_add(milliseconds,
_callback_wrapper, func, *args, **kw)
--
Tim Evans
also gets everything nice and serialised into one thread,
making race conditions easier to avoid.
Note that you should avoid interacting with the UI directly from the
background thread on Windows, as it will cause a lock up. It's generally
better to avoid it on non-Windows pla
verride.
You might look at how AutoHotkey (http://www.autohotkey.com/) does it,
or consider just using AutoHotkey to send the right keys to your app.
--
Tim Evans
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygt
window afterwards, after pulling
any information you need from the widgets within the window.
--
Tim Evans
Senior Software Engineer
ARANZ Geo Limited
p: +64 3 374 6120 | e: t.ev...@aranz.com
www.aranzgeo.com
from __future__ import division
import gtk, gobject
class RunAsDialog(object):
be sortable by number?
Use gtk.TreeViewColumn.set_sort_column_id to point the sorting at the
float column in the model. This is where the separation between view
columns and model columns comes in handy.
--
Tim Evans
___
pygtk mailing list pygtk@daa.com
d([MYFLOAT, round(MYFLOAT, 2)])
win.add(treeview)
win.show_all()
gtk.main()
Make the second column a string, and add the formatted value to it. If
you want two decimal places, use '%.2f' % MYFLOAT.
--
Tim Evans
___
pygtk mailing list pygtk@daa.c
for stacking widgets in a scrolled area?
Looks like you're just missing a "label.show()" call in there.
--
Tim Evans
Senior Software Engineer
ARANZ Geo Limited
p: +64 3 374 6120 | e: t.ev...@aranz.com
Level 6, 227 Cambridge Terrace, PO Box 3894, Christchurch, New Zealand
www.aran
ways the
case when threads are involved.
--
Tim Evans
Senior Software Engineer
ARANZ Geo Limited
p: +64 3 374 6120 | e: t.ev...@aranz.com
www.aranzgeo.com
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
x27;t work
properly, Courier New is the truetype version.
You could also use the font name "monospace" which will default to a
useful monospaced font. I'm not sure what the standard GTK+ install uses
but it should be Consolas where available (Vista and 7 for sure) falling
back t
efile = '../../data/' + service + '.png'
image = gtk.Image()
image.set_from_file(imagefile)
pixbuf = image.get_pixbuf()
The better way to load a pixbuf from a file is:
pixbuf = gtk.gdk.pixbuf_new_from_file(imagefile)
--
Tim Evans
of the list model. If you
just want to set a constant value for a cell renderer property, use
something like this:
render_pixbuf.props.stock_size = gtk.ICON_SIZE_BUTTON
--
Tim Evans
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.
our of composite when sampling an
area larger than the scaled source to be a minor bug. It can be worked
around pretty easily, but I can't imagine any situation where the
current behaviour would be useful. As you've demonstrated it can be
higher counter-intuitive.
--
Tim Evans
Appl
rge, 5, 5, 20, 20, 5, 5, 1, 1, 'nearest', 255)
small.composite(large, 10, 10, 20, 20, 10, 10, 1, 1, 'nearest', 255)
large.save('test.png', 'png')
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
gtk.TreeViewColumn.set_fixed_width
gtk.TreeView.set_fixed_height_mode
- If your list is large enough it may be worth subclassing
gtk.TreeModel and overriding the required methods. It's complex, but
it can avoid referencing all your data at tree build time, instead
loa
e arguments are a bit complex and I'd be
sure to get them wrong the first time and confuse you.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
On 2010-07-07 13:26, Jason Heeris wrote:
> Tim Evans wrote:
>> GTK+ 2.14.4
>> PyGObject 2.14.2
>> PyGTK 2.12.1
>
> Mine is
>
> GTK+ 2.20
> PyGObject 2.21.2
> PyGTK 2.17.1
>
> A few things about your changes confused me -
>
> 1. You call glib.i
:
try:
func(*args)
return False
finally:
event.set()
gobject.idle_add(idle)
event.wait()
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
read.
> Still getting my head around threads. See all sorts of references all of
> which seem a wee bit beyond my comprehension at the moment. Any comments
> would be appreciated.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
rking and I'll have a look at it.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
possible to
> define different user_data for callbacks?
You could construct each callback with functools.partial.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/list
ng and allocating
big blocks of video memory, instead copying data into the same block
each time.
- Use a "Pixel Buffer Object" to move data into the texture instead.
You'll need the "ARB_pixel_buffer_object" extension. This pages has
so set in
manually with this line of code:
my_entry.props.width_chars = 5
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
ip-taskbar-hint", True)
This looks much more sensible actually. Making changes to the
GtkWindow/GtkWidget and letting Gtk itself handle setting up the
GdkWindow tends to be the better option when it is possible.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
lize', configure_balloon,
self[PropertyDialogView.top])
Again, this seems to work on win32, and while I think it's more likely
to work on Linux it's not guaranteed.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
opup, w)
This should, at least on win32 where I tested it, give you a popup
window that stays above the specific parent window rather than everything.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.
storing that
size next time your software runs is also a good idea.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
Note that you need to wait for the GtkWindow to be realized before you
can access its GdkWindow. Handling the 'realize' signal is the normal
way to do that, so code often ends up looking like this:
def on_realize_set_decor(window, decor):
window.window.set_decorations(decor)
False
Call 'call()' whenever the entry changes. Your callback will be called
when nothing has happened in the last 'delay' milliseconds. You may
need something to force an early check on focus-out-event for the entry
or when the user clicks an "Ok" b
lumn(n)" to get the object if you don't
already have it, then "c.set_alignment(0.5)" to centre the text in it.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
you shouldn't modify the returned layout. I
think it would be better to use:
spin.modify_font(pango.FontDescription('10'))
You also don't need to specofy 'normal', '10' is a font description.
--
Tim Evans
Applied Research Associates NZ
http://www.
to
render the column header. Your button-press-event connection will work
on that widget, provided you make headers clickable on the treeview:
treeview.set_headers_clickable(True)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
orry if this is a stupid suggestion, but have you thought about loading
the HTML file in a web browser?
import webbrowser
webbrowser.open('file://path/to/file')
Personally I much prefer viewing help or similar things in a real web
browser where I can bookmark, search, etc. t
Tim Evans wrote:
> ganesh gajare wrote:
>> Hello,
>> I have created an entry box widget using glade.
>> and I am doing validation on that field...
>> So whenever an invalid text is entered in the entry box,the text color
>> of entry should change dynamically.
method 'modify_text' should do what you
need. For example, to set the text to red, use:
entry.modify_text(gtk.gdk.color_parse('red'))
and to set it back to the default black:
entry.modify_text(None)
--
Tim Evans
Applied Res
> The source code for python-poppler can be found here:
>
> http://bazaar.launchpad.net/~poppler-python/poppler-python/trunk/files
>
> I didn't write the wrapper, but if someone can help me fixing it I
> would be very happy!
Try running
s
to happen in PyGTK, including actual window operations I think.
Our app crashes without this hack, and previous versions would lock up.
I haven't had time to properly investigate the cause.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
__
gc.disable()
def collect():
with gtk.gdk.lock:
gc.collect()
return True
gobject.timeout_add_seconds(10, collect)
Not a long-term solution, but it gets your software working.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/
10) only half of that
1-pixel is in the 10th row, the other half being in the 9th row. Cairo
renders this by antialiasing, so you get a 2-pixel side 50% gray line
rather than the 1-pixel black line you were expecting.
--
Tim Evans
Applied Research Associates NZ
Tasos Latsas wrote:
> I tried it but unfortunately the normal and bold entries are in the same
> column, so I need the tags...:( Looks like I'll use the extra-column
> solution..
> Thanx anyway!!
>
> Tim Evans wrote:
>> gtk.CellRendererText has separate properties fo
you describe you would set the "weight"
property to pango.WEIGHT_BOLD and just use "text" rather than "markup".
Unless you need to change the font attributes mid-way through the text
using the specific attributes will be a little faster than markup and
won't
function, and once I had that I could use ctypes to set
the double it points to.
Attached an ugly hack that solves your problem. Thanks for posting btw,
this was fun ;)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
import gtk, ctypes
def _currency_input(spinbutton, gpoint
" the nothing will happen when you click the button. Put
whatever code you want into that method. The normal clicked behaviour
of gtk.CheckButton can be triggered by calling the superclass method
"gtk.CheckButton.do_clicked(self)" from within your method.
--
Tim Evans
Applie
e_widget(dummyWidget, self.shootingArea)" and wherever
dummyWidget was (and with whatever packing properties) your shootingArea
widget will be put there instead. You could add more copying of
properties is you need it, this function only copies visibility.
--
Tim Evans
Applied
ser's preferred browser:
import webbrowser
webbrowser.open('http://www.python.org/')
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/
containing one 'str' type and repeats the
list 10 times. The second line uses the python "*args" syntax to expand
the list into a list of arguments.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk
mage, text = hboxtemp.get_children()
text.set_text(' ')
Is there a more simple solution ?
image = gtk.Image()
image.set_from_stock(gtk.STOCK_SAVE, gtk.ICON_SIZE_BUTTON)
button = gtk.Button()
button.add(image)
image.show()
I would consider this to be the correct way to do it.
--
Tim Ev
sing
threading, but for an action that can take several seconds you should
probably look at using them.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.co.nz/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/
for GTK disables button images to make it look more
like windows. This might be what's breaking your button. You could try
changing the 'gtkrc' file associated with the ms-windows theme to remove
the line "gtk-button-images = 0".
--
Tim Evans
Applied Re
don't lide the
looks of this loop.. :-) )
This will work; I'd just recommend using descriptive variable names to
make it more obvious:
for row in matrix:
for pixel in row:
pixel[0] = color_red
pixel[1] = color_green
pixel[2] = color_blue
--
Tim Evans
A
ler = _CustomHandlerStack()
And use it later like this:
custom_handler.push(my_hander_func)
x = gtk.glade.XML(...)
custom_handler.pop()
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.co.nz/
___
pygtk mailing list pygtk@daa.com
n memory
buffer that stores the image in the given file type?
Untested, but maybe something like this, where 'p' is a pixbuf:
import cStringIO as StringIO
io = StringIO.StringIO()
p.save_to_callback(io.write, 'png')
buffer = io.getvalue()
--
Tim Evans
return gobject.idle_add(_with_lock, func, args)
def timeout_add_lock(millisecs, func, *args):
return gobject.timeout_add(millisecs, _with_lock, func, args)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.co.nz/
___
pygtk mailing list pygtk@
ry if you'll be doing these lookups often:
def named_widgets(root):
r = {}
for w in all_descendants(root):
name = w.get_name()
if name:
r[name] = w
return r
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.co.nz/
__
win.add(tree)
win.connect('delete-event',lambda x,y:gtk.main_quit())
win.show_all()
gtk.main()
Try setting the property "cell-background-gdk" rather than "background-gdk".
GtkCellRendererText::background-gdk colours the background of the text,
and excludes border
the
SIGCHLD signal, but this would be more complex and not portable to
Windows. I'll leave it as an exercise for the reader :)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.co.nz/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
e_ui(self, data):
gtk.threads_enter()
try:
#perform ui updating here
return False
finally:
gtk.threads_leave()
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list p
a:
array[y,x,:] = (r, g, b, 255)
pixbuf = gtk.gdk.pixbuf_new_from_array(array,
gtk.gdk.COLORSPACE_RGB, 8)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://
should call:
do_gui_operation(add_image_to_list, list, image)
You don't need to hold the thread lock to call gobject.idle_add (or
do_gui_operation) but you do need to acquire it inside the idle function
because they are, by default, run without holding the thread lock.
--
Tim Evans
Applied Rese
;m using PyGTK 2.4.1 with a patched pygobject.h and version of Python
2.4 that I compiled using MSVC 6 and it works fine for me.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com
w):
gobject.idle_add(in_idle, args, kw)
return wrapper
@idlefunction
def show_message(message):
w = gtk.Window()
w.add(gtk.Label(message))
w.show_all()
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
arent()
w.set_property("can-focus", False)
Note how I also add a mnemonic to the new label widget so that the
column header is still accessible from the keyboard.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygt
e a problem when
2.6 is released. If you want it fixed now the you could apply the
attached patch and recompile.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list pygtk@daa.com.au
http://www.daa.com.au/mailman/
given by p.get_rowstride().
Where 'p' is a pixbuf, the number of bytes per pixel is
'p.get_n_channels()', and row 'i' starts at byte 'i * p.get_rowstride()'.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
__
_idle_func(function, args, kw):
gtk.threads_enter()
try:
return function(*args, **kw)
finally:
gtk.threads_leave()
def idle_add_lock(function, *args, **kw):
gobject.idle_add(_idle_func, function, args, kw)
--
Tim Evans
Applied Research Asso
Johan Dahlin wrote:
I just put up a tarball of PyGTK 2.5.2 on ftp.gnome.org, it can be
fetched from:
ftp://ftp.gnome.org/pub/GNOME/sources/gnome-python/2.5/
once the mirrors have synced correctly.
I think that URL should have been:
ftp://ftp.gnome.org/pub/GNOME/sources/pygtk/2.5/
--
Tim Evans
the
set_icon_size method of Toolbar.
You can set the global toolbar icon size using GtkSettings. Look at the
documentation for gtk_settings_get_default and the GtkSettings property
'gtk-toolbar-icon-size'. You, or your users, can also set this via
configuration files.
--
Tim Eva
ation shows that the wrap
width passed here should be in pango units, not pixels. One pixel is
pango.SCALE pango units, so the line should be:
layout.set_width(cell_area.width * pango.scale)
--
Tim Evans
Applied Research Associates NZ
http://www.aran
lse
finally:
gtk.threads_leave()
def in_main_thread(func, *args, **kw):
gtk.idle_add(_in_main_thread_idle, func, args, kw)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED]
. I think that
all of this should go into a module called 'glog'. If anyone else likes
this idea I could try putting together an initial version of such a module.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pyg
t into the statusbar.
pixbuf = gtk.gdk.pixbuf_new_from_file('figure.xpm')
image = gtk.Image()
image.set_from_pixbuf(pixbuf)
statusbar.pack_start(image)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [E
use the "stock-id" and "stock-size"
properties of gtk.CellRendererPixbuf rather than setting the "pixbuf"
property directly.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL
ts of experience
in writing Python extensions by hand, so I'd be happy to write overrides
for functions that are too complex to wrap automatically.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED
()ing to it..
Producing a string from a pixbuf (in PNG format) is coverred here:
http://bugzilla.gnome.org/show_bug.cgi?id=82203
This patch will be part of GTK+-2.4. Until then the only way to get a
pixbuf in a string is to use a temporary file.
--
Tim Evans
Applied Research Associate
called by the
main thread?
Under Windows, if you don't call gtk.threads_init() then GTK will never
release the Python GIL (Global Interpreter Lock). This will mean that
other Python threads will hardly ever get a chance to run, and your
program will run slowly.
--
Tim Evans
Applied Re
function if you are doing any GUI stuff in it.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
ape = (w, h, -1)
p = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, i.mode == 'RGBA', 8, w, h)
p.pixel_array[:] = data
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/m
lex if you aren't careful. Use
Python's 'Queue' module for everything; if your algorithm requires
something more complicated than Queue then change your algorithm ;-)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
__
[EMAIL PROTECTED] wrote:
I need make zoomin and zoomout in one image using pygtk.
Take a look at the documentation for the Gdk-Pixbuf library:
http://developer.gnome.org/doc/API/2.0/gdk-pixbuf/index.html
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com
[-] expanders.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
to smooth edges of screen fonts"
and select "ClearType" from the combo box.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/
tp://www-106.ibm.com/developerworks/linux/library/l-wrap/
Looking at the source for pygtk is also a good source of information,
but it's rather complex. You will need to download the source anyway to
get the codegen package.
--
Tim Evans
Applied Research Associate
return NULL;
widget = GTK_WIDGET(py_widget->obj);
You might also want to look at the 'codegen' stuff that pygtk uses to
automatically generate most of the pygtk interface. Once you get used
to using it, it's much easier to use than writing everything by hand.
--
Tim Evans
reference counts when you started doing stuff like that
'connect' call above.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
was
recursive? GDK_THREADS_ENTER is a macro, so I don't think that the lock
could be changed from a GMutex to a GStaticRecMutex without breaking
binary compatibility.
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/
___
pygtk m
adding METH_CLASS
to the flags in the PyMethodDef array (with METH_VARARGS and
METH_KEYWORDS). This would make it possible to change from:
p = gtk.gdk.pixbuf_new_from_file(...)
to:
p = gtk.gdk.Pixbuf.new_from_file(...)
--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com
string (the current
contents of the entry). What you need to do is pass the entry widget
itself:
self.printButton.connect('clickec', self.printIt, entry)
And the inside 'printIt' call the get_text method. I have attached a
fixed and cleaned up version of your code.
Tim Evans wrote:
> [snip]
I'm not sure about 1.99.14, but 1.99.16 can be compiled with Numeric
support. If it is you can create a Pixbuf by modifying the array
returned be accessing the 'pixel_array' attribute of an existing pixbuf.
Assuming that you have a (n,m,3) or (n,m
x27;pixel_array' attribute is read-only in that you can't do
'p.pixel_array = data'. But it's not immutable, so you can still change
it's contents, which is what the [:] slice assignment does. The
reference could probably make this more clear.
--
Tim Evans
Applie
xbuf.
Assuming that you have a (n,m,3) or (n,m,4) shape 'b' type array of RGB
or RGBA values called 'data', you would do this:
w,h = data.shape[:2]
hasalpha = shape.shape[3] == 4
p = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, hasalpha, 8, w, h)
p.pixel_array[:] = data
--
Tim E
90 matches
Mail list logo