def builder(parent, index): "factory function for EditBitmapButton objects" name = parent.toplevel_parent.get_next_contained_name('bitmap_button_%d') bitmap = misc.RelativeFileSelector("Select the image for the button") with parent.frozen(): editor = EditBitmapButton(name, parent, index, bitmap) editor.check_defaults() if parent.widget: editor.create() return editor
def builder(parent, index, bitmap=None): "factory function for EditStaticBitmap objects" name = parent.toplevel_parent.get_next_contained_name('bitmap_%d') if bitmap is None: bitmap = misc.RelativeFileSelector("Select the image") if bitmap is None: return with parent.frozen(): editor = EditStaticBitmap(name, parent, index, bitmap) editor.properties["style"].set_to_default() editor.check_defaults() if parent.widget: editor.create() return editor
def _select_bitmap(self, event, colname, title): control = getattr(self, colname) current = control.GetValue() directory = os.path.split(current) if os.path.isdir(current): directory = current current = '' elif directory and os.path.isdir(directory[0]): current = directory[1] directory = directory [0] elif common.root.filename: #directory = self.startDirectory directory = common.root.filename current = "" else: directory = "" value = misc.RelativeFileSelector(title, directory, current, wildcard="*.*", flags=wx.FD_OPEN) if value: control.SetValue(value)