def AddButtonPanel(self, cancel_button=1): panel = Panel(self, direction='horizontal') self.okbutton = Button(panel, "OK", event=self.OnClickOKButton) self.okbutton.SetDefault() panel.AddComponent(self.okbutton, expand=1, border=5) if cancel_button: cancelbutton = Button(panel, "Cancel", event=self.OnClickCancelButton) panel.AddComponent(cancelbutton, expand=1, border=5) return panel
def __init__(self, parent, tickfreq=0.5, min=-5.0, max=5.0, format='%.1f', event=None, size=None, **kwargs): if 'labels' in kwargs: labels = kwargs['labels'] kwargs['labels'] = False Panel.__init__(self, parent, direction='v') intmin = 0 intmax = int(float(max - min) / tickfreq) inttickfreq = 1 self.min = min self.max = max self.tickfreq = tickfreq self.format = format self.slider = Slider(self, inttickfreq, intmin, intmax, event, size, **kwargs) self.slider.SetValue(self.slider.GetMax() / 2) self.slider.OnScroll = self.OnScroll self.AddComponent(self.slider, stretch=True, border=10) if labels: p = Panel(self, direction='h') self.text1 = Label(p, self.format % self.min, align='left') self.text2 = Label(p, self.format % self.max, align='right') self.text3 = Label(p, self.format % self.GetValue(), align='center') p.AddComponent(self.text1, expand=True, border=3) p.AddComponent(self.text3, expand=False, border=3) p.AddComponent(self.text2, expand=True, border=3) p.Pack() self.AddComponent(p, stretch=True) self.Pack()