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()
def __init__(self): super(mainWindow, self).__init__(None, title='Cura-BCN3D-' + version.getVersion() + '-beta2') 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) #Now we create the different menu options, the first one is the options displayed by the 'File' button 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, _("Load Draudi file...\tCTRL+D")) self.Bind(wx.EVT_MENU, self.OnLoadDraudiModel, 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\tCTRL+Q")) 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...\tCTRL+G")) 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...\tCTRL+C")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnLoadConfigurations(), i) i = self.fileMenu.Append(-1, _("Save Profile...")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) if version.isDevVersion(): i = self.fileMenu.Append(-1, "Save difference from default...") self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveDifferences, 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, _("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) #Here we set the name of the menubar, which in this case is 'File' self.menubar.Append(self.fileMenu, '&' + _("File")) #The next menu option is 'Tools' toolsMenu = wx.Menu() #At BCN3D we do not recommend printing one at a time and we have set a message to come up #in case a user does choose that option. 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) #We name this menu option self.menubar.Append(toolsMenu, _("Tools")) #Machine menu for machine configuration/tooling self.machineMenu = wx.Menu() self.updateMachineMenu() self.menubar.Append(self.machineMenu, _("Machine")) #we switch between panels 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() #Open a series of settings that you are not normally able to see i = expertMenu.Append(-1, _("Open expert settings...\tCTRL+E")) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() 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) #give the menu bar a name, in this case 'Expert' self.menubar.Append(expertMenu, _("Expert")) helpMenu = wx.Menu() i = helpMenu.Append(-1, _("Online documentation...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open( 'http://www.bcn3dtechnologies.com/es/forum'), i) if sys.platform.startswith('win'): i = helpMenu.Append(-1, _("Report a problem...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open( 'https://github.com/BCN3D/BCN3D-Cura-Windows/issues'), i) elif sys.platform.startswith('darwin'): i = helpMenu.Append(-1, _("Report a problem...")) self.Bind( wx.EVT_MENU, lambda e: webbrowser.open( 'https://github.com/BCN3D/BCN3D-Cura-Mac/issues'), i) i = helpMenu.Append(-1, _("Check for update...")) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, 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()) #Preview window self.scene = sceneView.SceneView(self.rightPane) ##Gui components## #We want two different simple modes, one for BCN3D users and the default cura one for other machines #Currently working on this, will be available soon #machine_type = profile.getMachineSetting('machine_type') #if machine_type == 'BCN3DSigma': # self.simpleSettingsPanel = simpleModeSigma(self.leftPane, self.scene.sceneUpdated) #else: #call to the different panels self.simpleSettingsPanel = simpleMode.simpleModePanel( self.leftPane, self.scene.sceneUpdated) self.normalSettingsPanel = normalSettingsPanel(self.leftPane, self.scene.sceneUpdated) #Simple panel will be fix while you can change the size for advanced panel 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) #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() self.dialogframe = None if Publisher is not None: Publisher().subscribe(self.onPluginUpdate, "pluginupdate") pluginCount = self.normalSettingsPanel.pluginPanel.GetActivePluginCount( ) if pluginCount == 1: self.scene.notification.message( "Warning: 1 plugin from the previous session is still active.") if pluginCount > 1: self.scene.notification.message( "Warning: %i plugins from the previous session are still active." % pluginCount)
def __init__(self): super(mainWindow, self).__init__(None, title='migbot ' ) self.extruderCount = int(profile.getPreference('extruder_amount')) if profile.getPreference('language') is not None: language.switchTo(profile.getPreference('language')) wx.EVT_CLOSE(self, self.OnClose) self.SetDropTarget(dropTarget.FileDropTarget(self.OnDropFiles, meshLoader.loadSupportedExtensions())) self.normalModeOnlyItems = [] mruFile = os.path.join(profile.getBasePath(), 'mru_filelist.ini') self.config = wx.FileConfig(appName="migbot", 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, language.getText('Load model file...\tCTRL+L')) self.Bind(wx.EVT_MENU, lambda e: self.scene.showLoadModel(), i) i = self.fileMenu.Append(-1, language.getText('Save model...\tCTRL+S')) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveModel(), i) i = self.fileMenu.Append(-1, language.getText('Clear platform')) self.Bind(wx.EVT_MENU, lambda e: self.scene.OnDeleteAll(e), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, language.getText('Print...\tCTRL+P')) self.Bind(wx.EVT_MENU, lambda e: self.scene.showPrintWindow(), i) i = self.fileMenu.Append(-1, language.getText('Save GCode...')) self.Bind(wx.EVT_MENU, lambda e: self.scene.showSaveGCode(), i) i = self.fileMenu.Append(-1, language.getText('Show slice engine log...')) self.Bind(wx.EVT_MENU, lambda e: self.scene._showSliceLog(), i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, language.getText('Open Profile...')) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfile, i) i = self.fileMenu.Append(-1, language.getText('Save Profile...')) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveProfile, i) i = self.fileMenu.Append(-1, language.getText('Load Profile from GCode...')) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnLoadProfileFromGcode, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, language.getText('Reset Profile to default')) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnResetProfile, i) self.fileMenu.AppendSeparator() i = self.fileMenu.Append(-1, language.getText('Preferences...\tCTRL+,')) self.Bind(wx.EVT_MENU, self.OnPreferences, i) i = self.fileMenu.Append(-1, language.getText('Language...')) self.Bind(wx.EVT_MENU, self.OnLanguage, i) self.fileMenu.AppendSeparator() # Model MRU list modelHistoryMenu = wx.Menu() self.fileMenu.AppendMenu(wx.NewId(), language.getText("&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(), language.getText("&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, language.getText('Quit')) self.Bind(wx.EVT_MENU, self.OnQuit, i) self.menubar.Append(self.fileMenu, language.getText('&File')) toolsMenu = wx.Menu() i = toolsMenu.Append(-1, language.getText('Switch to quickprint...')) self.switchToQuickprintMenuItem = i self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i) i = toolsMenu.Append(-1, language.getText('Switch to full settings...')) self.switchToNormalMenuItem = i self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i) toolsMenu.AppendSeparator() #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, language.getText('Minecraft import...')) self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i) self.menubar.Append(toolsMenu, language.getText('Tools')) expertMenu = wx.Menu() i = expertMenu.Append(-1, language.getText('Open expert settings...')) self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnExpertOpen, i) expertMenu.AppendSeparator() if firmwareInstall.getDefaultFirmware() is not None: i = expertMenu.Append(-1, language.getText('Install default Marlin firmware')) self.Bind(wx.EVT_MENU, self.OnDefaultMarlinFirmware, i) i = expertMenu.Append(-1, language.getText('Install custom firmware')) self.Bind(wx.EVT_MENU, self.OnCustomFirmware, i) expertMenu.AppendSeparator() i = expertMenu.Append(-1, language.getText('Run first run wizard...')) self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i) i = expertMenu.Append(-1, language.getText('Run bed leveling wizard...')) self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, i) if self.extruderCount > 1: i = expertMenu.Append(-1, language.getText('Run head offset wizard...')) self.Bind(wx.EVT_MENU, self.OnHeadOffsetWizard, i) self.menubar.Append(expertMenu, language.getText('Expert')) helpMenu = wx.Menu() i = helpMenu.Append(-1, language.getText('Online documentation...')) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('http://daid.github.com/Cura'), i) i = helpMenu.Append(-1, language.getText('Report a problem...')) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('https://github.com/daid/Cura/issues'), i) i = helpMenu.Append(-1, language.getText('migbot Documentation...')) self.Bind(wx.EVT_MENU, lambda e: webbrowser.open('www.migbot.com'), i) i = helpMenu.Append(-1, language.getText('Check for update...')) self.Bind(wx.EVT_MENU, self.OnCheckForUpdate, i) i = helpMenu.Append(-1, language.getText('About migbot...')) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, language.getText('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) 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.updateProfileToControls() 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() # 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()
def __init__(self): # 软件标题 super(mainWindow, self).__init__(None, title='Tianjin DaGe Technology Co.Ltd') 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() # 添加菜单栏 #file的菜单,第一个 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\tCTRL+D")) 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...\tCTRL+G")) 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) if version.isDevVersion(): i = self.fileMenu.Append(-1, "Save difference from default...") self.normalModeOnlyItems.append(i) self.Bind(wx.EVT_MENU, self.OnSaveDifferences, 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() ## Disabled the reset profile option, as it resets to global defaults, not machine defaults. # 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) # Profile 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")) # Tools菜单,第二个 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, _("Auto Firmware Update...")) self.Bind(wx.EVT_MENU, self.OnAutoFirmwareUpdate, 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")) # Expert菜单 第四个 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() 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")) # help菜单 第五个 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) 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 Software...")) self.Bind(wx.EVT_MENU, self.OnAbout, i) self.menubar.Append(helpMenu, _("Help")) self.SetMenuBar(self.menubar) ##################################以上5个菜单,全部结束########################### self.splitter = wx.SplitterWindow(self, style = wx.SP_3D | wx.SP_LIVE_UPDATE) # 将界面划分为两个子界面,一个是3D效果的 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()) #Preview window # 第一次调用该模块 # 该函数还有关于OpenGL的知识,需要学习掌握 self.scene = sceneView.SceneView(self.rightPane) # 将右边的界面传到该函数,实现预览功能 ##Gui components## # 第一次调用simpleMode # 将左边的界面传入,实现相关的功能 self.simpleSettingsPanel = simpleMode.simpleModePanel(self.leftPane, self.scene.sceneUpdated) # 调用simpleMode.py的功能 self.normalSettingsPanel = normalSettingsPanel(self.leftPane, self.scene.sceneUpdated) # BoxSizer # Google翻译一个框分级机背后的基本想法是,窗口将最多以相当简单的基本几何形状布置,通常在一排或一列或任几个层次结构。 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) #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 # Timer 设置,用来检查轮廓图是否在剪贴板上 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)) # 设置x,y坐标 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() self.dialogframe = None if Publisher is not None: Publisher().subscribe(self.onPluginUpdate, "pluginupdate") pluginCount = self.normalSettingsPanel.pluginPanel.GetActivePluginCount() if pluginCount == 1: self.scene.notification.message("Warning: 1 plugin from the previous session is still active.") if pluginCount > 1: self.scene.notification.message("Warning: %i plugins from the previous session are still active." % pluginCount)