mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-04 11:00:07 +01:00
Add ability to select some other SVG file to view
This commit is contained in:
@@ -28,6 +28,7 @@ class SVGBitmapDisplay(wx.Panel):
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
ADD_NEW = '[Double-click to Add New File]'
|
||||
|
||||
class TestPanel(wx.Panel):
|
||||
def __init__(self, parent, log):
|
||||
@@ -35,7 +36,8 @@ class TestPanel(wx.Panel):
|
||||
wx.Panel.__init__(self, parent, -1)
|
||||
|
||||
self.listbox = wx.ListBox(self, style=wx.LB_SINGLE, size=(250, -1))
|
||||
self.listbox.AppendItems(glob.glob(os.path.join('data', '*.svg')))
|
||||
self.listbox.Append(ADD_NEW)
|
||||
self.listbox.Append(glob.glob(os.path.join('data', '*.svg')))
|
||||
|
||||
self.updateables = []
|
||||
rightSizer = wx.BoxSizer(wx.VERTICAL)
|
||||
@@ -59,15 +61,29 @@ class TestPanel(wx.Panel):
|
||||
self.Sizer.Add(rightSizer, wx.SizerFlags(2).Border(wx.RIGHT|wx.BOTTOM|wx.TOP, 10).Expand())
|
||||
|
||||
self.Bind(wx.EVT_LISTBOX, self.OnSelectItem)
|
||||
self.listbox.SetSelection(0)
|
||||
self.Bind(wx.EVT_LISTBOX_DCLICK, self.OnDClickItem)
|
||||
|
||||
self.listbox.SetSelection(1)
|
||||
|
||||
# Load the first SVG in the list into the static bitmaps
|
||||
self.UpdateAll(self.listbox.GetString(0))
|
||||
self.UpdateAll(self.listbox.GetString(1))
|
||||
|
||||
|
||||
def OnSelectItem(self, evt):
|
||||
filename = self.listbox.GetStringSelection()
|
||||
self.UpdateAll(filename)
|
||||
if filename != ADD_NEW:
|
||||
self.UpdateAll(filename)
|
||||
|
||||
|
||||
def OnDClickItem(self, evt):
|
||||
if self.listbox.GetSelection() == 0:
|
||||
with wx.FileDialog(self, "Select SVG file", "data",
|
||||
wildcard="SVG files (*.svg)|*.svg",
|
||||
style=wx.FD_OPEN) as dlg:
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
self.listbox.Insert(dlg.GetPath(), 1)
|
||||
self.listbox.SetSelection(1)
|
||||
self.UpdateAll(self.listbox.GetString(1))
|
||||
|
||||
|
||||
def UpdateAll(self, svg_filename):
|
||||
|
||||
Reference in New Issue
Block a user