Esempio n. 1
0
    def finish_widget_creation(self, *args, **kwds):
        self._original["background"] = self.widget.GetBackgroundColour()
        self._original["foreground"] = self.widget.GetForegroundColour()
        fnt = self.widget.GetFont()
        if not fnt.Ok():
            fnt = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        self._original["font"] = fnt

        prop = self.properties
        size = prop["size"].get_value()
        if size:
            # self.widget.SetSize([int(s) for s in size.split(',')])
            self.set_size(size)
        else:
            prop["size"].set_value("%s, %s" % tuple(self.widget.GetSize()))
        if prop["background"].is_active():
            self.set_background(prop["background"].get_value())
        else:
            color = misc.color_to_string(self.widget.GetBackgroundColour())
            self.background = color
            prop["background"].set_value(color)
        if prop["foreground"].is_active():
            self.set_foreground(prop["foreground"].get_value())
        else:
            color = misc.color_to_string(self.widget.GetForegroundColour())
            self.foreground = color
            prop["foreground"].set_value(color)
        if prop["font"].is_active():
            self.set_font(prop["font"].get_value())
        EditBase.finish_widget_creation(self)
        wx.EVT_SIZE(self.widget, self.on_size)
        # after setting various Properties, we must Refresh widget in order to
        # see changes
        self.widget.Refresh()

        def on_key_down(event):
            evt_flags = 0
            if event.ControlDown():
                evt_flags = wx.ACCEL_CTRL
            evt_key = event.GetKeyCode()
            done = False
            for flags, key, function in misc.accel_table:
                if evt_flags == flags and evt_key == key:
                    misc.wxCallAfter(function)
                    done = True
                    break
            if not done:
                event.Skip()

        wx.EVT_KEY_DOWN(self.widget, on_key_down)
Esempio n. 2
0
    def finish_widget_creation(self, *args, **kwds):
        self._original['background'] = self.widget.GetBackgroundColour()
        self._original['foreground'] = self.widget.GetForegroundColour()
        fnt = self.widget.GetFont()
        if not fnt.Ok():
            fnt = wx.SystemSettings_GetFont(wx.SYS_DEFAULT_GUI_FONT)
        self._original['font'] = fnt

        prop = self.properties
        size = prop['size'].get_value()
        if size:
            #self.widget.SetSize([int(s) for s in size.split(',')])
            self.set_size(size)
        else:
            prop['size'].set_value('%s, %s' % tuple(self.widget.GetSize()))
        if prop['background'].is_active():
            self.set_background(prop['background'].get_value())
        else:
            color = misc.color_to_string(self.widget.GetBackgroundColour())
            self.background = color
            prop['background'].set_value(color)
        if prop['foreground'].is_active():
            self.set_foreground(prop['foreground'].get_value())
        else:
            color = misc.color_to_string(self.widget.GetForegroundColour())
            self.foreground = color
            prop['foreground'].set_value(color)
        if prop['font'].is_active():
            self.set_font(prop['font'].get_value())
        EditBase.finish_widget_creation(self)
        wx.EVT_SIZE(self.widget, self.on_size)
        # after setting various Properties, we must Refresh widget in order to
        # see changes
        self.widget.Refresh()

        def on_key_down(event):
            evt_flags = 0
            if event.ControlDown(): evt_flags = wx.ACCEL_CTRL
            evt_key = event.GetKeyCode()
            done = False
            for flags, key, function in misc.accel_table:
                if evt_flags == flags and evt_key == key:
                    misc.wxCallAfter(function)
                    done = True
                    break
            if not done:
                event.Skip()

        wx.EVT_KEY_DOWN(self.widget, on_key_down)
Esempio n. 3
0
 def get_value(self):
     if self.use_null_color.GetValue():
         return "wxNullColour"
     if self.use_sys_color.GetValue():
         return self.sys_color.GetStringSelection()
     else:
         return misc.color_to_string(self.color_chooser.GetValue())
Esempio n. 4
0
 def __init__(self, parent=None):
     wx.Dialog.__init__(self, parent, -1, _('About wxGlade'))
     html = wx.html.HtmlWindow(self, -1, size=(480, 250))
     html.Bind(wx.html.EVT_HTML_LINK_CLICKED, self.OnLinkClicked)
     # it's recommended at least for GTK2 based wxPython
     if "gtk2" in wx.PlatformInfo:
         html.SetStandardFonts()
     bgcolor = misc.color_to_string(self.GetBackgroundColour())
     icon_path = os.path.join(config.icons_path, 'wxglade_small.png')
     html.SetPage(self.text % (bgcolor, icon_path, config.version,
                               config.py_version, config.wx_version))
     ir = html.GetInternalRepresentation()
     ir.SetIndent(0, wx.html.HTML_INDENT_ALL)
     html.SetSize((ir.GetWidth(), ir.GetHeight()))
     szr = wx.BoxSizer(wx.VERTICAL)
     szr.Add(html, 0, wx.TOP | wx.ALIGN_CENTER, 10)
     szr.Add(wx.StaticLine(self, -1), 0, wx.LEFT | wx.RIGHT | wx.EXPAND, 20)
     szr2 = wx.BoxSizer(wx.HORIZONTAL)
     btn = wx.Button(self, wx.ID_OK, _("OK"))
     btn.SetDefault()
     szr2.Add(btn)
     if wx.Platform == '__WXGTK__':
         extra_border = 5  # border around a default button
     else:
         extra_border = 0
     szr.Add(szr2, 0, wx.ALL | wx.ALIGN_RIGHT, 20 + extra_border)
     self.SetAutoLayout(True)
     self.SetSizer(szr)
     szr.Fit(self)
     self.Layout()
     if parent: self.CenterOnParent()
     else: self.CenterOnScreen()
Esempio n. 5
0
    def create_widget(self):
        self.widget = Grid(self.parent.widget, self.id, (200, 200))
        self.widget.CreateGrid(self.rows_number, len(self.columns))

        # read default colors from created widget
        default_background = misc.color_to_string(
            self.widget.GetLabelBackgroundColour())
        default_lines = misc.color_to_string(self.widget.GetGridLineColour())
        self.properties['label_bg_color'].set_default(default_background)
        self.properties['lines_color'].set_default(default_lines)

        self._update_widget_properties(modified=None)

        # following two events are to permit select grid from designer frame
        EVT_GRID_CELL_LEFT_CLICK(self.widget, self.on_set_focus)
        EVT_GRID_LABEL_LEFT_CLICK(self.widget, self.on_set_focus)
        # these are to show the popup menu on right click
        EVT_GRID_CELL_RIGHT_CLICK(self.widget, self.popup_menu)
        EVT_GRID_LABEL_RIGHT_CLICK(self.widget, self.popup_menu)
Esempio n. 6
0
    def create_widget(self):
        self.widget = Grid(self.parent_window.widget, wx.ID_ANY)
        #self.widget.CreateGrid(self.rows_number, len(self.columns))
        self.widget.CreateGrid(len(self.rows), len(self.columns))

        # read default colors from created widget
        default_background = misc.color_to_string(
            self.widget.GetLabelBackgroundColour())
        default_lines = misc.color_to_string(self.widget.GetGridLineColour())
        self.properties['label_bg_color'].set_default(default_background)
        self.properties['lines_color'].set_default(default_lines)

        self._update_widget_properties(modified=None)

        # following two events are to permit select grid from designer frame
        self.widget.Bind(EVT_GRID_CELL_LEFT_CLICK, self.on_set_focus)
        self.widget.Bind(EVT_GRID_LABEL_LEFT_CLICK, self.on_set_focus)
        # these are to show the popup menu on right click
        self.widget.Bind(EVT_GRID_CELL_RIGHT_CLICK, self.popup_menu)
        self.widget.Bind(EVT_GRID_LABEL_RIGHT_CLICK, self.popup_menu)
        self.widget.Bind(EVT_GRID_COL_SIZE, self._on_grid_col_resize)
        self.widget.Bind(EVT_GRID_ROW_SIZE, self._on_grid_row_resize)
Esempio n. 7
0
    def create_widget(self):
        self.widget = Grid(self.parent.widget, self.id, (200, 200))
        self.widget.CreateGrid(self.rows_number, len(self.columns))
        if not self.properties['label_bg_color'].is_active():
            self.label_bg_color = misc.color_to_string(
                self.widget.GetLabelBackgroundColour())
            self.properties['label_bg_color'].set_value(self.label_bg_color)
        if not self.properties['lines_color'].is_active():
            self.lines_color = misc.color_to_string(
                self.widget.GetGridLineColour())
            self.properties['lines_color'].set_value(self.lines_color)
        self.widget.SetRowLabelSize(self.row_label_size)
        self.widget.SetColLabelSize(self.col_label_size)
        self.widget.EnableEditing(self.enable_editing)
        self.widget.EnableGridLines(self.enable_grid_lines)
        self.widget.EnableDragColSize(self.enable_col_resize)
        self.widget.EnableDragRowSize(self.enable_row_resize)
        self.widget.EnableDragGridSize(self.enable_grid_resize)
        self.widget.SetGridLineColour(misc.string_to_color(self.lines_color))
        self.widget.SetLabelBackgroundColour(misc.string_to_color(
            self.label_bg_color))
        i = 0
        for l, s in self.columns:
            try: s1 = int(s)
            except: s1 = 0
            self.widget.SetColLabelValue(i, l)
            if s1 > 0:
                self.widget.SetColSize(i, s1)
            i += 1

        self.set_selection_mode(self.selection_mode)
        # following two events are to permit select grid from designer frame
        EVT_GRID_CELL_LEFT_CLICK(self.widget, self.on_set_focus)  
        EVT_GRID_LABEL_LEFT_CLICK(self.widget, self.on_set_focus)
        # these are to show the popup menu on right click
        EVT_GRID_CELL_RIGHT_CLICK(self.widget, self.popup_menu)
        EVT_GRID_LABEL_RIGHT_CLICK(self.widget, self.popup_menu)
Esempio n. 8
0
    def create_widget(self):
        self.widget = Grid(self.parent.widget, self.id,(200,200))
        self.widget.CreateGrid(self.rows_number, len(self.columns))
        if not self.properties['label_bg_color'].is_active():
            self.label_bg_color = misc.color_to_string(
                self.widget.GetLabelBackgroundColour())
            self.properties['label_bg_color'].set_value(self.label_bg_color)
        if not self.properties['lines_color'].is_active():
            self.lines_color = misc.color_to_string(
                self.widget.GetGridLineColour())
            self.properties['lines_color'].set_value(self.lines_color)
        self.widget.SetRowLabelSize(self.row_label_size)
        self.widget.SetColLabelSize(self.col_label_size)
        self.widget.EnableEditing(self.enable_editing)
        self.widget.EnableGridLines(self.enable_grid_lines)
        self.widget.EnableDragColSize(self.enable_col_resize)
        self.widget.EnableDragRowSize(self.enable_row_resize)
        self.widget.EnableDragGridSize(self.enable_grid_resize)
        self.widget.SetGridLineColour(misc.string_to_color(self.lines_color))
        self.widget.SetLabelBackgroundColour(misc.string_to_color(
            self.label_bg_color))
        i = 0
        for l, s in self.columns:
            try: s1 = int(s)
            except: s1 = 0
            self.widget.SetColLabelValue(i, l)
            if s1 > 0:
                self.widget.SetColSize(i, s1)
            i += 1

        self.set_selection_mode(self.selection_mode)
        # following two events are to permit select grid from designer frame
        EVT_GRID_CELL_LEFT_CLICK(self.widget, self.on_set_focus)  
        EVT_GRID_LABEL_LEFT_CLICK(self.widget, self.on_set_focus)
        # these are to show the popup menu on right click
        EVT_GRID_CELL_RIGHT_CLICK(self.widget, self.popup_menu)
        EVT_GRID_LABEL_RIGHT_CLICK(self.widget, self.popup_menu)
Esempio n. 9
0
    def __init__(self, parent=None):
        wx.Dialog.__init__(self, parent, -1, _('About wxGlade'))

        class HtmlWin(wx.html.HtmlWindow):
            def OnLinkClicked(self, linkinfo):
                href = linkinfo.GetHref()
                if href == 'show_license':
                    if config.license_file:
                        from wx.lib.dialogs import ScrolledMessageDialog
                        try:
                            license_file = codecs.open(
                                config.license_file, encoding='UTF-8')
                            dlg = ScrolledMessageDialog(
                                self,
                                license_file.read(),
                                _("wxGlade - License")
                                )
                            license_file.close()
                            dlg.ShowModal()
                            dlg.Destroy()
                        except IOError:
                            wx.MessageBox(
                                _('License file "LICENSE.txt" not found!\n'
                                  'You can get a copy at \n'
                                  'http://www.opensource.org/licenses/'
                                  'mit-license.php'),
                                _('Error'),
                                wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
                    else:
                        wx.MessageBox(
                            _('License file "LICENSE.txt" not found!\n'
                              'You can get a copy at \n'
                              'http://www.opensource.org/licenses/'
                              'mit-license.php'),
                            _('Error'),
                            wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
                elif href == 'show_credits':
                    if config.credits_file:
                        from wx.lib.dialogs import ScrolledMessageDialog
                        try:
                            credits_file = codecs.open(
                                config.credits_file, encoding='UTF-8')
                            dlg = ScrolledMessageDialog(
                                self,
                                credits_file.read(),
                                _("wxGlade - Credits")
                                )
                            credits_file.close()
                            dlg.ShowModal()
                            dlg.Destroy()
                        except IOError:
                            wx.MessageBox(
                                _('Credits file "CREDITS.txt" not found!'),
                                _('Error'),
                                wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
                    else:
                        wx.MessageBox(
                            _('Credits file "CREDITS.txt" not found!'),
                            _('Error'),
                            wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
                else:
                    import webbrowser
                    webbrowser.open(linkinfo.GetHref(), new=True)
        html = HtmlWin(self, -1, size=(400, 250))
        # it's recommended at least for GTK2 based wxPython
        if "gtk2" in wx.PlatformInfo:
            html.SetStandardFonts()
        bgcolor = misc.color_to_string(self.GetBackgroundColour())
        icon_path = os.path.join(config.icons_path, 'wxglade_small.png')
        html.SetPage(self.text % (bgcolor, icon_path, config.version,
                                  config.py_version, config.wx_version))
        ir = html.GetInternalRepresentation()
        ir.SetIndent(0, wx.html.HTML_INDENT_ALL)
        html.SetSize((ir.GetWidth(), ir.GetHeight()))
        szr = wx.BoxSizer(wx.VERTICAL)
        szr.Add(html, 0, wx.TOP|wx.ALIGN_CENTER, 10)
        szr.Add(wx.StaticLine(self, -1), 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 20)
        szr2 = wx.BoxSizer(wx.HORIZONTAL)
        btn = wx.Button(self, wx.ID_OK, _("OK"))
        btn.SetDefault()
        szr2.Add(btn)
        if wx.Platform == '__WXGTK__':
            extra_border = 5  # border around a default button
        else: extra_border = 0
        szr.Add(szr2, 0, wx.ALL|wx.ALIGN_RIGHT, 20 + extra_border)
        self.SetAutoLayout(True)
        self.SetSizer(szr)
        szr.Fit(self)
        self.Layout()
        if parent: self.CenterOnParent()
        else: self.CenterOnScreen()
Esempio n. 10
0
 def __init__(self, parent=None):
     wx.Dialog.__init__(self, parent, -1, _('About wxGlade'))
     class HtmlWin(wx.html.HtmlWindow):
         def OnLinkClicked(self, linkinfo):
             href = linkinfo.GetHref()
             if href == 'show_license':
                 from wx.lib.dialogs import ScrolledMessageDialog
                 try:
                     license = open(os.path.join(common.wxglade_path,
                                                 'license.txt'))
                     dlg = ScrolledMessageDialog(self, license.read(),
                                                   _("wxGlade - License"))
                     license.close()
                     dlg.ShowModal()
                     dlg.Destroy()
                 except IOError:
                     wx.MessageBox(_("Can't find the license!\n"
                                  "You can get a copy at \n"
                                  "http://www.opensource.org/licenses/"
                                  "mit-license.php"), _("Error"),
                                  wx.OK|wx.CENTRE|wx.ICON_EXCLAMATION)
             elif href == 'show_credits':
                 from wx.lib.dialogs import ScrolledMessageDialog
                 try:
                     credits = open(os.path.join(common.wxglade_path,
                                                 'credits.txt'))
                     dlg = ScrolledMessageDialog(self, credits.read(),
                                                   _("wxGlade - Credits"))
                     credits.close()
                     dlg.ShowModal()
                     dlg.Destroy()
                 except IOError:
                     wx.MessageBox(_("Can't find the credits file!\n"), _("Oops!"),
                                  wx.OK|wx.CENTRE|wx.ICON_EXCLAMATION)
             else:
                 import webbrowser
                 webbrowser.open(linkinfo.GetHref(), new=True)
     html = HtmlWin(self, -1, size=(400, -1))
     if misc.check_wx_version(2, 5, 3):
         try:
             html.SetStandardFonts()
         except AttributeError:
             pass
     py_version = sys.version.split()[0]
     bgcolor = misc.color_to_string(self.GetBackgroundColour())
     icon_path = os.path.join(common.wxglade_path,
                              'icons/wxglade_small.png')
     html.SetPage(self.text % (bgcolor, icon_path, common.version,
                               py_version, wx.__version__))
     ir = html.GetInternalRepresentation()
     ir.SetIndent(0, wx.html.HTML_INDENT_ALL)
     html.SetSize((ir.GetWidth(), ir.GetHeight()))
     szr = wx.BoxSizer(wx.VERTICAL)
     szr.Add(html, 0, wx.TOP|wx.ALIGN_CENTER, 10)
     szr.Add(wx.StaticLine(self, -1), 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 20)
     szr2 = wx.BoxSizer(wx.HORIZONTAL)
     btn = wx.Button(self, wx.ID_OK, _("OK"))
     btn.SetDefault()
     szr2.Add(btn)
     if wx.Platform == '__WXGTK__':
         extra_border = 5 # border around a default button
     else: extra_border = 0
     szr.Add(szr2, 0, wx.ALL|wx.ALIGN_RIGHT, 20 + extra_border)
     self.SetAutoLayout(True)
     self.SetSizer(szr)
     szr.Fit(self)
     self.Layout()
     if parent: self.CenterOnParent()
     else: self.CenterOnScreen()
Esempio n. 11
0
 def get_value(self):
     if self.use_sys_color.GetValue():
         return self.sys_color.GetStringSelection()
     else:
         return misc.color_to_string(self.color_chooser.GetValue())
Esempio n. 12
0
    def __init__(self, parent=None):
        wx.Dialog.__init__(self, parent, -1, _('About wxGlade'))

        class HtmlWin(wx.html.HtmlWindow):
            def OnLinkClicked(self, linkinfo):
                href = linkinfo.GetHref()
                if href == 'show_license':
                    from wx.lib.dialogs import ScrolledMessageDialog
                    try:
                        license = open(
                            os.path.join(common.wxglade_path, 'license.txt'))
                        dlg = ScrolledMessageDialog(self, license.read(),
                                                    _("wxGlade - License"))
                        license.close()
                        dlg.ShowModal()
                        dlg.Destroy()
                    except IOError:
                        wx.MessageBox(
                            _("Can't find the license!\n"
                              "You can get a copy at \n"
                              "http://www.opensource.org/licenses/"
                              "mit-license.php"), _("Error"),
                            wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
                elif href == 'show_credits':
                    from wx.lib.dialogs import ScrolledMessageDialog
                    try:
                        credits = open(
                            os.path.join(common.wxglade_path, 'credits.txt'))
                        dlg = ScrolledMessageDialog(self, credits.read(),
                                                    _("wxGlade - Credits"))
                        credits.close()
                        dlg.ShowModal()
                        dlg.Destroy()
                    except IOError:
                        wx.MessageBox(_("Can't find the credits file!\n"),
                                      _("Oops!"),
                                      wx.OK | wx.CENTRE | wx.ICON_EXCLAMATION)
                else:
                    import webbrowser
                    webbrowser.open(linkinfo.GetHref(), new=True)

        html = HtmlWin(self, -1, size=(400, -1))
        if misc.check_wx_version(2, 5, 3):
            try:
                html.SetStandardFonts()
            except AttributeError:
                pass
        py_version = sys.version.split()[0]
        bgcolor = misc.color_to_string(self.GetBackgroundColour())
        icon_path = os.path.join(common.wxglade_path,
                                 'icons/wxglade_small.png')
        html.SetPage(
            self.text %
            (bgcolor, icon_path, common.version, py_version, wx.__version__))
        ir = html.GetInternalRepresentation()
        ir.SetIndent(0, wx.html.HTML_INDENT_ALL)
        html.SetSize((ir.GetWidth(), ir.GetHeight()))
        szr = wx.BoxSizer(wx.VERTICAL)
        szr.Add(html, 0, wx.TOP | wx.ALIGN_CENTER, 10)
        szr.Add(wx.StaticLine(self, -1), 0, wx.LEFT | wx.RIGHT | wx.EXPAND, 20)
        szr2 = wx.BoxSizer(wx.HORIZONTAL)
        btn = wx.Button(self, wx.ID_OK, _("OK"))
        btn.SetDefault()
        szr2.Add(btn)
        if wx.Platform == '__WXGTK__':
            extra_border = 5  # border around a default button
        else:
            extra_border = 0
        szr.Add(szr2, 0, wx.ALL | wx.ALIGN_RIGHT, 20 + extra_border)
        self.SetAutoLayout(True)
        self.SetSizer(szr)
        szr.Fit(self)
        self.Layout()
        if parent: self.CenterOnParent()
        else: self.CenterOnScreen()