要记住的是,人们不能只share
编码,除非他们正在做你想做的事情。它必须写出来。
尝试以此为起点。
图像重新缩放特定于我的图像,以使它们具有正确的大小。
import wx
from wx.lib.scrolledpanel import ScrolledPanel
imgs = ['ace.png','2.png','3.png','4.png','5.png']
links = ['https://www.asite.com/ace.mp4', 'https://www.asite.com/2.mp4', 'https://www.asite.com/3.mp4', 'https://www.asite.com/4.mp4', 'https://www.asite.com/5.mp4']
class Example(wx.Frame):
def __init__(self, parent, title):
super(Example, self).__init__(parent, title = title)
self.InitUI()
self.Centre()
self.Show()
def InitUI(self):
panel = ScrolledPanel(self, wx.ID_ANY)
panel.SetupScrolling()
vbox = wx.BoxSizer(wx.VERTICAL)
for index, img in enumerate(imgs):
bmp = wx.Bitmap(img)
image = bmp.ConvertToImage()
image.Rescale(70, 100)
bmp = wx.Bitmap(image)
video = wx.StaticBitmap(panel, wx.ID_ANY, bmp)
button = wx.Button(panel, wx.ID_ANY, "Play", name=str(index))
button.SetToolTip("Play "+links[index])
vbox.Add(video, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 0)
vbox.Add(button, 0, wx.ALL|wx.ALIGN_CENTER_HORIZONTAL, 5)
self.Bind(wx.EVT_BUTTON, self.OnPlay, button)
panel.SetSizer(vbox)
def OnPlay(self, event):
obj = event.GetEventObject()
print("Playing ..."+links[int(obj.GetName())])
app = wx.App()
Example(None, title = 'BoxSizer Demonstration')
app.MainLoop()