def setup(self, attribute, window, aguidata): #self.floatspin.SetRange( *self.aguidata.get('range',(None,None))) self.minval, self.maxval = self.aguidata.get('range',(None,None)) self.floatspin.SetIncrement(self.aguidata.get('increment',0.1)) self.floatspin.SetFormat(self.aguidata.get('format',"%f")) self.floatspin.SetDigits(self.aguidata.get('digits',2)) Base.setup(self, attribute, window, aguidata)
def apply(self, event=None): if self.applying: return self.applying = True self.item_selected() self.applying = False Base.apply( self, event)
def setup(self, attribute, window, aguidata): for child in self.control.GetChildren(): if isinstance(child, wx.TopLevelWindow): wx.CallAfter( child.Close) # aguidata.setdefault('background_color', self.defaultBackgroundColor) aguidata.setdefault('doc', "") aguidata.setdefault('label',' components') try: resetObject = self.object != window.object except: resetObject = True if resetObject: self.object = window.object # self.addTree.object = self.object self.editList.object = self.object try: selectComponent = self.editList.get_selected() except: selectComponent = None # try: # selectAddComponent = self.addTree.tree.GetStringValue() # except: # selectAddComponent = "" self.editList.refresh_components( selectComponent) # self.addTree.create_tree( self.object) # self.addTree.tree.SetStringValue( selectAddComponent) Base.setup(self, attribute, window, aguidata)
def __init__(self, attribute, window, aguidata={}, **kwargs): label = wx.Panel(window, style=0) #background color if not hasattr(self, 'defaultBackgroundColor'): backgroundColor = label.GetBackgroundColour() r = backgroundColor[0] g = backgroundColor[1] b = backgroundColor[2] r -= 30 g -= 30 b -= 30 if r < 0: r = 0 if g < 0: g = 0 if b < 0: b = 0 backgroundColor.Set(r, g, b) self.__class__.defaultBackgroundColor = backgroundColor #label if not hasattr(self, 'defaultFontSize'): dummyText = wx.StaticText(label) defaultFont = dummyText.GetFont() dummyText.Destroy() self.__class__.defaultFontSize = defaultFont.GetPointSize() aguidata.setdefault('font_size', self.defaultFontSize) font = wx.Font(aguidata['font_size'], wx.SWISS, wx.NORMAL, wx.FONTWEIGHT_BOLD) textSizer = AguiLabelSizer(parent=label, line=False, font=font) label.SetSizer(textSizer) label.textCtrl = textSizer.textCtrl # label.preferredWidth = textSizer.preferredWidth # FOR SASH aguidata.setdefault('label', attribute) kwargs['aguidata'] = aguidata kwargs['control_widget'] = label Base.__init__(self, '', window, **kwargs)
def setup(self, attribute, window, aguidata): #self.floatspin.SetRange( *self.aguidata.get('range',(None,None))) self.minval, self.maxval = self.aguidata.get('range', (None, None)) self.floatspin.SetIncrement(self.aguidata.get('increment', 0.1)) self.floatspin.SetFormat(self.aguidata.get('format', "%f")) self.floatspin.SetDigits(self.aguidata.get('digits', 2)) Base.setup(self, attribute, window, aguidata)
def setup(self, attribute, window, aguidata): for child in self.control.GetChildren(): if isinstance(child, wx.TopLevelWindow): wx.CallAfter(child.Close) # aguidata.setdefault('background_color', self.defaultBackgroundColor) aguidata.setdefault("doc", "") aguidata.setdefault("label", " components") try: resetObject = self.object != window.object except: resetObject = True if resetObject: self.object = window.object # self.addTree.object = self.object self.editList.object = self.object try: selectComponent = self.editList.get_selected() except: selectComponent = None # try: # selectAddComponent = self.addTree.tree.GetStringValue() # except: # selectAddComponent = "" self.editList.refresh_components(selectComponent) # self.addTree.create_tree( self.object) # self.addTree.tree.SetStringValue( selectAddComponent) Base.setup(self, attribute, window, aguidata)
def __init__(self, attribute, window, aguidata={}, **kwargs): #control control = wx.Panel(window) sizer = wx.BoxSizer(orient = wx.VERTICAL) self.sizer = sizer #edit editSizer = wx.BoxSizer(orient = wx.HORIZONTAL) sizer.Add(editSizer,flag=wx.EXPAND) # list of components on object editList = ComponentList(parent=control, size=WX_BUTTON_SIZE) editList.SetToolTipString("Components attached to object") editList.SetPopupMinWidth(100) editSizer.Add(editList, 1, wx.EXPAND, 5) self.editList = editList # edit button edit_image = wx.Bitmap(get_image_path("edit.png"), wx.BITMAP_TYPE_PNG) editButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=edit_image) # editButton.SetInitialSize((50,self.editList.Size[1])) editButton.SetToolTipString("Edit this component in a new window") editButton.Bind(wx.EVT_BUTTON, self.edit_button_click) self.editButton = editButton editSizer.Add(editButton, 0, wx.EAST) #delete remove_image = wx.Bitmap(get_image_path("delete.png"), wx.BITMAP_TYPE_PNG) removeButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=remove_image) removeButton.SetToolTipString("Remove this component from object") removeButton.Bind(wx.EVT_BUTTON, self.remove_button_click) editSizer.Add( removeButton,0, wx.EXPAND, 5) # add button add_image = wx.Bitmap(get_image_path("add.png"), wx.BITMAP_TYPE_PNG) addButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=add_image) # addButton.SetInitialSize(editButton.Size) addButton.SetToolTipString("Pick a component to add to this object") addButton.Bind(wx.EVT_BUTTON, self.add_button_click) editSizer.Add( addButton, 0, wx.EAST) control.SetSizer(sizer) control.SetMinSize((-1, -1)) sizer.SetMinSize((-1,-1)) sizer.Fit(control) # addTree.SetMinSize((1,self.addTree.Size[1])) editList.SetMinSize((1,self.editList.Size[1])) kwargs['aguidata'] = aguidata # kwargs['label_widget'] = label kwargs['control_widget'] = control Base.__init__(self, attribute, window, **kwargs) # keep the pug function around for button pressing # don't know if this is the right way to do it from pug.syswx.pugframe import PugFrame self.pugframe = PugFrame
def setup(self, attribute, window, aguidata): if self.aguidata != aguidata: self.control.Destroy() self.label.Destroy() self.__init__(attribute, window, aguidata) return else: Base.setup(self, attribute, window, aguidata)
def setup(self, attribute, window, aguidata): if self.aguidata != aguidata: self.control.Destroy() self.label.Destroy() self.__init__(attribute, window, aguidata) return else: Base.setup( self, attribute, window, aguidata)
def __init__(self, attribute, window, aguidata={}, **kwargs): # control control = wx.Panel(window) sizer = wx.BoxSizer(orient=wx.VERTICAL) self.sizer = sizer # edit editSizer = wx.BoxSizer(orient=wx.HORIZONTAL) sizer.Add(editSizer, flag=wx.EXPAND) # list of components on object editList = ComponentList(parent=control, size=WX_BUTTON_SIZE) editList.SetToolTipString("Components attached to object") editList.SetPopupMinWidth(100) editSizer.Add(editList, 1, wx.EXPAND, 5) self.editList = editList # edit button edit_image = wx.Bitmap(get_image_path("edit.png"), wx.BITMAP_TYPE_PNG) editButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=edit_image) # editButton.SetInitialSize((50,self.editList.Size[1])) editButton.SetToolTipString("Edit this component in a new window") editButton.Bind(wx.EVT_BUTTON, self.edit_button_click) self.editButton = editButton editSizer.Add(editButton, 0, wx.EAST) # delete remove_image = wx.Bitmap(get_image_path("delete.png"), wx.BITMAP_TYPE_PNG) removeButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=remove_image) removeButton.SetToolTipString("Remove this component from object") removeButton.Bind(wx.EVT_BUTTON, self.remove_button_click) editSizer.Add(removeButton, 0, wx.EXPAND, 5) # add button add_image = wx.Bitmap(get_image_path("add.png"), wx.BITMAP_TYPE_PNG) addButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=add_image) # addButton.SetInitialSize(editButton.Size) addButton.SetToolTipString("Pick a component to add to this object") addButton.Bind(wx.EVT_BUTTON, self.add_button_click) editSizer.Add(addButton, 0, wx.EAST) control.SetSizer(sizer) control.SetMinSize((-1, -1)) sizer.SetMinSize((-1, -1)) sizer.Fit(control) # addTree.SetMinSize((1,self.addTree.Size[1])) editList.SetMinSize((1, self.editList.Size[1])) kwargs["aguidata"] = aguidata # kwargs['label_widget'] = label kwargs["control_widget"] = control Base.__init__(self, attribute, window, **kwargs) # keep the pug function around for button pressing # don't know if this is the right way to do it from pug.syswx.pugframe import PugFrame self.pugframe = PugFrame
def setup(self, attribute, window, aguidata): if aguidata != self.aguidata: self.control.Destroy() self.label.Destroy() self.__init__( attribute, window, aguidata) return else: self.setup_buttons( window.object) self.set_control_value( window.object) Base.setup( self, attribute, window, aguidata)
def setup(self, attribute, window, aguidata): if aguidata != self.aguidata: self.control.Destroy() self.label.Destroy() self.__init__(attribute, window, aguidata) return else: self.setup_buttons(window.object) self.set_control_value(window.object) Base.setup(self, attribute, window, aguidata)
def apply(self, event=None): self.fix() if self.aguidata.get('adjust_digits', False): value = self.floatspin.GetValue() f = prettify_float(value) precision = len(f) - f.find('.') - 1 if precision > self.floatspin.GetDigits(): self.floatspin.SetDigits(precision) Base.apply(self, event) self.floatspin.GetTextCtrl().SetSelection(0, 0)
def apply(self, event=None): self.fix() if self.aguidata.get('adjust_digits', False): value = self.floatspin.GetValue() f = prettify_float(value) precision = len(f) - f.find('.') - 1 if precision > self.floatspin.GetDigits(): self.floatspin.SetDigits(precision) Base.apply(self, event) self.floatspin.GetTextCtrl().SetSelection(0,0)
def __init__(self, attribute, window, aguidata={}, **kwargs): control = wx.Panel(window) sizer = wx.BoxSizer(orient=wx.VERTICAL) control.SetSizer(sizer) floatspin = FS.FloatSpin(control, agwStyle=FS.FS_LEFT) sizer.Add(floatspin, 1, flag=wx.EXPAND) floatspin.Bind(wx.EVT_TEXT_ENTER, self.enter) floatspin.GetTextCtrl().Bind(wx.EVT_SET_FOCUS, self.enter) floatspin.GetTextCtrl().Bind(wx.EVT_KILL_FOCUS, self.exit) floatspin.Bind(FS.EVT_FLOATSPIN, self.apply) self.floatspin = floatspin kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata={}, **kwargs): control = wx.Panel(window) sizer = wx.BoxSizer(orient=wx.VERTICAL) control.SetSizer(sizer) floatspin = FS.FloatSpin(control, agwStyle = FS.FS_LEFT) sizer.Add(floatspin,1,flag=wx.EXPAND) floatspin.Bind(wx.EVT_TEXT_ENTER, self.enter) floatspin.GetTextCtrl().Bind(wx.EVT_SET_FOCUS, self.enter) floatspin.GetTextCtrl().Bind(wx.EVT_KILL_FOCUS, self.exit) floatspin.Bind(FS.EVT_FLOATSPIN, self.apply) self.floatspin = floatspin kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def item_selected(self, event=None): if self.allow_typing and \ self.listctrl.GetStringValue() != self.control.Value: self.data = self.control.Value self.text = self.control.Value else: self.data = self.listctrl.GetSelectedData() self.text = self.listctrl.GetStringValue() if not self.applying: Base.apply( self) if self.callback: self.callback(self.text, self.data) self.set_tooltip()
def setup(self, attribute, window, aguidata): aguidata['control_only'] = True fontsize = aguidata.get('font_size', self.defaultFontSize) if fontsize != self.aguidata.get('font_size', self.defaultFontSize): self.control.Destroy() self.label.Destroy() self.__init__(attribute, window, aguidata) return if attribute: aguidata.setdefault('label', attribute) labelText = aguidata.get('label', '') self.control.textCtrl.SetLabel(labelText) aguidata.setdefault('background_color', self.defaultBackgroundColor) Base.setup(self, '', window, aguidata)
def __init__(self, attribute, window, aguidata={}, **kwargs): control = wx.Panel(window) sizer = wx.BoxSizer(orient=wx.VERTICAL) control.SetSizer(sizer) textEntry = wx.TextCtrl( control) # textEntry.SetMinSize((-1, WX_STANDARD_HEIGHT)) sizer.Add(textEntry,1,flag=wx.EXPAND) textEntry.Bind(wx.EVT_TEXT_ENTER, self.apply) textEntry.Bind(wx.EVT_KILL_FOCUS, self.apply) self.textEntry = textEntry # textEntry = AguiTextCtrl( window) # control = textEntry kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata, **kwargs): control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT)) sizer = wx.BoxSizer(orient=wx.VERTICAL) picker = wx.FontPickerCtrl(control) # checkbox.Bind(wx.EVT_CHECKBOX, self.apply) # checkbox.Bind(wx.EVT_SET_FOCUS, self.focus) # checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus) self.picker = picker # line = wx.StaticLine(control) sizer.Add(picker,1) # sizer.Add(line,flag=wx.EXPAND) control.SetSizer(sizer) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata, **kwargs): control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT)) sizer = wx.BoxSizer(orient=wx.VERTICAL) picker = wx.FontPickerCtrl(control) # checkbox.Bind(wx.EVT_CHECKBOX, self.apply) # checkbox.Bind(wx.EVT_SET_FOCUS, self.focus) # checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus) self.picker = picker # line = wx.StaticLine(control) sizer.Add(picker, 1) # sizer.Add(line,flag=wx.EXPAND) control.SetSizer(sizer) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata, **kwargs): control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT)) sizer = wx.BoxSizer(orient=wx.VERTICAL) checkbox = wx.CheckBox(control, -1, label=" ") checkbox.Bind(wx.EVT_CHECKBOX, self.apply) # checkbox.Bind(wx.EVT_SET_FOCUS, self.focus) # checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus) self.checkbox = checkbox line = wx.StaticLine(control) sizer.Add(checkbox, 1, flag=wx.LEFT, border=5) sizer.Add(line, flag=wx.EXPAND) control.SetSizer(sizer) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def lost_focus(self, event=None): if self.allow_typing and \ self.listctrl.GetStringValue() != self.control.Value: self.data = self.control.Value self.text = self.control.Value elif not self.listctrl.didSelect: try: self.control.SetValue(self.control.GetValue()) except: pass return Base.apply( self) if self.callback: self.callback(self.text, self.data) self.control.SetValue(self.control.GetValue())
def __init__(self, attribute, window, aguidata, **kwargs): control = wx.Panel(window, size=wx.Size(30, WX_STANDARD_HEIGHT)) sizer = wx.BoxSizer(orient=wx.VERTICAL) checkbox = wx.CheckBox(control, -1, label=" ") checkbox.Bind(wx.EVT_CHECKBOX, self.apply) # checkbox.Bind(wx.EVT_SET_FOCUS, self.focus) # checkbox.Bind(wx.EVT_KILL_FOCUS, self.unfocus) self.checkbox = checkbox line = wx.StaticLine(control) sizer.Add(checkbox,1,flag=wx.LEFT, border=5) sizer.Add(line,flag=wx.EXPAND) control.SetSizer(sizer) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def setup(self, attribute, window, aguidata): if self.allow_typing != aguidata.get('allow_typing', False): self.control.Destroy() self.label.Destroy() self.__init__( attribute, window, aguidata) return if _DEBUG: print "DropDown.setup attribute:",attribute self.callback = aguidata.get('callback', None) self.sort = aguidata.get('sort', True) self.list_generator = aguidata.get('list_generator', None) if self.list_generator: self.listctrl.SetPopupCallback(self.setup_listctrl) else: self.listctrl.SetPopupCallback(None) Base.setup(self, attribute, window, aguidata) self.setup_listctrl(self.aguidata.get('list',[])) self.set_control_value(self.get_attribute_value())
def __init__(self, attribute, window, aguidata, **kwargs): """__init__(self, attribute, window, aguidata, **kwargs) special aguidata entries: 'routine': the callable object that will be used. This is as an alternative to the attribute argument. 'use_defaults': execute routine using all default args if possible 'no_return_popup': if this is true, don't show a return value popup 'show_parens': if True, show parenthesis even if method has no arguments See Base attribute gui for other argument info """ control = wx.Panel(window, size = (1,WX_STANDARD_HEIGHT)) control.SetMinSize((-1,WX_STANDARD_HEIGHT)) #widgets runButton = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) infoText = wx.StaticText(control) infoText.SetMinSize((-1,infoText.Size[1])) line = wx.StaticLine(control, style = 0) self.runButton = runButton self.infoText = infoText # sizers textSizer = wx.BoxSizer(orient=wx.VERTICAL) textSizer.AddSpacer((1,WX_TEXTEDIT_LABEL_YOFFSET)) textSizer.Add(infoText, 1) textSizer.Add(line, flag = wx.EXPAND | wx.BOTTOM) controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) control.SetSizer(controlSizer) controlSizer.Add(runButton) controlSizer.AddSpacer((3,3)) controlSizer.Add(textSizer,1,wx.EXPAND) control.sizer = controlSizer control.textSizer = textSizer kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs) from pug.syswx.pugframe import pug_frame self.pug_frame = pug_frame
def __init__(self, attribute, window, aguidata={}, **kwargs): style = wx.TE_PROCESS_ENTER if aguidata.get('allow_typing', False): self.allow_typing = True else: self.allow_typing = False style |= wx.CB_READONLY control = wx.combo.ComboCtrl(parent=window, style=style) if _DEBUG: print "DropDown.__init__ attribute:",attribute control.SetMinSize((1,WX_STANDARD_HEIGHT)) listctrl = ListCtrlComboPopup() self.listctrl = listctrl control.SetPopupControl(self.listctrl) self.listctrl.SetSelectCallback(self.item_selected) control.Bind(wx.EVT_TEXT_ENTER, self.item_selected) control.Bind(wx.EVT_KILL_FOCUS, self.lost_focus) control.Bind(wx.EVT_KEY_DOWN, self.OnKey) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata={}, **kwargs): aguidata.setdefault('view_button',False)#,True) aguidata.setdefault('new_view_button',True) #widgets control = wx.Panel(window, size=(1,WX_STANDARD_HEIGHT)) control.SetMinSize((-1,WX_STANDARD_HEIGHT)) controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) obj = getattr(window.object,attribute) control.value = obj if aguidata['new_view_button']: new_view_button = PugButton(control, obj, True, attribute, window) controlSizer.Add(new_view_button) self.new_view_button = new_view_button self.new_view_button.Bind(wx.EVT_BUTTON, self.evt_view) elif self.new_view_button: self.new_view_button.Destroy() if aguidata['view_button']: view_button = PugButton(control, obj, False, attribute, window) self.view_button = view_button controlSizer.Add(view_button) self.view_button.Bind(wx.EVT_BUTTON, self.evt_view) elif self.view_button: self.view_button.Destroy() textSizer = AguiLabelSizer(control) infoText = textSizer.textCtrl self.infoText = infoText self.textSizer = textSizer # sizers control.SetSizer(controlSizer) controlSizer.AddSpacer((3,3)) controlSizer.AddSizer(textSizer,1,wx.EXPAND) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata, **kwargs): """__init__(self, attribute, window, aguidata, **kwargs) special aguidata entries: 'routine': the callable object that will be used. This is as an alternative to the attribute argument. 'use_defaults': execute routine using all default args if possible 'no_return_popup': if this is true, don't show a return value popup 'show_parens': if True, show parenthesis even if method has no arguments See Base attribute gui for other argument info """ control = wx.Panel(window, size=(1, WX_STANDARD_HEIGHT)) control.SetMinSize((-1, WX_STANDARD_HEIGHT)) #widgets runButton = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) infoText = wx.StaticText(control) infoText.SetMinSize((-1, infoText.Size[1])) line = wx.StaticLine(control, style=0) self.runButton = runButton self.infoText = infoText # sizers textSizer = wx.BoxSizer(orient=wx.VERTICAL) textSizer.AddSpacer((1, WX_TEXTEDIT_LABEL_YOFFSET)) textSizer.Add(infoText, 1) textSizer.Add(line, flag=wx.EXPAND | wx.BOTTOM) controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) control.SetSizer(controlSizer) controlSizer.Add(runButton) controlSizer.AddSpacer((3, 3)) controlSizer.Add(textSizer, 1, wx.EXPAND) control.sizer = controlSizer control.textSizer = textSizer kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs) from pug.syswx.pugframe import pug_frame self.pug_frame = pug_frame
def __init__(self, attribute, window, aguidata={}, **kwargs): aguidata.setdefault('view_button', False) #,True) aguidata.setdefault('new_view_button', True) #widgets control = wx.Panel(window, size=(1, WX_STANDARD_HEIGHT)) control.SetMinSize((-1, WX_STANDARD_HEIGHT)) controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) obj = getattr(window.object, attribute) control.value = obj if aguidata['new_view_button']: new_view_button = PugButton(control, obj, True, attribute, window) controlSizer.Add(new_view_button) self.new_view_button = new_view_button self.new_view_button.Bind(wx.EVT_BUTTON, self.evt_view) elif self.new_view_button: self.new_view_button.Destroy() if aguidata['view_button']: view_button = PugButton(control, obj, False, attribute, window) self.view_button = view_button controlSizer.Add(view_button) self.view_button.Bind(wx.EVT_BUTTON, self.evt_view) elif self.view_button: self.view_button.Destroy() textSizer = AguiLabelSizer(control) infoText = textSizer.textCtrl self.infoText = infoText self.textSizer = textSizer # sizers control.SetSizer(controlSizer) controlSizer.AddSpacer((3, 3)) controlSizer.AddSizer(textSizer, 1, wx.EXPAND) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata={}, **kwargs): control = wx.Panel(window) sizer = wx.BoxSizer(orient=wx.VERTICAL) control.SetSizer(sizer) style = 0 if aguidata.get('text_control', True): style = style | wx.CLRP_USE_TEXTCTRL if aguidata.get('show_label', False): style = style | wx.CLRP_SHOW_LABEL colorPicker = wx.ColourPickerCtrl( control, style=style) if aguidata.get('text_control', False): colorPicker.SetTextCtrlProportion( 1) # textEntry.SetMinSize((-1, WX_STANDARD_HEIGHT)) sizer.Add(colorPicker,1,flag=wx.EXPAND) colorPicker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.apply) colorPicker.Bind(wx.EVT_KILL_FOCUS, self.apply) self.colorPicker = colorPicker # textEntry = AguiTextCtrl( window) # control = textEntry kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata={}, **kwargs): control = wx.Panel(window) sizer = wx.BoxSizer(orient=wx.VERTICAL) control.SetSizer(sizer) style = 0 if aguidata.get('text_control', True): style = style | wx.CLRP_USE_TEXTCTRL if aguidata.get('show_label', False): style = style | wx.CLRP_SHOW_LABEL colorPicker = wx.ColourPickerCtrl(control, style=style) if aguidata.get('text_control', False): colorPicker.SetTextCtrlProportion(1) # textEntry.SetMinSize((-1, WX_STANDARD_HEIGHT)) sizer.Add(colorPicker, 1, flag=wx.EXPAND) colorPicker.Bind(wx.EVT_COLOURPICKER_CHANGED, self.apply) colorPicker.Bind(wx.EVT_KILL_FOCUS, self.apply) self.colorPicker = colorPicker # textEntry = AguiTextCtrl( window) # control = textEntry kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def refresh(self, event=None): Base.refresh(self, event) self.set_control_value(self.control.value)
def __init__(self, attribute, window, aguidata ={}, **kwargs): #widgets control = wx.Panel(window, size=(1,WX_STANDARD_HEIGHT)) control.SetMinSize((-1, WX_STANDARD_HEIGHT)) controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) control.SetSizer(controlSizer) try: rewind_image = wx.Bitmap(get_image_path("rewind.png"), wx.BITMAP_TYPE_PNG) except: rewind_image = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: play_image = wx.Bitmap(get_image_path("play.png"), wx.BITMAP_TYPE_PNG) except: play_image = wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: pause_image = wx.Bitmap(get_image_path("pause.png"), wx.BITMAP_TYPE_PNG) except: pause_image = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: stop_image = wx.Bitmap(get_image_path("stop.png"), wx.BITMAP_TYPE_PNG) except: stop_image = wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: execute_image = wx.Bitmap(get_image_path("execute.png"), wx.BITMAP_TYPE_PNG) except: execute_image = wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: fast_forward_image = wx.Bitmap(get_image_path("fast_forward.png"), wx.BITMAP_TYPE_PNG) except: fast_forward_image = wx.ArtProvider.GetBitmap(wx.ART_REDO, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) buttonOrder = ['rewind', 'play', 'pause', 'stop', 'fast_forward', 'execute'] infoDict = { 'rewind':('Rewind', rewind_image), 'play':('Play', play_image), 'pause':('Pause', pause_image), 'stop':('Stop', stop_image), 'fast_forward':('Fast Forward', fast_forward_image), 'execute':('Execute in separate process', execute_image), } self.functionDict = {} self.buttonDict = {} for item in buttonOrder: info = infoDict[item] self.buttonDict[item] = None if not aguidata.has_key(item): continue if isroutine(aguidata[item]): func = aguidata[item] else: func = getattr( window.object, aguidata[item], None) if not isroutine(func): continue if item == 'play': button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) self.playbutton = button elif item == 'pause': button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) self.pausebutton = button button.Enable(False) else: button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) button.type = item self.buttonDict[item] = button # print info[1].Ok(), info[1] button.SetBitmapLabel(info[1]) self.functionDict[button] = func button.SetToolTipString(info[0]) control.Bind(wx.EVT_BUTTON, self.button_press, button) controlSizer.Add( button) line = AguiLabelSizer(control, ' ') controlSizer.Add(line, 1, wx.EXPAND) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def setup(self, attribute, window, aguidata): aguidata.setdefault('do_typecast',True) Base.setup(self, attribute, window, aguidata)
def apply(self, event=None): Base.apply(self, event) self.textEntry.select_all()
def setup(self, attribute, window, aguidata): Base.setup(self, attribute, window, aguidata)
def setup(self, attribute, window, aguidata): use_defaults = aguidata.get('use_defaults', False) # check if the callable is provided or if it's a true attribute if aguidata.get('routine', False): value = aguidata['routine'] self.routine = value if not aguidata.get('label', None): if attribute: aguidata['label'] = attribute else: aguidata['label'] = self.routine.__name__ attribute = '' else: value = getattr(window.object,attribute, None) isMethod = bool(ismethod(value) and value.im_self) doc = None if aguidata.has_key('doc'): doc = aguidata['doc'] else: doc = getdoc(value) if doc: aguidata['doc'] = doc # analyze the routine's arguments if callable(value): self.takesargs = False self.needsargs = False self.notpython = False try: argspec = getargspec(value) except: self.notpython = True arguments = "?args unknown?" else: arglist = [] if isMethod and len(argspec[0]): argspec[0].pop(0) if argspec[0]: self.takesargs = True mainargs = [] for arg in argspec[0]: if type(arg) in StringTypes: mainargs.append(arg) else: try: l = ''.join(["(",arg[0]]) for item in arg[1:]: l = ''.join([l,", ",item]) l = ''.join([l,")"]) mainargs.append(l) except: mainargs.append(repr(arg)) if argspec[3]: argcount = len(argspec[0]) if argcount < len(argspec[3]): self.needsargs = True for idx in range(argcount): kwidx = idx - (argcount - len(argspec[3])) if kwidx >= 0: mainargs[idx] = ''.join([mainargs[idx], '=',repr(argspec[3][kwidx])]) arglist += mainargs if argspec[1]: arglist += [''.join([ '*',argspec[1]])] self.takesargs = True if argspec[2]: arglist += [''.join([ '**',argspec[2]])] self.takesargs = True arguments = ', '.join(arglist) arguments = ''.join(["(",arguments,")"]) else: arguments = "?Not Callable?" self.arguments = arguments if (self.takesargs or self.notpython) and \ not(use_defaults and not self.needsargs): bmp = wx.ART_HELP_SIDE_PANEL if doc: tooltip = doc else: tooltip = "Enter arguments" fn = self.openExecuteWindow else: bmp = wx.ART_GO_FORWARD if doc: tooltip = doc else: tooltip = "Execute" fn = self.execute if self.aguidata.get('show_parens',False): arguments = '( )' else: arguments = '' buttonSize=WX_BUTTON_BMP_SIZE run_bmp = wx.ArtProvider.GetBitmap(bmp, wx.ART_TOOLBAR, buttonSize) self.runButton.SetBitmapLabel(run_bmp) self.runButton.SetToolTipString(tooltip) self.control.Unbind(wx.EVT_BUTTON, self.runButton) self.control.Bind(wx.EVT_BUTTON, fn, self.runButton) self.infoText.SetLabel( arguments) Base.setup(self, attribute, window, aguidata)
def __init__(self, attribute, window, aguidata={}, **kwargs): #widgets control = wx.Panel(window, size=(1, WX_STANDARD_HEIGHT)) control.SetMinSize((-1, WX_STANDARD_HEIGHT)) controlSizer = wx.BoxSizer(orient=wx.HORIZONTAL) control.SetSizer(controlSizer) try: rewind_image = wx.Bitmap(get_image_path("rewind.png"), wx.BITMAP_TYPE_PNG) except: rewind_image = wx.ArtProvider.GetBitmap(wx.ART_UNDO, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: play_image = wx.Bitmap(get_image_path("play.png"), wx.BITMAP_TYPE_PNG) except: play_image = wx.ArtProvider.GetBitmap(wx.ART_GO_FORWARD, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: pause_image = wx.Bitmap(get_image_path("pause.png"), wx.BITMAP_TYPE_PNG) except: pause_image = wx.ArtProvider.GetBitmap(wx.ART_WARNING, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: stop_image = wx.Bitmap(get_image_path("stop.png"), wx.BITMAP_TYPE_PNG) except: stop_image = wx.ArtProvider.GetBitmap(wx.ART_CROSS_MARK, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: execute_image = wx.Bitmap(get_image_path("execute.png"), wx.BITMAP_TYPE_PNG) except: execute_image = wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) try: fast_forward_image = wx.Bitmap(get_image_path("fast_forward.png"), wx.BITMAP_TYPE_PNG) except: fast_forward_image = wx.ArtProvider.GetBitmap( wx.ART_REDO, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) buttonOrder = [ 'rewind', 'play', 'pause', 'stop', 'fast_forward', 'execute' ] infoDict = { 'rewind': ('Rewind', rewind_image), 'play': ('Play', play_image), 'pause': ('Pause', pause_image), 'stop': ('Stop', stop_image), 'fast_forward': ('Fast Forward', fast_forward_image), 'execute': ('Execute in separate process', execute_image), } self.functionDict = {} self.buttonDict = {} for item in buttonOrder: info = infoDict[item] self.buttonDict[item] = None if not aguidata.has_key(item): continue if isroutine(aguidata[item]): func = aguidata[item] else: func = getattr(window.object, aguidata[item], None) if not isroutine(func): continue if item == 'play': button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) self.playbutton = button elif item == 'pause': button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) self.pausebutton = button button.Enable(False) else: button = wx.BitmapButton(control, -1, size=WX_BUTTON_SIZE) button.type = item self.buttonDict[item] = button # print info[1].Ok(), info[1] button.SetBitmapLabel(info[1]) self.functionDict[button] = func button.SetToolTipString(info[0]) control.Bind(wx.EVT_BUTTON, self.button_press, button) controlSizer.Add(button) line = AguiLabelSizer(control, ' ') controlSizer.Add(line, 1, wx.EXPAND) kwargs['control_widget'] = control Base.__init__(self, attribute, window, aguidata, **kwargs)
def __init__(self, attribute, window, aguidata={}, **kwargs): #label label = wx.Panel(window, style=0) # if not hasattr(self, 'defaultBackgroundColor'): # defaultBackgroundColor = label.GetBackgroundColour() # r = defaultBackgroundColor[0] - 10 # g = defaultBackgroundColor[1] - 10 # b = defaultBackgroundColor[2] - 10 # if r < 0: r = 0 # if g < 0: g = 0 # if b < 0: b = 0 # defaultBackgroundColor.Set(r,g,b) # self.__class__.defaultBackgroundColor = defaultBackgroundColor labelAreaSizer = wx.BoxSizer(orient=wx.VERTICAL) textSizer = AguiLabelSizer(parent=label, line=False) labelAreaSizer.AddSizer(textSizer, 0, wx.TOP, 1) availSizer = AguiLabelSizer(parent=label, line=True, label='available:') availSizer.textCtrl.SetWindowStyleFlag(wx.TE_RIGHT) availSizer.textCtrl.SetForegroundColour('gray') labelAreaSizer.AddSizer(availSizer, 1, wx.EXPAND | wx.TOP, 6) label.SetSizer(labelAreaSizer) label.textCtrl = textSizer.textCtrl #control control = wx.Panel(window) sizer = wx.BoxSizer(orient=wx.VERTICAL) self.sizer = sizer #edit editSizer = wx.BoxSizer(orient=wx.HORIZONTAL) sizer.Add(editSizer, flag=wx.EXPAND) # list of components on object editList = ComponentList(parent=control, size=WX_BUTTON_SIZE) editList.SetToolTipString("Components attached to object") editList.SetPopupMinWidth(100) editSizer.Add(editList, 1) self.editList = editList # edit editButton = buttons.ThemedGenButton(control, label='Edit') editButton.SetInitialSize((50, self.editList.Size[1])) editButton.SetToolTipString("Edit this component in a new window") editButton.Bind(wx.EVT_BUTTON, self.edit_button_click) self.editButton = editButton editSizer.Add(editButton, 0, wx.EAST, 5) #delete bmp = wx.ArtProvider.GetBitmap(wx.ART_DELETE, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) removeButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=bmp) removeButton.SetToolTipString("Remove this component from object") removeButton.Bind(wx.EVT_BUTTON, self.remove_button_click) editSizer.Add(removeButton, 0) #add addSizer = wx.BoxSizer(orient=wx.HORIZONTAL) sizer.Add(addSizer, flag=wx.EXPAND) # tree of available components addTree = ComponentAddTree(parent=control) addTree.SetPopupMinWidth(150) addTree.SetToolTipString("Component to add") addSizer.Add(addTree, 1) self.addTree = addTree # add button addButton = buttons.ThemedGenButton(control, label='Add', style=wx.BU_EXACTFIT) addButton.SetInitialSize(editButton.Size) addButton.SetToolTipString("Add selected component") addButton.Bind(wx.EVT_BUTTON, self.add_button_click) addSizer.Add(addButton, 0, wx.EAST, 5) # browse button bmp = wx.ArtProvider.GetBitmap(wx.ART_HELP_BOOK, wx.ART_TOOLBAR, WX_BUTTON_BMP_SIZE) browseButton = wx.BitmapButton(control, size=WX_BUTTON_SIZE, bitmap=bmp) browseButton.SetToolTipString("Browse available components") addSizer.Add(browseButton, 0) browseButton.Bind(wx.EVT_BUTTON, self.open_browser) # won't let me size normally!? #growertest # pane = control # button = wx.Button(pane, label='fakeass') # button.Bind(wx.EVT_BUTTON, self.expander_click) # button2 = wx.Button(pane, label='hider') # self.subButton = button2 # sizer.AddMany( [(button), (button2)]) # self.expanded = True control.SetSizer(sizer) control.SetMinSize((-1, -1)) sizer.SetMinSize((-1, -1)) sizer.Fit(control) addTree.SetMinSize((1, self.addTree.Size[1])) editList.SetMinSize((1, self.editList.Size[1])) kwargs['aguidata'] = aguidata kwargs['label_widget'] = label kwargs['control_widget'] = control Base.__init__(self, attribute, window, **kwargs) # keep the pug function around for button pressing # don't know if this is the right way to do it from pug.syswx.pugframe import PugFrame self.pug = PugFrame
def setup(self, attribute, window, aguidata): aguidata.setdefault('do_typecast', True) Base.setup(self, attribute, window, aguidata)
def setup(self, attribute, window, aguidata): use_defaults = aguidata.get('use_defaults', False) # check if the callable is provided or if it's a true attribute if aguidata.get('routine', False): value = aguidata['routine'] self.routine = value if not aguidata.get('label', None): if attribute: aguidata['label'] = attribute else: aguidata['label'] = self.routine.__name__ attribute = '' else: value = getattr(window.object, attribute, None) isMethod = bool(ismethod(value) and value.im_self) doc = None if aguidata.has_key('doc'): doc = aguidata['doc'] else: doc = getdoc(value) if doc: aguidata['doc'] = doc # analyze the routine's arguments if callable(value): self.takesargs = False self.needsargs = False self.notpython = False try: argspec = getargspec(value) except: self.notpython = True arguments = "?args unknown?" else: arglist = [] if isMethod and len(argspec[0]): argspec[0].pop(0) if argspec[0]: self.takesargs = True mainargs = [] for arg in argspec[0]: if type(arg) in StringTypes: mainargs.append(arg) else: try: l = ''.join(["(", arg[0]]) for item in arg[1:]: l = ''.join([l, ", ", item]) l = ''.join([l, ")"]) mainargs.append(l) except: mainargs.append(repr(arg)) if argspec[3]: argcount = len(argspec[0]) if argcount < len(argspec[3]): self.needsargs = True for idx in range(argcount): kwidx = idx - (argcount - len(argspec[3])) if kwidx >= 0: mainargs[idx] = ''.join([ mainargs[idx], '=', repr(argspec[3][kwidx]) ]) arglist += mainargs if argspec[1]: arglist += [''.join(['*', argspec[1]])] self.takesargs = True if argspec[2]: arglist += [''.join(['**', argspec[2]])] self.takesargs = True arguments = ', '.join(arglist) arguments = ''.join(["(", arguments, ")"]) else: arguments = "?Not Callable?" self.arguments = arguments if (self.takesargs or self.notpython) and \ not(use_defaults and not self.needsargs): bmp = wx.ART_HELP_SIDE_PANEL if doc: tooltip = doc else: tooltip = "Enter arguments" fn = self.openExecuteWindow else: bmp = wx.ART_GO_FORWARD if doc: tooltip = doc else: tooltip = "Execute" fn = self.execute if self.aguidata.get('show_parens', False): arguments = '( )' else: arguments = '' buttonSize = WX_BUTTON_BMP_SIZE run_bmp = wx.ArtProvider.GetBitmap(bmp, wx.ART_TOOLBAR, buttonSize) self.runButton.SetBitmapLabel(run_bmp) self.runButton.SetToolTipString(tooltip) self.control.Unbind(wx.EVT_BUTTON, self.runButton) self.control.Bind(wx.EVT_BUTTON, fn, self.runButton) self.infoText.SetLabel(arguments) Base.setup(self, attribute, window, aguidata)