Ejemplo n.º 1
0
    def __init__(self, parent, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.parent = parent
        self.file_history = wx.FileHistory()
        self.file_history.Load(app_config.conf)

        item = self.Append(wx.ID_NEW, '&New...\tCtrl-N', 'Start a new ClassInvoices file')
        self.Bind(wx.EVT_MENU, self.parent.on_new, item)
        item = self.Append(wx.ID_OPEN, '&Open...\tCtrl-O', 'Open a ClassInvoices file')
        self.Bind(wx.EVT_MENU, self.parent.on_open, item)
        self.add_recent_files()
        item = self.Append(wx.ID_ANY, 'Clear &Recent', 'Delete all entries from the "Open Recent" menu')
        self.Bind(wx.EVT_MENU, self.on_clear, item)

        # --------------------
        self.AppendSeparator()

        item = self.Append(wx.ID_CLOSE, '&Close\tCtrl-W', 'Close window and quit application')
        self.Bind(wx.EVT_MENU, self.parent.on_close, item)

        item = self.Append(wx.ID_SAVE, '&Save\tCtrl-S', 'Save the document')
        self.Bind(wx.EVT_MENU, self.parent.on_save, item)
        item = self.Append(wx.ID_SAVEAS, 'Save &As...\tCtrl-Alt-S', 'Save the document as...')
        self.Bind(wx.EVT_MENU, self.parent.on_save, item)

        # --------------------
        self.AppendSeparator()

        # Note: using ID_QUIT does not allow us to intercept the event to, for example, offer
        # to save the document. So, use ID_ANY instead :-(
        item = self.Append(wx.ID_ANY, 'E&xit\tCtrl-Q', 'Close this application')
        self.Bind(wx.EVT_MENU, self.parent.on_quit, item)
Ejemplo n.º 2
0
    def create_menu(self):
        """Creates the program menu."""
        menu = wx.MenuBar()

        menu_file = wx.Menu()
        menu.Insert(0, menu_file, "&File")
        menu_recent = self.menu_recent = wx.Menu()
        menu_file.AppendMenu(id=wx.NewId(),
                             text="&Recent files",
                             submenu=menu_recent,
                             help="Recently opened files.")
        menu_file.AppendSeparator()
        menu_console = self.menu_console = menu_file.Append(
            id=wx.NewId(),
            text="Show &console\tCtrl-W",
            help="Shows/hides the console window.")
        self.Bind(wx.EVT_MENU, self.on_showhide_console, menu_console)
        menu_inspect = self.menu_inspect = menu_file.Append(
            id=wx.NewId(),
            text="Show &widget inspector",
            help="Shows/hides the widget inspector.")
        self.Bind(wx.EVT_MENU, self.on_open_widget_inspector, menu_inspect)

        self.file_history = wx.FileHistory(conf.MaxRecentFiles)
        self.file_history.UseMenu(menu_recent)
        for filename in conf.RecentFiles[::-1]:
            # Iterate backwards, as FileHistory works like a stack
            if os.path.exists(filename):
                self.file_history.AddFileToHistory(filename)
        wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9, self.on_recent_file)
        menu_file.AppendSeparator()
        m_exit = menu_file.Append(-1, "E&xit\tAlt-X", "Exit")
        self.Bind(wx.EVT_MENU, self.on_exit, m_exit)
        self.SetMenuBar(menu)
Ejemplo n.º 3
0
    def createFileMenu(self):
        """Creates the file menu."""
        file_menu = wx.Menu()

        # File Menu ID's
        self.idOPEN = wx.NewId()
        self.idCLOSE = wx.NewId()
        self.idEXIT = wx.NewId()

        file_menu.Append(self.idOPEN, "&Open", "Open netcdf file")
        file_menu.Append(self.idCLOSE, "&Close", "Close netcdf file")

        file_history = self.file_history = wx.FileHistory(8)
        file_history.Load(self.config)
        recent = wx.Menu()
        file_history.UseMenu(recent)
        file_history.AddFilesToMenu()
        file_menu.AppendMenu(-1, "&Recent Files", recent)
        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnFileHistory,
                  id=wx.ID_FILE1,
                  id2=wx.ID_FILE9)

        file_menu.AppendSeparator()
        file_menu.Append(self.idEXIT, "E&xit", "Exit wxnciew")

        self.Bind(wx.EVT_MENU, self.OnOpen, id=self.idOPEN)
        self.Bind(wx.EVT_MENU, self.OnClose, id=self.idCLOSE)
        self.Bind(wx.EVT_MENU, self.OnExit, id=self.idEXIT)
        return file_menu
Ejemplo n.º 4
0
    def __init__(self, app_name, parent_menu, pos, history_len=10):
        self._history_len = history_len
        self._parent_menu = parent_menu
        self._pos = pos

        self.file_requested = Signal("RecentFilesMenu.FileRequested")

        self._filehistory = wx.FileHistory(maxFiles=history_len)
        # Recent files path stored in GRASS GIS config dir in the
        # .recent_files file in the group by application name
        self._config = wx.FileConfig(
            style=wx.CONFIG_USE_LOCAL_FILE,
            localFilename=os.path.join(
                utils.GetSettingsPath(),
                self.recent_files,
            ),
        )
        self._config.SetPath(strPath=app_name)
        self._filehistory.Load(self._config)
        self.RemoveNonExistentFiles()

        self.recent = wx.Menu()
        self._filehistory.UseMenu(self.recent)
        self._filehistory.AddFilesToMenu()

        # Show recent files menu if count of items in menu > 0
        if self._filehistory.GetCount() > 0:
            self._insertMenu()
Ejemplo n.º 5
0
    def on_initialize(self, event):
        self.dir = None
        self.documentPath = None
        self.documentChanged = 0
        
        # there should probably be a menu item to 
        # raise and lower the font size
        if wx.Platform in ('__WXMAC__', '__WXGTK__'):
            font = self.components.listResults.font
            if wx.Platform == '__WXMAC__':
                font.size = 10
            elif wx.Platform == '__WXGTK__':
                font.size = 12
            self.components.listResults.font = font

        # KEA 2002-06-27
        # copied from codeEditor.py
        # wxFileHistory isn't wrapped, so use raw wxPython
        # also the file list gets appended to the File menu
        # rather than going in front of the Exit menu
        # I suspect I have to add the Exit menu after the file history
        # which means changing how the menus in resources are loaded
        # so I'll do that later
        self.fileHistory = wx.FileHistory()
        fileMenu = self.GetMenuBar().GetMenu(0)
        self.fileHistory.UseMenu(fileMenu)
        wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9, self.OnFileHistory)

        self.sizerLayout()

        self.configPath = os.path.join(configuration.homedir, 'findfiles')
        self.loadConfig()

        path = os.path.join(self.configPath, LASTGREPFILE)
        self.loadGrepFile(path)
Ejemplo n.º 6
0
    def create_menu(self):
        """Creates the program menu."""
        menu = wx.MenuBar()
        menu_file = wx.Menu()
        menu.Insert(0, menu_file, "&File")
        menu_recent = self.menu_recent = wx.Menu()
        menu_file.AppendMenu(id=wx.NewId(), text="&Recent files",
            submenu=menu_recent, help="Recently opened files.")
        menu_file.AppendSeparator()
        menu_console = self.menu_console = menu_file.Append(
            id=wx.NewId(), kind=wx.ITEM_CHECK, text="Show &console\tCtrl-E",
            help="Show/hide a Python shell environment window")
        menu_inspect = self.menu_inspect = menu_file.Append(
            id=wx.NewId(), kind=wx.ITEM_CHECK, text="Show &widget inspector",
            help="Show/hide the widget inspector")

        self.file_history = wx.FileHistory(conf.MaxRecentFiles)
        self.file_history.UseMenu(menu_recent)
        for f in conf.RecentFiles[::-1]: # Backwards - FileHistory is a stack
            os.path.exists(f) and self.file_history.AddFileToHistory(f)
        wx.EVT_MENU_RANGE(self, wx.ID_FILE1, wx.ID_FILE9, self.on_recent_file)
        menu_file.AppendSeparator()
        m_exit = menu_file.Append(-1, "E&xit\tAlt-X", "Exit")

        self.Bind(wx.EVT_MENU, self.on_showhide_console, menu_console)
        self.Bind(wx.EVT_MENU, self.on_open_widget_inspector, menu_inspect)
        self.Bind(wx.EVT_MENU, self.on_exit, m_exit)
        self.SetMenuBar(menu)
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # FileHistory
        self.file_history = wx.FileHistory()

        # menu bar stuff
        menubar = wx.MenuBar()

        # File
        open_recent_menu = wx.Menu()
        file_menu = wx.Menu()
        file_open_item = file_menu.Append(wx.ID_OPEN, 'Open File...\tCtrl+O',
                                          'Open file')
        file_menu.AppendSubMenu(open_recent_menu, 'Open Recent',
                                'Open recent files')

        menubar.Append(file_menu, '&File')

        # register Open Recent menu, put under control of FileHistory obj
        self.file_history.UseMenu(open_recent_menu)
        self.file_history.AddFilesToMenu(open_recent_menu)

        self.SetMenuBar(menubar)

        # setup event handlers for menus
        # File menu items
        self.Bind(wx.EVT_MENU, self.on_open, file_open_item)

        self.Show(True)
Ejemplo n.º 8
0
 def __create_file_history(self):
     self.file_history = wx.FileHistory()
     self.file_history.UseMenu(self.mnuFile)
     old_path = self.wxcfg.GetPath()
     self.wxcfg.SetPath('/RecentFiles')
     self.file_history.Load(self.wxcfg)
     self.wxcfg.SetPath(old_path)
     self._need_save = False
Ejemplo n.º 9
0
    def makeMenu(self):
        """Make the menu bar."""
        menu_bar = wx.MenuBar()
                                                                                                    
        file_menu = wx.Menu()
        file_menu.Append(wx.ID_OPEN, "&Open", help="Open an existing flow in a new frame")
        file_menu.Append(wx.ID_CLOSE, "&Close", help="Close the file associated to the active tab")
        file_menu.Append(wx.ID_EXIT, "&Quit", help="Exit the application")

        file_history = self.file_history = wx.FileHistory(8)
        file_history.Load(self.config)
        recent = wx.Menu()
        file_history.UseMenu(recent)
        file_history.AddFilesToMenu()
        file_menu.AppendMenu(-1, "&Recent Files", recent)
        self.Bind(wx.EVT_MENU_RANGE, self.OnFileHistory, id=wx.ID_FILE1, id2=wx.ID_FILE9)
        menu_bar.Append(file_menu, "File")

        flow_menu = wx.Menu()

        #self.ID_FLOW_CHANGE_MANAGER = wx.NewId()
        #flow_menu.Append(self.ID_FLOW_CHANGE_MANAGER, "Change TaskManager", help="")

        self.ID_FLOW_OPEN_OUTFILES = wx.NewId()
        flow_menu.Append(self.ID_FLOW_OPEN_OUTFILES, "Open output files", help="")

        self.ID_FLOW_TREE_VIEW = wx.NewId()
        flow_menu.Append(self.ID_FLOW_TREE_VIEW, "Tree view", help="Tree view of the tasks")

        menu_bar.Append(flow_menu, "Flow")

        help_menu = wx.Menu()
        help_menu.Append(wx.ID_ABOUT, "About " + self.codename, help="Info on the application")
        menu_bar.Append(help_menu, "Help")

        self.ID_HELP_QUICKREF = wx.NewId()
        help_menu.Append(self.ID_HELP_QUICKREF, "Quick Reference ", help="Quick reference for " + self.codename)
        help_menu.Append(wx.ID_ABOUT, "About " + self.codename, help="Info on the application")
                                                                                                
        # Associate menu/toolbar items with their handlers.
        menu_handlers = [
            (wx.ID_OPEN, self.OnOpen),
            (wx.ID_CLOSE, self.OnClose),
            (wx.ID_EXIT, self.OnExit),
            (wx.ID_ABOUT, self.OnAboutBox),
            #
            #(self.ID_FLOW_CHANGE_MANAGER, self.onChangeManager),
            (self.ID_FLOW_OPEN_OUTFILES, self.onOpenOutFiles),
            (self.ID_FLOW_TREE_VIEW, self.onTaskTreeView),
            #
            (self.ID_HELP_QUICKREF, self.onQuickRef),
        ]
                                                            
        for combo in menu_handlers:
            mid, handler = combo[:2]
            self.Bind(wx.EVT_MENU, handler, id=mid)

        return menu_bar
Ejemplo n.º 10
0
    def __init__(self, parent, log):
        self.log = log
        wx.Panel.__init__(self, parent, -1)
        box = wx.BoxSizer(wx.VERTICAL)

        # Make and layout the controls
        fs = self.GetFont().GetPointSize()
        bf = wx.Font(fs + 4, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                     wx.FONTWEIGHT_BOLD)
        nf = wx.Font(fs + 2, wx.FONTFAMILY_SWISS, wx.FONTSTYLE_NORMAL,
                     wx.FONTWEIGHT_NORMAL)

        t = wx.StaticText(self, -1, "FileHistory")
        t.SetFont(bf)
        box.Add(t, 0, wx.CENTER | wx.ALL, 5)

        box.Add(wx.StaticLine(self, -1), 0, wx.EXPAND)
        box.Add((10, 20))

        t = wx.StaticText(self, -1, text)
        t.SetFont(nf)
        box.Add(t, 0, wx.CENTER | wx.ALL, 5)

        self.SetSizer(box)
        self.SetAutoLayout(True)

        # Make a menu
        self.menu = m = wx.Menu()

        # Little know wx Fact #42: there are a number of pre-set IDs
        # in the wx package, to be used for common controls such as those
        # illustrated below. Neat, huh?
        m.Append(wx.ID_NEW, "&New")
        m.Append(wx.ID_OPEN, "&Open...")
        m.Append(wx.ID_CLOSE, "&Close")
        m.Append(wx.ID_SAVE, "&Save")
        m.Append(wx.ID_SAVEAS, "Save &as...")
        m.Enable(wx.ID_NEW, False)
        m.Enable(wx.ID_CLOSE, False)
        m.Enable(wx.ID_SAVE, False)
        m.Enable(wx.ID_SAVEAS, False)

        # and a file history
        self.filehistory = wx.FileHistory()
        self.filehistory.UseMenu(self.menu)

        # and finally the event handler bindings
        self.Bind(wx.EVT_RIGHT_UP, self.OnRightClick)

        self.Bind(wx.EVT_MENU, self.OnFileOpenDialog, id=wx.ID_OPEN)

        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnFileHistory,
                  id=wx.ID_FILE1,
                  id2=wx.ID_FILE9)

        self.Bind(wx.EVT_WINDOW_DESTROY, self.Cleanup)
Ejemplo n.º 11
0
 def OnCreateFileHistory(self):
     """
     A hook to allow a derived class to create a different type of file
     history. Called from Initialize.
     """
     max_files = int(wx.ConfigBase_Get().Read("MRULength",str(DEFAULT_MRU_FILE_NUM)))
     enableMRU = wx.ConfigBase_Get().ReadInt("EnableMRU", True)
     if enableMRU:
         self._fileHistory = wx.FileHistory(maxFiles=max_files,idBase=ID_MRU_FILE1)
Ejemplo n.º 12
0
    def SetupMenu(self):
        "Create menubar"
        # TODO: need Help/About Test Run menu item, toolbar and dialog
        menuBar = wx.MenuBar()
        menu = wx.Menu()
        menu.Append(101, _("&New test run ...\tCtrl-N"),
                    _("Create a new test run"))
        menu.Append(102, _("&Open test run ...\tCtrl-O"),
                    _("Open an existing test run"))
        menu.Append(103, _("Export as HTML ..."),
                    _("Export test run to HTML file"))
        menu.Append(104, _("Export as XML ..."),
                    _("Export test run to XML files"))
        menu.Enable(103, False)
        menu.Enable(104, False)
        menu.Append(wx.ID_EXIT, _("E&xit\tAlt-X"), _("Exit this application"))
        self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT)

        # adding a file history to the menu
        self.filehistory = wx.FileHistory()
        self.filehistory.UseMenu(menu)
        self.filehistory.Load(self.config)

        menuBar.Append(menu, _("&File"))

        menu = wx.Menu()
        menu.Append(201, _("Run selected ...\tCtrl-R"),
                    _("Run selected test case"))
        menu.Enable(201, False)
        menu.Append(204, _("Run all scripted ..."),
                    _("Run all test case having a script"))
        menu.Enable(204, False)
        menu.Append(202, _("About current test run..."),
                    _("Info about the current test run"))
        menu.Enable(202, False)
        menu.Append(203, _("Cancel current test run..."),
                    _("Cancel the current test run"))
        menu.Enable(203, False)
        menuBar.Append(menu, _("&Test"))

        menu = wx.Menu()
        menu.Append(301, _('General ...'), _('General settings'))
        self.Bind(wx.EVT_MENU, self.OnSettings, id=301)
        menu.Enable(301, True)
        menuBar.Append(menu, _('&Settings'))

        menu = wx.Menu()
        menu.Append(901, _("About ..."), _("Info about this program"))
        self.Bind(wx.EVT_MENU, self.OnAbout, id=901)
        menu.Enable(901, True)
        menu.Append(902, _('Feedback ...'),
                    _('How to give feedback about this program'))
        self.Bind(wx.EVT_MENU, self.OnFeedback, id=902)
        menu.Enable(902, True)
        menuBar.Append(menu, _("&Help"))

        self.SetMenuBar(menuBar)
Ejemplo n.º 13
0
 def test_filehistory1(self):
     fh = wx.FileHistory()
     for fn in "one two three four".split():
         fh.AddFileToHistory(fn)
         
     self.assertEqual(fh.GetCount(), 4)
     self.assertEqual(fh.Count, 4)
     self.assertEqual(fh.GetHistoryFile(1), 'three')  # they are in LIFO order
     m = wx.Menu()
     fh.AddFilesToMenu(m)
Ejemplo n.º 14
0
 def __init__(self):
     """
     Constructor
     """
     super().__init__(None, title=APP_NAME, size=(800, 600))
     self.panel = SkeletonPanel(self)
     self.filehistory = wx.FileHistory(8)
     self.config = wx.Config(APP_NAME, style=wx.CONFIG_USE_LOCAL_FILE)
     self.create_menu()
     self.SetMinSize(wx.Size(400, 300))
     self.Show()
Ejemplo n.º 15
0
    def __init__(self):
        cfg = wx.GetApp().get_config("REPOSITORY")
        path = cfg.get("path", "")
        self.username = cfg.get("username", "")

        # keep track of remote opened files
        self.remote_files_map = {}

        # search "open file" menu item to insert "open repository" one
        for pos, it in enumerate(self.menu['file'].GetMenuItems()):
            if it.GetId() == wx.ID_OPEN:
                break
        self.ID_OPEN_REPO = wx.NewId()
        self.ID_OPEN_WEB_REPO = wx.NewId()
        self.menu['file'].Insert(pos + 1, self.ID_OPEN_REPO,
                                 "Open Repo\tCtrl-Shift-O")
        self.Bind(wx.EVT_MENU, self.OnOpenRepo, id=self.ID_OPEN_REPO)
        self.menu['file'].Insert(pos + 2, self.ID_OPEN_WEB_REPO,
                                 "Open Web Repo\tCtrl-Shift-Alt-O")
        self.Bind(wx.EVT_MENU, self.OnOpenWebRepo, id=self.ID_OPEN_WEB_REPO)

        # search "recent files" menu item to insert "recent repos" one
        for pos, it in enumerate(self.menu['file'].GetMenuItems()):
            if it.GetId() == wx.ID_FILE:
                break
        # and a file history
        recent_repos_submenu = wx.Menu()
        self.repo_filehistory = wx.FileHistory(idBase=ID_FILE_REPO[0])
        self.repo_filehistory.UseMenu(recent_repos_submenu)
        self.menu['file'].InsertMenu(pos + 1, -1, "Recent &Repos",
                                     recent_repos_submenu)
        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnRepoFileHistory,
                  id=ID_FILE_REPO[0],
                  id2=ID_FILE_REPO[9])

        self.repo = None  #MercurialRepo(path, self.username)
        repo_panel = self.CreateRepoTreeCtrl()
        self._mgr.AddPane(
            repo_panel,
            aui.AuiPaneInfo().Name("repo").Caption("Repository").Left().Layer(
                1).Position(1).CloseButton(True).MaximizeButton(True))
        self._mgr.Update()

        self.AppendWindowMenuItem('Repository', ('repo', ), self.OnWindowMenu)

        self.repo_tree.Bind(wx.EVT_LEFT_DCLICK, self.OnRepoLeftDClick)
        self.repo_tree.Bind(wx.EVT_CONTEXT_MENU, self.OnRepoContextMenu)

        self.Connect(-1, -1, EVT_REPO_ID, self.OnRepoEvent)

        # create pop-up menu
        self.CreateRepoMenu()
Ejemplo n.º 16
0
    def _load_config(self):
        # Handle legacy file location
        if os.path.exists(self._legacy_dir):
            print "Migrating config from legacy location"
            shutil.move(self._legacy_dir, self.config_dir)

        # Create the kicad bom manager folder if it doesn't already exist
        if not os.path.exists(self.config_dir):
            os.makedirs(self.config_dir)

        self.filehistory = wx.FileHistory(8)
        self.config = wx.Config("KiCADbom",
                                localFilename=self.config_file,
                                style=wx.CONFIG_USE_LOCAL_FILE)
        self.filehistory.Load(self.config)
Ejemplo n.º 17
0
    def __CreateMenu(self):
        menubar = wx.MenuBar()

        menu_recent = wx.Menu()
        menu_save = wx.Menu()
        menu_save.AppendCheckItem(ID_ONE_PAGE_PER_FILE, u"One Page Per File")
        menu_save.AppendSeparator()
        menu_save.Append(wx.ID_SAVE, u"All Pages\tCTRL-W", u"Save all pages")
        menu_save.Append(wx.ID_SAVEAS, u"Selected Pages\tCTRL-S",
                         u"Save selected pages")

        menu = wx.Menu()
        menu.Append(wx.ID_OPEN, u"Open PDF\tCTRL-O", u"Open a PDF document")
        menu.AppendMenu(wx.ID_ANY, u"Save SWF", menu_save)
        menu.AppendSeparator()
        menu.AppendMenu(wx.ID_ANY, u"Recent", menu_recent)
        menu.AppendSeparator()
        menu.Append(wx.ID_EXIT, u"Exit\tCTRL-Q")
        menubar.Append(menu, u"&File")

        self.filehistory = wx.FileHistory()
        self.filehistory.UseMenu(menu_recent)

        menu = wx.Menu()
        menu.Append(wx.ID_SELECTALL, u"Select All\tCTRL-A",
                    u"Select all pages")
        menu.Append(ID_INVERT_SELECTION, u"Invert Selection",
                    u"Invert current selection")
        menu.Append(ID_SELECT_ODD, u"Select Odd", u"Select odd pages")
        menu.Append(ID_SELECT_EVEN, u"Select Even", u"Select even pages")
        menu.AppendSeparator()
        menu.Append(wx.ID_PREFERENCES, u"Options\tCTRL-R",
                    u"Show options dialog")
        menubar.Append(menu, u"&Edit")

        menu = wx.Menu()
        menu.Append(wx.ID_ZOOM_IN, u"Zoom In\tCTRL-+")
        menu.Append(wx.ID_ZOOM_OUT, u"Zoom Out\tCTRL--")
        menu.Append(wx.ID_ZOOM_100, u"Normal Size\tCTRL-0")
        menu.Append(wx.ID_ZOOM_FIT, u"Fit\tCTRL-1")
        menu.AppendSeparator()
        menu.Append(ID_DOC_INFO, u"Document Info\tCTRL-I")
        menubar.Append(menu, u"&View")

        menu = wx.Menu()
        menu.Append(wx.ID_ABOUT, u"About")
        menubar.Append(menu, u"&Help")
        self.SetMenuBar(menubar)
Ejemplo n.º 18
0
    def InitGui(self):
        """ Create the GUI. """

        # Widgets
        text = wx.StaticText(
            self, wx.ID_ANY,
            "Select a previous PIM to open from the list below, or a new PIM.")
        self.history = wx.ListBox(self, size=(300, 200))
        self.remember = wx.CheckBox(self, wx.ID_ANY,
                                    "Open the selected PIM at startup.")
        choose_button = wx.Button(self, wx.ID_ANY, "Choose")

        self.Bind(wx.EVT_BUTTON, self.OnNew, choose_button)
        self.Bind(wx.EVT_BUTTON, self.OnOk, id=wx.ID_OK)

        # Positions
        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer.AddF(text, wx.SizerFlags(0).Expand().Border(wx.BOTTOM))
        sizer.AddF(self.history, wx.SizerFlags(1).Expand())
        sizer.AddF(
            self.remember,
            wx.SizerFlags(0).Expand().Align(wx.ALIGN_LEFT).Border(wx.BOTTOM))
        sizer.AddF(choose_button, wx.SizerFlags(0).Align(wx.ALIGN_RIGHT))

        btns = self.CreateSeparatedButtonSizer(wx.OK | wx.CANCEL)

        mainSizer = wx.BoxSizer(wx.VERTICAL)

        mainSizer.AddF(sizer, wx.SizerFlags(1).Expand().Border(wx.ALL))
        mainSizer.Add(btns, 0, wx.ALL | wx.EXPAND)
        self.SetSizerAndFit(mainSizer)

        # Load the list
        config = wx.Config.Get()

        history = wx.FileHistory()
        changer = wx.ConfigPathChanger(config, "/History/")
        history.Load(config)
        changer = None

        for i in range(history.GetCount()):
            self.history.Append(history.GetHistoryFile(i))

        # Remember
        self.remember.SetValue(config.ReadBool("/OpenLast", False))
Ejemplo n.º 19
0
 def test_filehistory2(self):
     fh = wx.FileHistory()
     for fn in "one two three four".split():
         fh.AddFileToHistory(fn)
     
     menu1 = wx.Menu()
     menu2 = wx.Menu()
     fh.UseMenu(menu1)
     fh.UseMenu(menu2)
     fh.AddFilesToMenu()
     
     lst = fh.GetMenus()
     self.assertTrue(isinstance(lst, wx.FileHistoryMenuList))
     self.assertTrue(len(lst) == 2)
     self.assertTrue(len(list(lst)) == 2)
     self.assertTrue(isinstance(lst[0], wx.Menu))
     self.assertTrue(isinstance(lst[1], wx.Menu))
     self.assertTrue(lst[0] is menu1)
     self.assertTrue(lst[1] is menu2)
Ejemplo n.º 20
0
    def __init__(self, parent, style=0):
        super().__init__(style)
        self.parent = parent

        file_menu = wx.Menu()
        file_menu.Append(wx.ID_NEW, "New \tCTRL-N")
        file_menu.AppendSeparator()
        file_menu.Append(wx.ID_OPEN, "Open... \tCTRL-O")
        file_menu.Append(wx.ID_SAVE, "Save... \tCTRL-S")
        file_menu.AppendSeparator()
        file_menu.Append(FILE_MENU_QUEUE, "Queue\tCTRL-R")
        file_menu.AppendSeparator()
        file_menu.Append(FILE_MENU_TO_DIR, "Select output folder\tCTRL-D")
        file_menu.AppendSeparator()
        file_menu.Append(wx.ID_EXIT, "Quit\tCTRL-Q")

        self.file_history = wx.FileHistory()
        self.file_history.UseMenu(file_menu)

        self.Append(file_menu, "&File")

        help_menu = wx.Menu()
        help_menu.Append(wx.ID_ABOUT)

        self.Append(help_menu, "&Help")

        menu_handlers = [
            (FILE_MENU_QUEUE, self.parent.on_queue),
            (wx.ID_NEW, self.parent.on_new),
            (FILE_MENU_TO_DIR, self.parent.on_select_dir),
            (wx.ID_OPEN, self.parent.on_open_project),
            (wx.ID_SAVE, self.parent.on_save_project),
            (wx.ID_EXIT, self.parent.on_exit),
            (wx.ID_ABOUT, self.parent.on_about),
        ]
        for menu_id, handler in menu_handlers:
            self.parent.Bind(wx.EVT_MENU, handler, id=menu_id)

        self.Bind(wx.EVT_MENU_RANGE,
                  self.parent.on_file_history,
                  id=wx.ID_FILE1,
                  id2=wx.ID_FILE9)
Ejemplo n.º 21
0
    def makeMenu(self):
        """
        Method of the base class that provides a base menu
        that can be extended by the subclass.
        """
        menu_bar = wx.MenuBar()

        file_menu = wx.Menu()
        file_menu.Append(wx.ID_OPEN,
                         "&Open",
                         help="Open an existing file in a new tab")
        file_menu.Append(wx.ID_CLOSE,
                         "&Close",
                         help="Close the file associated to the active tab")
        file_menu.Append(wx.ID_EXIT, "&Quit", help="Exit the application")

        file_history = self.file_history = wx.FileHistory(8)
        file_history.Load(self.config)
        recent = wx.Menu()
        file_history.UseMenu(recent)
        file_history.AddFilesToMenu()
        file_menu.AppendMenu(-1, "&Recent Files", recent)
        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnFileHistory,
                  id=wx.ID_FILE1,
                  id2=wx.ID_FILE9)
        menu_bar.Append(file_menu, "File")

        # Associate menu/toolbar items with their handlers.
        menu_handlers = [
            (wx.ID_OPEN, self.OnOpen),
            (wx.ID_CLOSE, self.OnClose),
            (wx.ID_EXIT, self.OnExit),
        ]

        for combo in menu_handlers:
            mid, handler = combo[:2]
            self.Bind(wx.EVT_MENU, handler, id=mid)

        return menu_bar
Ejemplo n.º 22
0
    def OnOk(self, event):
        index = self.history.GetSelection()
        if index >= 0:
            self.result = self.history.GetString(index)

        config = wx.Config.Get()

        # Save the History list
        history = wx.FileHistory()
        for i in reversed(range(self.history.GetCount())):
            history.AddFileToHistory(self.history.GetString(i))

        if self.result:
            history.AddFileToHistory(self.result)

        changer = wx.ConfigPathChanger(config, "/History/")
        history.Save(config)
        changer = None

        # Save the Current Item
        config.WriteBool("/OpenLast", self.remember.IsChecked())
        config.Write("/LastPIM", "")  # It is set by the main window after open

        self.EndModal(wx.ID_OK)
Ejemplo n.º 23
0
    def SetupMenu(self):
        "Create menubar"
        # Create the menubar
        menuBar = wx.MenuBar()
        # and a menu
        menu = wx.Menu()

        # add an item to the menu, using \tKeyName automatically
        # creates an accelerator, the third param is some help text
        # that will show up in the statusbar
        menu.Append(101, _('&New product ...\tCtrl-N'),
                    _('Create new product'))
        menu.Append(102, _('&Open product ...\tCtrl-O'),
                    _('Open existing product'))
        menu.Append(103, _('Export as HTML ...'),
                    _('Export product to HTML file'))
        menu.Append(104, _('Export as XML ...'),
                    _('Export product to XML files'))
        menu.Enable(103, False)
        menu.Enable(104, False)
        menu.Append(105, _('Import ...'),
                    _('Import artefacts from AF database'))
        menu.Enable(105, False)
        menu.AppendSeparator()
        menu.Append(106, _('Statistics ...'),
                    _('Statistics of current AF database'))
        menu.Enable(106, False)
        menu.AppendSeparator()
        menu.Append(wx.ID_EXIT, _('E&xit\tAlt-X'), _('Exit this application'))

        # adding a file history to the menu
        self.filehistory = wx.FileHistory()
        self.filehistory.UseMenu(menu)
        self.filehistory.Load(self.config)

        # bind the menu event to an event handler
        self.Bind(wx.EVT_MENU, self.OnClose, id=wx.ID_EXIT)

        # and put the menu on the menubar
        menuBar.Append(menu, _('&File'))

        menu = wx.Menu()
        menu.Append(201, _('&Edit artefact ...\tCtrl-E'),
                    _('Edit selected artefact'))
        menu.Enable(201, False)

        menu.Append(203, _('&Copy artefact\tCtrl-C'),
                    _('Copy selected artefact to clipboard'))
        menu.Enable(203, False)

        menu.Append(204, _('&Paste artefact\tCtrl-V'),
                    _('Paste artefact from clipboard'))
        menu.Enable(204, False)

        menu.Append(202, _('&Delete artefact ...\tDel'),
                    _('Delete selected artefact'))
        menu.Enable(202, False)

        menu.Append(205, _('&Edit tags ...'), _('Edit tags'))
        menu.Enable(205, False)
        menuBar.Append(menu, _('&Edit'))

        menu = wx.Menu()
        menu.Append(301, _('New &feature ...'), _('Create new feature'))
        menu.Enable(301, False)

        menu.Append(302, _('New &requirement ...'),
                    _('Create new requirement'))
        menu.Enable(302, False)

        menu.Append(305, _('New &usecase ...'), _('Create new usecase'))
        menu.Enable(305, False)

        menu.Append(303, _('New &testcase ...'), _('Create new testcase'))
        menu.Enable(303, False)

        menu.Append(304, _('New test&suite ...'), _('Create new testsuite'))
        menu.Enable(304, False)

        menu.Append(306, _('New text section ...'),
                    _('Create new text section'))
        menu.Enable(306, False)

        menu.Append(307, _('New glossary entry ...'),
                    _('Create new glossary entry'))
        menu.Enable(307, False)
        menuBar.Append(menu, _('&New'))

        menu = wx.Menu()
        menu.Append(401, _('Database to archive ...'),
                    _('Dump current database to archive file'))
        menu.Enable(401, False)
        menu.Append(402, _('Archive to database ...'),
                    _('Create database from archive file'))
        menu.Enable(402, True)
        menuBar.Append(menu, _('&Archive'))

        menu = wx.Menu()
        menu.Append(501, _('General ...'), _('General settings'))
        self.Bind(wx.EVT_MENU, self.OnSettings, id=501)
        menu.Enable(501, True)
        menuBar.Append(menu, _('&Settings'))

        menu = wx.Menu()
        menu.Append(901, _('About ...'), _('Info about this program'))
        self.Bind(wx.EVT_MENU, self.OnAbout, id=901)
        menu.Enable(901, True)
        menu.Append(902, _('Feedback ...'),
                    _('How to give feedback about this program'))
        self.Bind(wx.EVT_MENU, self.OnFeedback, id=902)
        menu.Enable(902, True)
        menuBar.Append(menu, _('&Help'))

        self.SetMenuBar(menuBar)
Ejemplo n.º 24
0
    def __init__(self):
        super(mainWindow,
              self).__init__(None, title='Cura - ' + version.getVersion())

        wx.EVT_CLOSE(self, self.OnClose)

        # allow dropping any file, restrict later
        self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles))

        # TODO: wxWidgets 2.9.4 has a bug when NSView does not register for dragged types when wx drop target is set. It was fixed in 2.9.5
        if sys.platform.startswith('darwin'):
            try:
                import objc
                nswindow = objc.objc_object(
                    c_void_p=self.MacGetTopLevelWindowRef())
                view = nswindow.contentView()
                view.registerForDraggedTypes_([u'NSFilenamesPboardType'])
            except:
                pass

        self.normalModeOnlyItems = []

        mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini')
        self.config = wx.FileConfig(appName="Cura",
                                    localFilename=mruFile,
                                    style=wx.CONFIG_USE_LOCAL_FILE)

        self.ID_MRU_MODEL1, self.ID_MRU_MODEL2, self.ID_MRU_MODEL3, self.ID_MRU_MODEL4, self.ID_MRU_MODEL5, self.ID_MRU_MODEL6, self.ID_MRU_MODEL7, self.ID_MRU_MODEL8, self.ID_MRU_MODEL9, self.ID_MRU_MODEL10 = [
            wx.NewId() for line in xrange(10)
        ]
        self.modelFileHistory = wx.FileHistory(10, self.ID_MRU_MODEL1)
        self.config.SetPath("/ModelMRU")
        self.modelFileHistory.Load(self.config)

        self.ID_MRU_PROFILE1, self.ID_MRU_PROFILE2, self.ID_MRU_PROFILE3, self.ID_MRU_PROFILE4, self.ID_MRU_PROFILE5, self.ID_MRU_PROFILE6, self.ID_MRU_PROFILE7, self.ID_MRU_PROFILE8, self.ID_MRU_PROFILE9, self.ID_MRU_PROFILE10 = [
            wx.NewId() for line in xrange(10)
        ]
        self.profileFileHistory = wx.FileHistory(10, self.ID_MRU_PROFILE1)
        self.config.SetPath("/ProfileMRU")
        self.profileFileHistory.Load(self.config)

        self.menubar = wx.MenuBar()
        self.fileMenu = wx.Menu()
        i = self.fileMenu.Append(-1, _("Load model file...\tCTRL+L"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i)
        i = self.fileMenu.Append(-1, _("Save model...\tCTRL+S"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i)
        i = self.fileMenu.Append(-1, _("Reload platform\tF5"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.reloadScene(e), i)
        i = self.fileMenu.Append(-1, _("Clear platform"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Print...\tCTRL+P"))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.OnPrintButton(1), i)
        i = self.fileMenu.Append(-1, _("Save GCode..."))
        self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i)
        i = self.fileMenu.Append(-1, _("Show slice engine log..."))
        self.Bind(wx.EVT_MENU, lambda e: self.scene._showEngineLog(), i)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Open Profile..."))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
        i = self.fileMenu.Append(-1, _("Save Profile..."))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnSaveProfile, i)
        i = self.fileMenu.Append(-1, _("Load Profile from GCode..."))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i)
        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Reset Profile to default"))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnResetProfile, i)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(-1, _("Preferences...\tCTRL+,"))
        self.Bind(wx.EVT_MENU, self.OnPreferences, i)
        i = self.fileMenu.Append(-1, _("Machine settings..."))
        self.Bind(wx.EVT_MENU, self.OnMachineSettings, i)
        self.fileMenu.AppendSeparator()

        # Model MRU list
        modelHistoryMenu = wx.Menu()
        self.fileMenu.AppendMenu(wx.NewId(), '&' + _("Recent Model Files"),
                                 modelHistoryMenu)
        self.modelFileHistory.UseMenu(modelHistoryMenu)
        self.modelFileHistory.AddFilesToMenu()
        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnModelMRU,
                  id=self.ID_MRU_MODEL1,
                  id2=self.ID_MRU_MODEL10)

        # Profle MRU list
        profileHistoryMenu = wx.Menu()
        self.fileMenu.AppendMenu(wx.NewId(), _("Recent Profile Files"),
                                 profileHistoryMenu)
        self.profileFileHistory.UseMenu(profileHistoryMenu)
        self.profileFileHistory.AddFilesToMenu()
        self.Bind(wx.EVT_MENU_RANGE,
                  self.OnProfileMRU,
                  id=self.ID_MRU_PROFILE1,
                  id2=self.ID_MRU_PROFILE10)

        self.fileMenu.AppendSeparator()
        i = self.fileMenu.Append(wx.ID_EXIT, _("Quit"))
        self.Bind(wx.EVT_MENU, self.OnQuit, i)
        self.menubar.Append(self.fileMenu, '&' + _("File"))

        toolsMenu = wx.Menu()
        #i = toolsMenu.Append(-1, 'Batch run...')
        #self.Bind(wx.EVT_MENU, self.OnBatchRun, i)
        #self.normalModeOnlyItems.append(i)

        if minecraftImport.hasMinecraft():
            i = toolsMenu.Append(-1, _("Minecraft map import..."))
            self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i)

        if version.isDevVersion():
            i = toolsMenu.Append(-1, _("PID Debugger..."))
            self.Bind(wx.EVT_MENU, self.OnPIDDebugger, i)

        i = toolsMenu.Append(-1, _("Copy profile to clipboard"))
        self.Bind(wx.EVT_MENU, self.onCopyProfileClipboard, i)

        toolsMenu.AppendSeparator()
        self.allAtOnceItem = toolsMenu.Append(-1,
                                              _("Print all at once"),
                                              kind=wx.ITEM_RADIO)
        self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.allAtOnceItem)
        self.oneAtATime = toolsMenu.Append(-1,
                                           _("Print one at a time"),
                                           kind=wx.ITEM_RADIO)
        self.Bind(wx.EVT_MENU, self.onOneAtATimeSwitch, self.oneAtATime)
        if profile.getPreference('oneAtATime') == 'True':
            self.oneAtATime.Check(True)
        else:
            self.allAtOnceItem.Check(True)

        self.menubar.Append(toolsMenu, _("Tools"))

        #Machine menu for machine configuration/tooling
        self.machineMenu = wx.Menu()
        self.updateMachineMenu()

        self.menubar.Append(self.machineMenu, _("Machine"))

        expertMenu = wx.Menu()
        i = expertMenu.Append(-1,
                              _("Switch to quickprint..."),
                              kind=wx.ITEM_RADIO)
        self.switchToQuickprintMenuItem = i
        self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i)

        i = expertMenu.Append(-1,
                              _("Switch to full settings..."),
                              kind=wx.ITEM_RADIO)
        self.switchToNormalMenuItem = i
        self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
        expertMenu.AppendSeparator()

        i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E"))
        self.normalModeOnlyItems.append(i)
        self.Bind(wx.EVT_MENU, self.OnExpertOpen, i)
        expertMenu.AppendSeparator()
        i = expertMenu.Append(-1, _("Run first run wizard..."))
        self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i)
        self.bedLevelWizardMenuItem = expertMenu.Append(
            -1, _("Run bed leveling wizard..."))
        self.Bind(wx.EVT_MENU, self.OnBedLevelWizard,
                  self.bedLevelWizardMenuItem)
        self.headOffsetWizardMenuItem = expertMenu.Append(
            -1, _("Run head offset wizard..."))
        self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard,
                  self.headOffsetWizardMenuItem)

        self.menubar.Append(expertMenu, _("Expert"))

        helpMenu = wx.Menu()
        i = helpMenu.Append(-1, _("Online documentation..."))
        self.Bind(wx.EVT_MENU,
                  lambda e: webbrowser.open('http://daid.github.com/Cura'), i)
        i = helpMenu.Append(-1, _("Report a problem..."))
        self.Bind(
            wx.EVT_MENU,
            lambda e: webbrowser.open('https://github.com/daid/Cura/issues'),
            i)
        i = helpMenu.Append(-1, _("Check for update..."))
        self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i)
        if profile.getPreference('use_youmagine') == 'True':
            i = helpMenu.Append(-1, _("Open YouMagine website..."))
            self.Bind(wx.EVT_MENU,
                      lambda e: webbrowser.open('https://www.youmagine.com/'),
                      i)
        i = helpMenu.Append(-1, _("About Cura..."))
        self.Bind(wx.EVT_MENU, self.OnAbout, i)
        self.menubar.Append(helpMenu, _("Help"))
        self.SetMenuBar(self.menubar)

        self.splitter = wx.SplitterWindow(self,
                                          style=wx.SP_3D | wx.SP_LIVE_UPDATE)
        self.leftPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
        self.rightPane = wx.Panel(self.splitter, style=wx.BORDER_NONE)
        self.splitter.Bind(wx.EVT_SPLITTER_DCLICK, lambda evt: evt.Veto())

        ##Gui components##
        self.simpleSettingsPanel = simpleMode.simpleModePanel(
            self.leftPane, lambda: self.scene.sceneUpdated())
        self.normalSettingsPanel = normalSettingsPanel(
            self.leftPane, lambda: self.scene.sceneUpdated())

        self.leftSizer = wx.BoxSizer(wx.VERTICAL)
        self.leftSizer.Add(self.simpleSettingsPanel, 1)
        self.leftSizer.Add(self.normalSettingsPanel, 1, wx.EXPAND)
        self.leftPane.SetSizer(self.leftSizer)

        #Preview window
        self.scene = sceneView.SceneView(self.rightPane)

        #Main sizer, to position the preview window, buttons and tab control
        sizer = wx.BoxSizer()
        self.rightPane.SetSizer(sizer)
        sizer.Add(self.scene, 1, flag=wx.EXPAND)

        # Main window sizer
        sizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(sizer)
        sizer.Add(self.splitter, 1, wx.EXPAND)
        sizer.Layout()
        self.sizer = sizer

        self.updateProfileToAllControls()

        self.SetBackgroundColour(
            self.normalSettingsPanel.GetBackgroundColour())

        self.simpleSettingsPanel.Show(False)
        self.normalSettingsPanel.Show(False)

        # Set default window size & position
        self.SetSize((wx.Display().GetClientArea().GetWidth() / 2,
                      wx.Display().GetClientArea().GetHeight() / 2))
        self.Centre()

        #Timer set; used to check if profile is on the clipboard
        self.timer = wx.Timer(self)
        self.Bind(wx.EVT_TIMER, self.onTimer)
        self.timer.Start(1000)
        self.lastTriedClipboard = profile.getProfileString()

        # Restore the window position, size & state from the preferences file
        try:
            if profile.getPreference('window_maximized') == 'True':
                self.Maximize(True)
            else:
                posx = int(profile.getPreference('window_pos_x'))
                posy = int(profile.getPreference('window_pos_y'))
                width = int(profile.getPreference('window_width'))
                height = int(profile.getPreference('window_height'))
                if posx > 0 or posy > 0:
                    self.SetPosition((posx, posy))
                if width > 0 and height > 0:
                    self.SetSize((width, height))

            self.normalSashPos = int(
                profile.getPreference('window_normal_sash'))
        except:
            self.normalSashPos = 0
            self.Maximize(True)
        if self.normalSashPos < self.normalSettingsPanel.printPanel.GetBestSize(
        )[0] + 5:
            self.normalSashPos = self.normalSettingsPanel.printPanel.GetBestSize(
            )[0] + 5

        self.splitter.SplitVertically(self.leftPane, self.rightPane,
                                      self.normalSashPos)

        if wx.Display.GetFromPoint(self.GetPosition()) < 0:
            self.Centre()
        if wx.Display.GetFromPoint(
            (self.GetPositionTuple()[0] + self.GetSizeTuple()[1],
             self.GetPositionTuple()[1] + self.GetSizeTuple()[1])) < 0:
            self.Centre()
        if wx.Display.GetFromPoint(self.GetPosition()) < 0:
            self.SetSize((800, 600))
            self.Centre()

        self.updateSliceMode()
        self.scene.SetFocus()
Ejemplo n.º 25
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "pythonOCC Interactive Console %s"%VERSION, style=wx.DEFAULT_FRAME_STYLE,size = (1024,768))
        
        self._mgr = wx.aui.AuiManager()
        self._mgr.SetManagedWindow(self) 

        self._recentfiles = GetRecentFiles(os.path.join(THISPATH, "recentfiles"))
        self.canva = GraphicsCanva3D(self)
        self._mgr.AddPane(self.canva, wx.aui.AuiPaneInfo().Name("Canvas").Caption("Canvas").MaximizeButton().BestSize(wx.Size(300,100)).MinSize(wx.Size(300,100)).CenterPane())
        
        nb = wx.aui.AuiNotebook(self, -1)
        self.notebook = nb
        self._createbrowser()
        self._createpythonshell()
        nb.SetSelection(0)

        start_help_height = self.GetSize()[1]/3
        self._mgr.AddPane(nb, wx.aui.AuiPaneInfo().Name("Help").BestSize(wx.Size(500,500)).MinSize(wx.Size(400, start_help_height)).Right())

        self.tb = self.CreateRightToolbar()        
        self._mgr.AddPane(self.tb, wx.aui.AuiPaneInfo().Name("View").Caption("View").ToolbarPane().Top().TopDockable(True).BottomDockable(True))

        self._mgr.Update()
        self._mgr.GetPane("Help").MinSize((-1,-1)) # now make it so that the help pane can be resized

        self.DefaultPerspective = self._mgr.SavePerspective()
        # Load Layout
        tmp = LoadLayout(os.path.join(THISPATH, "layout"))
        if tmp:
            maximised, position, size, perspective = tmp
            self.LoadedPerspective = perspective
            self._mgr.LoadPerspective(self.LoadedPerspective)
            self._mgr.Update()
            self.SetSize(size)
            self.SetPosition(position)
            if maximised:
                self.Maximize()
        self.statusbar = self.CreateStatusBar(1, wx.ST_SIZEGRIP)

        # Creating Menu
        menuBar = wx.MenuBar()
        FileMenu = wx.Menu()
        
        file_id = wx.NewId()
        FileMenu.Append(file_id, "&Open", "Open a STEP file")
        self.Bind(wx.EVT_MENU, self.OnOpen, id=file_id)

        FileMenu.AppendSeparator()
        saveasbmp_id = wx.NewId()
        FileMenu.Append(saveasbmp_id, "Save as &image\tAlt-I", "Saves the current view as an image.")
        self.Bind(wx.EVT_MENU, self.SaveAsImage, id=saveasbmp_id)
        FileMenu.AppendSeparator()
        
        execpy_id = wx.NewId()
        FileMenu.Append(execpy_id, "Execute Script", "Execute a Python script in the current session.")
        self.Bind(wx.EVT_MENU, self.ExecPyFile, id=execpy_id)
        FileMenu.AppendSeparator()
        
        exit_id = wx.NewId()
        FileMenu.Append(exit_id, "&Exit", "Exit application")
        self.Bind(wx.EVT_MENU, self.OnExit, id=exit_id)

        self.filehistory = wx.FileHistory()
        self.filehistory.UseMenu(FileMenu)
        print self._recentfiles
        if len(self._recentfiles)>0:
            for f in reversed(self._recentfiles):
                self.filehistory.AddFileToHistory(f)
        self.Bind(wx.EVT_MENU_RANGE, self.OnClickRecentFile, id=wx.ID_FILE1, id2=wx.ID_FILE9)
        
        menuBar.Append(FileMenu, "&File")
        # View menu
        viewmenu = wx.Menu()
        restoreperspectiveID = wx.NewId()
        viewmenu.Append(restoreperspectiveID, u'Restore default layout', 'Restore the UI to the default layout.')
        self.Bind(wx.EVT_MENU, self.OnRestoreDefaultPerspective, id=restoreperspectiveID)       
        viewmenu.AppendSeparator()
        v_Top = wx.NewId()
        viewmenu.Append(v_Top, "Top\tAlt-1", "Top View")
        self.Bind(wx.EVT_MENU, self.View_Top, id=v_Top)
        v_Bottom = wx.NewId()
        viewmenu.Append(v_Bottom, "Bottom\tAlt-2", "Bottom View")
        self.Bind(wx.EVT_MENU, self.View_Bottom, id=v_Bottom)
        v_Left = wx.NewId()
        viewmenu.Append(v_Left, "Left\tAlt-3", "Left View")
        self.Bind(wx.EVT_MENU, self.View_Left, id=v_Left)
        v_Right = wx.NewId()
        viewmenu.Append(v_Right, "Right\tAlt-4", "Right View")
        self.Bind(wx.EVT_MENU, self.View_Right, id=v_Right)
        v_Front = wx.NewId()
        viewmenu.Append(v_Front, "Front\tAlt-5", "Front View")
        self.Bind(wx.EVT_MENU, self.View_Front, id=v_Front)
        v_Rear = wx.NewId()
        viewmenu.Append(v_Rear, "Rear\tAlt-6", "Rear View")
        self.Bind(wx.EVT_MENU, self.View_Rear, id=v_Rear)
        v_Iso = wx.NewId()
        viewmenu.Append(v_Iso, "Iso\tAlt-7", "Iso View")
        self.Bind(wx.EVT_MENU, self.View_Iso, id=v_Iso)
        z = wx.NewId()
        viewmenu.Append(z, "Zoom &All\tAlt-A", "Zoom All")
        self.Bind(wx.EVT_MENU, self._zoomall, id=z)
        menuBar.Append(viewmenu, "&View")

        # Selection menu
        selection_menu = wx.Menu()
        s_vertex = wx.NewId()
        selection_menu.Append(s_vertex, u'Vertex', 'Select vertices.')
        self.Bind(wx.EVT_MENU, self.OnSelectionVertex, id=s_vertex)
        s_edge = wx.NewId()
        selection_menu.Append(s_edge, u'Edge', 'Select edges.')
        self.Bind(wx.EVT_MENU, self.OnSelectionEdge, id=s_edge)
        s_face = wx.NewId()
        selection_menu.Append(s_face, u'Face', 'Select faces.')
        self.Bind(wx.EVT_MENU, self.OnSelectionFace, id=s_face)
        s_neutral = wx.NewId()
        selection_menu.Append(s_neutral, u'Neutral', 'Switch back to global shapes selction.')
        self.Bind(wx.EVT_MENU, self.OnSelectionNeutral, id=s_neutral)
        menuBar.Append(selection_menu, "&Selection")

        # DisplayMode menu
        displaymode_menu = wx.Menu()
        d_wireframe = wx.NewId()
        displaymode_menu.Append(d_wireframe, u'Wireframe', 'Switch to wireframe mode.')
        self.Bind(wx.EVT_MENU, self.OnDisplayModeWireframe, id=d_wireframe)
        d_shaded = wx.NewId()
        displaymode_menu.Append(d_shaded, u'Shaded', 'Switch to shaded mode.')
        self.Bind(wx.EVT_MENU, self.OnDisplayModeShaded, id=d_shaded)
        displaymode_menu.AppendSeparator()
        d_qhlr = wx.NewId()
        displaymode_menu.Append(d_qhlr, u'Quick HLR', 'Switch to Quick Hidden Line Removal mode.')
        self.Bind(wx.EVT_MENU, self.OnDisplayModeQHLR, id=d_qhlr)
        d_ehlr = wx.NewId()
        displaymode_menu.Append(d_ehlr, u'Exact HLR', 'Switch to Exact Hidden Line Removal mode.')
        self.Bind(wx.EVT_MENU, self.OnDisplayModeEHLR, id=d_ehlr)
        displaymode_menu.AppendSeparator()
        d_aon = wx.NewId()
        displaymode_menu.Append(d_aon, u'AntiAliasing On', 'Enable antialiasing.')
        self.Bind(wx.EVT_MENU, self.OnAntialiasingOn, id=d_aon)
        d_aoff = wx.NewId()
        displaymode_menu.Append(d_aoff, u'Antialiasing Off', 'Disable antialiasing.')
        self.Bind(wx.EVT_MENU, self.OnAntialiasingOff, id=d_aoff)
        menuBar.Append(displaymode_menu, "&Display mode")
        
        # About menu
        about_menu = wx.Menu()
        a_id = wx.NewId()
        about_menu.Append(a_id, "&About", "")
        self.Bind(wx.EVT_MENU, self.OnAbout, id=a_id)
        menuBar.Append(about_menu, "&Help")
        
        self.SetMenuBar(menuBar)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        self._refreshui()
Ejemplo n.º 26
0
Archivo: app.py Proyecto: stcorp/visan
    def OnInit(self):

        # Make sure the file location for our preferences exists
        userDataDir = wx.StandardPaths.Get().GetUserDataDir()
        if not os.path.exists(userDataDir):
            os.mkdir(userDataDir)

        self.productdir = wx.StandardPaths.Get().GetDocumentsDir()

        # Initialize preferences
        configStyle = wx.CONFIG_USE_LOCAL_FILE
        if wx.Platform == '__WXGTK__':
            configStyle |= wx.CONFIG_USE_SUBDIR
        config = wx.Config(appName='visan', style=configStyle)
        config.SetRecordDefaults()
        wx.Config.Set(config)

        # Set some global defaults
        config.Read('UserMode', 'EndUser')
        config.Read('DirectoryLocation/Export', wx.StandardPaths.Get().GetDocumentsDir())
        config.Read('DirectoryLocation/Products', self.productdir)
        config.Read('DirectoryLocation/Scripts', self.exampledir)
        # datadir is not something that the user should change, but it is usefull to be able to get
        # to this parameter using the Config system, so that is why we set it here explicitly
        config.Write('DirectoryLocation/ApplicationData', self.datadir)
        # since icons are platform specific we store the appropriate icon to use in the config
        if wx.Platform == '__WXGTK__':
            config.Write('IconFile', os.path.join(self.datadir, "visan32.ico"))
        else:
            config.Write('IconFile', os.path.join(self.datadir, "visan.ico"))

        if config.Read('UserMode') == 'Developer':
            # allows you to pop up a window with an overview of all the widgets in VISAN
            # the shortcut for this is Ctrl-Alt-I (or Cmd-Alt-I on Mac)
            InspectionMixin.Init(self)

        self.filehistory = wx.FileHistory()
        self.recentfiles = False

        coda.set_option_perform_conversions(config.ReadBool('CODA/PerformConversions', True))
        coda.set_option_filter_record_fields(config.ReadBool('CODA/FilterRecordFields', True))

        self.frame = VisanFrame(self, "VISAN " + VERSION, WindowHandler.GetNextPosition((800, 640)), (800, 640))
        self.SetTopWindow(self.frame)
        self.shell = self.frame.shell

        self._PrefsToFileHistory()

        self._SetupLogging()

        wx.py.dispatcher.connect(receiver=self.CheckForExit, signal='Interpreter.push')

        self.frame.Show(True)

        if wx.Config.Get().ReadBool('ShowIntroFrame', True):
            self.ShowIntro()

        self._CreateSplashScreen()

        if len(sys.argv) > 1:
            # don't treat macos -psn arguments as a startup script
            if not (wx.Platform == '__WXMAC__' and sys.argv[1].startswith('-psn_')):
                self._ExecuteScript(sys.argv[1])

        return True
Ejemplo n.º 27
0
    def __init__(self,
                 parent,
                 configfile,
                 fileconfigfile,
                 suggestedTrackers,
                 toChannel=False):
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           'Create a .torrent',
                           size=(600, 200))
        self.guiutility = GUIUtility.getInstance()
        self.toChannel = toChannel

        vSizer = wx.BoxSizer(wx.VERTICAL)

        header = wx.StaticText(self, -1, 'Browse for a file or files')
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.locationText = StaticText(self, -1, '')
        vSizer.Add(self.locationText, 0, wx.EXPAND | wx.BOTTOM, 3)

        browseButton = wx.Button(self, -1, 'Browse')
        browseButton.Bind(wx.EVT_BUTTON, self.OnBrowse)

        browseDirButton = wx.Button(self, -1, 'Browse for a Directory')
        browseDirButton.Bind(wx.EVT_BUTTON, self.OnBrowseDir)

        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(browseButton)
        hSizer.Add(browseDirButton)
        vSizer.Add(hSizer, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 3)

        #self.recursive = wx.CheckBox(self, -1, 'Include all subdirectories')
        #self.recursive.Bind(wx.EVT_CHECKBOX, self.OnRecursive)
        #vSizer.Add(self.recursive, 0, wx.ALIGN_RIGHT|wx.BOTTOM, 3)

        vSizer.Add(wx.StaticLine(self, -1), 0,
                   wx.EXPAND | wx.LEFT | wx.RIGHT | wx.BOTTOM, 10)

        header = wx.StaticText(self, -1, '.Torrent details')
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.foundFilesText = StaticText(
            self, -1, 'Please select a file or files first')
        vSizer.Add(self.foundFilesText, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.combineRadio = wx.RadioButton(
            self,
            -1,
            'Combine files into a single .torrent',
            style=wx.RB_GROUP)
        self.combineRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine)
        self.combineRadio.Enable(False)

        self.sepRadio = wx.RadioButton(
            self, -1, 'Create separate .torrent for every file')
        self.sepRadio.Bind(wx.EVT_RADIOBUTTON, self.OnCombine)
        self.sepRadio.Enable(False)

        vSizer.Add(self.combineRadio, 0, wx.EXPAND | wx.BOTTOM, 3)
        vSizer.Add(self.sepRadio, 0, wx.EXPAND | wx.BOTTOM, 3)

        self.specifiedName = wx.TextCtrl(self, -1, '')
        self.specifiedName.Enable(False)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(wx.StaticText(self, -1, 'Specify a name'), 0,
                   wx.ALIGN_CENTER_VERTICAL)
        hSizer.Add(self.specifiedName, 1, wx.EXPAND)
        vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, 'Trackers'))
        self.trackerList = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE)
        self.trackerList.SetMinSize((500, -1))

        self.trackerHistory = wx.FileHistory(10)
        self.config = wx.FileConfig(appName="Tribler",
                                    localFilename=configfile)
        self.trackerHistory.Load(self.config)

        if self.trackerHistory.GetCount() > 0:
            trackers = [
                self.trackerHistory.GetHistoryFile(i)
                for i in range(self.trackerHistory.GetCount())
            ]
            if len(trackers) < len(suggestedTrackers):
                trackers.extend(suggestedTrackers[:len(suggestedTrackers) -
                                                  len(trackers)])
        else:
            trackers = suggestedTrackers

        for tracker in trackers:
            self.trackerList.AppendText(tracker + "\n")

        vSizer.Add(self.trackerList, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, 'Comment'))
        self.commentList = wx.TextCtrl(self, -1, '', style=wx.TE_MULTILINE)
        vSizer.Add(self.commentList, 0, wx.EXPAND, 3)

        vSizer.Add(wx.StaticLine(self, -1), 0,
                   wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 10)

        header = wx.StaticText(self, -1, 'Advanced options')
        _set_font(header, fontweight=wx.FONTWEIGHT_BOLD)
        vSizer.Add(header, 0, wx.EXPAND | wx.BOTTOM | wx.TOP, 3)

        abbrev_mb = " " + self.guiutility.utility.lang.get('MB')
        abbrev_kb = " " + self.guiutility.utility.lang.get('KB')
        piece_choices = [
            self.guiutility.utility.lang.get('automatic'), '4' + abbrev_mb,
            '2' + abbrev_mb, '1' + abbrev_mb, '512' + abbrev_kb,
            '256' + abbrev_kb, '128' + abbrev_kb, '64' + abbrev_kb,
            '32' + abbrev_kb
        ]
        self.pieceChoice = wx.Choice(self, -1, choices=piece_choices)
        self.pieceChoice.SetSelection(0)
        hSizer = wx.BoxSizer(wx.HORIZONTAL)
        hSizer.Add(StaticText(self, -1, 'Piecesize'), 1)
        hSizer.Add(self.pieceChoice)
        vSizer.Add(hSizer, 0, wx.EXPAND | wx.BOTTOM, 3)

        vSizer.Add(StaticText(self, -1, 'Webseed'))
        self.webSeed = wx.TextCtrl(self, -1,
                                   'Please select a file or files first')
        self.webSeed.Enable(False)
        vSizer.Add(self.webSeed, 0, wx.EXPAND | wx.BOTTOM, 3)

        cancel = wx.Button(self, wx.ID_CANCEL)
        cancel.Bind(wx.EVT_BUTTON, self.OnCancel)

        create = wx.Button(self, wx.ID_OK, 'Create .torrent(s)')
        create.Bind(wx.EVT_BUTTON, self.OnOk)

        bSizer = wx.StdDialogButtonSizer()
        bSizer.AddButton(cancel)
        bSizer.AddButton(create)
        bSizer.Realize()
        vSizer.Add(bSizer, 0, wx.EXPAND)

        sizer = wx.BoxSizer()
        sizer.Add(vSizer, 1, wx.EXPAND | wx.ALL, 10)
        self.SetSizerAndFit(sizer)

        self.selectedPaths = []
        self.createdTorrents = []
        self.cancelEvent = Event()

        self.filehistory = wx.FileHistory(1)
        self.fileconfig = wx.FileConfig(appName="Tribler",
                                        localFilename=fileconfigfile)
        self.filehistory.Load(self.fileconfig)

        if self.filehistory.GetCount() > 0:
            self.latestFile = self.filehistory.GetHistoryFile(0)
        else:
            self.latestFile = ''
        self.paths = None
Ejemplo n.º 28
0
from .localization import _translate
import requests.exceptions

try:
    import pyosf
    from pyosf import constants
    constants.PROJECT_NAME = "PsychoPy"
    havePyosf = True
    if pyosf.__version__ < "1.0.3":
        logging.warn(
            "pyosf is version {} whereas PsychoPy expects 1.0.3+".format(
                pyosf.__version__))
except ImportError:
    havePyosf = False

usersList = wx.FileHistory(maxFiles=10, idBase=wx.NewId())

projectsFolder = os.path.join(prefs.paths['userPrefsDir'], 'projects')


class ProjectCatalog(dict):
    """Handles info about known project files (either in project history or in
    the ~/.psychopy/projects folder).
    """
    def __init__(self, *args, **kwargs):
        dict.__init__(self, *args, **kwargs)
        self.refresh()

    def projFromId(self, id):
        for key, item in list(self.items()):
            if item.project_id == id:
Ejemplo n.º 29
0
 def __setFileHistory(self):
     self.filehistory = wx.FileHistory(5)
     self.history_config = wx.Config("Good Viewer",
                                     style=wx.CONFIG_USE_LOCAL_FILE)
     self.filehistory.Load(self.history_config)
Ejemplo n.º 30
0
    def __init__(self):
        # os.environ['LANGUAGE'] = 'ko'
        trans = gettext.translation("service_ppt", "locale", fallback=True)
        trans.install()
        global _
        _ = trans.gettext

        cmdui.set_translation(trans)
        pd.set_translation(trans)

        self.image_path24 = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "image24")
        self.image_path32 = os.path.join(
            os.path.dirname(os.path.abspath(__file__)), "image32")

        self.command_toolbar = None
        self.command_ctrl = None
        self.command_imglist = None
        self.settings_panel = None
        self.uimgr = cmdui.UIManager()

        self._filename = None
        self.m_save = None

        self.config = wx.FileConfig("ServicePPT", vendorName="EMC")
        self.pconfig = pc.PreferencesConfig()
        self.pconfig.read_config(self.config)
        cmdui.GenerateBibleVerseUI.current_bible_format = self.pconfig.current_bible_format
        bibfileformat.set_format_option(self.pconfig.current_bible_format,
                                        "ROOT_DIR", self.pconfig.bible_rootdir)

        self.filehistory = wx.FileHistory(8)
        self.filehistory.Load(self.config)
        self.m_recent = None

        self.window_rect = None
        sw = pc.SW_RESTORED
        window_rect = None
        wp = self.pconfig.read_window_rect(self.config)
        if wp:
            sw = wp[0]
            window_rect = wp[1]
        else:
            sw = pc.SW_RESTORED
            disp = wx.Display(0)
            rc = disp.GetClientArea()
            tl = rc.GetTopLeft()
            wh = rc.GetSize()
            window_rect = (tl[0] + wh[0] // 4, tl[1] + wh[1] // 4, wh[0] // 2,
                           wh[1] // 2)

        app_display_name = _("Service Presentation Generator")
        style = wx.DEFAULT_DIALOG_STYLE | wx.SYSTEM_MENU | wx.CLOSE_BOX | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX
        wx.Frame.__init__(
            self,
            None,
            title=app_display_name,
            style=style,
        )
        wx.App.Get().SetAppDisplayName(app_display_name)
        self.Bind(wx.EVT_MOVE, self.on_move)
        self.Bind(wx.EVT_SIZE, self.on_move)

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

        self.SetIcon(wx.Icon(os.path.join(self.image_path32, "bible.png")))

        self.create_menubar()
        self.create_toolbar()
        self.create_statusbar()
        self.init_controls()
        self._set_title()

        if self.window_rect:
            self.SetSize(*window_rect)
        if sw == pc.SW_ICONIZED:
            self.Iconize()
        elif sw == pc.SW_MAXIMIZED:
            self.Maximize()