Ed, Is scrollbar present is misfiring on Ubuntu. See my test grid at http://www.flickr.com/photos/natelowrie/4341853567/ I don't really have time to do some testing tonight, but I will see what getScrollRange is returning in the morning.
Regards, Nate On Mon, Feb 8, 2010 at 21:22, Nate Lowrie <[email protected]> wrote: > Ed, > > +1 on correcting this. It is annoying to see the grid correctly sized > to fit within the window with a single expand column and having scroll > bars pop up on the end...I will do some testing on Windows and Ubuntu > tomorrow. > > Regards, > > Nate > > On Mon, Feb 8, 2010 at 20:53, Ed Leafe <[email protected]> wrote: >> dabo Commit >> Revision 5669 >> Date: 2010-02-08 17:53:10 -0800 (Mon, 08 Feb 2010) >> Author: Ed >> Trac: http://trac.dabodev.com/changeset/5669 >> >> Changed: >> U trunk/dabo/ui/uiwx/dGrid.py >> >> Log: >> Improved the behavior of the Expand property to take into account the >> presence of scrollbars. However, detecting scrollbar visibility is not >> straightforward. I'm sure that this will need more platform-specific >> tweaking. >> >> >> Diff: >> Modified: trunk/dabo/ui/uiwx/dGrid.py >> =================================================================== >> --- trunk/dabo/ui/uiwx/dGrid.py 2010-02-08 22:31:03 UTC (rev 5668) >> +++ trunk/dabo/ui/uiwx/dGrid.py 2010-02-09 01:53:10 UTC (rev 5669) >> @@ -2286,24 +2286,57 @@ >> >> >> def _onGridResize(self, evt): >> - dabo.ui.callAfterInterval(50, self._updateColumnWidths) >> + dabo.ui.callAfter(self._updateColumnWidths) >> >> >> + def _totalContentWidth(self): >> + ret = sum([col.Width for col in self.Columns]) >> + if self.ShowRowLabels: >> + ret += self.RowLabelWidth >> + return ret >> + >> + >> + def _totalContentHeight(self): >> + if self.SameSizeRows: >> + ret = self.RowHeight * self.RowCount >> + else: >> + ret = sum([self.GetRowSize(r) for r in >> xrange(self.RowCount)]) >> + if self.ShowHeaders: >> + ret += self.HeaderHeight >> + return ret >> + >> + >> + def isScrollBarVisible(self, which): >> + whichSide = {"h": wx.HORIZONTAL, "v": >> wx.VERTICAL}[which[0].lower()] >> + sr = self.GetScrollRange(whichSide) >> + if self.Application.Platform == "Win": >> + # For some reason, GetScrollRange() returns either 1 >> or 101 when the scrollbar >> + # is not visible under Windows. Under OS X, it >> returns 0 as expected. >> + return sr not in (1, 101) >> + return bool(sr) >> + >> + >> �[email protected] >> def _updateColumnWidths(self): >> """See if there are any dynamically-sized columns, and resize >> them >> accordingly. >> """ >> + if not [col for col in self.Columns if col.Expand]: >> + return >> + dabo.ui.callAfterInterval(10, >> self._delayedUpdateColumnWidths) >> + def _delayedUpdateColumnWidths(self): >> dynCols = [col for col in self.Columns >> if col.Expand] >> - if not dynCols: >> - return >> dynColCnt = len(dynCols) >> - # Add up the current widths >> - wds = [col.Width for col in self.Columns] >> - wd = reduce(lambda x, y: x+y, wds) >> - # Subtract one extra pixel to avoid triggering the scroll >> bar. >> - diff = self.Width - wd - 1 >> + colWd = self._totalContentWidth() >> + rowHt = self._totalContentHeight() >> + if self.isScrollBarVisible("v"): >> + # This will probably be OS-dependent. This works on >> OS X. >> + colWd += 17 >> + wd, ht = self.Size >> + # Subtract extra pixels to avoid triggering the scroll bar. >> Again, this >> + # will probably be OS-dependent >> + diff = self.Width - colWd - 10 >> if not diff: >> return >> adj = diff/ dynColCnt >> @@ -4801,7 +4834,7 @@ >> >> col = dColumn(self, Name="Person", Order=20, DataField="name", >> DataType="string", Width=200, >> Caption="Celebrity Name", >> - Sortable=True, Searchable=True, >> Editable=True, Expand=False) >> + Sortable=True, Searchable=True, >> Editable=True, Expand=True) >> self.addColumn(col) >> >> col.HeaderFontItalic = True >> @@ -4837,7 +4870,8 @@ >> col.HeaderHorizontalAlignment = "Right" >> col.HeaderForeColor = "brown" >> >> - for i in range(20): >> + for i in range(1): >> + # Can't test Expand with so many columns! Just add >> one. >> self.addColumn(DataField="i_%s" % i, Caption="i_%s" % >> i) >> >> >> >> >> [excessive quoting removed by server] _______________________________________________ Post Messages to: [email protected] Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev Searchable Archives: http://leafe.com/archives/search/dabo-dev This message: http://leafe.com/archives/byMID/[email protected]
