Beispiel #1
0
    def __init__(self, name, klass, parent, id):
        EditBase.__init__(self, name, klass, parent, id)

        self.window_id = np.TextPropertyD("wxID_ANY",
                                          name="id",
                                          default_value=None)
        self.size = np.SizePropertyD("-1, -1", default_value="-1, -1")

        self.sel_marker = None  # selection markers (a SelectionMarker instance)

        # background, foreground, font properties
        # their actual values will be stored/modified after widget creation in 'finish_widget_creation'
        # before that, the actual values will be stored in this dict from the actual values of the widget:
        self._original = {'font': None}
        # colors
        self.background = np.ColorPropertyD(None)
        self.foreground = np.ColorPropertyD(None)
        # font
        if "font" in self.PROPERTIES:
            self._font_changed = False  # this is True if the user has selected a custom font
            if config.use_gui:
                font = self._build_from_font(
                    compat.wx_SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT))
                font[1] = 'default'
            else:
                font = (9, 'default', 'normal', 'normal', 0, 'Segoe UI')
            self.font = np.FontPropertyD(tuple(font))

        # tooltip, focused, hiden
        self.tooltip = np.TextPropertyD(multiline="grow")
        self.disabled = np.CheckBoxProperty(False, default_value=False)
        self.focused = np.CheckBoxProperty(False, default_value=False)
        self.hidden = np.CheckBoxProperty(False, default_value=False)
Beispiel #2
0
    def __init__(self, name, klass, parent, id, custom_class=True):
        np.PropertyOwner.__init__(self)
        # initialise instance logger
        self._logger = logging.getLogger(self.__class__.__name__)

        # initialise instance
        self.parent = parent
        self.id = id          # id used for internal purpose events

        # initialise instance properties
        self.name  = name_p  = np.NameProperty(name)
        self.classname = klass
        self.klass = klass_p = np.ClassProperty(klass, name="class") # Name of the object's class: read/write or read only
        if not custom_class: klass_p.readonly = True  # only used for StatusBar, ToolBar and also non-standalone MenuBar

        # Name of object's wxWidget class; base and klass are mostly the same, except e.g. wxDialog:
        self.base = klass  # not editable; e.g. wxFrame or wxComboBox; used to find the code generator
        # If true, the user can change the value of the 'class' property:
        self.custom_class = custom_class

        if getattr(self, '_custom_base_classes', False):
            self.custom_base = np.TextPropertyD("", multiline=False, default_value=None)
        else:
            self.custom_base = None

        self.extracode       = np.CodeProperty()
        self.extracode_pre   = np.CodeProperty()
        self.extracode_post  = np.CodeProperty()
        self.extraproperties = np.ExtraPropertiesProperty()

        self.widget = None  # this is the reference to the actual wxWindow widget, created when required
        self._dont_destroy = False

        EventsMixin.__init__(self)
Beispiel #3
0
    def __init__(self, name, klass, parent, id, sizer, pos):
        ManagedBase.__init__(self, name, klass, parent, id, sizer, pos)

        # initialise instance properties
        cols      = [('Arguments', np.GridProperty.STRING)]
        self.arguments   = ArgumentsProperty( [], cols )
        self.custom_ctor = np.TextPropertyD("", name="custom_constructor", strip=True, default_value="")
    def __init__(self, name, klass, parent, id, sizer, pos):
        ManagedBase.__init__(self, name, klass, parent, id, sizer, pos)

        # initialise instance properties
        arguments = [['$parent'], ['$id']]  # ,['$width'],['$height']]
        cols = [('Arguments', np.GridProperty.STRING)]
        self.arguments = ArgumentsProperty(arguments, cols)
        self.custom_ctor = np.TextPropertyD("",
                                            name="custom_constructor",
                                            strip=True)
Beispiel #5
0
    def __init__(self, name, parent, pos):
        # initialize base classes
        ManagedBase.__init__(self, name, 'wxSearchCtrl', parent, pos)
        EditStylesMixin.__init__(self)

        # initialize instance properties
        self.value = np.TextProperty("")
        self.descriptive_text = np.TextPropertyD("Search", default_value="")
        self.search_button = np.CheckBoxProperty(True, default_value=True)
        self.cancel_button = np.CheckBoxProperty(True, default_value=True)
        self.max_length = np.SpinPropertyD(80, val_range=(1,1000), default_value=-1)
Beispiel #6
0
    def __init__(self, name, parent, index, instance_class=None):
        ManagedBase.__init__(self, name, parent, index, instance_class
                             or "wxWindow")
        self.properties["instance_class"].deactivated = None

        # initialise instance properties
        cols = [('Arguments', np.GridProperty.STRING)]
        self.arguments = ArgumentsProperty([], cols)
        self.custom_ctor = np.TextPropertyD("",
                                            name="custom_constructor",
                                            strip=True,
                                            default_value="")
Beispiel #7
0
    def __init__(self, name, parent, index, instance_class=None):
        ManagedBase.__init__(self, name, parent, index, instance_class or "wxWindow")
        self.properties["instance_class"].deactivated = None

        # initialise instance properties
        cols      = [('Arguments', np.GridProperty.STRING)]
        self.arguments   = ArgumentsProperty( [], cols )
        self.custom_ctor = np.TextPropertyD("", name="custom_constructor", strip=True, default_value="")

        self.show_design = np.CheckBoxProperty(False, default_value=False)
        self.show_preview = np.CheckBoxProperty(False, default_value=False)
        if not config.preferences.allow_custom_widgets:
            self.properties["show_design"].set_blocked()
            self.properties["show_preview"].set_blocked()
        self._error_message = None  # when there's an error message due to the previous option
    def __init__(self, name, klass, parent, id, custom_class=True):
        np.PropertyOwner.__init__(self)
        # initialise instance logger
        self._logger = logging.getLogger(self.__class__.__name__)

        # initialise instance
        self.parent = parent
        self.id = id  # id used for internal purpose events

        # initialise instance properties
        self.name = name_p = np.NameProperty(name)
        self.klass = klass_p = np.TextProperty(
            klass, name="class"
        )  # Name of the object's class: read/write or read only
        if not custom_class: klass_p.readonly = True
        # validation for class
        klass_p.validation_re = re.compile(r'^[a-zA-Z_]+[\w:.0-9-]*$')

        # Name of object's wxWidget class; base and klass are mostly the same, except e.g. wxDialog:
        self.base = np.TextProperty(klass, "base")
        # If true, the user can change the value of the 'class' property:
        self.custom_class = custom_class

        if getattr(self, '_custom_base_classes', False):
            self.custom_base = np.TextPropertyD("", multiline=False)
        else:
            self.custom_base = None

        self.extracode = cp.CodePropertyD()  # code property
        self.extraproperties = cp.ExtraPropertiesProperty()

        self.widget = None  # this is the reference to the actual wxWindow widget, created when required
        self._rmenu = None  # popup menu
        self._dont_destroy = False

        EventsMixin.__init__(self)
Beispiel #9
0
    def __init__(self):
        np.PropertyOwner.__init__(self)
        self._logger = logging.getLogger(self.__class__.__name__)

        self.__saved = True  # raw value for self.saved property; if True, there are no changes to save
        self.__filename = None  # raw value for the self.filename property; Name of the output XML file

        # initialise instance properties
        self.is_template = np.Property(False)  # hidden property
        # name and derived class name, including validation
        self.name = np.TextPropertyD("app", default_value="")
        self.klass = np.TextPropertyD("MyApp", default_value="", name="class")
        self.properties["name"].validation_re = re.compile(
            r'^[a-zA-Z]+[\w0-9-]*$')
        self.properties["name"].validation_re = re.compile(
            r'^[a-zA-Z]+[\w:.0-9-]*$')

        # generate separate file for each class?
        labels = [_("Single file"), _("Separate file for each class")]
        tooltips = [
            _("Write all source code in one file"),
            _("Split source code in one file per class / widget")
        ]
        self.multiple_files = np.RadioProperty(config.default_multiple_files,
                                               values=[0, 1],
                                               labels=labels,
                                               tooltips=tooltips)

        # code indentation: mode and count
        self.indent_mode = np.RadioProperty(1, [0, 1], ["Tabs", "Spaces"],
                                            aliases=["tab", "space"],
                                            columns=2)
        self.indent_amount = np.SpinProperty(config.default_indent_amount,
                                             val_range=(1, 100))
        # C++ file extension
        self.source_extension = np.TextProperty('cpp')
        self.header_extension = np.TextProperty('h')
        # output path
        output_path = config.default_output_path if self.multiple_files else config.default_output_file
        self.output_path = np.FileNameProperty(output_path,
                                               style=wx.FD_SAVE
                                               | wx.FD_OVERWRITE_PROMPT)
        self._update_output_path('python')

        self.overwrite = np.CheckBoxProperty(config.default_overwrite)

        # output language
        languages = sorted(common.code_writers.keys())
        labels = [misc.capitalize(s) for s in languages]
        self.language = np.RadioProperty('python',
                                         languages,
                                         labels,
                                         columns=3)

        # gettext?
        self.use_gettext = np.CheckBoxProperty(config.default_use_gettext)
        # wx Version
        version = wx.VERSION_STRING[:
                                    3]  # Version string of major dot minor version number
        self.for_version = np.RadioProperty(version,
                                            self.all_supported_versions,
                                            tooltips=self._VERSION_TOOLTIPS)

        # encoding
        self.encoding = np.TextProperty(config.encoding)

        # top window name for the generated app
        self.top_window = np.ComboBoxProperty(
            "", choices=[])  # is actually only a ListBox
        self.generate_code = np.ActionButtonProperty(self.generate_code)

        self.widget = None  # always None, just to keep interface to Tree similar to other editors
        self.node = None
        self._rmenu = None