Exemple #1
0
 def __init__(self):
     wx.Frame.__init__(self,None,title="P6 Proving Ground",size=(1230,425))
     
     self.guiLoop=None
     
     self.vSizer = wx.BoxSizer(wx.VERTICAL)
     self.grid = wx.GridBagSizer(hgap=5, vgap=5)
     self.hSizer = wx.BoxSizer(wx.HORIZONTAL)
     
     filemenu=wx.Menu()        
     # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
     menuAbout = filemenu.Append(wx.ID_ABOUT,"&About"," Info about this program") 
     filemenu.AppendSeparator()
     menuExit = filemenu.Append(wx.ID_EXIT,"E&xit"," Terminate the program")        
     
     reportmenu=wx.Menu()
     menuEmailOn = reportmenu.Append(ID_EMAILON,"&Enable Email","Enable Email Reporting")
     menuEmailOff = reportmenu.Append(ID_EMAILOFF,"&Disable Email","Disable Email Reporting")
     menuEmailReady = reportmenu.Append(ID_EMAILREADY,"&Send Email Now","Force Send New Report")
     reportmenu.AppendSeparator()
     menuShowAddr = reportmenu.Append(ID_ADDRBOOK,"Show Active &Address Book","Display Email Recipient List")
     
     datamenu=wx.Menu()
     menuReconnectTtData=datamenu.Append(ID_GETTTDATA,"Reconnect &TT Data","Reconnect to TT Price Server")
     menuReconnectArcLogData=datamenu.Append(ID_GETARCLOGDATA,"Reconnect &Arc Log","Reconnect to ARC Log")
     datamenu.AppendSeparator()
     menuReloadData=datamenu.Append(ID_RELOADDATA,"&Reload Today's Fills","Reload TT and Manual Fills from File")
     menuLoadOvernight=datamenu.Append(ID_LOADOVERNIGHT,"&Load Overnight Positions","Load Positions Carried Overnight")
     
     menuBar=wx.MenuBar()
     menuBar.Append(filemenu,"&File")
     menuBar.Append(reportmenu,"&Reporting")
     menuBar.Append(datamenu,"&Data")
     self.SetMenuBar(menuBar)    #add the MenuBar to the frame content
     self.sb=CustomStatusBar(self)
     self.SetStatusBar(self.sb)
     
     self.Bind(wx.EVT_MENU, self.OnAbout, menuAbout)
     self.Bind(wx.EVT_MENU, self.DoExit, menuExit)
     
     self.Bind(wx.EVT_MENU, self.OnEmailEnabled, menuEmailOn)
     self.Bind(wx.EVT_MENU, self.OnEmailDisabled, menuEmailOff)
     self.Bind(wx.EVT_MENU, self.OnEmailReady, menuEmailReady)
     self.Bind(wx.EVT_MENU, self.OnShowAddr, menuShowAddr)
     
     self.Bind(wx.EVT_MENU, self.OnReconnectTt, menuReconnectTtData)
     self.Bind(wx.EVT_MENU, self.OnReconnectArcLog, menuReconnectArcLogData)
     self.Bind(wx.EVT_MENU, self.OnReloadData, menuReloadData)
     self.Bind(wx.EVT_MENU, self.OnLoadOvernight, menuLoadOvernight)
     
     wx.EVT_MENU(self, ID_EXIT,  self.DoExit)
     wx.EVT_MENU(self, ID_EMAILON,  self.OnEmailEnabled)
     wx.EVT_MENU(self, ID_EMAILOFF,  self.OnEmailDisabled)
     wx.EVT_MENU(self, ID_EMAILREADY,  self.OnEmailReady)
     wx.EVT_MENU(self, ID_ADDRBOOK,  self.OnShowAddr)
     wx.EVT_MENU(self, ID_GETTTDATA,  self.OnReconnectTt)
     wx.EVT_MENU(self, ID_GETARCLOGDATA,  self.OnReconnectArcLog)
     wx.EVT_MENU(self, ID_RELOADDATA,  self.OnReloadData)
     wx.EVT_MENU(self, ID_LOADOVERNIGHT,  self.OnLoadOvernight)
     
     #create panel and notebook on the panel
     p = wx.Panel(self)
     self.nb = wx.Notebook(p)
     #self.sb = StateBar(p)
     
     #create page windows as children of notebook
     self.pages=[]
     #self.pages.append(StatusPanel(self.nb))
     self.pages.append(SummaryGrid(self.nb))
     self.pages.append(ManualOrderPanel(self.nb))
     self.pages.append(ReportingPanel(self.nb))
     self.pages.append(SynthGrid(self.nb,cfg.BOOK.ngxPrompt))
     for n in cfg.BOOK.All:
         self.pages.append(PortfolioGrid(self.nb,n))          
     
     #add pages to notebook
     self.nb.AddPage(self.pages[0],"Sum")
     self.nb.AddPage(self.pages[1],"OrderEntry")
     self.nb.AddPage(self.pages[2],"Reporting")
     self.nb.AddPage(self.pages[3],"Synth")
     i=self.nb.GetPageCount()
     for n in cfg.BOOK.All:
         self.nb.AddPage(self.pages[i],n.Name)
         i+=1
         
     #put notebook in sizer for panel to manage
     sizer = wx.BoxSizer()
     sizer.Add(self.nb,1,wx.EXPAND)
     p.SetSizer(sizer)
     
     self.guiLoop=LoopingCall(self.OnGuiUpdate)
     self.guiLoop.start(cfg.INTERVAL_UPDATE_GUI)
             
     # make sure reactor.stop() is used to stop event loop:
     wx.EVT_CLOSE(self, lambda evt: reactor.stop())
Exemple #2
0
    def __init__(self):
        super(mainWindow,
              self).__init__(title='Cura - ' + version.getVersion())

        wx.EVT_CLOSE(self, self.OnClose)
        #self.SetIcon(icon.getMainIcon())

        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        i = fileMenu.Append(-1, 'Load model file...')
        self.Bind(wx.EVT_MENU, lambda e: self._showModelLoadDialog(1), i)
        fileMenu.AppendSeparator()
        i = fileMenu.Append(-1, 'Open Profile...')
        self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
        i = fileMenu.Append(-1, 'Save Profile...')
        self.Bind(wx.EVT_MENU, self.OnSaveProfile, i)
        fileMenu.AppendSeparator()
        i = fileMenu.Append(-1, 'Reset Profile to default')
        self.Bind(wx.EVT_MENU, self.OnResetProfile, i)
        fileMenu.AppendSeparator()
        i = fileMenu.Append(-1, 'Preferences...')
        self.Bind(wx.EVT_MENU, self.OnPreferences, i)
        fileMenu.AppendSeparator()
        i = fileMenu.Append(-1, 'Open project planner...')
        self.Bind(wx.EVT_MENU, self.OnProjectPlanner, i)
        fileMenu.AppendSeparator()
        i = fileMenu.Append(wx.ID_EXIT, 'Quit')
        self.Bind(wx.EVT_MENU, self.OnQuit, i)
        menubar.Append(fileMenu, '&File')

        simpleMenu = wx.Menu()
        i = simpleMenu.Append(-1, 'Switch to Quickprint...')
        self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i)
        menubar.Append(simpleMenu, 'Simple')

        expertMenu = wx.Menu()
        i = expertMenu.Append(-1, 'Open expert settings...')
        self.Bind(wx.EVT_MENU, self.OnExpertOpen, i)
        i = expertMenu.Append(-1, 'Open SVG (2D) slicer...')
        self.Bind(wx.EVT_MENU, self.OnSVGSlicerOpen, i)
        expertMenu.AppendSeparator()
        i = expertMenu.Append(-1, 'Install default Marlin firmware')
        self.Bind(wx.EVT_MENU, self.OnDefaultMarlinFirmware, i)
        i = expertMenu.Append(-1, 'Install custom firmware')
        self.Bind(wx.EVT_MENU, self.OnCustomFirmware, i)
        expertMenu.AppendSeparator()
        i = expertMenu.Append(-1, 'ReRun first run wizard...')
        self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i)
        menubar.Append(expertMenu, 'Expert')

        helpMenu = wx.Menu()
        i = helpMenu.Append(-1, 'Online documentation...')
        self.Bind(
            wx.EVT_MENU,
            lambda e: webbrowser.open('https://github.com/daid/Cura/wiki'), i)
        i = helpMenu.Append(-1, 'Report a problem...')
        self.Bind(
            wx.EVT_MENU,
            lambda e: webbrowser.open('https://github.com/daid/Cura/issues'),
            i)
        menubar.Append(helpMenu, 'Help')
        self.SetMenuBar(menubar)

        if profile.getPreference('lastFile') != '':
            self.filelist = profile.getPreference('lastFile').split(';')
            self.SetTitle(self.filelist[-1] + ' - Cura - ' +
                          version.getVersion())
        else:
            self.filelist = []
        self.progressPanelList = []

        #Preview window
        self.preview3d = preview3d.previewPanel(self)

        #Main tabs
        nb = wx.Notebook(self)

        (left, right) = self.CreateConfigTab(nb, 'Print config')

        configBase.TitleRow(left, "Accuracy")
        c = configBase.SettingRow(
            left, "Layer height (mm)", 'layer_height', '0.2',
            'Layer height in millimeters.\n0.2 is a good value for quick prints.\n0.1 gives high quality prints.'
        )
        validators.validFloat(c, 0.0001)
        validators.warningAbove(
            c, lambda:
            (float(profile.getProfileSetting('nozzle_size')) * 80.0 / 100.0),
            "Thicker layers then %.2fmm (80%% nozzle size) usually give bad results and are not recommended."
        )
        c = configBase.SettingRow(
            left, "Wall thickness (mm)", 'wall_thickness', '0.8',
            'Thickness of the walls.\nThis is used in combination with the nozzle size to define the number\nof perimeter lines and the thickness of those perimeter lines.'
        )
        validators.validFloat(c, 0.0001)
        validators.wallThicknessValidator(c)

        configBase.TitleRow(left, "Fill")
        c = configBase.SettingRow(
            left, "Bottom/Top thickness (mm)", 'solid_layer_thickness', '0.6',
            'This controls the thickness of the bottom and top layers, the amount of solid layers put down is calculated by the layer thickness and this value.\nHaving this value a multiply of the layer thickness makes sense. And keep it near your wall thickness to make an evenly strong part.'
        )
        validators.validFloat(c, 0.0)
        c = configBase.SettingRow(
            left, "Fill Density (%)", 'fill_density', '20',
            'This controls how densily filled the insides of your print will be. For a solid part use 100%, for an empty part use 0%. A value around 20% is usually enough'
        )
        validators.validFloat(c, 0.0, 100.0)

        configBase.TitleRow(left, "Skirt")
        c = configBase.SettingRow(
            left, "Line count", 'skirt_line_count', '1',
            'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt. Multiple skirt lines can help priming your extruder better for small objects.'
        )
        validators.validInt(c, 0, 10)
        c = configBase.SettingRow(
            left, "Start distance (mm)", 'skirt_gap', '6.0',
            'The distance between the skirt and the first layer.\nThis is the minimal distance, multiple skirt lines will be put outwards from this distance.'
        )
        validators.validFloat(c, 0.0)

        configBase.TitleRow(right, "Speed")
        c = configBase.SettingRow(
            right, "Print speed (mm/s)", 'print_speed', '50',
            'Speed at which printing happens. A well adjusted Ultimaker can reach 150mm/s, but for good quality prints you want to print slower. Printing speed depends on a lot of factors. So you will be experimenting with optimal settings for this.'
        )
        validators.validFloat(c, 1.0)
        validators.warningAbove(
            c, 150.0,
            "It is highly unlikely that your machine can achieve a printing speed above 150mm/s"
        )
        validators.printSpeedValidator(c)

        configBase.TitleRow(right, "Temperature")
        c = configBase.SettingRow(
            right, "Printing temperature", 'print_temperature', '0',
            'Temperature used for printing. Set at 0 to pre-heat yourself')
        validators.validFloat(c, 0.0, 340.0)
        validators.warningAbove(
            c, 260.0,
            "Temperatures above 260C could damage your machine, be careful!")

        configBase.TitleRow(right, "Support")
        c = configBase.SettingRow(
            right, "Support type", 'support',
            ['None', 'Exterior Only', 'Everywhere', 'Empty Layers Only'],
            'Type of support structure build.\n"Exterior only" is the most commonly used support setting.\n\nNone does not do any support.\nExterior only only creates support on the outside.\nEverywhere creates support even on the insides of the model.\nOnly on empty layers is for stacked objects.'
        )
        c = configBase.SettingRow(
            right, "Add raft", 'enable_raft', False,
            'A raft is a few layers of lines below the bottom of the object. It prevents warping. Full raft settings can be found in the expert settings.\nFor PLA this is usually not required. But if you print with ABS it is almost required.'
        )

        configBase.TitleRow(right, "Filament")
        c = configBase.SettingRow(
            right, "Diameter (mm)", 'filament_diameter', '2.89',
            'Diameter of your filament, as accurately as possible.\nIf you cannot measure this value you will have to callibrate it, a higher number means less extrusion, a smaller number generates more extrusion.'
        )
        validators.validFloat(c, 1.0)
        validators.warningAbove(
            c, 3.5,
            "Are you sure your filament is that thick? Normal filament is around 3mm or 1.75mm."
        )
        c = configBase.SettingRow(
            right, "Packing Density", 'filament_density', '1.00',
            'Packing density of your filament. This should be 1.00 for PLA and 0.85 for ABS'
        )
        validators.validFloat(c, 0.5, 1.5)

        (left, right) = self.CreateConfigTab(nb, 'Advanced config')

        configBase.TitleRow(left, "Machine size")
        c = configBase.SettingRow(
            left, "Nozzle size (mm)", 'nozzle_size', '0.4',
            'The nozzle size is very important, this is used to calculate the line width of the infill, and used to calculate the amount of outside wall lines and thickness for the wall thickness you entered in the print settings.'
        )
        validators.validFloat(c, 0.1, 1.0)
        c = configBase.SettingRow(
            left, "Machine center X (mm)", 'machine_center_x', '100',
            'The center of your machine, your print will be placed at this location'
        )
        validators.validInt(c, 10)
        configBase.settingNotify(c, self.preview3d.updateCenterX)
        c = configBase.SettingRow(
            left, "Machine center Y (mm)", 'machine_center_y', '100',
            'The center of your machine, your print will be placed at this location'
        )
        validators.validInt(c, 10)
        configBase.settingNotify(c, self.preview3d.updateCenterY)

        configBase.TitleRow(left, "Retraction")
        c = configBase.SettingRow(
            left, "Minimal travel (mm)", 'retraction_min_travel', '5.0',
            'Minimal amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area'
        )
        validators.validFloat(c, 0.0)
        c = configBase.SettingRow(
            left, "Speed (mm/s)", 'retraction_speed', '40.0',
            'Speed at which the filament is retracted, a higher retraction speed works better. But a very high retraction speed can lead to filament grinding.'
        )
        validators.validFloat(c, 0.1)
        c = configBase.SettingRow(
            left, "Distance (mm)", 'retraction_amount', '0.0',
            'Amount of retraction, set at 0 for no retraction at all. A value of 2.0mm seems to generate good results.'
        )
        validators.validFloat(c, 0.0)
        c = configBase.SettingRow(
            left, "Extra length on start (mm)", 'retraction_extra', '0.0',
            'Extra extrusion amount when restarting after a retraction, to better "Prime" your extruder after retraction.'
        )
        validators.validFloat(c, 0.0)

        configBase.TitleRow(right, "Speed")
        c = configBase.SettingRow(
            right, "Travel speed (mm/s)", 'travel_speed', '150',
            'Speed at which travel moves are done, a high quality build Ultimaker can reach speeds of 250mm/s. But some machines might miss steps then.'
        )
        validators.validFloat(c, 1.0)
        validators.warningAbove(
            c, 300.0,
            "It is highly unlikely that your machine can achieve a travel speed above 300mm/s"
        )
        c = configBase.SettingRow(
            right, "Max Z speed (mm/s)", 'max_z_speed', '1.0',
            'Speed at which Z moves are done. When you Z axis is properly lubercated you can increase this for less Z blob.'
        )
        validators.validFloat(c, 0.5)
        c = configBase.SettingRow(
            right, "Bottom layer speed (mm/s)", 'bottom_layer_speed', '25',
            'Print speed for the bottom layer, you want to print the first layer slower so it sticks better to the printer bed.'
        )
        validators.validFloat(c, 0.0)

        configBase.TitleRow(right, "Cool")
        c = configBase.SettingRow(
            right, "Minimal layer time (sec)", 'cool_min_layer_time', '10',
            'Minimum time spend in a layer, gives the layer time to cool down before the next layer is put on top. If the layer will be placed down too fast the printer will slow down to make sure it has spend atleast this amount of seconds printing this layer.'
        )
        validators.validFloat(c, 0.0)
        c = configBase.SettingRow(
            right, "Enable cooling fan", 'fan_enabled', True,
            'Enable the cooling fan during the print. The extra cooling from the cooling fan is essensial during faster prints.'
        )

        configBase.TitleRow(right, "Accuracy")
        c = configBase.SettingRow(
            right, "Initial layer thickness (mm)", 'bottom_thickness', '0.0',
            'Layer thickness of the bottom layer. A thicker bottom layer makes sticking to the bed easier. Set to 0.0 to have the bottom layer thickness the same as the other layers.'
        )
        validators.validFloat(c, 0.0)
        validators.warningAbove(
            c, lambda:
            (float(profile.getProfileSetting('nozzle_size')) * 3.0 / 4.0),
            "A bottom layer of more then %.2fmm (3/4 nozzle size) usually give bad results and is not recommended."
        )
        c = configBase.SettingRow(
            right, "Enable 'skin'", 'enable_skin', False,
            'Skin prints the outer lines of the prints twice, each time with half the thickness. This gives the illusion of a higher print quality.'
        )

        nb.AddPage(alterationPanel.alterationPanel(nb), "Start/End-GCode")

        # load and slice buttons.
        loadButton = wx.Button(self, -1, 'Load Model')
        sliceButton = wx.Button(self, -1, 'Slice to GCode')
        printButton = wx.Button(self, -1, 'Print GCode')
        self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(1),
                  loadButton)
        self.Bind(wx.EVT_BUTTON, self.OnSlice, sliceButton)
        self.Bind(wx.EVT_BUTTON, self.OnPrint, printButton)

        extruderCount = int(profile.getPreference('extruder_amount'))
        if extruderCount > 1:
            loadButton2 = wx.Button(self, -1, 'Load Dual')
            self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(2),
                      loadButton2)
        if extruderCount > 2:
            loadButton3 = wx.Button(self, -1, 'Load Tripple')
            self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(3),
                      loadButton3)
        if extruderCount > 2:
            loadButton4 = wx.Button(self, -1, 'Load Quad')
            self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(4),
                      loadButton4)

        #Also bind double clicking the 3D preview to load an STL file.
        self.preview3d.glCanvas.Bind(wx.EVT_LEFT_DCLICK,
                                     lambda e: self._showModelLoadDialog(1),
                                     self.preview3d.glCanvas)

        #Main sizer, to position the preview window, buttons and tab control
        sizer = wx.GridBagSizer()
        self.SetSizer(sizer)
        sizer.Add(nb, (0, 0), span=(1, 1), flag=wx.EXPAND)
        sizer.Add(self.preview3d, (0, 1),
                  span=(1, 2 + extruderCount),
                  flag=wx.EXPAND)
        sizer.AddGrowableCol(2 + extruderCount)
        sizer.AddGrowableRow(0)
        sizer.Add(loadButton, (1, 1), flag=wx.RIGHT, border=5)
        if extruderCount > 1:
            sizer.Add(loadButton2, (1, 2), flag=wx.RIGHT, border=5)
        if extruderCount > 2:
            sizer.Add(loadButton3, (1, 3), flag=wx.RIGHT, border=5)
        if extruderCount > 3:
            sizer.Add(loadButton4, (1, 4), flag=wx.RIGHT, border=5)
        sizer.Add(sliceButton, (1, 1 + extruderCount), flag=wx.RIGHT, border=5)
        sizer.Add(printButton, (1, 2 + extruderCount), flag=wx.RIGHT, border=5)
        self.sizer = sizer

        if len(self.filelist) > 0:
            self.preview3d.loadModelFiles(self.filelist)

        self.updateProfileToControls()

        self.Fit()
        self.SetMinSize(self.GetSize())
        self.Centre()
        self.Show(True)
Exemple #3
0
    def __init__(self):
        super(mainWindow,
              self).__init__(None, title='Cura - ' + version.getVersion())

        self.extruderCount = int(profile.getPreference('extruder_amount'))

        wx.EVT_CLOSE(self, self.OnClose)

        self.SetDropTarget(
            dropTarget.FileDropTarget(self.OnDropFiles,
                                      meshLoader.supportedExtensions()))

        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._showModelLoadDialog(1), i)
        i = self.fileMenu.Append(-1, 'Prepare print...\tCTRL+R')
        self.Bind(wx.EVT_MENU, self.OnSlice, i)
        i = self.fileMenu.Append(-1, 'Print...\tCTRL+P')
        self.Bind(wx.EVT_MENU, self.OnPrint, 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)
        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, 'Switch to quickprint...')
        self.switchToQuickprintMenuItem = i
        self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i)
        i = toolsMenu.Append(-1, 'Switch to full settings...')
        self.switchToNormalMenuItem = i
        self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
        toolsMenu.AppendSeparator()
        i = toolsMenu.Append(-1, 'Project planner...')
        self.Bind(wx.EVT_MENU, self.OnProjectPlanner, i)
        self.normalModeOnlyItems.append(i)
        i = toolsMenu.Append(-1, 'Batch run...')
        self.Bind(wx.EVT_MENU, self.OnBatchRun, i)
        self.normalModeOnlyItems.append(i)
        #		i = toolsMenu.Append(-1, 'Open SVG (2D) slicer...')
        #		self.Bind(wx.EVT_MENU, self.OnSVGSlicerOpen, i)
        if minecraftImport.hasMinecraft():
            i = toolsMenu.Append(-1, 'Minecraft import...')
            self.Bind(wx.EVT_MENU, self.OnMinecraftImport, i)
        self.menubar.Append(toolsMenu, 'Tools')

        expertMenu = wx.Menu()
        i = expertMenu.Append(-1, '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, 'Install default Marlin firmware')
            self.Bind(wx.EVT_MENU, self.OnDefaultMarlinFirmware, i)
        i = expertMenu.Append(-1, 'Install custom firmware')
        self.Bind(wx.EVT_MENU, self.OnCustomFirmware, i)
        expertMenu.AppendSeparator()
        i = expertMenu.Append(-1, 'Run first run wizard...')
        self.Bind(wx.EVT_MENU, self.OnFirstRunWizard, i)
        i = expertMenu.Append(-1, 'Run bed leveling wizard...')
        self.Bind(wx.EVT_MENU, self.OnBedLevelWizard, i)
        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)
        self.menubar.Append(helpMenu, 'Help')
        self.SetMenuBar(self.menubar)

        if profile.getPreference('lastFile') != '':
            self.filelist = profile.getPreference('lastFile').split(';')
            self.SetTitle('Cura - %s - %s' %
                          (version.getVersion(), self.filelist[-1]))
        else:
            self.filelist = []
        self.progressPanelList = []

        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)
        self.normalSettingsPanel = normalSettingsPanel(self.leftPane)

        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.preview3d = preview3d.previewPanel(self.rightPane)

        #Also bind double clicking the 3D preview to load an STL file.
        #self.preview3d.glCanvas.Bind(wx.EVT_LEFT_DCLICK, lambda e: self._showModelLoadDialog(1), self.preview3d.glCanvas)

        #Main sizer, to position the preview window, buttons and tab control
        sizer = wx.BoxSizer()
        self.rightPane.SetSizer(sizer)
        sizer.Add(self.preview3d, 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

        if len(self.filelist) > 0:
            self.preview3d.loadModelFiles(self.filelist)

            # Update the Model MRU
            for idx in xrange(0, len(self.filelist)):
                self.addToModelMRU(self.filelist[idx])

        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()

        self.Show(True)
Exemple #4
0
    def __init__(self, cfgGl):
        wx.Frame.__init__(self, None, -1, "Commands",
                          size = (650, 600), style = wx.DEFAULT_FRAME_STYLE)

        self.Center()

        vsizer = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(vsizer)

        s = '<table border="1"><tr><td><b>Key(s)</b></td>'\
            '<td><b>Command</b></td></tr>'

        for cmd in cfgGl.commands:
            s += '<tr><td bgcolor="#dddddd" valign="top">'

            if cmd.keys:
                for key in cmd.keys:
                    k = util.Key.fromInt(key)
                    s += "%s<br>" % xss.escape(k.toStr())
            else:
                s += "No key defined<br>"

            s += '</td><td valign="top">'
            s += "%s" % xss.escape(cmd.desc)
            s += "</td></tr>"

        s += "</table>"

        self.html = """
<html><head></head><body>

%s

<pre>
<b>Mouse:</b>

Left click             Position cursor
Left click + drag      Select text
Right click            Unselect

<b>Keyboard shortcuts in Find/Replace dialog:</b>

F                      Find
R                      Replace
</pre>
</body></html>
        """ % s

        htmlWin = wx.html.HtmlWindow(self)
        rep = htmlWin.GetInternalRepresentation()
        rep.SetIndent(0, wx.html.HTML_INDENT_BOTTOM)
        htmlWin.SetPage(self.html)
        htmlWin.SetFocus()

        vsizer.Add(htmlWin, 1, wx.EXPAND)

        id = wx.NewId()
        menu = wx.Menu()
        menu.Append(id, "&Save as...")

        mb = wx.MenuBar()
        mb.Append(menu, "&File")
        self.SetMenuBar(mb)

        wx.EVT_MENU(self, id, self.OnSave)

        self.Layout()

        wx.EVT_CLOSE(self, self.OnCloseWindow)
Exemple #5
0
    def _setup_exit_hook(self):
        def set_finished(event):
            logger.debug("Window closed")
            self.finished.set()

        wx.EVT_CLOSE(self.m.win, set_finished)
Exemple #6
0
    def make_menu(self):
        # event section
        #wx.EVT_BUTTON(self._mainframe, 1003, self.on_close)
        wx.EVT_CLOSE(self._mainframe, self.on_close)
        #wx.EVT_IDLE(self._mainframe, self.on_idle)

        # print 'make_menu'
        menubar = self._mainframe.menubar
        menubar.append_menu('Scenario')
        # menubar.append_menu( 'Scenario/import',
        #    bitmap = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE,wx.ART_MENU),
        #    )

        menubar.append_menu(
            'Scenario/create',
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_MENU),
        )

        menubar.append_item(
            'Scenario/create/new...',
            self.on_create,
            info='Create new, empty scenario.',
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_MENU),
        )

        menubar.append_item(
            'Scenario/create/create from xml...',
            self.on_create_from_xml,
            info='Create scenario from various sumo xml files.',
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_MENU),
        )

        if networkxtools.IS_NX:
            menubar.append_item(
                'Scenario/create/create from osmnx...',
                self.on_create_from_osmnx,
                bitmap=wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_MENU),
            )
            menubar.append_item(
                'Scenario/create/import from osmnx in current...',
                self.on_import_osmnx,
                bitmap=wx.ArtProvider.GetBitmap(wx.ART_NEW, wx.ART_MENU),
            )

        menubar.append_item(
            'Scenario/open...',
            self.on_open,
            info='Open a new scenario from a Python binary file.',
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_MENU),
        )

        menubar.append_item(
            'Scenario/browse',
            self.on_browse_obj,  # common function in modulegui
            info='View and browse Scenario in object panel.',
            bitmap=self.get_agileicon('icon_browse_24px.png'),  # ,
        )

        menubar.append_item(
            'Scenario/safe',
            self.on_save,
            shortkey='Ctrl+S',
            info='Save current scenario in a Python binary file.',
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE, wx.ART_MENU),
        )

        menubar.append_item(
            'Scenario/safe as...',
            self.on_save_as,
            info='Save as scenario in a Python binary file.',
            bitmap=wx.ArtProvider.GetBitmap(wx.ART_FILE_SAVE_AS, wx.ART_MENU),
        )

        menubar.append_item('Scenario/quit...',
                            self.on_close,
                            info='Quit Sumopy',
                            shortkey='Ctrl+Q',
                            bitmap=wx.ArtProvider.GetBitmap(
                                wx.ART_QUIT, wx.ART_MENU))
Exemple #7
0
    def __init__(self):
        super(simpleModeWindow, self).__init__(title='Cura - Quickprint - ' +
                                               version.getVersion())

        wx.EVT_CLOSE(self, self.OnClose)
        #self.SetIcon(icon.getMainIcon())

        self.SetDropTarget(
            dropTarget.FileDropTarget(self.OnDropFiles,
                                      meshLoader.supportedExtensions()))

        menubar = wx.MenuBar()
        fileMenu = wx.Menu()
        i = fileMenu.Append(-1, 'Load model file...\tCTRL+L')
        self.Bind(wx.EVT_MENU, self.OnLoadModel, i)
        i = fileMenu.Append(-1, 'Prepare print...\tCTRL+R')
        self.Bind(wx.EVT_MENU, self.OnSlice, i)
        i = fileMenu.Append(-1, 'Print...\tCTRL+P')
        self.Bind(wx.EVT_MENU, self.OnPrint, i)
        fileMenu.AppendSeparator()
        i = fileMenu.Append(-1, 'Preferences...\tCTRL+,')
        self.Bind(wx.EVT_MENU, self.OnPreferences, i)
        fileMenu.AppendSeparator()
        i = fileMenu.Append(wx.ID_EXIT, 'Quit')
        self.Bind(wx.EVT_MENU, self.OnQuit, i)
        menubar.Append(fileMenu, '&File')

        toolsMenu = wx.Menu()
        i = toolsMenu.Append(-1, 'Switch to Normal mode...')
        self.Bind(wx.EVT_MENU, self.OnNormalSwitch, i)
        menubar.Append(toolsMenu, 'Normal mode')

        helpMenu = wx.Menu()
        i = helpMenu.Append(-1, 'Online documentation...')
        self.Bind(wx.EVT_MENU,
                  lambda e: webbrowser.open('https://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)
        menubar.Append(helpMenu, 'Help')
        self.SetMenuBar(menubar)

        if profile.getPreference('lastFile') != '':
            self.filelist = profile.getPreference('lastFile').split(';')
            self.SetTitle('Cura - %s - %s' %
                          (version.getVersion(), self.filelist[-1]))
        else:
            self.filelist = []
        self.progressPanelList = []

        #Preview window
        self.preview3d = preview3d.previewPanel(self)

        configPanel = wx.Panel(self)
        printTypePanel = wx.Panel(configPanel)
        self.printTypeNormal = wx.RadioButton(printTypePanel,
                                              -1,
                                              'Normal quality print',
                                              style=wx.RB_GROUP)
        self.printTypeLow = wx.RadioButton(printTypePanel, -1,
                                           'Fast low quality print')
        self.printTypeHigh = wx.RadioButton(printTypePanel, -1,
                                            'High quality print')
        self.printTypeJoris = wx.RadioButton(printTypePanel, -1,
                                             'Thin walled cup or vase')

        printMaterialPanel = wx.Panel(configPanel)
        self.printMaterialPLA = wx.RadioButton(printMaterialPanel,
                                               -1,
                                               'PLA',
                                               style=wx.RB_GROUP)
        self.printMaterialABS = wx.RadioButton(printMaterialPanel, -1, 'ABS')
        self.printMaterialDiameter = wx.TextCtrl(
            printMaterialPanel, -1,
            profile.getProfileSetting('filament_diameter'))

        self.printSupport = wx.CheckBox(configPanel, -1,
                                        'Print support structure')

        sizer = wx.GridBagSizer()
        configPanel.SetSizer(sizer)

        sb = wx.StaticBox(printTypePanel, label="Select a print type:")
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        boxsizer.Add(self.printTypeNormal)
        boxsizer.Add(self.printTypeLow)
        boxsizer.Add(self.printTypeHigh)
        boxsizer.Add(self.printTypeJoris)
        printTypePanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
        printTypePanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
        sizer.Add(printTypePanel, (0, 0), flag=wx.EXPAND)

        sb = wx.StaticBox(printMaterialPanel, label="Material:")
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        boxsizer.Add(self.printMaterialPLA)
        boxsizer.Add(self.printMaterialABS)
        boxsizer.Add(wx.StaticText(printMaterialPanel, -1, 'Diameter:'))
        boxsizer.Add(self.printMaterialDiameter)
        printMaterialPanel.SetSizer(wx.BoxSizer(wx.VERTICAL))
        printMaterialPanel.GetSizer().Add(boxsizer, flag=wx.EXPAND)
        sizer.Add(printMaterialPanel, (1, 0), flag=wx.EXPAND)

        sb = wx.StaticBox(configPanel, label="Other:")
        boxsizer = wx.StaticBoxSizer(sb, wx.VERTICAL)
        boxsizer.Add(self.printSupport)
        sizer.Add(boxsizer, (2, 0), flag=wx.EXPAND)

        # load and slice buttons.
        loadButton = wx.Button(self, -1, '&Load Model')
        sliceButton = wx.Button(self, -1, 'P&repare print')
        printButton = wx.Button(self, -1, '&Print')
        self.Bind(wx.EVT_BUTTON, self.OnLoadModel, loadButton)
        self.Bind(wx.EVT_BUTTON, self.OnSlice, sliceButton)
        self.Bind(wx.EVT_BUTTON, self.OnPrint, printButton)
        #Also bind double clicking the 3D preview to load an STL file.
        self.preview3d.glCanvas.Bind(wx.EVT_LEFT_DCLICK, self.OnLoadModel,
                                     self.preview3d.glCanvas)

        #Main sizer, to position the preview window, buttons and tab control
        sizer = wx.GridBagSizer()
        self.SetSizer(sizer)
        sizer.Add(configPanel, (0, 0), span=(1, 1), flag=wx.EXPAND)
        sizer.Add(self.preview3d, (0, 1), span=(1, 3), flag=wx.EXPAND)
        sizer.AddGrowableCol(2)
        sizer.AddGrowableRow(0)
        sizer.Add(loadButton, (1, 1),
                  flag=wx.RIGHT | wx.BOTTOM | wx.TOP,
                  border=5)
        sizer.Add(sliceButton, (1, 2),
                  flag=wx.RIGHT | wx.BOTTOM | wx.TOP,
                  border=5)
        sizer.Add(printButton, (1, 3),
                  flag=wx.RIGHT | wx.BOTTOM | wx.TOP,
                  border=5)
        self.sizer = sizer

        if len(self.filelist) > 0:
            self.preview3d.loadModelFiles(self.filelist)

        self.SetBackgroundColour(configPanel.GetBackgroundColour())

        self.updateProfileToControls()

        self.printTypeNormal.SetValue(True)
        self.printMaterialPLA.SetValue(True)

        self.Fit()
        self.preview3d.Fit()
        self.SetMinSize(self.GetSize())
        self.Centre()
        self.Show(True)
Exemple #8
0
    def __init__(self, parent, renwin, objs=None):
        """Constructor of the vtkPipelineBrowser.

        If objs == None, this class assumes that you want a full pipeline
        which it will extract starting at the renwin.  If you have some
        vtk objects however, this class will act as a segment browser with
        those objects as the root nodes.  In the latter case, the renwin
        will still be used for performing updates.
        """

        self.renwin = renwin
        self._objs = objs

        # this will be a dictionary of already existing ConfigVtkObj's using
        # the vtk_obj as key... this is to enable us to lookup already running
        # instances and just reactivate them
        self._config_vtk_objs = {}

        self._frame = wx.Frame(parent=parent,
                               id=-1,
                               title="VTK Pipeline Browser")
        wx.EVT_CLOSE(self._frame, lambda e: self.hide())

        panel = wx.Panel(parent=self._frame, id=-1)

        tree_id = wx.NewId()
        self._tree_ctrl = wx.TreeCtrl(parent=panel,
                                      id=tree_id,
                                      size=wx.Size(300, 400),
                                      style=wx.TR_HAS_BUTTONS)

        wx.EVT_TREE_ITEM_ACTIVATED(panel, tree_id, self.item_activate_cb)

        button_sizer = wx.BoxSizer(wx.HORIZONTAL)

        refr_id = wx.NewId()
        refr = wx.Button(parent=panel, id=refr_id, label="Refresh")
        wx.EVT_BUTTON(panel, refr_id, self.refresh)
        button_sizer.Add(refr)

        q_id = wx.NewId()
        q = wx.Button(parent=panel, id=q_id, label="Close")
        wx.EVT_BUTTON(panel, q_id, lambda e, s=self: s.hide())
        button_sizer.Add(q)

        top_sizer = wx.BoxSizer(wx.VERTICAL)

        top_sizer.Add(self._tree_ctrl, proportion=1, flag=wx.EXPAND)
        top_sizer.Add(button_sizer,
                      proportion=0,
                      flag=wx.ALIGN_CENTER_HORIZONTAL)

        panel.SetAutoLayout(True)
        panel.SetSizer(top_sizer)
        top_sizer.Fit(self._frame)
        top_sizer.SetSizeHints(self._frame)

        #self._frame.Show(True)

        ICONDIR = "Icons"

        # Look for Icons subdirectory in the same directory as this module
        try:
            # handling frozen installs.
            home, exe = os.path.split(sys.executable)
            if string.lower(exe[:6]) == 'python':
                _icondir = os.path.join(os.path.dirname(__file__), ICONDIR)
            else:  # frozen (added by Prabhu, I think?)
                _icondir = os.path.join(home, ICONDIR)
        except NameError:
            # this probably means that __file__ didn't exist, and that
            # we're being run directly, in which case we have to use
            # argv[0] and ICONDIR to find the real icondir
            _icondir = os.path.join(os.path.dirname(sys.argv[0]), ICONDIR)
        if os.path.isdir(_icondir):
            ICONDIR = _icondir
        elif not os.path.isdir(ICONDIR):
            raise RuntimeError, "can't find icon directory (%s)" % ` ICONDIR `

        self._image_list = wx.ImageList(16, 16)
        for i in icon_map.values():
            self._image_list.Add(
                wx.Bitmap(os.path.join(ICONDIR, i + ".xpm"),
                          wx.BITMAP_TYPE_XPM))
        self._tree_ctrl.SetImageList(self._image_list)

        # do initial population of tree
        self.refresh()
    def __init__(self, parent, ID, title, messenger, exitCallback):
        wx.Frame.__init__(self, parent, ID, title)

        self._messenger = messenger
        self.exitCallback = exitCallback

        DISCONNECT = 100
        EXIT = 101

        # Create a menu bar
        # TRANSLATORS: this is a menu bar entry
        fileMenu = wx.Menu(_("File"))
        # TRANSLATORS: this is a menu bar entry
        fileMenu.Append(DISCONNECT, _("Disconnect"),
                        _("Disconnect from server"))
        fileMenu.Append(EXIT,
                        _("Exit%(hotkey)s") % {"hotkey": "\tCTRL+Q"},
                        _("Exit London Law"))
        menuBar = wx.MenuBar()
        # TRANSLATORS: this is a menu bar entry
        menuBar.Append(fileMenu, _("File"))
        self.SetMenuBar(menuBar)

        self.status = self.CreateStatusBar()

        # stick everything in a panel
        mainPanel = wx.Panel(self, -1)

        self.list = AutoListCtrl(
            mainPanel,
            -1,
            # TRANSLATORS: these are column labels for the window where the user chooses a game
            (
                _("Game Room"),
                # TRANSLATORS: these are column labels for the window where the user chooses a game
                _("Status"),
                # TRANSLATORS: these are column labels for the window where the user chooses a game
                _("Game Type"),
                # TRANSLATORS: these are column labels for the window where the user chooses a game
                _("Players")),
            (_("(no games currently available)"), "", "", ""))

        self.list.SetColumnWidth(1, 140)
        self.list.SetColumnWidth(2, 140)

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.list, 1, wx.ALIGN_CENTRE | wx.EXPAND | wx.ALL, 5)

        self.selectButton = wx.Button(mainPanel, -1, _("Join Game"))
        self.selectButton.Disable()
        self.createButton = wx.Button(mainPanel, -1, _("New Game"))
        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
        buttonSizer.Add((1, 1), 1, wx.EXPAND)
        buttonSizer.Add(self.createButton, 0,
                        wx.ALIGN_CENTRE | wx.RIGHT | wx.BOTTOM | wx.ALL, 5)
        buttonSizer.Add(self.selectButton, 0,
                        wx.ALIGN_CENTRE | wx.RIGHT | wx.BOTTOM | wx.ALL, 5)
        mainSizer.Add(buttonSizer, 0, wx.EXPAND, 0)

        mainPanel.SetSizer(mainSizer)
        mainSizer.Fit(mainPanel)

        wx.EVT_CLOSE(self, self.menuExit)
        wx.EVT_MENU(self, EXIT, self.menuExit)
        wx.EVT_MENU(self, DISCONNECT, self.menuDisconnect)
        wx.EVT_LIST_ITEM_SELECTED(self, self.list.GetId(),
                                  self.enableSelectButton)
        wx.EVT_LIST_ITEM_DESELECTED(self, self.list.GetId(),
                                    self.disableSelectButton)
        wx.EVT_BUTTON(self, self.selectButton.GetId(), self.joinGame)
        wx.EVT_BUTTON(self, self.createButton.GetId(), self.createGame)
Exemple #10
0
    def __init__(self):
        super(newVersionDialog,
              self).__init__(None, title="Welcome to the new version!")

        wx.EVT_CLOSE(self, self.OnClose)

        p = wx.Panel(self)
        self.panel = p
        s = wx.BoxSizer()
        self.SetSizer(s)
        s.Add(p, flag=wx.ALL, border=15)
        s = wx.BoxSizer(wx.VERTICAL)
        p.SetSizer(s)

        title = wx.StaticText(p, -1, 'Cura - ' + version.getVersion())
        title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
        s.Add(title, flag=wx.ALIGN_CENTRE | wx.EXPAND | wx.BOTTOM, border=5)
        s.Add(wx.StaticText(p, -1, 'Welcome to the new version of Cura.'))
        s.Add(wx.StaticText(p, -1, '(This dialog is only shown once)'))
        s.Add(wx.StaticLine(p), flag=wx.EXPAND | wx.TOP | wx.BOTTOM, border=10)
        s.Add(wx.StaticText(p, -1, 'New in this version:'))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed a problem which was introduced in 14.09.\n    There are extreme amounts of head movements generated.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Speed up GCode generation for large models by as much as 40%'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed problems with placement of multiple objects on the build platform'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Prevent installing firmware for Ultimaker Original+ on an Ultimaker Original'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed generating big GCode files (more then 200MB) on Windows'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* French translation updates (Thanks to Jeremie Francois)'))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed a problem where "everywhere" support did not work when german was used as language.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Changed the handling of the heated bed, now always heats\n    the bed first instead of bed and nozzle at the same time.\n    This to prevent the nozzle from leaking empty.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed the "uninstall old Cura versions" option in the windows installer.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Improved the search for old installations, so old settings are copied over.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed a bug where double clicking a file on windows did not load the file in Cura.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Made sure the firmware versions for Ultimaker printers always match the Cura release number.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Added a quick access button for expert settings of a certain setting.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Added some more raft settings to dial in the raft better.'))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed the tooltip of support material. Now it actually explains the angles properly.'
            ))
        s.Add(
            wx.StaticText(
                p, -1,
                '* Fixed a bug which caused the USB printing window to stop working (Thanks to SpaxGuy)'
            ))
        s.Add(
            wx.StaticText(
                p, -1, '* Fix a bug where Cura would stop generating GCode'))
        s.Add(wx.StaticText(p, -1, '* Added latest offerings of Printrbot'))

        self.hasUltimaker = None
        self.hasUltimaker2 = None
        for n in xrange(0, profile.getMachineCount()):
            if profile.getMachineSetting('machine_type', n) == 'ultimaker':
                self.hasUltimaker = n
            if profile.getMachineSetting('machine_type', n) == 'ultimaker2':
                self.hasUltimaker2 = n
        if self.hasUltimaker is not None and False:
            s.Add(wx.StaticLine(p),
                  flag=wx.EXPAND | wx.TOP | wx.BOTTOM,
                  border=10)
            s.Add(
                wx.StaticText(p, -1,
                              'New firmware for your Ultimaker Original:'))
            s.Add(wx.StaticText(p, -1, '* .'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, self.OnUltimakerFirmware, button)
            s.Add(button, flag=wx.TOP, border=5)
        if self.hasUltimaker2 is not None:
            s.Add(wx.StaticLine(p),
                  flag=wx.EXPAND | wx.TOP | wx.BOTTOM,
                  border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your Ultimaker2:'))
            s.Add(
                wx.StaticText(
                    p, -1,
                    '* Detect when the endstops are not working properly.\n    Which prevents the bed from damaging the nozzle.'
                ))
            s.Add(
                wx.StaticText(
                    p, -1,
                    '* Added the ability to import/export material profiles to the SD card.'
                ))
            s.Add(
                wx.StaticText(p, -1,
                              '* Improved hotend temperature stability.'))
            s.Add(wx.StaticText(p, -1, '* Added UPET material profile.'))
            s.Add(
                wx.StaticText(
                    p, -1, '* Minor improvements to the time estimate code.'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, self.OnUltimaker2Firmware, button)
            s.Add(button, flag=wx.TOP, border=5)

        s.Add(wx.StaticLine(p), flag=wx.EXPAND | wx.TOP | wx.BOTTOM, border=10)
        button = wx.Button(p, -1, 'Ok')
        self.Bind(wx.EVT_BUTTON, self.OnOk, button)
        s.Add(button, flag=wx.TOP | wx.ALIGN_RIGHT, border=5)

        self.Fit()
        self.Centre()
Exemple #11
0
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        wx.EVT_CLOSE(self, self.OnCloseWindow)

        self.Canvas1 = MyCanvas(self, wx.NewId())
	def __init__(self, parent):
		super(machineSettingsDialog, self).__init__(None, title="Machine settings")

		wx.EVT_CLOSE(self, self.OnClose)

		self.parent = parent
		extruderCount = int(profile.getMachineSetting('extruder_amount'))

		self.panel = configBase.configPanelBase(self)
		self.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
		self.GetSizer().Add(self.panel, 1, wx.EXPAND)
		self.nb = wx.Notebook(self.panel)
		self.panel.SetSizer(wx.BoxSizer(wx.VERTICAL))
		self.panel.GetSizer().Add(self.nb, 1, wx.EXPAND)

		for idx in xrange(0, profile.getMachineCount()):
			left, right, main = self.panel.CreateConfigPanel(self.nb)
			configBase.TitleRow(left, _("Machine settings"))
			configBase.SettingRow(left, 'steps_per_e', index=idx)
			configBase.SettingRow(left, 'machine_width', index=idx)
			configBase.SettingRow(left, 'machine_depth', index=idx)
			configBase.SettingRow(left, 'machine_height', index=idx)
			configBase.SettingRow(left, 'extruder_amount', index=idx)
			configBase.SettingRow(left, 'has_heated_bed', index=idx)
			configBase.SettingRow(left, 'machine_center_is_zero', index=idx)
			configBase.SettingRow(left, 'machine_shape', index=idx)
			configBase.SettingRow(left, 'gcode_flavor', index=idx)

			configBase.TitleRow(right, _("Printer head size"))
			configBase.SettingRow(right, 'extruder_head_size_min_x', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_min_y', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_max_x', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_max_y', index=idx)
			configBase.SettingRow(right, 'extruder_head_size_height', index=idx)

			for i in xrange(1, extruderCount):
				configBase.TitleRow(left, _("Extruder %d") % (i+1))
				configBase.SettingRow(left, 'extruder_offset_x%d' % (i), index=idx)
				configBase.SettingRow(left, 'extruder_offset_y%d' % (i), index=idx)

			configBase.TitleRow(right, _("Communication settings"))
			configBase.SettingRow(right, 'serial_port', ['AUTO'] + machineCom.serialList(), index=idx)
			configBase.SettingRow(right, 'serial_baud', ['AUTO'] + map(str, machineCom.baudrateList()), index=idx)

			self.nb.AddPage(main, profile.getMachineSetting('machine_name', idx).title())

		self.nb.SetSelection(int(profile.getPreferenceFloat('active_machine')))

		self.buttonPanel = wx.Panel(self.panel)
		self.panel.GetSizer().Add(self.buttonPanel)

		self.buttonPanel.SetSizer(wx.BoxSizer(wx.HORIZONTAL))
		self.okButton = wx.Button(self.buttonPanel, -1, 'Ok')
		self.okButton.Bind(wx.EVT_BUTTON, lambda e: self.Close())
		self.buttonPanel.GetSizer().Add(self.okButton, flag=wx.ALL, border=5)

		self.addButton = wx.Button(self.buttonPanel, -1, 'Add new machine')
		self.addButton.Bind(wx.EVT_BUTTON, self.OnAddMachine)
		self.buttonPanel.GetSizer().Add(self.addButton, flag=wx.ALL, border=5)

		self.remButton = wx.Button(self.buttonPanel, -1, 'Remove machine')
		self.remButton.Bind(wx.EVT_BUTTON, self.OnRemoveMachine)
		self.buttonPanel.GetSizer().Add(self.remButton, flag=wx.ALL, border=5)

		main.Fit()
		self.Fit()
Exemple #13
0
    def init(self, ui, parent, is_modal):
        self.is_modal = is_modal
        style = 0
        view = ui.view
        if view.resizable:
            style |= wx.RESIZE_BORDER

        title = view.title
        if title == '':
            title = DefaultTitle

        revert = apply = False
        window = ui.control
        if window is not None:
            window.SetSizer(None)
            ui.reset()
            if hasattr(self, 'revert'):
                revert = self.revert.IsEnabled()
            if hasattr(self, 'apply'):
                apply = self.apply.IsEnabled()
        else:
            self.ui = ui
            if is_modal:
                window = wx.Dialog(parent,
                                   -1,
                                   title,
                                   style=style | wx.DEFAULT_DIALOG_STYLE)
            else:
                window = wx.Frame(parent,
                                  -1,
                                  title,
                                  style=style | (wx.DEFAULT_FRAME_STYLE &
                                                 (~wx.RESIZE_BORDER)))

            window.SetBackgroundColour(WindowColor)
            self.control = window
            self.set_icon(view.icon)
            wx.EVT_CLOSE(window, self._on_close_page)
            wx.EVT_CHAR(window, self._on_key)

            # Create the 'context' copies we will need while editing:
            context = ui.context
            ui._context = context
            ui.context = self._copy_context(context)
            ui._revert = self._copy_context(context)

        # Create the actual trait sheet panel and imbed it in a scrollable
        # window (if requested):
        sw_sizer = wx.BoxSizer(wx.VERTICAL)
        if ui.scrollable:
            sizer = wx.BoxSizer(wx.VERTICAL)
            sw = TraitsUIScrolledPanel(window)
            trait_sheet = panel(ui, sw)
            sizer.Add(trait_sheet, 1, wx.EXPAND | wx.ALL, 4)
            tsdx, tsdy = trait_sheet.GetSizeTuple()
            tsdx += 8
            tsdy += 8
            sw.SetScrollRate(16, 16)
            max_dy = (2 * screen_dy) / 3
            sw.SetSizer(sizer)
            sw.SetSize(
                wx.Size(tsdx + ((tsdy > max_dy) * scrollbar_dx),
                        min(tsdy, max_dy)))
        else:
            sw = panel(ui, window)

        sw_sizer.Add(sw, 1, wx.EXPAND)

        buttons = [self.coerce_button(button) for button in view.buttons]
        nbuttons = len(buttons)
        if (nbuttons != 1) or (not self.is_button(buttons[0], '')):

            # Create the necessary special function buttons:
            sw_sizer.Add(wx.StaticLine(window, -1), 0, wx.EXPAND)
            b_sizer = wx.BoxSizer(wx.HORIZONTAL)

            if nbuttons == 0:
                if view.apply:
                    self.check_button(buttons, ApplyButton)
                    if view.revert:
                        self.check_button(buttons, RevertButton)

                if view.ok:
                    self.check_button(buttons, OKButton)

                if view.cancel:
                    self.check_button(buttons, CancelButton)

                if view.help:
                    self.check_button(buttons, HelpButton)

            for raw_button, button in zip(view.buttons, buttons):
                default = raw_button == view.default_button

                if self.is_button(button, 'Apply'):
                    self.apply = self.add_button(button,
                                                 b_sizer,
                                                 self._on_apply,
                                                 apply,
                                                 default=default)
                    ui.on_trait_change(self._on_applyable,
                                       'modified',
                                       dispatch='ui')

                elif self.is_button(button, 'Revert'):
                    self.revert = self.add_button(button,
                                                  b_sizer,
                                                  self._on_revert,
                                                  revert,
                                                  default=default)

                elif self.is_button(button, 'OK'):
                    self.ok = self.add_button(button,
                                              b_sizer,
                                              self._on_ok,
                                              default=default)
                    ui.on_trait_change(self._on_error, 'errors', dispatch='ui')

                elif self.is_button(button, 'Cancel'):
                    self.add_button(button,
                                    b_sizer,
                                    self._on_cancel,
                                    default=default)

                elif self.is_button(button, 'Help'):
                    self.add_button(button,
                                    b_sizer,
                                    self._on_help,
                                    default=default)

                elif not self.is_button(button, ''):
                    self.add_button(button, b_sizer, default=default)

            sw_sizer.Add(b_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        # Add the menu bar, tool bar and status bar (if any):
        self.add_menubar()
        self.add_toolbar()
        self.add_statusbar()

        # Lay all of the dialog contents out:
        window.SetSizerAndFit(sw_sizer)
Exemple #14
0
    def __init__(self,parent,modal,withBtnPanel,
                 withMainPanel=True):
        self.title = "modal=%s,withBtnPanel=%s,withMainPanel=%s" % (
            modal, withBtnPanel, withMainPanel)
        #self.modal = modal
        if modal:
            self.wxctrl = wx.Dialog(parent,-1,self.title,
                                    style=wx.DEFAULT_FRAME_STYLE|
                                    wx.NO_FULL_REPAINT_ON_RESIZE)
        else:
            self.wxctrl = wx.Frame(parent,-1,self.title,
                                   style=wx.DEFAULT_FRAME_STYLE|
                                   wx.NO_FULL_REPAINT_ON_RESIZE|
                                   wx.TAB_TRAVERSAL
                                   )
            #self.wxctrl.CreateStatusBar(1, wx.ST_SIZEGRIP)
            
        #showEvents(self.wxctrl)

        #wx.EVT_CHAR(self.wxctrl, self.OnChar)
        wx.EVT_CLOSE(self.wxctrl, self.OnCloseWindow)
        if withMainPanel:
            mainPanel = wx.Panel(self.wxctrl)
            mainPanel.SetBackgroundColour(wx.RED)
        else:
            mainPanel = self.wxctrl
        
        mainBox = wx.BoxSizer(wx.VERTICAL)

        txt = wx.TextCtrl(mainPanel,-1, "text1",size=(400,20))
        mainBox.Add(txt,border=10)
        #wx.EVT_LEAVE_WINDOW(txt,self.showEvent)
        showEvents(txt)
        
        txt = wx.TextCtrl(mainPanel,-1, "text2",size=(400,20))
        #wx.EVT_LEAVE_WINDOW(txt,self.showEvent)
        mainBox.Add(txt,border=10)

        buttonBox = wx.BoxSizer(wx.HORIZONTAL)
        if withBtnPanel:
            btnPanel = wx.Panel(mainPanel,-1)
            mainBox.Add(btnPanel,border=10)
            btnPanel.SetSizer(buttonBox)
            btnPanel.SetBackgroundColour(wx.GREEN)
        else:
            btnPanel = mainPanel
            mainBox.Add(buttonBox,border=10)
        

        btn = wx.Button(btnPanel,-1,"&OK")
        self.wxctrl.Bind(wx.EVT_BUTTON,
                         lambda e: self.ok(e),
                         btn)
        buttonBox.Add(btn,border=10)
        btn.SetDefault()
        
        btn = wx.Button(btnPanel,-1,"&Cancel")
        self.wxctrl.Bind(wx.EVT_BUTTON,
                         lambda e: self.cancel(e),
                         btn)
        buttonBox.Add(btn,border=10)
        

        mainPanel.SetSizerAndFit(mainBox)

        if modal:
            self.wxctrl.ShowModal()
        else:
            self.wxctrl.Show()
Exemple #15
0
    def __init__(self, parent, options=None):
        self._init_ctrls(parent)
        self.options = options

        self._mgr = aui.AuiManager(agwFlags=aui.AUI_MGR_DEFAULT
                                   | aui.AUI_MGR_AUTONB_NO_CAPTION)

        atabstyle = self._mgr.GetAutoNotebookStyle()
        self._mgr.SetAutoNotebookStyle((atabstyle ^ aui.AUI_NB_BOTTOM)
                                       | aui.AUI_NB_TOP)

        # tell AuiManager to manage this frame
        self._mgr.SetManagedWindow(self)

        self.snapNum = 0

        wx.EVT_CLOSE(self, self.OnCloseWindow)

        self.MainFrame = self  #reference to this window for use in scripts etc...
        self.MainMenu = self.menuBar1
        protocol.MainFrame = self

        self.toolPanels = []
        self.camPanels = []
        self.postInit = []

        self.initDone = False

        self.scope = microscope.microscope()

        self.splash = splashScreen.SplashScreen(self, self.scope)
        self.splash.Show()

        #        self.sh = wx.py.shell.Shell(id=-1,
        #              parent=self.notebook1, size=wx.Size(-1, -1), style=0, locals=self.__dict__,
        #              introText='Python SMI bindings - note that help, license etc below is for Python, not PySMI\n\n')
        #
        self.sh = wx.py.shell.Shell(
            id=-1,
            parent=self,
            size=wx.Size(-1, -1),
            style=0,
            locals=self.__dict__,
            introText=
            'Python SMI bindings - note that help, license etc below is for Python, not PySMI\n\n'
        )

        #self.notebook1.AddPage(imageId=-1, page=self.sh, select=True, text='Console')
        #self.notebook1.AddPage(imageId=-1, page=self.panel1, select=False, text='About')

        #self.notebook1.AddPage(page=self.sh, select=True, caption='Console')
        self._mgr.AddPane(
            self.sh,
            aui.AuiPaneInfo().Name("shell").Caption(
                "Console").Centre().CloseButton(False))
        #        self.notebook1.AddPage( page=self.panel1, select=False, caption='About')

        #self.SetSize((400, 800))
        self.CreateToolPanel()
        #self.SetSize((1000, 800))

        #self.sizer = wx.BoxSizer()
        #self.sizer.Add(self.notebook1, 1, wx.EXPAND)
        #self.SetSizer(self.Sizer)
        self.SetSize((1030, 895))
        #self._mgr.Update()

        self.roi_on = False
        self.bin_on = False

        self.time1 = mytimer.mytimer()

        self.time1.Start(500)

        self.time1.WantNotification.append(self.runInitScript)
        self.time1.WantNotification.append(self.checkInitDone)
        self.time1.WantNotification.append(self.splash.Tick)
    def __init__(self, parent, debug=False):
        wx.Frame.__init__(
            self,
            parent,
            -1,
            "ArbotiX Controller GUI",
            style=wx.DEFAULT_FRAME_STYLE &
            ~(wx.RESIZE_BORDER | wx.MAXIMIZE_BOX))
        sizer = wx.GridBagSizer(5, 5)

        self.cmdspeedLabel = wx.StaticText(self, -1, "cmdspeed", (100, 0))
        self.hallspeedLabel = wx.StaticText(self, -1, "hallspeed", (200, 0))
        self.hallSubscriber = rospy.Subscriber("/wheel_circles", TwistStamped, self.hallCB)
        self.wheelSpeed = 0;

        # Move Base
        drive = wx.StaticBox(self, -1, 'Move Base')
        drive.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD))
        driveBox = wx.StaticBoxSizer(drive, orient=wx.VERTICAL)
        self.movebase = wx.Panel(self, size=(width, width - 20))
        self.movebase.SetBackgroundColour('WHITE')
        self.movebase.Bind(wx.EVT_MOTION, self.onMove)
        wx.StaticLine(
            self.movebase,
            -1, (width / 2, 0), (1, width),
            style=wx.LI_VERTICAL)
        wx.StaticLine(self.movebase, -1, (0, width / 2), (width, 1))
        driveBox.Add(self.movebase)
        sizer.Add(driveBox, (0, 0), wx.GBSpan(1, 1),
                  wx.EXPAND | wx.TOP | wx.BOTTOM | wx.LEFT, 5)
        self.forward = 0
        self.turn = 0
        self.X = 0
        self.Y = 0
        self.pub_cmd_vel = rospy.Publisher("/vehicle_cmd", VehicleCmd)
        self.pre_mode = 1
        self.pre_cmd_vel = VehicleCmd()
        self.changing_mode = 0

        # Move Servos
        servo = wx.StaticBox(self, -1, 'Move Servos')
        servo.SetFont(wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.BOLD))
        servoBox = wx.StaticBoxSizer(servo, orient=wx.VERTICAL)
        servoSizer = wx.GridBagSizer(5, 5)

        joint_defaults = getJointsFromURDF()

        i = 0
        dynamixels = rospy.get_param('/arbotix/dynamixels', dict())
        self.servos = list()
        self.publishers = list()
        self.relaxers = list()

        joints = rospy.get_param('/arbotix/joints', dict())
        # create sliders and publishers
        for name in sorted(joints.keys()):
            # pull angles
            min_angle, max_angle = getJointLimits(name, joint_defaults)
            # create publisher
            self.publishers.append(
                rospy.Publisher(name + '/command', Float64, queue_size=5))
            if rospy.get_param('/arbotix/joints/' + name + '/type',
                               'dynamixel') == 'dynamixel':
                self.relaxers.append(
                    rospy.ServiceProxy(name + '/relax', Relax))
            else:
                self.relaxers.append(None)
            # create slider
            s = servoSlider(self, min_angle, max_angle, name, i)
            servoSizer.Add(s.enabled, (i, 0), wx.GBSpan(1, 1),
                           wx.ALIGN_CENTER_VERTICAL)
            servoSizer.Add(s.position, (i, 1), wx.GBSpan(1, 1),
                           wx.ALIGN_CENTER_VERTICAL)
            self.servos.append(s)
            i += 1

        # add everything
        servoBox.Add(servoSizer)
        sizer.Add(servoBox, (0, 1), wx.GBSpan(1, 1),
                  wx.EXPAND | wx.TOP | wx.BOTTOM | wx.RIGHT, 5)
        self.Bind(wx.EVT_CHECKBOX, self.enableSliders)
        # now we can subscribe
        rospy.Subscriber('joint_states', JointState, self.stateCb)

        # timer for output
        self.timer = wx.Timer(self, self.TIMER_ID)
        self.timer.Start(50)
        wx.EVT_CLOSE(self, self.onClose)
        wx.EVT_TIMER(self, self.TIMER_ID, self.onTimer)

        # bind the panel to the paint event
        wx.EVT_PAINT(self, self.onPaint)
        self.dirty = 1
        self.onPaint()

        self.SetSizerAndFit(sizer)
        self.Show(True)
Exemple #17
0
 def __init__(self,*args):
     wxSpellCheckerDialog.__init__(self,*args)
     wx.EVT_CLOSE(self,self.OnClose)
    def __init__(self, parent, title=''):
        if hasattr(Globals.pref, 'searchwin_pos') and hasattr(
                Globals.pref, 'searchwin_size'):
            searchwin_pos = Globals.pref.searchwin_pos
            searchwin_size = Globals.pref.searchwin_size
            wx.Dialog.__init__(self,
                               parent,
                               -1,
                               title,
                               searchwin_pos,
                               searchwin_size,
                               style=wx.RESIZE_BORDER
                               | wx.DEFAULT_DIALOG_STYLE)
        else:
            wx.Dialog.__init__(self,
                               parent,
                               -1,
                               title,
                               size=(600, 400),
                               style=wx.RESIZE_BORDER
                               | wx.DEFAULT_DIALOG_STYLE)
            self.Center()

        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
        sizer = wx.BoxSizer(wx.VERTICAL)

        sizer1 = wx.BoxSizer(wx.HORIZONTAL)
        label = wx.StaticText(self, -1, tr("Search for:"))
        sizer1.Add(label, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
        self.text = wx.TextCtrl(self, -1, "", style=wx.TE_PROCESS_ENTER)
        self.impact_check = wx.CheckBox(self, -1, tr("Impact Mode"))
        self.autoclose_check = wx.CheckBox(self, -1, tr("Auto Close"))
        sizer1.Add(self.text, 1, wx.ALL, 2)
        sizer1.Add(self.impact_check, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL, 2)
        sizer1.Add(self.autoclose_check, 0, wx.ALL | wx.ALIGN_CENTER_VERTICAL,
                   2)

        self.list = CheckList.List(self,
                                   columns=[
                                       (tr("Function"), 300, 'left'),
                                       (tr("ShortCuts"), 120, 'left'),
                                       (tr("Impact"), 80, 'left'),
                                   ],
                                   style=wx.LC_REPORT | wx.SUNKEN_BORDER
                                   | wx.LC_SINGLE_SEL)
        self.commandar = Commands.getinstance()
        self.cmdbuf = {}
        self.load(self.commandar.search(''))

        sizer.Add(sizer1, 0, wx.EXPAND)
        sizer.Add(self.list, 1, wx.EXPAND, 2)

        btnCancel = wx.Button(self, wx.ID_CANCEL, tr("Cancel"))
        sizer.Add(btnCancel, 0, wx.ALIGN_CENTER, 2)

        wx.EVT_CLOSE(self, self.OnClose)
        wx.EVT_SIZE(self, self.OnSize)
        wx.EVT_BUTTON(self, wx.ID_CANCEL, self.OnClose)
        wx.EVT_TEXT(self.text, self.text.GetId(), self.OnChange)
        wx.EVT_KEY_DOWN(self.text, self.OnKeyDown)
        wx.EVT_LIST_ITEM_ACTIVATED(self.list, self.list.GetId(), self.OnEnter)
        wx.EVT_CHECKBOX(self.impact_check, self.impact_check.GetId(),
                        self.OnCheckImpact)
        wx.EVT_CHECKBOX(self.autoclose_check, self.autoclose_check.GetId(),
                        self.OnCheckAutoClose)

        self.impact_check.SetValue(Globals.pref.commands_impact)
        self.autoclose_check.SetValue(Globals.pref.commands_autoclose)

        Globals.mainframe.command_mode = True

        self.SetSizer(sizer)
        self.SetAutoLayout(True)
    def __init__(self):
        super(newVersionDialog, self).__init__(None, title="Welcome to the new version!")

        wx.EVT_CLOSE(self, self.OnClose)

        p = wx.Panel(self)
        self.panel = p
        s = wx.BoxSizer()
        self.SetSizer(s)
        s.Add(p, flag=wx.ALL, border=15)
        s = wx.BoxSizer(wx.VERTICAL)
        p.SetSizer(s)

        title = wx.StaticText(p, -1, 'Cura-BCN3D-' + version.getVersion() + ' (beta2)')
        title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
        s.Add(title, flag=wx.ALIGN_CENTRE|wx.EXPAND|wx.BOTTOM, border=5)
        s.Add(wx.StaticText(p, -1, 'Welcome to the new version of Cura-BCN3D.'))
        s.Add(wx.StaticText(p, -1, '(This dialog is only shown once)'))
        s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
        s.Add(wx.StaticText(p, -1, 'New in version 0.1.5 (beta2)'))
        s.Add(wx.StaticText(p, -1, '* Fixed several bugs'))
        s.Add(wx.StaticText(p, -1, '* Fixed sequence that would make Cura-BCN3D crash'))
        self.has_machine = {}
        for n in xrange(0, profile.getMachineCount()):
            self.has_machine[profile.getMachineSetting('machine_type', n)] = n
            if profile.getMachineSetting('machine_type', n) == 'BCN3DSigma':
                self.hasBCN3DSigma = n
            if profile.getMachineSetting('machine_type', n) == 'BCN3DPlus':
                self.hasBCN3DPlus = n
            if profile.getMachineSetting('machine_type', n) == 'BCN3DR':
                self.hasBCN3DR = n
            if profile.getMachineSetting('machine_type', n) == 'ultimaker':
                self.hasUltimaker = n
            if profile.getMachineSetting('machine_type', n) == 'ultimaker2':
                self.hasUltimaker2 = n
        if 'BCN3DSigma' in self.has_machine and False:
            s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your BCN3D Sigma:'))
            s.Add(wx.StaticText(p, -1, '* .'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, lambda e: self.OnFirmwareInstall(self.has_machine['BCN3DSigma']), button)
            s.Add(button, flag=wx.TOP, border=5)
        if 'BCN3DPlus' in self.has_machine and False:
            s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your BCN3D Plus:'))
            s.Add(wx.StaticText(p, -1, '* .'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, lambda e: self.OnFirmwareInstall(self.has_machine['BCN3DPlus']), button)
            s.Add(button, flag=wx.TOP, border=5)
        if 'BCN3DR' in self.has_machine and False:
            s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your BCN3D R:'))
            s.Add(wx.StaticText(p, -1, '* .'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, lambda e: self.OnFirmwareInstall(self.has_machine['BCN3DR']), button)
            s.Add(button, flag=wx.TOP, border=5)
        if 'ultimaker' in self.has_machine and False:
            s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your Ultimaker Original:'))
            s.Add(wx.StaticText(p, -1, '* .'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, lambda e: self.OnFirmwareInstall(self.has_machine['ultimaker']), button)
            s.Add(button, flag=wx.TOP, border=5)
        if 'ultimaker2' in self.has_machine and True:
            s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your Ultimaker 2:'))
            s.Add(wx.StaticText(p, -1, '* Updated error messages, to assist in getting better support'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, lambda e: self.OnFirmwareInstall(self.has_machine['ultimaker2']), button)
            s.Add(button, flag=wx.TOP, border=5)
        if 'ultimaker2+' in self.has_machine and True:
            s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your Ultimaker 2+:'))
            s.Add(wx.StaticText(p, -1, '* Updated error messages, to assist in getting better support'))
            s.Add(wx.StaticText(p, -1, '* Bugfix for the import/export material settings which was not working properly'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, lambda e: self.OnFirmwareInstall(self.has_machine['ultimaker2+']), button)
            s.Add(button, flag=wx.TOP, border=5)
        if 'ultimaker2+extended' in self.has_machine and True:
            s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
            s.Add(wx.StaticText(p, -1, 'New firmware for your Ultimaker2+Extended:'))
            s.Add(wx.StaticText(p, -1, '* Fixed temperature stability.'))
            s.Add(wx.StaticText(p, -1, '* Fixed print starting problems when a material warning was ignored'))
            button = wx.Button(p, -1, 'Install now')
            self.Bind(wx.EVT_BUTTON, lambda e: self.OnFirmwareInstall(self.has_machine['ultimaker2+extended']), button)
            s.Add(button, flag=wx.TOP, border=5)

        s.Add(wx.StaticLine(p), flag=wx.EXPAND|wx.TOP|wx.BOTTOM, border=10)
        button = wx.Button(p, -1, 'Ok')
        self.Bind(wx.EVT_BUTTON, self.OnOk, button)
        s.Add(button, flag=wx.TOP|wx.ALIGN_RIGHT, border=5)

        self.Fit()
        self.Centre()
   def __init__(self, parent, ID, title, messenger, exitCallback):
      wx.Frame.__init__(self, parent, ID, title)

      self.exitCallback = exitCallback
      self._messenger   = messenger

      DISCONNECT = 100
      EXIT       = 101

      # Create a menu bar
      # TRANSLATORS: this is a menu bar entry
      fileMenu = wx.Menu(_("File"))
      # TRANSLATORS: this is a menu bar entry
      fileMenu.Append(DISCONNECT, _("Disconnect"), _("Disconnect from server"))
      # TRANSLATORS: this is a menu bar entry
      fileMenu.Append(EXIT, _("Exit%(hotkey)s") % {"hotkey" : "\tCTRL+Q"}, _("Exit London Law"))
      menuBar = wx.MenuBar()
      # TRANSLATORS: this is a menu bar entry
      menuBar.Append(fileMenu, _("File"))
      self.SetMenuBar(menuBar)

      self.status = self.CreateStatusBar()

      # stick everything in a panel
      mainPanel = wx.Panel(self, -1)

      self.list = AutoListCtrl(mainPanel, -1,
            # TRANSLATORS: these are column labels for the window where the players choose teams for a game
            (_("Player"), 
            # TRANSLATORS: these are column labels for the window where the players choose teams for a game
               _("Team"), 
            # TRANSLATORS: these are column labels for the window where the players choose teams for a game
               _("Votes to Start?"), 
            # TRANSLATORS: these are column labels for the window where the players choose teams for a game
               _("Pawns")),
            # TRANSLATORS: this is displayed in a column when no players have joined one of the games
            (_("(no players joined)"), "", "", ""))

      self.list.SetColumnWidth(1, 140) 

      mainSizer = wx.BoxSizer(wx.VERTICAL)
      mainSizer.Add(self.list, 3, wx.ALIGN_CENTRE|wx.EXPAND|wx.ALL, 5)

      self.chatWindow = ChatPanel(mainPanel, "", False)
      mainSizer.Add(self.chatWindow, 2, wx.EXPAND|wx.ALL, 5)

      self.leaveButton = wx.Button(mainPanel, -1, _("Leave Game"))
      self.teamButton  = wx.Button(mainPanel, -1, _("Choose Team"))
      self.aiButton    = wx.Button(mainPanel, -1, _("Request AI"))
      self.voteButton  = wx.Button(mainPanel, -1, _("Vote to Start"))
      buttonSizer      = wx.BoxSizer(wx.HORIZONTAL)
      buttonSizer.Add(self.leaveButton, 0, wx.ALIGN_CENTRE | wx.LEFT | wx.RIGHT | wx.BOTTOM | wx.ALL, 5)
      buttonSizer.Add((1, 1), 1, wx.EXPAND)
      buttonSizer.Add(self.teamButton, 0, wx.ALIGN_CENTRE | wx.RIGHT | wx.BOTTOM | wx.ALL, 5)
      buttonSizer.Add(self.aiButton,   0, wx.ALIGN_CENTRE | wx.RIGHT | wx.BOTTOM | wx.ALL, 5)
      buttonSizer.Add(self.voteButton, 0, wx.ALIGN_CENTRE | wx.RIGHT | wx.BOTTOM | wx.ALL, 5)
      mainSizer.Add(buttonSizer, 0, wx.EXPAND, 0)

      mainPanel.SetSizer(mainSizer)
      mainSizer.Fit(mainPanel)

      wx.EVT_CLOSE(self, self.menuExit)
      wx.EVT_MENU(self, EXIT, self.menuExit)
      wx.EVT_MENU(self, DISCONNECT, self.menuDisconnect)
      wx.EVT_BUTTON(self, self.leaveButton.GetId(), self.leaveGame)
      wx.EVT_BUTTON(self, self.aiButton.GetId(), self.requestAIList)
      wx.EVT_BUTTON(self, self.teamButton.GetId(), self.chooseTeam)
      wx.EVT_BUTTON(self, self.voteButton.GetId(), self.voteStart)
      wx.EVT_TEXT_ENTER(self, self.chatWindow.chatEntry.GetId(), self.chatSend)
Exemple #21
0
 def __init__(self, parent, id, title):
     wx.Dialog.__init__(self,
                        parent,
                        id,
                        'SimFluo: fluorescence spectrum simulation',
                        size=(350, 480))
     #-------------  read simulated spectrum and set plot limits  --------------------------
     self.data = []
     self.data2 = []
     self.plot_on = 0
     self.path = os.getcwd()  # remembers current directory
     inputfile = 'simSpectrum_plot.txt'
     if os.path.exists(inputfile) == 0:
         fo = open(inputfile, 'w')
         out1 = str(1e3) + ' ' + str(1e6) + '\n'
         fo.write(out1)
         out1 = str(10e3) + ' ' + str(10e6) + '\n'
         fo.write(out1)
         fo.close()
     f = open(inputfile)
     lines = f.readlines()
     self.xMin = 1e6
     self.xMax = -1e6
     self.yMin = 1e6
     self.yMax = -1e6
     for line in lines:
         if line.startswith('#'): continue
         words = line.split()
         xx = float(words[0])
         if self.xMin > xx: self.xMin = xx
         if self.xMax <= xx: self.xMax = xx
         yy = float(words[1])
         if self.yMin > yy: self.yMin = yy
         if self.yMax <= yy: self.yMax = yy
         self.data.append((xx, yy))
     f.close()
     HeList = ['Yes', 'No']
     xswList = ['WD60mm(XRM)', 'WD30mm(XSW)', 'none']
     self.fyList = []
     self.locationList = ['all', 'top', 'bottom', 'surface']
     self.ppmList = ['atomic fraction', 'weight fraction']
     self.TextOutputList = []
     self.input = fluo_det.input_param()
     #--------------------------------------------------------------------------
     btnSim = wx.Button(self, 1, 'Simulate!', (30, 10))
     btnPlot = wx.Button(self, 2, 'Plot!', (30, 35))
     self.cbLINES = wx.ComboBox(self, 3, 'emission lines', (120, 30),
                                (165, 10), self.fyList, wx.CB_DROPDOWN)
     #
     wx.StaticText(self, -1, "incident x-ray energy (eV)", (5, 60))
     self.textENERGY = wx.TextCtrl(self, 10, '7500', (10, 75))
     wx.StaticText(self, -1, "incident x-ray angle (Deg.)", (165, 60))
     self.textANGLE = wx.TextCtrl(self, 11, '45.', (170, 75))
     #
     wx.StaticText(
         self, -1,
         "elements and concentrations (ppm of top substrate material)",
         (5, 100))
     wx.StaticText(self, -1, "in atomic fraction or weight fraction",
                   (5, 115))
     self.cbPPM = wx.ComboBox(self, 12, 'atomic fraction', (200, 113),
                              (140, 10), self.ppmList, wx.CB_DROPDOWN)
     self.textELEMENT = wx.TextCtrl(self,
                                    13,
                                    'La 10 Ce 10 Nd 10', (10, 135),
                                    size=(280, 20))
     #
     wx.StaticText(self, -1, "top substrate material", (5, 155))
     self.textSUBSTRATE = wx.TextCtrl(self, 14, 'CaCO3', (10, 170),
                                      (80, 20))
     wx.StaticText(self, -1, "density (g/cc)", (135, 155))
     self.textDENSITY = wx.TextCtrl(self, 15, '2.71', (140, 170), (80, 20))
     wx.StaticText(self, -1, "thickness (cm)", (235, 155))
     self.textTOP = wx.TextCtrl(self, 16, '0.001', (240, 170), (80, 20))
     #
     wx.StaticText(self, -1, "bottom substrate material", (5, 195))
     self.textSUBSTRATE2 = wx.TextCtrl(self, 17, 'Al2O3', (10, 210),
                                       (80, 20))
     wx.StaticText(self, -1, "density (g/cc)", (135, 195))
     self.textDENSITY2 = wx.TextCtrl(self, 18, '3.97', (140, 210), (80, 20))
     wx.StaticText(self, -1, "thickness (cm)", (235, 195))
     self.textBOT = wx.TextCtrl(self, 19, '0.001', (240, 210), (80, 20))
     #
     wx.StaticText(self, -1, 'location of fluorescence elements', (5, 235))
     self.cbLOCATION = wx.ComboBox(self, 20, 'all', (10, 250), (165, 10), \
                            self.locationList, wx.CB_DROPDOWN)
     #
     wx.StaticText(self, -1, "He-path used?", (5, 275))
     self.cbHE = wx.ComboBox(self, 21, 'No', (10, 290), (95, 10), HeList,
                             wx.CB_DROPDOWN)
     wx.StaticText(self, -1, '# of Al film (1.5mil)', (5, 315))
     self.textAL = wx.TextCtrl(self, 22, '0', (10, 330))
     wx.StaticText(self, -1, "# of Kapton film (0.3mil)", (165, 315))
     self.textKAPTON = wx.TextCtrl(self, 23, '0', (170, 330))
     wx.StaticText(self, -1, "Vortex detector distance (cm)", (5, 355))
     self.textWD = wx.TextCtrl(self, 24, '6.0', (10, 370))
     wx.StaticText(self, -1, "detector collimator", (165, 355))
     self.cbXSW = wx.ComboBox(self, 25, 'WD60mm(XRM)', (170, 370),
                              (120, 10), xswList, wx.CB_DROPDOWN)
     self.TextOutput = wx.ComboBox(self, 26, 'output message', (10, 410),
                                   (250, 20), self.TextOutputList,
                                   wx.CB_DROPDOWN)
     #
     wx.EVT_BUTTON(self, 1, self.OnSimulate)
     wx.EVT_BUTTON(self, 2, self.OnPlot)
     wx.EVT_TEXT(self, 14, self.OntextSUBSTRATE)
     wx.EVT_TEXT(self, 17, self.OntextSUBSTRATE2)
     wx.EVT_TEXT(self, 25, self.OnCBXSW)
     wx.EVT_CLOSE(self, self.OnQuit)
Exemple #22
0
    def __init__(self, parent, id, title):
        wx.Frame.__init__(self, parent, id, title, pos=(100, 100))

        self.tbicon = wx.TaskBarIcon()
        self.tbicon.SetIcon(res.cs_icon.GetIcon(), "CS Notifier")

        # Bind some events to it
        wx.EVT_TASKBAR_LEFT_DCLICK(self.tbicon, self.OnMenuCheck)  # left click
        wx.EVT_TASKBAR_RIGHT_UP(self.tbicon,
                                self.ShowMenu)  # single left click
        wx.EVT_CLOSE(
            self, self.OnClose
        )  # triggered when the app is closed, which deletes the icon from tray

        # build the menu that we'll show when someone right-clicks
        self.menu = wx.Menu()  # the menu object

        self.menu.Append(101, 'Check now...')  # Check
        wx.EVT_MENU(self, 101, self.OnMenuCheck)  # Bind a function to it

        self.menu.AppendSeparator()  # Separator

        if settings.DEBUG:
            self.menu.Append(102, 'Show log...')  # Show log
            wx.EVT_MENU(self, 102, self.OnMenuShowLog)  # Bind a function to it

        if settings.AUTOUPDATE:
            self.menu.Append(105, 'Check for updates')  # AutoUpdate
            wx.EVT_MENU(self, 105, self.OnUpdate)  # Bind a function to it

        self.menu.Append(103, 'About...')  # About
        wx.EVT_MENU(self, 103,
                    self.OnMenuShowAboutBox)  # Bind a function to it

        self.menu.Append(104, 'Close')  # Close
        wx.EVT_MENU(self, 104, self.OnMenuClose)  # Bind a function to it

        if settings.DEBUG:
            self.log = Log(self)
            sys.stdout = RedirectStdOut(self.log)
            sys.stderr = RedirectStdErr(self.log)

            log = self.log
            sizer = wx.BoxSizer(wx.HORIZONTAL)
            sizer.Add(log, 1, wx.EXPAND)
            self.SetSizer(sizer)
            self.Layout()
            log('CouchSurfing Notifier 1.0.0 (beta) started...', 'blue')

        else:
            self.log = self.dummylog

        self.cs = cslib.cslib(self.log)

        self.posts = []
        if os.path.exists('current.dat'):
            f = file('current.dat', 'rb')
            self.posts = json.loads(f.read())
            f.close()
        else:
            self.posts.append({'postid': ''})

        self.messages_unread = 0

        self.timer = wx.Timer(self, -1)
        self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
        self.timer.Start(settings.CHECK_INTERVAL * 1000)
        self.OnTimer(evt=True)
Exemple #23
0
    def __init__(self, app, filenames):
        self.initmixin()

        self.app = app
        self.pref = app.pref
        self.filenames = filenames
        self.closeflag = False

        self.callplugin_once('start', self)

        wx.Frame.__init__(self,
                          None,
                          -1,
                          self.app.appname,
                          size=wx.Size(600, 400),
                          name=self.app.appname)

        Globals.mainframe = self

        #@add_menu menulist
        self.callplugin_once('add_menu', MainFrame.menulist)
        #@add_menu_image_list
        self.callplugin_once('add_menu_image_list', MainFrame.imagelist)
        #@add_filewildchar filewildchar
        self.callplugin_once('add_filewildchar', MainFrame.filewildchar)
        #@add_tool_list
        self.callplugin_once('add_tool_list', MainFrame.toollist,
                             MainFrame.toolbaritems)
        #@add_new_files
        self.callplugin_once('add_new_files', MainFrame.filenewtypes)

        self.id = self.GetId()
        self.menubar = makemenu.makemenu(self, self.menulist,
                                         MainFrame.accellist,
                                         MainFrame.editoraccellist,
                                         MainFrame.imagelist)
        self.SetMenuBar(self.menubar)

        a = {}
        self.callplugin_once('init_accelerator', self, MainFrame.accellist,
                             MainFrame.editoraccellist)
        a.update(MainFrame.accellist)
        a.update(MainFrame.editoraccellist)
        MainFrame.default_accellist = copy.deepcopy(MainFrame.accellist)
        MainFrame.default_editoraccellist = copy.deepcopy(
            MainFrame.editoraccellist)

        self.editorkeycodes = {}
        Accelerator.getkeycodes(self.editoraccellist, self.editorkeycodes)

        makemenu.setmenutext(self, a)
        Accelerator.initaccelerator(self, MainFrame.accellist)

        self.statusbar = MyStatusBar.MyStatusBar(self)
        self.SetStatusBar(self.statusbar)
        self.progressbar = self.statusbar.g1

        self.callplugin('beforeinit', self)
        self.callplugin('init', self)
        self.callplugin('show', self)
        wx.EVT_IDLE(self, self.OnIdle)
        wx.EVT_CLOSE(self, self.OnClose)
        wx.EVT_ACTIVATE(self, self.OnActive)
Exemple #24
0
 def __do_events(self):
     wx.EVT_CLOSE(self, self.OnClose)
Exemple #25
0
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)

        self.MaxImageSizeX = 320
        self.MaxImageSizeY = 240

        btn_nxt_refl = wx.Button(self, -1, "Next Reflection ")
        btn_prv_refl = wx.Button(self, -1, "Previous Reflection")
        btn_nxt_slice = wx.Button(self, -1, "Next slice ")
        btn_prv_slice = wx.Button(self, -1, "Previous slice")
        btn_tst = wx.Button(self, -1, "tst btn")
        btn_tst1 = wx.Button(self, -1, "tst btn1")

        self.Image_01 = wx.StaticBitmap(self,
                                        bitmap=wx.EmptyBitmap(
                                            self.MaxImageSizeX,
                                            self.MaxImageSizeY))
        self.Image_02 = wx.StaticBitmap(self,
                                        bitmap=wx.EmptyBitmap(
                                            self.MaxImageSizeX,
                                            self.MaxImageSizeY))
        self.Image_03 = wx.StaticBitmap(self,
                                        bitmap=wx.EmptyBitmap(
                                            self.MaxImageSizeX,
                                            self.MaxImageSizeY))

        v_box = wx.BoxSizer(wx.VERTICAL)
        h_box = wx.BoxSizer(wx.HORIZONTAL)
        u_box = wx.BoxSizer(wx.HORIZONTAL)

        u_box.Add(btn_prv_refl, 0, wx.CENTER | wx.ALL, 5)
        u_box.Add(btn_nxt_refl, 0, wx.CENTER | wx.ALL, 5)

        v_box.Add(u_box)

        h_box.Add(self.Image_01, 0,
                  wx.ALIGN_CENTER_HORIZONTAL | wx.ALL | wx.ADJUST_MINSIZE, 7)

        h_box.Add(self.Image_02, 0,
                  wx.ALIGN_CENTER_HORIZONTAL | wx.ALL | wx.ADJUST_MINSIZE, 7)

        h_box.Add(self.Image_03, 0,
                  wx.ALIGN_CENTER_HORIZONTAL | wx.ALL | wx.ADJUST_MINSIZE, 7)

        r_box = wx.BoxSizer(wx.VERTICAL)
        r_box.Add(btn_nxt_slice, 0, wx.CENTER | wx.ALL, 5)
        r_box.Add(btn_prv_slice, 0, wx.CENTER | wx.ALL, 5)
        r_box.AddSpacer(50)

        r_box.Add(btn_tst, 0, wx.CENTER | wx.ALL, 5)
        r_box.Add(btn_tst1, 0, wx.CENTER | wx.ALL, 5)

        h_box.Add(r_box)
        v_box.Add(h_box)

        self.frame_scale = 0.5

        self.sizing_counter = 0
        self.SetSizerAndFit(v_box)

        btn_tst.Bind(wx.EVT_BUTTON, self.B_tst)
        btn_tst1.Bind(wx.EVT_BUTTON, self.B_tst1)
        self.Bind(wx.EVT_SIZE, self.OnSize)

        wx.EVT_CLOSE(self, self.On_Close_Window)
Exemple #26
0
    def init(self, ui, parent, style):
        self.is_modal = (style == MODAL)
        window_style = 0
        view = ui.view
        if view.resizable:
            window_style |= wx.RESIZE_BORDER

        title = view.title
        if title == '':
            title = DefaultTitle

        history = ui.history
        window = ui.control
        if window is not None:
            if history is not None:
                history.on_trait_change(self._on_undoable,
                                        'undoable',
                                        remove=True)
                history.on_trait_change(self._on_redoable,
                                        'redoable',
                                        remove=True)
                history.on_trait_change(self._on_revertable,
                                        'undoable',
                                        remove=True)
            window.SetSizer(None)
            ui.reset()
        else:
            self.ui = ui
            if style == MODAL:
                if view.resizable:
                    window_style |= (wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
                window = wx.Dialog(parent,
                                   -1,
                                   title,
                                   style=window_style
                                   | wx.DEFAULT_DIALOG_STYLE)
            elif style == NONMODAL:
                if parent is not None:
                    window_style |= (wx.FRAME_FLOAT_ON_PARENT
                                     | wx.FRAME_NO_TASKBAR)
                window = wx.Frame(parent,
                                  -1,
                                  title,
                                  style=window_style |
                                  (wx.DEFAULT_FRAME_STYLE &
                                   (~wx.RESIZE_BORDER)))
            else:
                if window_style == 0:
                    window_style = wx.SIMPLE_BORDER
                if parent is not None:
                    window_style |= (wx.FRAME_FLOAT_ON_PARENT
                                     | wx.FRAME_NO_TASKBAR)

                window = wx.Frame(parent, -1, '', style=window_style)
                window._kind = ui.view.kind
                self._monitor = MouseMonitor(ui)

            # Set the correct default window background color:
            window.SetBackgroundColour(WindowColor)

            self.control = window
            wx.EVT_CLOSE(window, self._on_close_page)
            wx.EVT_CHAR(window, self._on_key)

        self.set_icon(view.icon)
        buttons = [self.coerce_button(button) for button in view.buttons]
        nbuttons = len(buttons)
        no_buttons = ((nbuttons == 1) and self.is_button(buttons[0], ''))
        has_buttons = ((not no_buttons)
                       and ((nbuttons > 0) or view.undo or view.revert
                            or view.ok or view.cancel))
        if has_buttons or (view.menubar is not None):
            if history is None:
                history = UndoHistory()
        else:
            history = None
        ui.history = history

        # Create the actual trait sheet panel and imbed it in a scrollable
        # window (if requested):
        sw_sizer = wx.BoxSizer(wx.VERTICAL)
        if ui.scrollable:
            sizer = wx.BoxSizer(wx.VERTICAL)
            sw = TraitsUIScrolledPanel(window)
            trait_sheet = panel(ui, sw)
            sizer.Add(trait_sheet, 1, wx.EXPAND)
            tsdx, tsdy = trait_sheet.GetSize()
            sw.SetScrollRate(16, 16)
            max_dy = (2 * screen_dy) / 3
            sw.SetSizer(sizer)
            sw.SetSize(
                wx.Size(tsdx + ((tsdy > max_dy) * scrollbar_dx),
                        min(tsdy, max_dy)))
        else:
            sw = panel(ui, window)

        sw_sizer.Add(sw, 1, wx.EXPAND)
        sw_sizer.SetMinSize(sw.GetSize())

        # Check to see if we need to add any of the special function buttons:
        if (not no_buttons) and (has_buttons or view.help):
            sw_sizer.Add(wx.StaticLine(window, -1), 0, wx.EXPAND)
            b_sizer = wx.BoxSizer(wx.HORIZONTAL)

            # Convert all button flags to actual button actions if no buttons
            # were specified in the 'buttons' trait:
            if nbuttons == 0:
                if view.undo:
                    self.check_button(buttons, UndoButton)

                if view.revert:
                    self.check_button(buttons, RevertButton)

                if view.ok:
                    self.check_button(buttons, OKButton)

                if view.cancel:
                    self.check_button(buttons, CancelButton)

                if view.help:
                    self.check_button(buttons, HelpButton)

            # Create a button for each button action:
            for raw_button, button in zip(view.buttons, buttons):
                button = self.coerce_button(button)
                default = raw_button == view.default_button

                if self.is_button(button, 'Undo'):
                    self.undo = self.add_button(button,
                                                b_sizer,
                                                self._on_undo,
                                                False,
                                                default=default)
                    self.redo = self.add_button(button, b_sizer, self._on_redo,
                                                False, 'Redo')
                    history.on_trait_change(self._on_undoable,
                                            'undoable',
                                            dispatch='ui')
                    history.on_trait_change(self._on_redoable,
                                            'redoable',
                                            dispatch='ui')
                    if history.can_undo:
                        self._on_undoable(True)

                    if history.can_redo:
                        self._on_redoable(True)

                elif self.is_button(button, 'Revert'):
                    self.revert = self.add_button(button,
                                                  b_sizer,
                                                  self._on_revert,
                                                  False,
                                                  default=default)
                    history.on_trait_change(self._on_revertable,
                                            'undoable',
                                            dispatch='ui')
                    if history.can_undo:
                        self._on_revertable(True)

                elif self.is_button(button, 'OK'):
                    self.ok = self.add_button(button,
                                              b_sizer,
                                              self._on_ok,
                                              default=default)
                    ui.on_trait_change(self._on_error, 'errors', dispatch='ui')

                elif self.is_button(button, 'Cancel'):
                    self.add_button(button,
                                    b_sizer,
                                    self._on_cancel,
                                    default=default)

                elif self.is_button(button, 'Help'):
                    self.add_button(button,
                                    b_sizer,
                                    self._on_help,
                                    default=default)

                elif not self.is_button(button, ''):
                    self.add_button(button, b_sizer, default=default)

            sw_sizer.Add(b_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 5)

        # Add the menu bar, tool bar and status bar (if any):
        self.add_menubar()
        self.add_toolbar()
        self.add_statusbar()

        # Lay all of the dialog contents out:
        window.SetSizer(sw_sizer)
        window.Fit()
    def __init__(self,
                 exctype,
                 value,
                 tb,
                 title="Uncaught exception occured",
                 parent=None):
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          title,
                          size=(600, 600),
                          style=wx.DEFAULT_FRAME_STYLE | wx.CENTER)

        self.exctype = exctype
        self.value = value
        self.tb = tb
        self.resetStdOut = None
        #ExcType = str(exctype)
        #ExcVal  = str(value)
        EStr = traceback.format_exception_only(exctype, value)[0]
        # >>> traceback.format_exception_only.__doc__
        # 'Format the exception part of a traceback.

        #     The arguments are the exception type and value such as given by
        #     sys.last_type and sys.last_value. The return value is a list of
        #     strings, each ending in a newline.

        #     Normally, the list contains a single string; however, for
        #     SyntaxError exceptions, it contains several lines that (when
        #     printed) display detailed information about where the syntax
        #     error occurred.

        #     The message indicating which exception occurred is always the last
        #     string in the list.

        ExcStr = '\n********************************************\n'.join(
            traceback.format_exception(exctype, value, tb, limit=None))

        self.sizer = wx.BoxSizer(wx.VERTICAL)

        #         hs = wx.BoxSizer(wx.HORIZONTAL)
        #         self.sizer.Add(hs, 0, wx.EXPAND)
        #         hs.Add(wx.StaticText(self, -1, "Exc Type:"), 0, wx.ALL, 5)
        #         self.txtZ = wx.TextCtrl(self, -1, ExcType, size=(40,-1))
        #         #wx.EVT_TEXT(self, self.txtZ.GetId(), self.OnTxtZ)
        #         hs.Add(self.txtZ, 1)

        #         hs = wx.BoxSizer(wx.HORIZONTAL)
        #         self.sizer.Add(hs, 0, wx.EXPAND)
        #         hs.Add(wx.StaticText(self, -1, "Exc Value:"), 0, wx.ALL, 5)
        #         self.txtZ = wx.TextCtrl(self, -1, ExcVal, size=(40,-1))
        #         #wx.EVT_TEXT(self, self.txtZ.GetId(), self.OnTxtZ)
        #         hs.Add(self.txtZ, 1)

        hs = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(hs, 0, wx.EXPAND)
        hs.Add(wx.StaticText(self, -1, "Exception:"), 0, wx.ALL, 5)
        style = wx.TE_MULTILINE if EStr.count('\n') > 1 else 0
        self.txtZ = wx.TextCtrl(self, -1, EStr, size=(40, -1), style=style)
        #wx.EVT_TEXT(self, self.txtZ.GetId(), self.OnTxtZ)
        hs.Add(self.txtZ, 1)

        #hs = wx.BoxSizer(wx.HORIZONTAL)
        #self.sizer.Add(hs, 1, wx.EXPAND)

        tc = wx.TextCtrl(self, -1, ExcStr, style=wx.TE_MULTILINE)
        tc.SetInsertionPointEnd(
        )  # scroll to end of the traceback (Traceback (most recent call last):)
        #hs.Add(tc, 1, wx.ALL, 2)
        self.sizer.Add(tc, 1, wx.EXPAND)

        hs = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer.Add(hs, 0, wx.EXPAND)
        b = wx.Button(self, id_close, "dismiss [ESC]")
        wx.EVT_BUTTON(self, id_close, self.OnClose)
        hs.Add(b, 0, wx.ALL, 5)

        b = wx.Button(self, id_print, "print to stderr & dismiss")
        wx.EVT_BUTTON(self, id_print, self.OnPrint)
        hs.Add(b, 0, wx.ALL, 5)

        b = wx.Button(self, id_debug, "debug")
        wx.EVT_BUTTON(self, id_debug, self.OnDebug)
        hs.Add(b, 0, wx.ALL, 5)

        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        for w in self.GetChildren():
            w.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)
        wx.EVT_CLOSE(self, self.OnClose)
        #self.sizer.Fit(self)

        self.SetAutoLayout(True)
        self.SetSizer(self.sizer)

        #slider.SetBackgroundColour(wx.LIGHT_GREY)
        #self.SetBackgroundColour(wx.LIGHT_GREY)

        global numberOfOpenExcWindows
        numberOfOpenExcWindows += 1
        self.Center()
        self.Show()
Exemple #28
0
 def _add_event_listeners(self):
     wx.EVT_ACTIVATE(self.control, self._wx_on_activate)
     wx.EVT_CLOSE(self.control, self._wx_on_close)
     wx.EVT_SIZE(self.control, self._wx_on_control_size)
     wx.EVT_MOVE(self.control, self._wx_on_control_move)
     wx.EVT_CHAR(self.control, self._wx_on_char)
Exemple #29
0
    def __init__(self):
        super(mainWindow,
              self).__init__(None, title='W-Engine - ' + version.getVersion())

        self.extruderCount = int(profile.getMachineSetting('extruder_amount'))

        wx.EVT_CLOSE(self, self.OnClose)

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

        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"))
        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, _("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.showPrintWindow(), i)
        i = self.fileMenu.Append(-1, _("Output 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._showSliceLog(), 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)
        # 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..."))
        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)
        # if self.extruderCount > 1:
        # 	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)
        # 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 W-Engine"))
        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)
        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)
        # sizer = wx.BoxSizer()
        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()
Exemple #30
0
    def OnCreate(self, doc, flags):
        config = wx.ConfigBase_Get()
        windowLoc = self._service.GetEmbeddedWindowLocation()
        if windowLoc == FLOATING_MINIFRAME:
            pos = config.ReadInt(self._service.GetServiceName() + "FrameXLoc",
                                 -1), config.ReadInt(
                                     self._service.GetServiceName() +
                                     "FrameYLoc", -1)
            # make sure frame is visible
            screenWidth = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
            screenHeight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
            if pos[0] < 0 or pos[0] >= screenWidth or pos[1] < 0 or pos[
                    1] >= screenHeight:
                pos = wx.DefaultPosition

            size = wx.Size(
                config.ReadInt(self._service.GetServiceName() + "FrameXSize",
                               -1),
                config.ReadInt(self._service.GetServiceName() + "FrameYSize",
                               -1))
            title = _(self._service.GetServiceName())
            if wx.GetApp().GetDocumentManager().GetFlags(
            ) & wx.lib.docview.DOC_SDI and wx.GetApp().GetAppName():
                title = title + " - " + wx.GetApp().GetAppName()
            frame = wx.MiniFrame(wx.GetApp().GetTopWindow(),
                                 -1,
                                 title,
                                 pos=pos,
                                 size=size,
                                 style=wx.CLOSE_BOX | wx.CAPTION
                                 | wx.SYSTEM_MENU)
            wx.EVT_CLOSE(frame, self.OnCloseWindow)
        elif wx.GetApp().IsMDI():
            self._embeddedWindow = wx.GetApp().GetTopWindow(
            ).GetEmbeddedWindow(windowLoc)
            frame = self._embeddedWindow
        else:
            pos = config.ReadInt(self._service.GetServiceName() + "FrameXLoc",
                                 -1), config.ReadInt(
                                     self._service.GetServiceName() +
                                     "FrameYLoc", -1)
            # make sure frame is visible
            screenWidth = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X)
            screenHeight = wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y)
            if pos[0] < 0 or pos[0] >= screenWidth or pos[1] < 0 or pos[
                    1] >= screenHeight:
                pos = wx.DefaultPosition

            size = wx.Size(
                config.ReadInt(self._service.GetServiceName() + "FrameXSize",
                               -1),
                config.ReadInt(self._service.GetServiceName() + "FrameYSize",
                               -1))
            title = _(self._service.GetServiceName())
            if wx.GetApp().GetDocumentManager().GetFlags(
            ) & wx.lib.docview.DOC_SDI and wx.GetApp().GetAppName():
                title = title + " - " + wx.GetApp().GetAppName()
            frame = wx.GetApp().CreateDocumentFrame(self,
                                                    doc,
                                                    flags,
                                                    pos=pos,
                                                    size=size)
            frame.SetTitle(title)
            if config.ReadInt(
                    self._service.GetServiceName() + "FrameMaximized", False):
                frame.Maximize(True)
            wx.EVT_CLOSE(frame, self.OnCloseWindow)

        self.SetFrame(frame)
        sizer = wx.BoxSizer(wx.VERTICAL)

        windowLoc = self._service.GetEmbeddedWindowLocation()
        if self._embeddedWindow or windowLoc == FLOATING_MINIFRAME:
            if (self._service.GetEmbeddedWindowLocation() ==
                    wx.lib.pydocview.EMBEDDED_WINDOW_BOTTOM):
                if ServiceView.bottomTab == None:
                    ServiceView.bottomTab = wx.Notebook(
                        frame, wx.NewId(), (0, 0), (100, 100), wx.LB_DEFAULT,
                        "Bottom Tab")
                    wx.EVT_RIGHT_DOWN(ServiceView.bottomTab,
                                      self.OnNotebookRightClick)
                    wx.EVT_MIDDLE_DOWN(ServiceView.bottomTab,
                                       self.OnNotebookMiddleClick)
                    sizer.Add(ServiceView.bottomTab, 1, wx.TOP | wx.EXPAND, 4)

                    def OnFrameResize(event):
                        ServiceView.bottomTab.SetSize(
                            ServiceView.bottomTab.GetParent().GetSize())

                    frame.Bind(wx.EVT_SIZE, OnFrameResize)
                # Factor this out.
                self._control = self._CreateControl(ServiceView.bottomTab,
                                                    wx.NewId())
                if self._control != None:
                    ServiceView.bottomTab.AddPage(
                        self._control, self._service.GetServiceName())
                ServiceView.bottomTab.Layout()
            else:
                # Factor this out.
                self._control = self._CreateControl(frame, wx.NewId())
                sizer.Add(self._control)
        else:
            # Factor this out.
            self._control = self._CreateControl(frame, wx.NewId())
            sizer.Add(self._control, 1, wx.EXPAND, 0)
        frame.SetSizer(sizer)
        frame.Layout()
        self.Activate()
        return True