Ejemplo n.º 1
0
    def build_settings(self, settings):
        """
		Add our custom section to the default configuration object.
		"""
        # We use the string defined above for our JSON, but it could also b
        # loaded from a file as follows:
        #     settings.add_json_panel('My Label', self.config, 'settings.json')
        #        settings.add_json_panel('My Label', self.config, data=json)
        title = 'Sync Settings'
        settings_list = settings_master_list()
        panel = SettingsPanel(title=title,
                              settings=settings,
                              config=self.config)

        for setting in settings_list.keys():
            if settings_list[setting][0] == 'boolean':
                s = SettingBoolean(panel=panel,
                                   title=setting,
                                   section="Sync Settings",
                                   key=setting)
            elif settings_list[setting][0] == 'numeric':
                s = SettingNumeric(panel=panel,
                                   title=setting,
                                   section="Sync Settings",
                                   key=setting)
            panel.add_widget(s)


#        panel.add_widget(SettingTitle(text = 'Active Spiders'))
        uid = panel.uid
        if settings.interface is not None:
            settings.interface.add_panel(panel, title, uid)
Ejemplo n.º 2
0
    def generate_settings(self):

        settings_panel = Settings() #create instance of Settings

#        def add_one_panel(from_instance):
#            panel = SettingsPanel(title="I like trains", settings=self)
#            panel.add_widget(AsyncImage(source="http://i3.kym-cdn.com/entries/icons/original/000/004/795/I-LIKE-TRAINS.jpg"))
#            settings_panel.add_widget(panel)
#            print "Hello World from ", from_instance

        panel = SettingsPanel(title="Engine") #create instance of left side panel
        item1 = SettingItem(panel=panel, title="Board") #create instance of one item in left side panel
        item2 = SettingItem(panel=panel, title="Level") #create instance of one item in left side panel

    #        item2 = SettingTitle(title="Level") #another widget in left side panel
#        button = Button(text="Add one more panel")

#        item1.add_widget(button) #add widget to item1 in left side panel
#        button.bind(on_release=add_one_panel) #bind that button to function

        panel.add_widget(item1) # add item1 to left side panel
        panel.add_widget(item2) # add item2 to left side panel
        settings_panel.add_widget(panel) #add left side panel itself to the settings menu
        def go_back():
            self.root.current = 'main'
        settings_panel.on_close=go_back

        return settings_panel # show the settings interface
Ejemplo n.º 3
0
 def setUp(self):
     super().setUp()
     panel = SettingsPanel()
     self.fp = SettingCustomConfigFilePath(panel=panel)
     self.fp.value = self.T.file.aname
     self.fp._create_popup(self.fp)
     self.fp.textinput.filename = self.T.filename.aname
Ejemplo n.º 4
0
 def test_base(self):
     panel = SettingsPanel()
     self.fp = SettingLabel(panel=panel)
     self.fp.value = "some url"
     with patch("mydevoirs.custom_setting.webbrowser.open_new") as m:
         self.fp.dispatch("on_release")
         assert m.called
         assert m.call_args_list == [call("some url")]
Ejemplo n.º 5
0
    def create_json_panel(self, title, config, filename=None, data=None):
        """Create new :class:`SettingsPanel`.

        .. versionadded:: 1.5.0

        Check the documentation of :meth:`add_json_panel` for more information.
        """
        if filename is None and data is None:
            raise Exception('You must specify either the filename or data')
        if filename is not None:
            with open(filename, 'r') as fd:
                data = json.loads(fd.read())
        else:
            data = json.loads(data)
        if type(data) != list:
            raise ValueError('The first element must be a list')
        panel = SettingsPanel(title=title, settings=self, config=config)

        for setting in data:
            # determine the type and the class to use
            if not 'type' in setting:
                raise ValueError('One setting are missing the "type" element')
            ttype = setting['type']
            cls = self._types.get(ttype)
            if cls is None:
                raise ValueError(
                    'No class registered to handle the <%s> type' %
                    setting['type'])

            # create a instance of the class, without the type attribute
            del setting['type']
            str_settings = {}
            for key, item in setting.items():
                str_settings[str(key)] = item

            instance = cls(panel=panel, **str_settings)

            # instance created, add to the panel
            panel.add_widget(instance)

        return panel
Ejemplo n.º 6
0
    def create_json_panel(self, title, config, filename=None, data=None):
        import settings as platform_settings
        from kivy.utils import platform

        import json
        sdata = [d for d in json.loads(data)]
        processed_data = []
        for d in sdata:
            platforms = d.get('platforms', None)
            profiles = d.get('profiles', None)
            to_add = bool(not platforms and not profiles)
            to_add |= bool(platforms and platform in platforms
                           and not profiles)
            to_add |= bool(platforms and platform in platforms
                           and platform_settings.PROFILE in profiles)

            if to_add:
                processed_data.append(d)

        panel = SettingsPanel(title=title, settings=self, config=config)

        for setting in processed_data:
            # determine the type and the class to use
            if 'type' not in setting:
                raise ValueError('One setting are missing the "type" element')
            ttype = setting['type']
            cls = self._types.get(ttype)
            if cls is None:
                raise ValueError(
                    'No class registered to handle the <%s> type' %
                    setting['type'])

            # create a instance of the class, without the type attribute
            del setting['type']
            str_settings = {}
            for key, item in setting.items():
                str_settings[str(key)] = item

            instance = cls(panel=panel, **str_settings)

            # instance created, add to the panel
            panel.add_widget(instance)

        notification_toggle = self.get_item('enable_notifications', panel)

        # needed to trigger enabling/disabling the groups after the settings panel is built
        notification_toggle.on_value(self, notification_toggle.value)
        panel.add_widget(RateUsLabel())
        panel.add_widget(VersionLabel())

        return panel
Ejemplo n.º 7
0
    def generate_settings(self):

        settings_panel = Settings()  #create instance of Settings

        #        def add_one_panel(from_instance):
        #            panel = SettingsPanel(title="I like trains", settings=self)
        #            panel.add_widget(AsyncImage(source="http://i3.kym-cdn.com/entries/icons/original/000/004/795/I-LIKE-TRAINS.jpg"))
        #            settings_panel.add_widget(panel)
        #            print "Hello World from ", from_instance

        panel = SettingsPanel(
            title="Engine")  #create instance of left side panel
        item1 = SettingItem(
            panel=panel,
            title="Board")  #create instance of one item in left side panel
        item2 = SettingItem(
            panel=panel,
            title="Level")  #create instance of one item in left side panel

        #        item2 = SettingTitle(title="Level") #another widget in left side panel
        #        button = Button(text="Add one more panel")

        #        item1.add_widget(button) #add widget to item1 in left side panel
        #        button.bind(on_release=add_one_panel) #bind that button to function

        panel.add_widget(item1)  # add item1 to left side panel
        panel.add_widget(item2)  # add item2 to left side panel
        settings_panel.add_widget(
            panel)  #add left side panel itself to the settings menu

        def go_back():
            self.root.current = 'main'

        settings_panel.on_close = go_back

        return settings_panel  # show the settings interface
Ejemplo n.º 8
0
def FramePop(self):
    layout = GridLayout(cols=1, size_hint=(None, 2.5), width=700)
    layout.bind(minimum_height=layout.setter('height'))
    panel = SettingsPanel(title="Framework Mods", settings=self)
    main = BoxLayout(orientation='vertical')
    root = ScrollView(size_hint=(None, None),
                      bar_margin=-11,
                      bar_color=(47 / 255., 167 / 255., 212 / 255., 1.),
                      do_scroll_x=False)
    root.size = (600, 400)
    root.add_widget(layout)
    main.add_widget(root)
    done = Button(text='Done Choosing Options')
    main.add_widget(done)

    popup = Popup(background='atlas://images/eds/pop',
                  title='Framework Mods',
                  content=main,
                  auto_dismiss=True,
                  size_hint=(None, None),
                  size=(630, 500))
    popup.open()
Ejemplo n.º 9
0
def BrowserPop(self):
    layout = GridLayout(cols=1, size_hint=(None, 1.0), width=700)
    layout.bind(minimum_height=layout.setter('height'))
    panel = SettingsPanel(title="Browser Mods", settings=self)   
    main = BoxLayout(orientation = 'vertical')
    root = ScrollView(size_hint=(None, None),bar_margin=-11, bar_color=(47 / 255., 167 / 255., 212 / 255., 1.), do_scroll_x=False)
    root.size = (600, 400)
    root.add_widget(layout)
    main.add_widget(root)
    done = Button(text ='Done Choosing Options')
    main.add_widget(done)
    if 'const/4 v0, 0x4' in open("%s/BrowserSettings.smali" % (Browser)).read():
        fp = open("%s/BrowserSettings.smali" % (Browser), "r")
        lines = fp.readlines()
        fp.close()
        tabs = SettingItem(panel = panel, title = "Unlimited Browser Tabs",disabled=False, desc = "Allows Unlimited number of browser tabs to be open")
        for i in range(len(lines)):
            if 'const/4 v0, 0x4' in open("%s/BrowserSettings.smali" % (Browser)).read():
                tabs_switch = Switch(active=False)
                continue
            if 'const/4 v0, 0x4' in open("%s/BrowserSettings.smali" % (Browser)).read():
                tabs_switch = Switch(active=True)
        tabs.add_widget(tabs_switch)
        layout.add_widget(tabs)
    
        def callback(instance, value):
            tabs_state(instance, value)
        tabs_switch.bind(active=callback)
    
    popup = Popup(background='atlas://images/eds/pop', title='Browser Mods', content=main, auto_dismiss=False, size_hint=(None, None), size=(630, 500))
    popup.open()

    def finish(self):
        finish_browser(self)
        popup.dismiss()
    done.bind(on_release=finish)
Ejemplo n.º 10
0
 def cm_branch(self):
     config.read('%s/eds.ini' % Usr)
     Box = BoxLayout(orientation="vertical", spacing=10)
     base = SettingsPanel(title="", settings=self)
     btn_layout = GridLayout(cols=2, spacing=10)
     select = Button(text="Select")
     btn_layout.add_widget(select)
     cancel = Button(text='Cancel')
     btn_layout.add_widget(cancel)
     base.bind(minimum_height=base.setter('height'))
 
 #################################################
 # Removed branch type selection menu because I think it was useless
 # Should be the same for Aosp and CM 
 # If not I can redo it.
 #################################################
     
     Cm7 = SettingItem(panel = base, title = "Cyanogenmod 7",disabled=False, desc = "Android 2.3,  kernel 2.6.35,  Api 9-10 ")
     Cm7_radio = CheckBox(group='base',active=False)
     Cm7.add_widget(Cm7_radio)
     base.add_widget(Cm7)
 
     Cm9 = SettingItem(panel = base, title = "Cyanogenmod 9",disabled=False, desc = "Android 4.0,  kernel 3.0.1,  Api 14-15")
     Cm9_radio = CheckBox(group='base',active=False)
     Cm9.add_widget(Cm9_radio)
     base.add_widget(Cm9)
 
     Cm10 = SettingItem(panel = base, title = "Cyanogenmod 10",disabled=False, desc = "Android 4.1,  kernel 3.1.10,  Api 16-?")
     Cm10_radio = CheckBox(group='base',active=False)
     Cm10.add_widget(Cm10_radio)
     base.add_widget(Cm10)    
     
     # for root widget do_scroll_y=True to enable scrolling 
     root = ScrollView(size_hint=(None, None), size=(525, 240), do_scroll_x=False, do_scroll_y=False)
     root.add_widget(base)
     Box.add_widget(root)
     Box.add_widget(btn_layout)
 
 ########################################
 # This should be working fine 
 # Not sure if there is a better way to do this
 #########################################
 
     def on_checkbox(checkbox, value):
         title = Cm7.title
         if value:
             bra.text="[b][color=#adadad]Current Branch =[/color][/b] cm-gb"
             config.set("Source", "branch", "cm-gb")
         else:
             pass
 
     Cm7_radio.bind(active=on_checkbox)
     
     def checkbox_active(checkbox, value):
         title = Cm9.title
         if value:
             bra.text="[b][color=#adadad]Current Branch =[/color][/b] cm-ics"
             config.set("Source", "branch", "cm-ics")
         else:
             pass
     
     Cm9_radio.bind(active=checkbox_active)
     
     def on_active(checkbox, value):
         title = Cm10.title
         if value:
             bra.text="[b][color=#adadad]Current Branch =[/color][/b] cm-jb"
             config.set("Source", "branch", "cm-jb")
         else:
             pass
                         
     Cm10_radio.bind(active=on_active)
     
     def set_branch(self):
         config.write()
     select.bind(on_release=set_branch)
     
     popup = Popup(background='atlas://images/eds/pop', title='Branch Selection',content=Box, auto_dismiss=True,
     size_hint=(None, None), size=(550, 350))
     select.bind(on_release=popup.dismiss)
     cancel.bind(on_release=popup.dismiss)
     popup.open() 
Ejemplo n.º 11
0
    def cm_branch(self):
        config.read('%s/eds.ini' % Usr)
        Box = BoxLayout(orientation="vertical", spacing=10)
        base = SettingsPanel(title="", settings=self)
        btn_layout = GridLayout(cols=2, spacing=10)
        select = Button(text="Select")
        btn_layout.add_widget(select)
        cancel = Button(text='Cancel')
        btn_layout.add_widget(cancel)
        base.bind(minimum_height=base.setter('height'))

        #################################################
        # Removed branch type selection menu because I think it was useless
        # Should be the same for Aosp and CM
        # If not I can redo it.
        #################################################

        Cm7 = SettingItem(panel=base,
                          title="Cyanogenmod 7",
                          disabled=False,
                          desc="Android 2.3,  kernel 2.6.35,  Api 9-10 ")
        Cm7_radio = CheckBox(group='base', active=False)
        Cm7.add_widget(Cm7_radio)
        base.add_widget(Cm7)

        Cm9 = SettingItem(panel=base,
                          title="Cyanogenmod 9",
                          disabled=False,
                          desc="Android 4.0,  kernel 3.0.1,  Api 14-15")
        Cm9_radio = CheckBox(group='base', active=False)
        Cm9.add_widget(Cm9_radio)
        base.add_widget(Cm9)

        Cm10 = SettingItem(panel=base,
                           title="Cyanogenmod 10",
                           disabled=False,
                           desc="Android 4.1,  kernel 3.1.10,  Api 16-?")
        Cm10_radio = CheckBox(group='base', active=False)
        Cm10.add_widget(Cm10_radio)
        base.add_widget(Cm10)

        # for root widget do_scroll_y=True to enable scrolling
        root = ScrollView(size_hint=(None, None),
                          size=(525, 240),
                          do_scroll_x=False,
                          do_scroll_y=False)
        root.add_widget(base)
        Box.add_widget(root)
        Box.add_widget(btn_layout)

        ########################################
        # This should be working fine
        # Not sure if there is a better way to do this
        #########################################

        def on_checkbox(checkbox, value):
            title = Cm7.title
            if value:
                bra.text = "[b][color=#adadad]Current Branch =[/color][/b] cm-gb"
                config.set("Source", "branch", "cm-gb")
            else:
                pass

        Cm7_radio.bind(active=on_checkbox)

        def checkbox_active(checkbox, value):
            title = Cm9.title
            if value:
                bra.text = "[b][color=#adadad]Current Branch =[/color][/b] cm-ics"
                config.set("Source", "branch", "cm-ics")
            else:
                pass

        Cm9_radio.bind(active=checkbox_active)

        def on_active(checkbox, value):
            title = Cm10.title
            if value:
                bra.text = "[b][color=#adadad]Current Branch =[/color][/b] cm-jb"
                config.set("Source", "branch", "cm-jb")
            else:
                pass

        Cm10_radio.bind(active=on_active)

        def set_branch(self):
            config.write()

        select.bind(on_release=set_branch)

        popup = Popup(background='atlas://images/eds/pop',
                      title='Branch Selection',
                      content=Box,
                      auto_dismiss=True,
                      size_hint=(None, None),
                      size=(550, 350))
        select.bind(on_release=popup.dismiss)
        cancel.bind(on_release=popup.dismiss)
        popup.open()
Ejemplo n.º 12
0
    def aosp_branch(self):
        config.read('%s/eds.ini' % Usr)
        Box = BoxLayout(orientation="vertical", spacing=10)
        base = SettingsPanel(title="", settings=self)
        btn_layout = GridLayout(cols=2, spacing=10)
        select = Button(text="Select")
        btn_layout.add_widget(select)
        cancel = Button(text='Cancel')
        btn_layout.add_widget(cancel)
        base.bind(minimum_height=base.setter('height'))

        GB = SettingItem(panel=base,
                         title="Gingerbread",
                         disabled=False,
                         desc="Android 2.3,  kernel 2.6.35,  Api 9-10 ")
        GB_radio = CheckBox(group='base', active=False)
        GB.add_widget(GB_radio)
        base.add_widget(GB)

        ICS = SettingItem(panel=base,
                          title="Ice Cream Sandwitch",
                          disabled=False,
                          desc="Android 4.0,  kernel 3.0.1,  Api 14-15")
        ICS_radio = CheckBox(group='base', active=False)
        ICS.add_widget(ICS_radio)
        base.add_widget(ICS)

        JB = SettingItem(panel=base,
                         title="Jellybean",
                         disabled=False,
                         desc="Android 4.1,  kernel 3.1.10,  Api 16-?")
        JB_radio = CheckBox(group='base', active=False)
        JB.add_widget(JB_radio)
        base.add_widget(JB)

        # for root widget do_scroll_y=True to enable scrolling
        root = ScrollView(size_hint=(None, None),
                          size=(525, 240),
                          do_scroll_x=False,
                          do_scroll_y=False)
        root.add_widget(base)
        Box.add_widget(root)
        Box.add_widget(btn_layout)

        ########################################
        # This should be working fine
        # Not sure if there is a better way to do this
        #########################################

        def on_checkbox(checkbox, value):
            title = GB.title
            if value:
                bra.text = "[b][color=#adadad]Current Branch =[/color][/b] aosp-gb"
                config.set("Source", "branch", "aosp-gb")
            else:
                pass

        GB_radio.bind(active=on_checkbox)

        def checkbox_active(checkbox, value):
            title = ICS.title
            if value:
                bra.text = "[b][color=#adadad]Current Branch =[/color][/b] aosp-ics"
                config.set("Source", "branch", "aosp-ics")
            else:
                pass

        ICS_radio.bind(active=checkbox_active)

        def on_active(checkbox, value):
            title = JB.title
            if value:
                bra.text = "[b][color=#adadad]Current Branch =[/color][/b] aosp-jb"
                config.set("Source", "branch", "aosp-jb")
            else:
                pass

        JB_radio.bind(active=on_active)

        def set_branch(self):
            config.write()

        select.bind(on_release=set_branch)

        popup = Popup(background='atlas://images/eds/pop',
                      title='Branch Selection',
                      content=Box,
                      auto_dismiss=True,
                      size_hint=(None, None),
                      size=(550, 350))
        select.bind(on_release=popup.dismiss)
        cancel.bind(on_release=popup.dismiss)
        popup.open()
Ejemplo n.º 13
0
def MmsPop(self):
    layout = GridLayout(cols=1, size_hint=(None, 1.0), width=700)
    layout.bind(minimum_height=layout.setter('height'))
    panel = SettingsPanel(title="Mms Mods", settings=self)
    main = BoxLayout(orientation='vertical')
    root = ScrollView(size_hint=(None, None),
                      bar_margin=-11,
                      bar_color=(47 / 255., 167 / 255., 212 / 255., 1.),
                      do_scroll_x=False)
    root.size = (600, 400)
    root.add_widget(layout)
    main.add_widget(root)
    done = Button(text='Done Choosing Options')
    main.add_widget(done)
    if """    .line 77
    const/4 v0, 0x1

    sput-boolean v0, Lcom/android/mms/model/ImageModel;->mCheckResolution:Z""" in open(
            "%s/ImageModel.smali" % (Mms)).read():
        fp = open("%s/ImageModel.smali" % (Mms), "r")
        lines = fp.readlines()
        fp.close()
        comp = SettingItem(panel=panel,
                           title="Remove Mms Compression",
                           disabled=False,
                           desc="Disables Compression of Mms Messages")
        for i in range(len(lines)):
            if """    .line 77
    const/4 v0, 0x1

    sput-boolean v0, Lcom/android/mms/model/ImageModel;->mCheckResolution:Z""" in open(
                    "%s/ImageModel.smali" % (Mms)).read():
                comp_switch = Switch(active=False)
                continue
            if """    .line 77
    const/4 v0, 0x1

    sput-boolean v0, Lcom/android/mms/model/ImageModel;->mCheckResolution:Z""" in open(
                    "%s/ImageModel.smali" % (Mms)).read():
                comp_switch = Switch(active=True)
        comp.add_widget(comp_switch)
        layout.add_widget(comp)

        def callback(instance, value):
            comp_state(instance, value)

        comp_switch.bind(active=callback)

    popup = Popup(background='atlas://images/eds/pop',
                  title='Mms Mods',
                  content=main,
                  auto_dismiss=False,
                  size_hint=(None, None),
                  size=(630, 500))
    popup.open()

    def finish(self):
        finish_comp(self)
        popup.dismiss()

    done.bind(on_release=finish)
Ejemplo n.º 14
0
def credits_popup(self):
    layout = GridLayout(cols=1, size_hint=(None, 1.4), width=700)
    layout.bind(minimum_height=layout.setter('height'))
    panel = SettingsPanel(title="Credits", settings=self)   
    main = BoxLayout(orientation = 'vertical')
    root = ScrollView(size_hint=(None, None),bar_margin=-11, bar_color=(47 / 255., 167 / 255., 212 / 255., 1.), do_scroll_x=False)
    root.size = (600, 400)
    root.add_widget(layout)
    main.add_widget(root)
    done = Button(text ='Close')
    main.add_widget(done)

    wes_btns = GridLayout(cols=3, spacing=10, padding=5)
    wes_twit = CustomButton(text='Twitter', size_hint_x=None, size_hint_y=30, width=60)
    wes_btns.add_widget(wes_twit)
    wes_contact = CustomButton(text='Gmail', size_hint_x=None, size_hint_y=30, width=60)
    wes_btns.add_widget(wes_contact)
    wes_site = CustomButton(text='Site', size_hint_x=None, size_hint_y=30, width=60)
    wes_btns.add_widget(wes_site)

    wes = SettingItem(panel = panel, title = "Wes342",disabled=False, desc = "Lead Developer:  -  Python,  xml,  java,  smali,  json\nLead Site Maintainer: - Html,  Xml,  Php")
    wes.add_widget(wes_btns)
    layout.add_widget(wes)

    sac_btns = GridLayout(cols=3, spacing=10, padding=5)
    sac_twit = CustomButton(text='Twitter',size_hint_x=None, size_hint_y=60, width=60)
    sac_btns.add_widget(sac_twit)
    sac_contact = CustomButton(text='Gmail',size_hint_x=None, size_hint_y=60, width=60)
    sac_btns.add_widget(sac_contact)
    sac_site = CustomButton(text='Site',size_hint_x=None, size_hint_y=60, width=60)
    sac_btns.add_widget(sac_site)
    
    zar_btns = GridLayout(cols=3, spacing=10, padding=5)
    zar_twit = CustomButton(text='Twitter',size_hint_x=None, size_hint_y=60, width=60)
    zar_btns.add_widget(zar_twit)
    zar_contact = CustomButton(text='Gmail',size_hint_x=None, size_hint_y=60, width=60)
    zar_btns.add_widget(zar_contact)
    zar_site = CustomButton(text='Site',size_hint_x=None, size_hint_y=60, width=60)
    zar_btns.add_widget(zar_site)

    sac = SettingItem(panel = panel, title = "Sac23",disabled=False, desc = "Lead Developer:  -  Android,  xml,  smali")
    sac.add_widget(sac_btns)
    layout.add_widget(sac)

    zar = SettingItem(panel = panel, title = "Zarboz",disabled=False, desc = "Kernel Development:  -  Source, Make, Github")
    zar.add_widget(zar_btns)
    layout.add_widget(zar)
   
   
    thanks = SettingItem(panel = panel, title = "Credits",disabled=True, desc = Credits)
    layout.add_widget(thanks)
    
    donors = SettingItem(panel = panel, title = "Donors",disabled=True, desc = Donors)
    layout.add_widget(donors)

    popup = Popup(background='atlas://images/eds/pop', title='Credits', content=main, auto_dismiss=True, size_hint=(None, None), size=(630, 500))
    popup.open()
    done.bind(on_release=popup.dismiss)

    def wes_twitter(self):
        webbrowser.open('http://twitter.com/wes342')
    wes_twit.bind(on_press=wes_twitter)
    
    def wes_gtalk(self):
        webbrowser.open("mailto:[email protected]")
    wes_contact.bind(on_press=wes_gtalk)
    
    def wes_website(self):
        webbrowser.open('http://easydevstudio.com/home')
    wes_site.bind(on_press=wes_website)
       
    def sac_twitter(self):
        webbrowser.open('http://twitter.com/sac232')
    sac_twit.bind(on_press=sac_twitter)

    def sac_gtalk(self):
        webbrowser.open("mailto:[email protected]")
    sac_contact.bind(on_press=sac_gtalk)
    
    def sac_website(self):
        webbrowser.open('http://citycollisioncenter.com')
    sac_site.bind(on_press=sac_website)
    
    def zar_twitter(self):
        webbrowser.open('http://twitter.com/zarboz')
    zar_twit.bind(on_press=zar_twitter)

    def zar_gtalk(self):
        webbrowser.open("mailto:[email protected]")
    zar_contact.bind(on_press=zar_gtalk)
    
    def zar_website(self):
        webbrowser.open('https://github.com/zarboz')
    zar_site.bind(on_press=zar_website)
Ejemplo n.º 15
0
    def __init__(self, rend, **kwargs):
        self.texture = Texture.create(size=BUF_DIMENSIONS)
        self.texture_size = BUF_DIMENSIONS
        self.cbtex = Texture.create(size=self.cbsize)
        super(RenderGUI, self).__init__(**kwargs)

        self.rend = rend
        self.buffer_array = np.empty(BUF_DIMENSIONS[::-1] + (4, ), dtype='uint8')
        self.distance_per_pixel = self.rend.distance_per_pixel
        self.stepsize = self.rend.stepsize

        self.x_pixel_offset = rend.x_pixel_offset
        self.y_pixel_offset = rend.y_pixel_offset
        self.snap = self.rend.snap

        self.config = ConfigParser()
        self.channellist = [os.path.basename(os.path.splitext(a)[0]) for a in self.rend.channellist()]
        self.config.setdefaults('renderer', {'rendermode': self.rendermode,
                                             'channel': self.channellist[0],
                                             'snap': self.rend.snap,
                                             'nlamb': self.nlamb,
                                             'opacity': int(self.rend_opacity),
                                             'altitude': self.altitude,
                                             'azimuth': self.azimuth,
                                             'distance_per_pixel': self.distance_per_pixel,
                                             'stepsize': self.stepsize,
                                             'noise_snr': self.noise_snr})
        self.config.setdefaults('display', {'log_offset': self.log_offset,
                                            'cbar_num': self.cbar_num,
                                            'asym_sep': self.asym_sep,
                                            'asym_width': self.asym_width})

        self.spanel = SettingsPanel(settings=self.s, title='Render Settings', config=self.config)
        self.s.interface.add_panel(self.spanel, 'Render Settings', self.spanel.uid)

        self.dpanel = SettingsPanel(settings=self.s, title='Display Settings', config=self.config)
        self.s.interface.add_panel(self.dpanel, 'Display Settings', self.dpanel.uid)

        self.mode_opt = SettingOptions(title='Render Mode',
                                       desc='What to simulate and display',
                                       key='rendermode',
                                       section='renderer',
                                       options=[Mode.__dict__[x] for x in dir(Mode) if not x.startswith('_')],
                                       panel=self.spanel)
        self.spanel.add_widget(self.mode_opt)

        self.chan_opt = SettingOptions(title='Channel',
                                       desc='Emissions channel to select',
                                       key='channel',
                                       section='renderer',
                                       options=self.channellist,
                                       panel=self.spanel)
        self.spanel.add_widget(self.chan_opt)

        self.snap_opt = SettingNumeric(title='Snap',
                                       desc='Snap number to select',
                                       key='snap',
                                       section='renderer',
                                       panel=self.spanel)
        self.spanel.add_widget(self.snap_opt)

        self.nlamb_opt = SettingNumeric(title='NLamb',
                                        desc='Number of frequencies to sample during spectra calculations',
                                        key='nlamb',
                                        section='renderer',
                                        panel=self.spanel)
        self.spanel.add_widget(self.nlamb_opt)

        self.opa_opt = SettingBoolean(title='Opacity',
                                      desc='Whether or not to enable opacity in the simulation',
                                      key='opacity',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.opa_opt)

        self.alt_opt = SettingNumeric(title='Altitude',
                                      desc='The POV angle above horizontal',
                                      key='altitude',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.alt_opt)

        self.azi_opt = SettingNumeric(title='Azimuth',
                                      desc='The POV angle lateral to the x-axis',
                                      key='azimuth',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.azi_opt)

        self.dpp_opt = SettingNumeric(title='Distance per Pixel',
                                      desc='Distance in simulation between pixels in km, specifies zoom',
                                      key='distance_per_pixel',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.dpp_opt)

        self.stp_opt = SettingNumeric(title='Step Size',
                                      desc='Magnitude of the integration stepsize, increase for performance',
                                      key='stepsize',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.stp_opt)

        self.noise_snr_opt = SettingNumeric(title='Spectral SNR',
                                            desc=u'Spectral signal to noise ratio, in dB\u2014to disable, set to 999',
                                            key='noise_snr',
                                            section='renderer',
                                            panel=self.spanel)
        self.spanel.add_widget(self.noise_snr_opt)

        self.range_opt = SettingNumeric(title='Dynamic Range',
                                        desc='Orders of magnitude to span in display',
                                        key='log_offset',
                                        section='display',
                                        panel=self.spanel)
        self.dpanel.add_widget(self.range_opt)

        self.cbarnum_opt = SettingNumeric(title='Colorbar Numbers',
                                          desc='Number of data points to indicate on the colorbar',
                                          key='cbar_num',
                                          section='display',
                                          panel=self.spanel)
        self.dpanel.add_widget(self.cbarnum_opt)

        self.asym_width_opt = SettingNumeric(title='Asymmetry Window Width',
                                             desc='Width of integration window, in km/s',
                                             key='asym_width',
                                             section='display',
                                             panel=self.spanel)
        self.dpanel.add_widget(self.asym_width_opt)

        self.asym_sep_opt = SettingNumeric(title='Asymmetry Window Separation',
                                           desc='Separation of integration windows, in km/s',
                                           key='asym_sep',
                                           section='display',
                                           panel=self.spanel)
        self.dpanel.add_widget(self.asym_sep_opt)

        self._keyboard_open()
        Window.bind(on_resize=self._on_resize)

        #initial update
        self._on_resize(Window, Window.size[0], Window.size[1])
        self._saverangedialog = SaveRangeDialog(self, size_hint=(.8, .8), title="Save Range")

        self.initialized = True
Ejemplo n.º 16
0
 def aosp_branch(self):
     config.read('%s/eds.ini' % Usr)
     Box = BoxLayout(orientation="vertical", spacing=10)
     base = SettingsPanel(title="", settings=self)
     btn_layout = GridLayout(cols=2, spacing=10)
     select = Button(text="Select")
     btn_layout.add_widget(select)
     cancel = Button(text='Cancel')
     btn_layout.add_widget(cancel)
     base.bind(minimum_height=base.setter('height'))
 
     
     GB = SettingItem(panel = base, title = "Gingerbread",disabled=False, desc = "Android 2.3,  kernel 2.6.35,  Api 9-10 ")
     GB_radio = CheckBox(group='base',active=False)
     GB.add_widget(GB_radio)
     base.add_widget(GB)
 
     ICS = SettingItem(panel = base, title = "Ice Cream Sandwitch",disabled=False, desc = "Android 4.0,  kernel 3.0.1,  Api 14-15")
     ICS_radio = CheckBox(group='base',active=False)
     ICS.add_widget(ICS_radio)
     base.add_widget(ICS)
 
     JB = SettingItem(panel = base, title = "Jellybean",disabled=False, desc = "Android 4.1,  kernel 3.1.10,  Api 16-?")
     JB_radio = CheckBox(group='base',active=False)
     JB.add_widget(JB_radio)
     base.add_widget(JB)    
     
     # for root widget do_scroll_y=True to enable scrolling 
     root = ScrollView(size_hint=(None, None), size=(525, 240), do_scroll_x=False, do_scroll_y=False)
     root.add_widget(base)
     Box.add_widget(root)
     Box.add_widget(btn_layout)
 
 ########################################
 # This should be working fine 
 # Not sure if there is a better way to do this
 #########################################
 
     def on_checkbox(checkbox, value):
         title = GB.title
         if value:
             bra.text="[b][color=#adadad]Current Branch =[/color][/b] aosp-gb"
             config.set("Source", "branch", "aosp-gb")
         else:
             pass
 
     GB_radio.bind(active=on_checkbox)
     
     def checkbox_active(checkbox, value):
         title = ICS.title
         if value:
             bra.text="[b][color=#adadad]Current Branch =[/color][/b] aosp-ics"
             config.set("Source", "branch", "aosp-ics")
         else:
             pass
     
     ICS_radio.bind(active=checkbox_active)
     
     def on_active(checkbox, value):
         title = JB.title
         if value:
             bra.text="[b][color=#adadad]Current Branch =[/color][/b] aosp-jb"
             config.set("Source", "branch", "aosp-jb")
         else:
             pass
                         
     JB_radio.bind(active=on_active)
     
     def set_branch(self):
         config.write()
     select.bind(on_release=set_branch)
     
     popup = Popup(background='atlas://images/eds/pop', title='Branch Selection',content=Box, auto_dismiss=True,
     size_hint=(None, None), size=(550, 350))
     select.bind(on_release=popup.dismiss)
     cancel.bind(on_release=popup.dismiss)
     popup.open()
Ejemplo n.º 17
0
class RenderGUI(Widget):
    rend = None
    azimuth = NumericProperty(20.0)
    altitude = NumericProperty(20.0)
    distance_per_pixel = NumericProperty(0.0)
    stepsize = NumericProperty(0.0)
    x_pixel_offset = NumericProperty(0)
    y_pixel_offset = NumericProperty(0)
    rend_opacity = BooleanProperty(False)
    channel = NumericProperty(0)
    log_offset = NumericProperty(6.0)
    cbar_num = NumericProperty(10)
    snap = NumericProperty(0)
    rendermode = Mode.intensity
    spect_analyzer = spectAnlys.Analyzer()
    nlamb = NumericProperty(41)
    cbsize = (30, 3000)
    asym_sep = NumericProperty(0.0)
    asym_width = NumericProperty(0.0)
    noise_snr = NumericProperty(999.)

    helptext = ('Pan l/r: a/d\n'
                'Tilt u/d: w/s\n'
                'zoom in/out: j/k\n'
                'Shift l/r: [left]/[right]\n'
                'Shift u/d: [up]/[down]\n'
                'Recenter shift: c\n'
                'Dynamic range inc/dec: i/u\n'
                'Stepsize inc/dec: ./,\n'
                'Toggle opacity: o\n'
                'Change timestep: [/]')
    initialized = False

    def __init__(self, rend, **kwargs):
        self.texture = Texture.create(size=BUF_DIMENSIONS)
        self.texture_size = BUF_DIMENSIONS
        self.cbtex = Texture.create(size=self.cbsize)
        super(RenderGUI, self).__init__(**kwargs)

        self.rend = rend
        self.buffer_array = np.empty(BUF_DIMENSIONS[::-1] + (4, ), dtype='uint8')
        self.distance_per_pixel = self.rend.distance_per_pixel
        self.stepsize = self.rend.stepsize

        self.x_pixel_offset = rend.x_pixel_offset
        self.y_pixel_offset = rend.y_pixel_offset
        self.snap = self.rend.snap

        self.config = ConfigParser()
        self.channellist = [os.path.basename(os.path.splitext(a)[0]) for a in self.rend.channellist()]
        self.config.setdefaults('renderer', {'rendermode': self.rendermode,
                                             'channel': self.channellist[0],
                                             'snap': self.rend.snap,
                                             'nlamb': self.nlamb,
                                             'opacity': int(self.rend_opacity),
                                             'altitude': self.altitude,
                                             'azimuth': self.azimuth,
                                             'distance_per_pixel': self.distance_per_pixel,
                                             'stepsize': self.stepsize,
                                             'noise_snr': self.noise_snr})
        self.config.setdefaults('display', {'log_offset': self.log_offset,
                                            'cbar_num': self.cbar_num,
                                            'asym_sep': self.asym_sep,
                                            'asym_width': self.asym_width})

        self.spanel = SettingsPanel(settings=self.s, title='Render Settings', config=self.config)
        self.s.interface.add_panel(self.spanel, 'Render Settings', self.spanel.uid)

        self.dpanel = SettingsPanel(settings=self.s, title='Display Settings', config=self.config)
        self.s.interface.add_panel(self.dpanel, 'Display Settings', self.dpanel.uid)

        self.mode_opt = SettingOptions(title='Render Mode',
                                       desc='What to simulate and display',
                                       key='rendermode',
                                       section='renderer',
                                       options=[Mode.__dict__[x] for x in dir(Mode) if not x.startswith('_')],
                                       panel=self.spanel)
        self.spanel.add_widget(self.mode_opt)

        self.chan_opt = SettingOptions(title='Channel',
                                       desc='Emissions channel to select',
                                       key='channel',
                                       section='renderer',
                                       options=self.channellist,
                                       panel=self.spanel)
        self.spanel.add_widget(self.chan_opt)

        self.snap_opt = SettingNumeric(title='Snap',
                                       desc='Snap number to select',
                                       key='snap',
                                       section='renderer',
                                       panel=self.spanel)
        self.spanel.add_widget(self.snap_opt)

        self.nlamb_opt = SettingNumeric(title='NLamb',
                                        desc='Number of frequencies to sample during spectra calculations',
                                        key='nlamb',
                                        section='renderer',
                                        panel=self.spanel)
        self.spanel.add_widget(self.nlamb_opt)

        self.opa_opt = SettingBoolean(title='Opacity',
                                      desc='Whether or not to enable opacity in the simulation',
                                      key='opacity',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.opa_opt)

        self.alt_opt = SettingNumeric(title='Altitude',
                                      desc='The POV angle above horizontal',
                                      key='altitude',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.alt_opt)

        self.azi_opt = SettingNumeric(title='Azimuth',
                                      desc='The POV angle lateral to the x-axis',
                                      key='azimuth',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.azi_opt)

        self.dpp_opt = SettingNumeric(title='Distance per Pixel',
                                      desc='Distance in simulation between pixels in km, specifies zoom',
                                      key='distance_per_pixel',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.dpp_opt)

        self.stp_opt = SettingNumeric(title='Step Size',
                                      desc='Magnitude of the integration stepsize, increase for performance',
                                      key='stepsize',
                                      section='renderer',
                                      panel=self.spanel)
        self.spanel.add_widget(self.stp_opt)

        self.noise_snr_opt = SettingNumeric(title='Spectral SNR',
                                            desc=u'Spectral signal to noise ratio, in dB\u2014to disable, set to 999',
                                            key='noise_snr',
                                            section='renderer',
                                            panel=self.spanel)
        self.spanel.add_widget(self.noise_snr_opt)

        self.range_opt = SettingNumeric(title='Dynamic Range',
                                        desc='Orders of magnitude to span in display',
                                        key='log_offset',
                                        section='display',
                                        panel=self.spanel)
        self.dpanel.add_widget(self.range_opt)

        self.cbarnum_opt = SettingNumeric(title='Colorbar Numbers',
                                          desc='Number of data points to indicate on the colorbar',
                                          key='cbar_num',
                                          section='display',
                                          panel=self.spanel)
        self.dpanel.add_widget(self.cbarnum_opt)

        self.asym_width_opt = SettingNumeric(title='Asymmetry Window Width',
                                             desc='Width of integration window, in km/s',
                                             key='asym_width',
                                             section='display',
                                             panel=self.spanel)
        self.dpanel.add_widget(self.asym_width_opt)

        self.asym_sep_opt = SettingNumeric(title='Asymmetry Window Separation',
                                           desc='Separation of integration windows, in km/s',
                                           key='asym_sep',
                                           section='display',
                                           panel=self.spanel)
        self.dpanel.add_widget(self.asym_sep_opt)

        self._keyboard_open()
        Window.bind(on_resize=self._on_resize)

        #initial update
        self._on_resize(Window, Window.size[0], Window.size[1])
        self._saverangedialog = SaveRangeDialog(self, size_hint=(.8, .8), title="Save Range")

        self.initialized = True

    def _settings_change(self, section, key, value):
        '''
        Called on setting panel change, updates values in renderer config
        '''
        self._keyboard_open()
        if key == 'opacity':
            self.rend_opacity = (value == '1')
        elif key in ('snap', 'nlamb'):
            setattr(self, key, int(value))
        elif key == 'channel':
            self.channel = self.channellist.index(value)
        elif key == 'rendermode':
            self.rendermode = value
        elif key in ('rendermode', 'altitude', 'azimuth', 'distance_per_pixel', 'stepsize',
                     'log_offset', 'cbar_num', 'asym_width', 'asym_sep', 'noise_snr'):
            setattr(self, key, float(value))
        else:
            return
        if section == 'renderer':
            self.update()
        else:
            self.update_display()

    def _keyboard_open(self):
        self._keyboard = Window.request_keyboard(self._keyboard_closed, self)
        self._keyboard.bind(on_key_down=self._on_keyboard_down)

    def _keyboard_closed(self):
        self._keyboard.unbind(on_key_down=self._on_keyboard_down)
        self._keyboard = None

    def _on_keyboard_down(self, keyboard, keycode, text, modifiers):
        '''
        Does stuff on some keypresses
        '''
        if keycode[1] == 'w':  # view up
            self.altitude += 2
        elif keycode[1] == 's':  # view down
            self.altitude -= 2
        elif keycode[1] == 'a':  # view left
            self.azimuth -= 2
        elif keycode[1] == 'd':  # view right
            self.azimuth += 2
        elif keycode[1] == 'j':  # zoom in
            self.distance_per_pixel *= 0.95
        elif keycode[1] == 'k':  # zoom out
            self.distance_per_pixel /= 0.95
        elif keycode[1] == 'u':  # decrease contrast, increasing dyn range
            self.log_offset += 0.4
            self.update_display()  # don't rerender, just update display
            return
        elif keycode[1] == 'i':  # increase contrast
            if self.log_offset > 0:
                self.log_offset -= 0.4
            self.update_display()
            return
        elif keycode[1] == 'up':  # shift view up
            self.y_pixel_offset += 5
        elif keycode[1] == 'down':  # shift view down
            self.y_pixel_offset -= 5
        elif keycode[1] == 'left':  # shift view left
            self.x_pixel_offset -= 5
        elif keycode[1] == 'right':  # shift view right
            self.x_pixel_offset += 5
        elif keycode[1] == 'c':
            self.x_pixel_offset = self.y_pixel_offset = 0
        elif keycode[1] == ',':  # decreases stepsize, increasing resolution
            self.stepsize *= 0.8
        elif keycode[1] == '.':  # increases stepsize, decreasing resolution
            self.stepsize /= 0.8
        elif keycode[1] == '[':  # go back 1 snap
            self.snap -= 1
        elif keycode[1] == ']':  # go forward 1 snap
            self.snap += 1
        elif keycode[1] == 'o':  # toggle opacity
            self.rend_opacity = not self.rend_opacity
        else:
            return

        self.alt_opt.value = str(self.altitude)
        self.azi_opt.value = str(self.azimuth)
        self.range_opt.value = str(self.log_offset)
        self.dpp_opt.value = str(round(self.distance_per_pixel, 6))
        self.stp_opt.value = str(round(self.stepsize, 6))
        self.opa_opt.value = '1' if self.rend_opacity else '0'
        self.snap_opt.value = str(self.rend.snap)
        self.update()

    def _on_resize(self, window, width, height):
        '''
        Rerenders, resizes objects on window resize
        '''
        self.rend.projection_x_size, self.rend.projection_y_size = width, height
        self.s.size = (self.s.size[0], height)
        self.cbsize = (self.cbsize[0], height - 100)
        self.update()

    def update(self, updatedisplay=True):
        '''
        Rerenders stuff and caches it, then updates display if specified
        '''
        if not self.initialized:
            return
        # limit some values
        self.azimuth = self.azimuth % 360
        self.altitude = sorted((-90, self.altitude, 90))[1]
        self.snap = sorted(self.rend.snap_range + (self.snap,))[1]

        # set values in renderer, and render
        self.rend.distance_per_pixel = self.distance_per_pixel
        self.rend.stepsize = self.stepsize
        self.rend.y_pixel_offset = self.y_pixel_offset
        self.rend.x_pixel_offset = self.x_pixel_offset
        self.rend.set_snap(self.snap)

        # render appropriate data, cache it
        if self.rendermode == Mode.intensity:
            data, _ = self.get_i_render()
            self.raw_spectra = None
            self.raw_data = data
        else:
            data, dfreqs, ny0, _ = self.get_il_render()
            self.raw_spectra = (noisify_spectra(data, self.noise_snr), dfreqs, ny0)
            self.raw_data = None
            self.spect_analyzer.set_data(*self.raw_spectra)

        if updatedisplay:
            self.update_display()

    def update_display(self):
        '''
        Rejiggers display objects if no rerendering is required
        '''
        if self.rendermode == Mode.intensity:
            self.unittxt.text = 'Intensity: erg s[sup]-1[/sup] cm[sup]-2[/sup] sr[sup]-1[/sup]'
        elif self.rendermode == Mode.doppler_shift:
            self.raw_data = self.spect_analyzer.quad_regc()
            self.raw_data *= -CC / 1e3 / self.spect_analyzer.center_freq  # convert to km/s
            self.unittxt.text = 'Doppler shift: km/s'
        elif self.rendermode == Mode.width:
            self.raw_data = self.spect_analyzer.fwhm()
            self.raw_data *= CC / 1e3 / self.spect_analyzer.center_freq  # convert to km/s
            self.unittxt.text = 'Line width at half max: km/s'
        elif self.rendermode == Mode.asym:
            self.raw_data = self.spect_analyzer.split_integral_vel(self.asym_sep, self.asym_width, 2)
            self.raw_data = self.raw_data[..., 1] - self.raw_data[..., 0]
            self.unittxt.text = 'Intensity: erg s[sup]-1[/sup] cm[sup]-2[/sup] sr[sup]-1[/sup]'

        bounds = (np.nanmin(self.raw_data), np.nanmax(self.raw_data))
        if bounds[0] >= 0:  # use symlog-based approach starting from 0
            SCALAR_MAP.set_norm(colors.SymLogNorm(bounds[1] * 0.1 ** self.log_offset))
            SCALAR_MAP.set_cmap(cm.bone)
            SCALAR_MAP.set_clim(0, bounds[1])
        else:  # use symlog approach
            b2 = max((abs(bounds[0]), bounds[1]))
            SCALAR_MAP.set_cmap(SYM_MAP)
            SCALAR_MAP.set_norm(colors.SymLogNorm(b2 * 0.1 ** self.log_offset))
            SCALAR_MAP.set_clim(-b2, b2)

        data = SCALAR_MAP.to_rgba(self.raw_data) * 255

        # update display buffer
        self.buffer_array[:data.shape[0], :data.shape[1]] = data
        self.texture.blit_buffer(self.buffer_array.tostring(), colorfmt='rgba')

        # colorbar text generation
        self.cbtxt.text = '\n' + '\n'.join(('%.3e' % val for val in
                                            reversed(SCALAR_MAP.norm.inverse(np.linspace(0, 1, self.cbar_num)))))
        self.cbtxt.line_height = self.cbsize[1] / (self.cbar_num - 1) / (self.cbtxt.font_size + 3)
        self.cbtxt.center_y = 50 + self.cbsize[1] / 2 + self.cbtxt.font_size / 2

        # colorbar generation
        SCALAR_MAP.set_norm(colors.NoNorm())
        cb_raw = np.empty(self.cbsize[::-1])
        cb_raw[:] = np.expand_dims(np.linspace(0, 1, self.cbsize[1]), 1)
        cb_data = SCALAR_MAP.to_rgba(cb_raw) * 255
        self.cbtex.blit_buffer(cb_data.astype('uint8').tostring(), size=self.cbsize, colorfmt='rgba')

    def save_image(self):
        output_name = tkFileDialog.asksaveasfilename(title='Image Array Filename')
        if not output_name:
            return
        self.rend.save_irender(output_name, self.raw_data)

    def save_spectra(self):
        output_name = tkFileDialog.asksaveasfilename(title='Spectra Array Filename')
        if not output_name:
            return
        if self.raw_spectra is None:
            self.rend.distance_per_pixel = self.distance_per_pixel
            self.rend.stepsize = self.stepsize
            self.rend.y_pixel_offset = self.y_pixel_offset
            self.rend.x_pixel_offset = self.x_pixel_offset
            data, dfreqs, ny0, _ = self.get_il_render()
            self.raw_spectra = (noisify_spectra(data, self.noise_snr), dfreqs, ny0)
        self.rend.save_ilrender(output_name, self.raw_spectra)

    def save_range(self):
        self._saverangedialog.rend_choice = None
        self._saverangedialog.open()

    def _renderrangefromdialog(self, srd, choice):
        snap_bounds = sorted((int(srd.slider_snapmin.value), int(srd.slider_snapmax.value)))
        snap_skip = int(srd.slider_snapskip.value)
        snap_range = range(snap_bounds[0], snap_bounds[1], snap_skip)
        channellist = self.channellist
        channel_ids = [channellist.index(lib.text) for lib in srd.channelselect.adapter.selection]
        save_loc = srd.savefilename.text
        save_loct = Template(save_loc)
        if len(snap_range) > 1 and '${num}' not in save_loc or len(channel_ids) > 1 and '${chan}' not in save_loc:
            ed = ErrorDialog()
            ed.errortext = 'Missing "${num}" or "${chan}" in file descriptor'
            ed.open()
            return

        orig_mode, orig_snap, orig_channel = self.rendermode, self.snap, self.channel

        # if spectra is chosen, choose mode that caches spectra
        if choice == 'il':
            self.rendermode = Mode.doppler_shift

        for snap in snap_range:
            self.snap = snap
            for channel_id in channel_ids:
                self.channel = channel_id
                save_file = save_loct.substitute(num=str(snap), chan=channellist[channel_id])

                self.update(False)

                if choice == 'il':
                    self.rend.save_ilrender(save_file, self.raw_spectra)
                elif choice == 'i':
                    # process spectra into raw data if necessary
                    if self.rendermode == Mode.doppler_shift:
                        self.raw_data = self.spect_analyzer.quad_regc()
                        self.raw_data *= -CC / 1e3 / self.spect_analyzer.center_freq  # convert to km/s
                    elif self.rendermode == Mode.width:
                        self.raw_data = self.spect_analyzer.fwhm()
                        self.raw_data *= CC / 1e3 / self.spect_analyzer.center_freq  # convert to km/s
                    elif self.rendermode == Mode.asym:
                        self.raw_data = self.spect_analyzer.split_integral_vel(self.asym_sep, self.asym_width, 2)
                        self.raw_data = self.raw_data[..., 1] - self.raw_data[..., 0]
                    self.rend.save_irender(save_file, self.raw_data)

        srd.dismiss()
        self.mode, self.snap, self.channel = orig_mode, orig_snap, orig_channel
        self.raw_data = self.raw_spectra = None
        self.update()

    def get_i_render(self):
        return self.rend.i_render(self.channel, self.azimuth, -self.altitude,
                                  opacity=self.rend_opacity, verbose=False)

    def get_il_render(self):
        return self.rend.il_render(self.channel, self.azimuth, -self.altitude, nlamb=self.nlamb,
                                   opacity=self.rend_opacity, verbose=False)