Hi,
I have a wxHtmlWindow that has images on it. Currently, it opens up a
splash screen on a left click and a popup menu on the right click.
What I'm trying to do is add another menu on the popup menu to copy
the image to clipboard. How do I do this? Is it possible?
Thanks for any help
This is what it kinda looks like:
class MyHtmlWindow(html.HtmlWindow):
def __init__(self,*args, **kwargs):
html.HtmlWindow.__init__(self, *args, **kwargs)
self.right = False
self.left = False
if "gtk2" in wx.PlatformInfo:
self.SetStandardFonts()
def OnSaveAs(self,event):
dlg = wx.FileDialog(
self, message="Save file as ...", defaultDir=os.getcwd(),
defaultFile="", wildcard="*.png", style=wx.SAVE
)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
cont = True
if os.path.exists(path):
dlg = wx.MessageDialog(self, 'The file already exists.
Overwrite?',
'Overwrite?',
wx.YES_NO | wx.ICON_INFORMATION
#wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL
wx.ICON_INFORMATION
)
if dlg.ShowModal() == wx.ID_YES:
cont = True
else:
cont = False
if cont and os.path.exists(self.link):
shutil.copyfile(self.link,path)
def OnCellClicked(self, cell, x, y, evt):
self.m_x = x
self.m_y = y
self.link = None
if evt.GetButton() == 1:
self.left = True
self.right = False
if evt.GetButton() == 3:
self.left = False
self.right = True
self.saveAs=wx.NewId()
wx.EVT_MENU(self,self.saveAs,self.OnSaveAs)
self.menuMenu = wx.Menu()
self.menuMenu.Append(self.saveAs,"&Save As")
sel = html.HtmlSelection()
if isinstance(cell, html.HtmlWordCell):
sel = html.HtmlSelection()
super(MyHtmlWindow, self).OnCellClicked(cell, x, y, evt)
def OnLinkClicked(self, linkinfo):
if self.left and not self.right:
print ('OnLinkClicked: %s\n' % linkinfo.GetHref())
self.link = str(linkinfo.GetHref())
splash = MySplashScreen(str(linkinfo.GetHref()))
splash.SetTransparent(220)
showed = True
splash.Show()
if not self.left and self.right:
self.link = str(linkinfo.GetHref())
self.PopupMenu(self.menuMenu,(self.m_x,self.m_y))