new parameter -s textonly
[swftools.git] / wx / gui / choicetext.py
1 #!/usr/bin/env python
2 # -*- coding: UTF-8 -*-
3 #
4 # gpdf2swf.py
5 # graphical user interface for pdf2swf
6 #
7 # Part of the swftools package.
8
9 # Copyright (c) 2008,2009 Matthias Kramm <kramm@quiss.org> 
10 #
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.
15 #
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.
20 #
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 */
24
25 import wx
26 import  wx.lib.intctrl
27
28 class ChoiceInt(wx.Panel):
29     def __init__(self, parent, choices=[], editselection=None):
30         wx.Panel.__init__(self, parent)
31         choices = choices
32         self.editselection = editselection
33
34         s = wx.BoxSizer(wx.HORIZONTAL)
35
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)
40
41         self.SetSizer(s)
42
43         choice.Bind(wx.EVT_CHOICE, self.__OnChoice)
44
45     def IsEditableSelection(self, n):
46         return n == self.editselection
47  
48     def GetValue(self):
49         return self.text.GetValue()
50
51     def SetValue(self, value):
52         self.text.SetValue(value)
53
54     def GetSelectionAndValue(self):
55         return self.choice.GetSelection(), self.text.GetValue()
56
57     def SetSelectionAndValue(self, n, value):
58         self.SetSelection(n)
59         self.text.SetValue(value)
60
61     def GetSelection(self):
62         return self.choice.GetSelection()
63
64     def SetSelection(self, n):
65         self.choice.SetSelection(n)
66         self.EnableText(self.IsEditableSelection(n))
67
68     def EnableText(self, enable):
69         self.text.Enable(enable)
70
71     def __OnChoice(self, event):
72         self.EnableText(self.IsEditableSelection(event.Selection))
73