0

I'm trying to put an image background using wx.html2 I've tried all of the css / html tags, but the images will not go in. I guess I'm using it wrong. I made an html document and tested it. It will work normally in the browser. What is the problem? In html2, the image related css seems not to be all.

For example, image related things like gradients.

#-*- coding: utf-8 -*-
import wx.html2

HTML_CODE= """
<!DOCTYPE HTML>
<html lang="ko">
  <head>
    <meta charset="utf-8">
    <title>HTML TEST</title>
    <style type="text/css">
      body{{
        background-image: url(1.png);
      }} 
      table{{
        width: 100%;
        border-collapse: collapse      
      }}
      table, caption, th, td{{
        border: 1px solid black;
        text-align: center;   
        color:black;    
        height: 100px;
        font-size: 20px;           
      }}
    </style>
  </head>
  <body scroll='no'>
    <table>
      <caption>Hello world</caption>
      <thead>
        <tr>      
          <th>Ipsum</th>
          <th>Ipsum</th>
          <th>Ipsum</th>
          <th>Ipsum</th>
          <th>Ipsum</th>
          <th>Ipsum</th>  
        </tr>
      </thead>
      <tbody>
        <tr>       
          <td>{0}</td>
          <td>{1}</td>
          <td>{2}</td>     
          <td><p style='color:{3}'>{4}</p></td>
          <td><p style='color:{5}'>{6}</p></td>
          <td><p style='color:{7}'>{8}</p></td>      
        </tr>
        <tr>       
          <td>{9}</td>
          <td>{10}</td>
          <td>{11}</td>     
          <td><p style='color:{12}'>{13}</p></td>
          <td><p style='color:{14}'>{15}</p></td>
          <td><p style='color:{16}'>{17}</p></td>      
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <td colspan="6">Table Foot</td>
        </tr>
      </tfoot>  
    </table> 
  </body>
</html>
"""
app = wx.App()
frame=wx.Frame(None,-1)
browser = wx.html2.WebView.New(frame, size=(460, 400))
browser.SetPage(HTML_CODE,"")
frame.Show(True)
app.MainLoop()

enter image description here

다크매터
  • 69
  • 13

1 Answers1

1

You are using relative names for the image files, but the WebView does not know where to start when looking for that resource. You'll either need to specify the full pathname for the image resources, or you should pass a URL use use as the base location in the baseURL parameter of SetPage. It will probably need to be a file://... URL.

RobinDunn
  • 6,116
  • 1
  • 15
  • 14