コード例 #1
0
ファイル: main.py プロジェクト: italomaia/spe
 def open_app(self, event_unused):
     """\
     loads a wxGlade project from an xml file
     NOTE: this is very slow and needs optimisation efforts
     NOTE2: the note above should not be True anymore :)
     """
     if not self.ask_save(): return
     from xml_parse import XmlWidgetBuilder, ProgressXmlWidgetBuilder
     infile = misc.FileSelector(_("Open file"),
                                wildcard="wxGlade files (*.wxg)|*.wxg|"
                                "wxGlade Template files (*.wgt)|*.wgt|"
                                "XML files (*.xml)|*.xml|All files|*",
                                flags=wx.OPEN | wx.FILE_MUST_EXIST,
                                default_path=self.cur_dir)
     if infile:
         # ALB 2004-10-15 try to restore possible autosave content...
         if common.check_autosaved(infile) and \
                wx.MessageBox(_("There seems to be auto saved data for "
                             "this file: do you want to restore it?"),
                             _("Auto save detected"),
                             style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
             common.restore_from_autosaved(infile)
         else:
             common.remove_autosaved(infile)
         self._open_app(infile)
         self.cur_dir = os.path.dirname(infile)
コード例 #2
0
ファイル: main.py プロジェクト: NonPlayerCtrl/FreePLC_IDE
    def open_app(self, event_unused):
        """loads a wxGlade project from an xml file
        NOTE: this is very slow and needs optimisation efforts
        NOTE2: the note above should not be True anymore :) """
        if not self.ask_save():
            return
        default_path = os.path.dirname(common.app_tree.app.filename
                                       or "") or self.cur_dir
        infile = wx.FileSelector(_("Open file"),
                                 wildcard="wxGlade files (*.wxg)|*.wxg|"
                                 "wxGlade Template files (*.wgt)|*.wgt|"
                                 "XML files (*.xml)|*.xml|All files|*",
                                 flags=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST,
                                 default_path=default_path)
        if not infile: return
        if common.check_autosaved(infile):
            if wx.MessageBox(_(
                    "There seems to be auto saved data for this file: do you want to restore it?"
            ),
                             _("Auto save detected"),
                             style=wx.ICON_QUESTION | wx.YES_NO) == wx.YES:
                common.restore_from_autosaved(infile)
            else:
                common.remove_autosaved(infile)
        if infile == common.app_tree.app.filename:
            # if we are re-loading the file, go the the previous position
            path = common.app_tree.get_selected_path()
        else:
            path = None
        self._open_app(infile)
        self.cur_dir = os.path.dirname(infile)

        if path is not None:
            common.app_tree.select_path(
                path)  # re-loaded file -> go to previous position
コード例 #3
0
ファイル: main.py プロジェクト: NonPlayerCtrl/FreePLC_IDE
 def open_from_history(self, event):
     if not self.ask_save():
         return
     pos = event.GetId() - wx.ID_FILE1
     filename = self.file_history.GetHistoryFile(pos)
     if not os.path.exists(filename):
         wx.MessageBox(_("The file %s doesn't exist.") % filename,
                       _('Information'),
                       style=wx.CENTER | wx.ICON_INFORMATION | wx.OK)
         self.file_history.RemoveFileFromHistory(pos)
         common.remove_autosaved(filename)
         return
     if common.check_autosaved(filename):
         res = wx.MessageBox(_(
             'There seems to be auto saved data for this file: do you want to restore it?'
         ),
                             _('Auto save detected'),
                             style=wx.ICON_QUESTION | wx.YES_NO)
         if res == wx.YES:
             common.restore_from_autosaved(filename)
         else:
             common.remove_autosaved(filename)
     else:
         common.remove_autosaved(filename)
     self._open_app(filename)
     self.cur_dir = os.path.dirname(filename)
コード例 #4
0
ファイル: main.py プロジェクト: CrazyPython/SPE
 def open_app(self, event_unused):
     """\
     loads a wxGlade project from an xml file
     NOTE: this is very slow and needs optimisation efforts
     NOTE2: the note above should not be True anymore :)
     """
     if not self.ask_save(): return
     from xml_parse import XmlWidgetBuilder, ProgressXmlWidgetBuilder
     infile = misc.FileSelector(_("Open file"),
                                wildcard="wxGlade files (*.wxg)|*.wxg|"
                                "wxGlade Template files (*.wgt)|*.wgt|"
                                "XML files (*.xml)|*.xml|All files|*",
                                flags=wx.OPEN|wx.FILE_MUST_EXIST,
                                default_path=self.cur_dir)
     if infile:
         # ALB 2004-10-15 try to restore possible autosave content...
         if common.check_autosaved(infile) and \
                wx.MessageBox(_("There seems to be auto saved data for "
                             "this file: do you want to restore it?"),
                             _("Auto save detected"),
                             style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
             common.restore_from_autosaved(infile)
         else:
             common.remove_autosaved(infile)
         self._open_app(infile)
         self.cur_dir = os.path.dirname(infile)
コード例 #5
0
ファイル: main.py プロジェクト: italomaia/spe
 def open_from_history(event):
     if not self.ask_save(): return
     infile = self.file_history.GetHistoryFile(event.GetId() -
                                               wx.ID_FILE1)
     # ALB 2004-10-15 try to restore possible autosave content...
     if common.check_autosaved(infile) and \
            wx.MessageBox(_("There seems to be auto saved data for "
                         "this file: do you want to restore it?"),
                         _("Auto save detected"),
                         style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
         common.restore_from_autosaved(infile)
     else:
         common.remove_autosaved(infile)
     self._open_app(infile)
コード例 #6
0
ファイル: main.py プロジェクト: CrazyPython/SPE
 def open_from_history(event):
     if not self.ask_save(): return
     infile = self.file_history.GetHistoryFile(
         event.GetId() - wx.ID_FILE1)
     # ALB 2004-10-15 try to restore possible autosave content...
     if common.check_autosaved(infile) and \
            wx.MessageBox(_("There seems to be auto saved data for "
                         "this file: do you want to restore it?"),
                         _("Auto save detected"),
                         style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
         common.restore_from_autosaved(infile)
     else:
         common.remove_autosaved(infile)
     self._open_app(infile)
コード例 #7
0
    def open_from_history(self, event):
        if not self.ask_save():
            return
        pos = event.GetId() - wx.ID_FILE1
        filename = self.file_history.GetHistoryFile(pos)
        if not os.path.exists(filename):
            wx.MessageBox(_("The file %s doesn't exist.") % filename,
                          _('Information'),
                          style=wx.CENTER | wx.ICON_INFORMATION | wx.OK)
            self.file_history.RemoveFileFromHistory(pos)
            common.remove_autosaved(filename)
            return
        if common.check_autosaved(filename):
            res = wx.MessageBox(_(
                'There seems to be auto saved data for this file: do you want to restore it?'
            ),
                                _('Auto save detected'),
                                style=wx.ICON_QUESTION | wx.YES_NO)
            if res == wx.YES:
                common.restore_from_autosaved(filename)
            else:
                common.remove_autosaved(filename)
        else:
            common.remove_autosaved(filename)

        if filename == common.app_tree.app.filename:
            # if we are re-loading the file, go the the previous position
            path = common.app_tree.get_selected_path()
        else:
            path = None

        self._open_app(filename)
        self.cur_dir = os.path.dirname(filename)
        if path is not None:
            common.app_tree.select_path(
                path)  # re-loaded file -> go to previous position
コード例 #8
0
ファイル: main.py プロジェクト: italomaia/spe
            self.autosave_timer = wx.Timer(self, TIMER_ID)
            wx.EVT_TIMER(self, TIMER_ID, self.on_autosave_timer)
            self.autosave_timer.Start(
                int(config.preferences.autosave_delay) * 1000)
        # ALB 2004-10-15
        CLEAR_SB_TIMER_ID = wx.NewId()
        self.clear_sb_timer = wx.Timer(self, CLEAR_SB_TIMER_ID)
        wx.EVT_TIMER(self, CLEAR_SB_TIMER_ID, self.on_clear_sb_timer)

        self.frame2.SetAcceleratorTable(self.accel_table)
        self.tree_frame.SetAcceleratorTable(self.accel_table)

        self.Raise()

        # ALB 2004-10-16
        if common.check_autosaved(None) and \
               wx.MessageBox(_("There seems to be auto saved data "
                            "from last wxGlade session: "
                            "do you want to restore it?"),
                            _("Auto save detected"),
                            style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
            if self._open_app(common.get_name_for_autosave(),
                              add_to_history=False):
                common.app_tree.app.saved = False
                common.app_tree.app.filename = None
                self.user_message(_("Recovery from auto save complete"))
                common.remove_autosaved()
        else:
            common.remove_autosaved()

    def on_autosave_timer(self, event):
コード例 #9
0
    def __init__(self, parent=None):
        self._logger = logging.getLogger(self.__class__.__name__)
        style = wx.SYSTEM_MENU | wx.CAPTION | wx.MINIMIZE_BOX
        style |= wx.RESIZE_BORDER | wx.CLOSE_BOX
        version = config.version
        if version == '"faked test version"':
            version = "%s on Python %d.%d" % (version, sys.version_info.major,
                                              sys.version_info.minor)
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          "wxGlade v%s" % version,
                          style=style,
                          name='MainFrame')

        if parent is None:
            parent = self
        common.palette = self  # to provide a reference accessible by the various widget classes
        icon = compat.wx_EmptyIcon()
        bmp = wx.Bitmap(os.path.join(config.icons_path, "icon.xpm"),
                        wx.BITMAP_TYPE_XPM)
        icon.CopyFromBitmap(bmp)
        self.SetIcon(icon)
        self.SetBackgroundColour(
            compat.wx_SystemSettings_GetColour(wx.SYS_COLOUR_BTNFACE))

        self.create_menu(parent)

        # load the available code generators
        all_widgets = common.init_codegen()
        if config.use_gui:
            # build the palette for all_widgets
            sizer = wx.FlexGridSizer(0, 2, 0, 0)
            sizer.AddGrowableCol(0)
            self.SetAutoLayout(True)
            maxlen = max([len(all_widgets[sect]) for sect in all_widgets
                          ])  # the maximum number of buttons in a section
            for section in all_widgets:
                if section:
                    label = wx.StaticText(self, -1,
                                          "%s:" % section.replace('&', '&&'))
                    sizer.Add(label, 1, wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 2)

                bsizer = wx.GridSizer(cols=maxlen, hgap=2, vgap=2)
                for button in all_widgets[section]:
                    bsizer.Add(button, flag=wx.ALL, border=1)
                sizer.Add(bsizer)
            self.SetSizer(sizer)
            sizer.Fit(self)

        self.Bind(wx.EVT_CLOSE, self.cleanup)

        # the style for the property and tree frames
        frame_style = wx.DEFAULT_FRAME_STYLE
        frame_tool_win = config.preferences.frame_tool_win
        if frame_tool_win:
            frame_style |= wx.FRAME_NO_TASKBAR | wx.FRAME_FLOAT_ON_PARENT
            frame_style &= ~wx.MINIMIZE_BOX
            if wx.Platform != '__WXGTK__':
                frame_style |= wx.FRAME_TOOL_WINDOW

        # set window geometry
        main_geometry = None
        extend_Y = False
        if config.preferences.remember_geometry:
            main_geometry = config.preferences.get_geometry('main')
            if isinstance(main_geometry, tuple):
                main_geometry = wx.Rect(*main_geometry)
        if not main_geometry:
            main_geometry = wx.Rect()
            main_geometry.TopLeft = wx.Display().GetClientArea().GetTopLeft()
            main_geometry.Size = (-1, -1)
            extend_Y = True
        self._set_geometry(self, main_geometry)
        if extend_Y:
            # expand in Y by 40 pixels
            size = self.GetSize()
            self.SetSize((size[0], size[1] + 20))
        self.Show()
        main_geometry.Size = self.GetSize()

        # create the property and the tree frame
        self.create_property_panel(frame_style, icon, main_geometry)
        common.property_panel = self.property_frame
        self.create_tree_frame(
            frame_style, icon,
            main_geometry)  # also creates Application object

        # last visited directory, used on GTK for wxFileDialog
        self.cur_dir = config.preferences.open_save_path

        # set a drop target for us...
        self._droptarget = clipboard.FileDropTarget(self)
        self.SetDropTarget(self._droptarget)
        #self.tree_frame.SetDropTarget(self._droptarget)
        #self.property_frame.SetDropTarget(self._droptarget)

        # ALB 2004-10-15, autosave support...
        self.autosave_timer = None
        if config.preferences.autosave:
            self.autosave_timer = wx.Timer(self, -1)
            self.Bind(wx.EVT_TIMER, self.on_autosave_timer,
                      self.autosave_timer)
            self.autosave_timer.Start(
                int(config.preferences.autosave_delay) * 1000)

        self.create_statusbar()  # create statusbar for display of messages

        self.Raise()
        misc.set_focused_widget(common.app_tree.app)

        # disable autosave checks during unittests
        if config.testing: return
        if common.check_autosaved(None):
            res = wx.MessageBox(_(
                'There seems to be auto saved data from last wxGlade session: do you want to restore it?'
            ),
                                _('Auto save detected'),
                                style=wx.ICON_QUESTION | wx.YES_NO)
            if res == wx.YES:
                filename = common.get_name_for_autosave()
                if self._open_app(filename, add_to_history=False):
                    self.cur_dir = os.path.dirname(filename)
                    common.app_tree.app.saved = False
                    common.app_tree.app.filename = None
                    self.user_message(_('Auto save loaded'))
            common.remove_autosaved()

        self.Bind(wx.EVT_CHAR_HOOK, self.on_key_event)
コード例 #10
0
ファイル: main.py プロジェクト: CrazyPython/SPE
            self.autosave_timer = wx.Timer(self, TIMER_ID)
            wx.EVT_TIMER(self, TIMER_ID, self.on_autosave_timer)
            self.autosave_timer.Start(
                int(config.preferences.autosave_delay) * 1000)
        # ALB 2004-10-15
        CLEAR_SB_TIMER_ID = wx.NewId()
        self.clear_sb_timer = wx.Timer(self, CLEAR_SB_TIMER_ID)
        wx.EVT_TIMER(self, CLEAR_SB_TIMER_ID, self.on_clear_sb_timer)

        self.frame2.SetAcceleratorTable(self.accel_table)
        self.tree_frame.SetAcceleratorTable(self.accel_table)

        self.Raise()

        # ALB 2004-10-16
        if common.check_autosaved(None) and \
               wx.MessageBox(_("There seems to be auto saved data "
                            "from last wxGlade session: "
                            "do you want to restore it?"),
                            _("Auto save detected"),
                            style=wx.ICON_QUESTION|wx.YES_NO) == wx.YES:
            if self._open_app(common.get_name_for_autosave(),
                              add_to_history=False):
                common.app_tree.app.saved = False
                common.app_tree.app.filename = None
                self.user_message(_("Recovery from auto save complete"))
                common.remove_autosaved()
        else:
            common.remove_autosaved()

    def on_autosave_timer(self, event):