0

I've read almost all i could find on internet to solve this, but no way to find out !

so i will post here. I would like my news to have a vertical scrollbar in the gridbagsizer.

I tried to put it on wxscrolledWindow and many other things, there's no way to get this VScroll !!!

Maybe i should attach it to gridbagsizer but i don't know how to...

Here's an example of my problem :

import wx
import wx.html2
from os import getcwd
import wx.media


class MyFrame(wx.Frame):
      def __init__(self, parent, id, title):
          wx.Frame.__init__(self, None, id, u"PC GAMES Updater/Launcher V2.0 By -Fawn-", wx.DefaultPosition, wx.Size(1280, 650),style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)

        ImgDir = (getcwd()+u"\\img\\fond.jpg")
        fond = wx.Image(ImgDir, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bg = wx.StaticBitmap(self, -1, fond)

        self.browser = wx.html2.WebView.New(self.bg,-1,size=(370,200))
        self.browser.LoadURL("http://utrem.tf/www/news.html")

        #Sizer news
        gbox7 = wx.GridBagSizer(1,1)
        gbox7.SetEmptyCellSize((10,10))
        gbox7.Add(self.browser,(0,0))

        #NEWS
        box7= wx.StaticBox(self, -1, "NEWS")
        bsizer7 = wx.StaticBoxSizer(box7, wx.HORIZONTAL)
        sizerH7 = wx.BoxSizer(wx.VERTICAL)
        sizerH7.Add(gbox7, 0, wx.ALL|wx.CENTER, 10)
        bsizer7.Add(sizerH7, 1, wx.EXPAND, 0)

        vSizer3 = wx.BoxSizer(wx.VERTICAL,)
        vSizer3.Add(bsizer7, 0,wx.ALL|wx.EXPAND, 10)

        hmainSizer=wx.BoxSizer(wx.HORIZONTAL)
        hmainSizer.Add(vSizer3, 0,wx.ALL|wx.EXPAND, 10)

        vmainSizer=wx.BoxSizer(wx.VERTICAL)
        vmainSizer.Add(hmainSizer, 0,wx.ALL|wx.EXPAND, 10)

        self.SetSizer(vmainSizer)

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, None)
        frame.Show(True)
        frame.Centre()
        return True

if __name__=='__main__':    

    app = MyApp(0)
    app.MainLoop()

PS: I must keep my "news" size (370,200) !

Thanks if someone can help and explain what i am doing wrong.

Garbez François
  • 327
  • 3
  • 13

2 Answers2

2

I'm glad you resolved the issue to your satisfaction, however, as pointed out in my comment, if you simply adjust your code to make the webview a child of self rather than the image, it would work.

import wx
import wx.html2
from os import getcwd
import wx.media


class MyFrame(wx.Frame):
      def __init__(self, parent, id, title):
        wx.Frame.__init__(self, None, id, u"PC GAMES Updater/Launcher V2.0 By -Fawn-", wx.DefaultPosition, wx.Size(1280, 650))#,style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)

        ImgDir = (getcwd()+u"/frame1.png")
        fond = wx.Image(ImgDir, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bg = wx.StaticBitmap(self, -1, fond)

        self.browser = wx.html2.WebView.New(self,-1,size=(370,200))
        self.browser.LoadURL("http://utrem.tf/www/news.html")
        #self.browser.LoadURL("http://ninjaaior.free.fr/2505/news.html")

        #Sizer news
        gbox7 = wx.GridBagSizer(1,1)
        gbox7.SetEmptyCellSize((10,10))
        gbox7.Add(self.browser,(0,0))

        #NEWS
        box7= wx.StaticBox(self, -1, "NEWS")
        bsizer7 = wx.StaticBoxSizer(box7, wx.HORIZONTAL)
        sizerH7 = wx.BoxSizer(wx.VERTICAL)
        sizerH7.Add(gbox7, 0, wx.ALL|wx.CENTER, 10)
        bsizer7.Add(sizerH7, 1, wx.EXPAND, 0)

        vSizer3 = wx.BoxSizer(wx.VERTICAL,)
        vSizer3.Add(bsizer7, 0,wx.ALL|wx.EXPAND, 10)

        hmainSizer=wx.BoxSizer(wx.HORIZONTAL)
        hmainSizer.Add(vSizer3, 0,wx.ALL|wx.EXPAND, 10)

        vmainSizer=wx.BoxSizer(wx.VERTICAL)
        vmainSizer.Add(hmainSizer, 0,wx.ALL|wx.EXPAND, 10)

        self.SetSizer(vmainSizer)

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, None)
        frame.Show(True)
        frame.Centre()
        return True

if __name__=='__main__':    

    app = MyApp(0)
    app.MainLoop()

enter image description here

Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60
  • Yes but it works on "self.bg" and so you don't have the frame background behind but the image. Well all this story was because of html code the had a no-scroll ON ! – Garbez François Dec 27 '20 at 11:21
0

Ok it was totally because of HTML page's code, working fine now...

I recoded HTML page after asking for source here's the result :

import wx
import wx.html2
from os import getcwd
import wx.media


class MyFrame(wx.Frame):
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, None, id, u"PC GAMES Updater/Launcher V2.0 By -Fawn-", wx.DefaultPosition, wx.Size(1280, 650),style=wx.MINIMIZE_BOX|wx.SYSTEM_MENU | wx.CAPTION | wx.CLOSE_BOX)

        ImgDir = (getcwd()+u"\\img\\fond.jpg")
        fond = wx.Image(ImgDir, wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        self.bg = wx.StaticBitmap(self, -1, fond)

        self.browser = wx.html2.WebView.New(self.bg,-1,size=(370,200))
        self.browser.LoadURL("http://ninjaaior.free.fr/2505/news.html")

        #Sizer news
        gbox7 = wx.GridBagSizer(1,1)
        gbox7.SetEmptyCellSize((10,10))
        gbox7.Add(self.browser,(0,0))

        #NEWS
        box7= wx.StaticBox(self, -1, "NEWS")
        bsizer7 = wx.StaticBoxSizer(box7, wx.HORIZONTAL)
        sizerH7 = wx.BoxSizer(wx.VERTICAL)
        sizerH7.Add(gbox7, 0, wx.ALL|wx.CENTER, 10)
        bsizer7.Add(sizerH7, 1, wx.EXPAND, 0)

        vSizer3 = wx.BoxSizer(wx.VERTICAL,)
        vSizer3.Add(bsizer7, 0,wx.ALL|wx.EXPAND, 10)

        hmainSizer=wx.BoxSizer(wx.HORIZONTAL)
        hmainSizer.Add(vSizer3, 0,wx.ALL|wx.EXPAND, 10)

        vmainSizer=wx.BoxSizer(wx.VERTICAL)
        vmainSizer.Add(hmainSizer, 0,wx.ALL|wx.EXPAND, 10)

        self.SetSizer(vmainSizer)

class MyApp(wx.App):
    def OnInit(self):
        frame = MyFrame(None, -1, None)
        frame.Show(True)
        frame.Centre()
        return True
 
if __name__=='__main__':    
 
    app = MyApp(0)
    app.MainLoop()
Garbez François
  • 327
  • 3
  • 13