2 # -*- coding: UTF-8 -*-
5 # graphical user interface for pdf2swf
7 # Part of the swftools package.
9 # Copyright (c) 2008,2009 Matthias Kramm <kramm@quiss.org>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; either version 2 of the License, or
14 # (at your option) any later version.
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
28 class ChoiceInt(wx.Panel):
29 def __init__(self, parent, choices=[], editselection=None):
30 wx.Panel.__init__(self, parent)
32 self.editselection = editselection
34 s = wx.BoxSizer(wx.HORIZONTAL)
36 self.choice = choice = wx.Choice(self, choices=choices)
37 self.text = text = wx.lib.intctrl.IntCtrl(self)
38 s.Add(choice, 1, wx.EXPAND)
39 s.Add(text, 1, wx.EXPAND)
43 choice.Bind(wx.EVT_CHOICE, self.__OnChoice)
45 def IsEditableSelection(self, n):
46 return n == self.editselection
49 return self.text.GetValue()
51 def SetValue(self, value):
52 self.text.SetValue(value)
54 def GetSelectionAndValue(self):
55 return self.choice.GetSelection(), self.text.GetValue()
57 def SetSelectionAndValue(self, n, value):
59 self.text.SetValue(value)
61 def GetSelection(self):
62 return self.choice.GetSelection()
64 def SetSelection(self, n):
65 self.choice.SetSelection(n)
66 self.EnableText(self.IsEditableSelection(n))
68 def EnableText(self, enable):
69 self.text.Enable(enable)
71 def __OnChoice(self, event):
72 self.EnableText(self.IsEditableSelection(event.Selection))