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

How to do_size_allocate properly in a gtk.Viewport subclass

Hi!

I've raised this issue on #pygtk and #gtk+ but with no luck. I haven't
been able to solve this even with aid of google, the pygtk reference and
the gtk C source, so pretty please help?

I'm making an application that you can think of as an image viewer. I
want to display a widget in a gtk.Viewport. The widget can have any size
from tiny to humungous. I don't want the viewport to ever give the
widget a larger size allocation than requested, and I don't want the
viewport to ever resize to accomodate a large widget. It should rather
leave grey areas around the widget/show only a portion of the widget.

To do this I have subclassed gtk.Viewport (MyViewport) and overrided the
do_size_allocate method:
def do_size_allocate(self, allocation):
self.allocation = allocation
child_req = self.child.get_child_requisition()
child_alloc = gtk.gdk.Rectangle(0, 0, *child_req)
self.child.size_allocate(child_alloc)
self.props.hadjustment.update(allocation.width, child_alloc.width)
self.props.vadjustment.update(allocation.height, child_alloc.height)
if self.flags() & gtk.REALIZED:
self.window.move_resize(*self.allocation)
self.child.window()
When I add a very large widget (a gtk.DrawingArea) to MyViewport only
the originally visible portion of the widget is redrawn when I resize
the window using the mouse, and the grey area around widget gets
littered with grey lines that are not redrawn if you minimize and
restore the window. I assume this comes from that the proper gdk windows
haven't been updated, and that the grey lines are remnants of old
Viewport borders.

In gtk_viewport_size_allocate in gtkviewport.c, gdk_window_move_resize
is called on three gdk windows: viewport->window, viewport->view_window
and viewport->bin_window, but in pygtk I only have gtk.Viewport.window.
I assume that this is the problem? If so, how can I fix this? Or is
there something else that I have overlooked?

And another relevant question: am I overcomplicating this? Is there some
kind of flag that I could set on a vanilla viewport to accomplish this?

Thanks in advance,
Joel
Oct 22 '08 #1
3 1948
Joel Hedlund <jo**********@gmail.comwrites:
I've raised this issue on #pygtk and #gtk+ but with no luck.
Note that there's a mailing list dedicated to PyGTK,
<py***@daa.com.au>, so you might also want to ask your question there.
Oct 22 '08 #2
Hrvoje Niksic wrote:
Note that there's a mailing list dedicated to PyGTK,
<py***@daa.com.au>, so you might also want to ask your question there.
Thanks. I'll try that and hope people won't take offense from
cross-posting. I'll be wathching this thread for answers too though. In
my experience, c.l.p usually delivers.

Cheers!
/Joel
Oct 22 '08 #3
Joel Hedlund wrote:
And another relevant question: am I overcomplicating this?
Yes. :-)

The proper way of doing this is to pack the widget in a container, and
then add the container (with viewport) to a scrolledwindow.

For example, for a centered widget choose a 1x1 gtk.Table and attach the
widget using xoptions = yoptions = gtk.EXPAND (and not gtk.FILL). For a
widget glued to the upper left corner choose a gtk.Alignment().

Thanks John Finlay at py***@daa.com.au!

/Joel
Oct 23 '08 #4

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

Similar topics

1
by: Gerry Sutton | last post by:
Hi All! I have noticed a strange behavior when using a constant identifier to initialize an instance list variable in a base class and then trying to modifying the list in subclasses by using...
8
by: Warren Post | last post by:
Here's a problem I've never seen before. On <http://snow.prohosting.com/srcopan/anti/>, should the viewport width be less than the width of the page's header, then the right margin becomes stuck...
2
by: tomasio | last post by:
dear group, as nobody answered my recent posts (maybe they were too complicated) i just ask you to help me on a rather simple issue: how can i stretch divs to the full height of the viewport (in...
12
by: Csaba Gabor | last post by:
I'd like to have a pic (.jpg - think Map) on a page and a 'viewport' onto that pic, either of whose sizes I could alter by appropriately dragging the element (using, for example, code from the...
4
by: john | last post by:
Hi to All, I am new to html authoring, so sorry if my terminology is not correct or exact. I would like to position a footer div to the bottom of the browser window. As I research in the web...
0
by: Joel DaBona | last post by:
Hello, I have a DIV with a background image. The height of the parent is 100% and both the HTML and the BODY tag have a 100% height. The DIV is larger than the viewport, but the background...
6
by: Chris Fonnesbeck | last post by:
I have a class that does MCMC sampling (Python 2.5) that uses decorators -- one in particular called _add_to_post that appends the output of the decorated method to a class attribute. However, when...
6
by: 123shailesh | last post by:
Hello everyone, I need some help. I have been working on it for some time but havent been able to think of any solution. Even had thought of making do without it, even though it was a major part...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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.