Python

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • GetDC of WxScrolledWindow

    7 answers - 514 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    I have a wxScrolledWindow I want to get the device context of the
    entire area of the window. When I blit the windows dc onto a bitmap,
    however, I get a cut off version of the window exactaly how it appears
    on the screen.
    How can I get a picture of the entire area of a wxScrolledWindow?
    Thanks,
    Matt K
    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.1 | | 658 bytes | |

    Hi,

    I think SetVirtualSize is what solved it for me.

    Regards,

    Philippe

    Monday 20 June 2005 03:13 pm, Matt Kubilus wrote:
    I have a wxScrolledWindow I want to get the device context of the
    entire area of the window. When I blit the windows dc onto a bitmap,
    however, I get a cut off version of the window exactaly how it appears
    on the screen.

    How can I get a picture of the entire area of a wxScrolledWindow?
    --
    Thanks,
    Matt K

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.2 | | 928 bytes | |

    Tried SetVirtualSize for the frame. I still get a cutoff bitmap from
    the dc of the window however. How do I get the entire window data
    into the bitmap?

    Thanks,
    Matt

    6/20/05, Philippe C. Martin <philippecmartin (AT) sbcglobal (DOT) netwrote:
    Hi,

    I think SetVirtualSize is what solved it for me.

    Regards,

    Philippe

    Monday 20 June 2005 03:13 pm, Matt Kubilus wrote:
    I have a wxScrolledWindow I want to get the device context of the
    entire area of the window. When I blit the windows dc onto a bitmap,
    however, I get a cut off version of the window exactaly how it appears
    on the screen.

    How can I get a picture of the entire area of a wxScrolledWindow?
    --
    Thanks,
    Matt K

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.3 | | 1602 bytes | |

    I SetVirtualSize on the ScrolledWindow:

    def Set_Plot_Size(self, p_one_student):
    if False == p_one_student:
    l_num_students = len (selfm_data.Get_Students(selfm_class) )

    l_x = (300) + l_num_students * 30
    l_y = (300) + l_num_students * 10
    else:
    l_x = 400
    l_y = 400
    print (l_x,l_y)

    ((l_x,l_y))
    self.client = PlotCanvas(self._m_report_windows, id = -1,
    pos=wx.DefaultPosition,
    size=(l_x,l_y), style=wx.RESIZE_BRDER )
    #define the function for drawing pointLabels
    self.client.SetPointLabelFunc(self.DrawPointLabel)

    Regards,

    Philippe

    Monday 20 June 2005 06:19 pm, Matt Kubilus wrote:
    Tried SetVirtualSize for the frame. I still get a cutoff bitmap from
    the dc of the window however. How do I get the entire window data
    into the bitmap?

    Thanks,
    Matt

    6/20/05, Philippe C. Martin <philippecmartin (AT) sbcglobal (DOT) netwrote:
    Hi,

    I think SetVirtualSize is what solved it for me.

    Regards,

    Philippe

    Monday 20 June 2005 03:13 pm, Matt Kubilus wrote:
    I have a wxScrolledWindow I want to get the device context of the
    entire area of the window. When I blit the windows dc onto a bitmap,
    however, I get a cut off version of the window exactaly how it appears
    on the screen.

    How can I get a picture of the entire area of a wxScrolledWindow?
    --
    Thanks,
    Matt K

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail:
    wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.4 | | 1508 bytes | |

    Hmm. That still just takes a picture of the screen (including the
    Windows menu bar). Albeit in the correct overall size. I need to get
    a hold of the actual buffer behind the WxScrolledWindow.

    Here is a simplified version of what I am trying to do:

    from wxPython.wx import *
    from wxPython.xrc import *

    class scrollFrame(wxFrame):
    def __init__(self):

    wxFrameinit__(self,None,-1,"Title",size=wxSize(300,400))
    self.scroll=wxScrolledWindow(self,-1)

    x = 20
    y = 20

    for i in range(50):
    st=wxStaticText(self.scroll, -1, " Text %d : " %(i),
    pos=wxPoint(x,y))
    w,h = st.GetSizeTuple()
    tc=wxTextCtrl(self.scroll,-1, pos=wxPoint(x+w+5, y))
    dy = h + 10
    y += dy

    self.scroll.SetScrollbars(0,dy,0,y/dy+1)
    self.Show(1)

    class MyApp( wx.App ):
    def Init( self ):
    self.frame2 = scrollFrame()
    ((300,1200))

    panelDC = wx.ClientDC(self.frame2.scroll)
    panelWidth, panelHeight = ()
    bm = wx.EmptyBitmap(panelWidth, panelHeight)

    temp_dc = wx.MemoryDC()
    temp_dc.S(bm)
    temp_dc.Blit(0,0, panelWidth, panelHeight, panelDC, 0,0)

    bm.SaveFile("aBitmap.bmp", wxBITMAP_TYPE_BMP )

    return 1

    if __name__ == '__main__':
    app = MyApp(0)
    app.MainLoop()

    Thanks,
    Matt

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.5 | | 1840 bytes | |

    Matt Kubilus wrote:
    I have a wxScrolledWindow I want to get the device context of the
    entire area of the window. When I blit the windows dc onto a bitmap,
    however, I get a cut off version of the window exactaly how it appears
    on the screen.

    How can I get a picture of the entire area of a wxScrolledWindow?

    Thanks,
    Matt K

    I don't know if this can be applicable to your case, but I have done the
    following for an application using GL and a wxScrolledWindow:

    1) at init time, I create a memory DC with something like

    self._virtualScreenBitmap = wx.EmptyBitmap(self.maxWidth,
    self.maxHeight, -1)
    self._memoryDC = wx.MemoryDC()
    self._memoryDC.S(self._virtualScreenBitmap)

    2) when I need to generate a picture, I have a method that simply does
    this (canvas is the reference to the wxScrolledWindow):

    dc = canvas._memoryDC
    dc.SetBackground(wx.Brush(gDef.DEFAULT_BACKGRUND))
    dc.Clear()

    # redraw the GL shapes on the virtual bitmap
    for shape in canvas.getShapes():
    if not shape.GetParent():
    shape.Draw(dc)

    bitmap = canvas._virtualScreenBitmap
    image = wx.ImageFromBitmap(bitmap)
    image.SaveFile(filepath, wx.BITMAP_TYPE_PNG)

    i.e. I redraw the entire content of the wxScrolledWindow myself on a
    wx.MemoryDC, since IIRC the displayed content of a wxScrolledWindow is
    generated dynamically. (i.e. the wxScrolledWindow only holds the content
    for the displayed size and that's why you are getting a partial picture.)

    If there is a different or simpler way to do this I would be glad to
    know of course.

    Davide

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.6 | | 3862 bytes | |

    Thanks, but that won't work since I am trying to get a picture of the
    actual widgets on a scrolled window, text controls and such. There
    may not be a direct way so I created this function. It scrolls
    through the window and puts together a bitmap for saving, printing,
    whatever. It's a little rough around the edges but here you have it:

    #>

    def getBitmapFromScrolledPanel(panel):
    xScroll,yScroll = panel.GetScrollPixelsPerUnit()
    panel.SetScrollRate(1,1)

    xSource = ySource = xDest = yDest = 0.0

    visibleWidth, visibleHeight = panel.GetSizeTuple()
    virtualWidth, virtualHeight = panel.GetVirtualSize()
    bm = wx.EmptyBitmap(virtualWidth, virtualHeight)
    tempDC = wx.MemoryDC()
    tempDC.S(bm)

    visibleWidth = visibleWidth - 20
    visibleHeight = visibleHeight - 20

    xUnits = visibleWidth
    yUnits = visibleHeight

    print "XUNITS: " + str(xUnits)
    print "YUNITS: " + str(yUnits)

    xSegments = int(ceil(float(virtualWidth)/float(xUnits)))
    ySegments = int(ceil(float(virtualHeight)/float(yUnits)))

    print "XSEGMENTS: " + str(xSegments)
    print "YSEGMENTS: " + str(ySegments)

    for x in range(xSegments):
    if ((x * xUnits) + xUnits) < virtualWidth:
    xDest = xUnits * x
    else:
    xDest = xDest + (virtualWidth - xUnits)
    panel.Scroll(xDest, -1)
    print "XDEST: " + str(xDest)
    for y in range(ySegments):
    if ((y * yUnits) + yUnits) < virtualHeight:
    yDest = yUnits * y
    else:
    yDest = (yUnits * y) - ((yUnits * (y + 1)) - virtualHeight)
    panel.Scroll(-1, yDest)
    print "YDEST: " + str(yDest)
    panel.Update()
    panelDC = wx.ClientDC(panel)
    tempDC.Blit(xDest, yDest, visibleWidth, visibleHeight,
    panelDC, xSource, ySource)

    panel.SetScrollRate(xScroll, yScroll)

    print bm.GetWidth()
    print bm.GetHeight()
    print panel.GetVirtualSize()

    return bm

    #-< CUT

    6/21/05, Davide Salomoni <dsalomoni (AT) gmail (DOT) comwrote:
    Matt Kubilus wrote:
    I have a wxScrolledWindow I want to get the device context of the
    entire area of the window. When I blit the windows dc onto a bitmap,
    however, I get a cut off version of the window exactaly how it appears
    on the screen.

    How can I get a picture of the entire area of a wxScrolledWindow?
    --
    Thanks,
    Matt K

    I don't know if this can be applicable to your case, but I have done the
    following for an application using GL and a wxScrolledWindow:

    1) at init time, I create a memory DC with something like

    self._virtualScreenBitmap = wx.EmptyBitmap(self.maxWidth,
    self.maxHeight, -1)
    self._memoryDC = wx.MemoryDC()
    self._memoryDC.S(self._virtualScreenBitmap)

    2) when I need to generate a picture, I have a method that simply does
    this (canvas is the reference to the wxScrolledWindow):

    dc = canvas._memoryDC
    dc.SetBackground(wx.Brush(gDef.DEFAULT_BACKGRUND))
    dc.Clear()

    # redraw the GL shapes on the virtual bitmap
    for shape in canvas.getShapes():
    if not shape.GetParent():
    shape.Draw(dc)

    bitmap = canvas._virtualScreenBitmap
    image = wx.ImageFromBitmap(bitmap)
    image.SaveFile(filepath, wx.BITMAP_TYPE_PNG)

    i.e. I redraw the entire content of the wxScrolledWindow myself on a
    wx.MemoryDC, since IIRC the displayed content of a wxScrolledWindow is
    generated dynamically. (i.e. the wxScrolledWindow only holds the content
    for the displayed size and that's why you are getting a partial picture.)

    If there is a different or simpler way to do this I would be glad to
    know of course.

    Davide

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org
  • No.7 | | 2034 bytes | |

    Matt Kubilus wrote:
    Hmm. That still just takes a picture of the screen (including the
    Windows menu bar). Albeit in the correct overall size. I need to get
    a hold of the actual buffer behind the WxScrolledWindow.

    I think you have a problem here. There is no buffer behind a
    wx.ScrolledWindow. As the window scrolls, Paint events are sent, and the
    part uncovered needs to be re-drawn.

    If I understand what you are trying to do, it way well be impossible, at
    least directly. If you wanted to capture just custom drawn (wxDC) stuff,
    then you could create an off screen buffer that is large enough to
    capture everything, but I don't think there is any way to get native
    widgets to draw to a buffer you create.
    -Chris

    Here is a simplified version of what I am trying to do:

    from wxPython.wx import *
    from wxPython.xrc import *

    class scrollFrame(wxFrame):
    def __init__(self):

    wxFrameinit__(self,None,-1,"Title",size=wxSize(300,400))
    self.scroll=wxScrolledWindow(self,-1)

    x = 20
    y = 20

    for i in range(50):
    st=wxStaticText(self.scroll, -1, " Text %d : " %(i),
    pos=wxPoint(x,y))
    w,h = st.GetSizeTuple()
    tc=wxTextCtrl(self.scroll,-1, pos=wxPoint(x+w+5, y))
    dy = h + 10
    y += dy

    self.scroll.SetScrollbars(0,dy,0,y/dy+1)
    self.Show(1)

    class MyApp( wx.App ):
    def Init( self ):
    self.frame2 = scrollFrame()
    ((300,1200))

    panelDC = wx.ClientDC(self.frame2.scroll)
    panelWidth, panelHeight = ()
    bm = wx.EmptyBitmap(panelWidth, panelHeight)

    temp_dc = wx.MemoryDC()
    temp_dc.S(bm)
    temp_dc.Blit(0,0, panelWidth, panelHeight, panelDC, 0,0)

    bm.SaveFile("aBitmap.bmp", wxBITMAP_TYPE_BMP )

    return 1

    if __name__ == '__main__':
    app = MyApp(0)
    app.MainLoop()

    Thanks,
    Matt

    To unsubscribe, e-mail: wxPython-users-unsubscribe (AT) lists (DOT) wxwidgets.org
    For additional commands, e-mail: wxPython-users-help (AT) lists (DOT) wxwidgets.org

Re: GetDC of WxScrolledWindow


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "Python"

EMSDN.COM