示例#1
0
class VariableDescriptions(Widget):
    
    def tab_info(self):
        self.pbuilder = self.parent.parent
        self.description_tab = TabbedPanel()
        particle_info = TabbedPanelHeader(text = 'Particle')
        behavior_info = TabbedPanelHeader(text = 'Behavior')
        color_info = TabbedPanelHeader(text = 'Color')
        particle_info.font_size = self.size[0]*.28
        behavior_info.font_size = self.size[0]*.28
        color_info.font_size = self.size[0]*.28
        particle_info.content = RstDocument(source="param_descriptions/ParticleTab.rst")
        behavior_info.content = RstDocument(source="param_descriptions/BehaviorTab.rst")
        color_info.content = RstDocument(source="param_descriptions/ColorTab.rst")
        particle_info.scroll_distance = 2
        particle_info.scroll_timeout = 500
        behavior_info.scroll_distance = 2
        behavior_info.scroll_timeout = 500
        color_info.scroll_distance = 2
        color_info.scroll_timeout = 500
        self.description_tab.default_tab = particle_info
        self.description_tab.tab_width = self.size[0]*4.36
        self.description_tab.tab_height = self.size[1]*.7
        self.description_tab.add_widget(particle_info)
        self.description_tab.add_widget(behavior_info)
        self.description_tab.add_widget(color_info)
        self.description_popup = Popup(title="Variable Descriptions", content = self.description_tab, size_hint = (.8,.8), on_open=self._popup_opened, on_dismiss=self._popup_dismissed)
        self.description_popup.open()

    def _popup_opened(self, instance):
        self.pbuilder.demo_particle.pause()

    def _popup_dismissed(self, instance):
        self.pbuilder.demo_particle.resume()
示例#2
0
    def __init__(self, **kwargs):
        super(RootWidget, self).__init__(**kwargs)

        panel = TabbedPanel(do_default_tab=False,
                            tab_width=300,
                            tab_height=100)

        pc_tab = CharcterTab("PCs")
        pc_tab.load_characters(Character)

        npc_tab = CharcterTab("NPCs")
        npc_tab.load_characters(NPC)

        monster_tab = MonsterTab("Monsters")

        sounds_tab = SoundsTab("Sounds")
        encounters_tab = EncountersTab()

        panel.add_widget(pc_tab)
        panel.add_widget(npc_tab)
        panel.add_widget(sounds_tab)
        panel.add_widget(monster_tab)
        panel.add_widget(encounters_tab)

        self.add_widget(panel)
示例#3
0
      def build(self):
          tb_panel= TabbedPanel()
          tb_panel.background_image ="fundal2.jpg"
          tb_panel.default_tab_text =  "tab-ul default"
          tb_panel.default_tab_content = Image(source='infoacademy3.gif',pos=(200, 100), size=(200, 200))

          th_text_head = TabbedPanelHeader(text='Text tab')
          th_text_head.content= Label(text='Infoacademy', font_size = 40)
 
          th_img_head= TabbedPanelHeader(text='Image tab')
          th_img_head.content= Image(source='infoacademy4.gif',pos=(400, 100), size=(400, 400))
 
          th_btn_head = TabbedPanelHeader(text='Button tab')
          layout= GridLayout(cols=1)
          eticheta=Label(text='tab-ul cu buton', font_size = 40)
          buton=Button(text='Acesta este un buton',font_size=20)
          layout.add_widget(eticheta)
          layout.add_widget(buton)
          th_btn_head.content= layout
          th_btn_head.content.padding = 200
          
 
          tb_panel.add_widget(th_text_head)
          tb_panel.add_widget(th_img_head)
          tb_panel.add_widget(th_btn_head)         
 
          return tb_panel
示例#4
0
class CelticKnotwork(App):
    '''Main tabbed interface, each tab contains its own instance of CelticKnotwork2'''
    def build(self):
        ##Instance Variables
        self.showDots = True
        self.showGrid = True
        self.showBreaklines = True
        self.showSkeleton = True
        self.showKnot = True
        self.knotX = 4
        self.knotY = 4
        self.knotWidth = 8
        self.knotWidthView = 8
        self.gridUnits = 50
        self.gridUnitsView = 50
        self.offsetX = 150
        self.offsetY = 50
        self.totTabs = 1
        self.tabNo = 1
        
        
        ##Main Layout
        self.layout_main = AnchorLayout(anchor_x = "left", anchor_y="top")
        self.layout_tabs= FloatLayout(size=(Window.width, Window.height), size_hint=(0.1, 0.08))

        
        ##Top Tab Bar - allowing multiple knots
        self.tp = TabbedPanel()
        self.tp.default_tab_text = "Knot 1"
        self.layout_main.add_widget(self.tp)
        self.addTab = TabbedPanelHeader(text='+')
        self.addTab.bind(on_release = self.onPressAddTab)
        self.addTab = Button(text='+', pos =(Window.width*.9,Window.height*.92))
        self.addTab.bind(on_press = self.onPressAddTab)
        self.tp.default_tab_content = CelticKnotwork2().build() #get tab content from CelticKnotwork2
        self.layout_tabs.add_widget(self.addTab)
        self.layout_main.add_widget(self.layout_tabs)

        Window.bind(on_resize=self.on_resize)

        
        
        return self.layout_main
    def onPressAddTab(self, instance):
        '''Add a tab when "+" button pressed'''
        self.totTabs += 1
        self.tabNo = self.totTabs
        self.th = TabbedPanelHeader(text='Knot '+str(self.totTabs))
        self.th.content = CelticKnotwork2().build()
        self.tp.add_widget(self.th)
        
        self.tp.switch_to(self.th)
    def on_resize(self, window, height, somethingesle):
        '''Handles window resize'''
        self.layout_main.remove_widget(self.layout_tabs)
        self.layout_tabs= FloatLayout(size=(Window.width, Window.height), size_hint=(0.1, 0.05))
        self.addTab = Button(text='+', pos =(Window.width*.9,Window.height*.95))
        self.addTab.bind(on_press = self.onPressAddTab)
        self.layout_tabs.add_widget(self.addTab)
        self.layout_main.add_widget(self.layout_tabs)
示例#5
0
文件: stats.py 项目: phiotr/DysDroid
class ScoresPopupContent(BoxLayout):
    """Element `content` dla obiektu Popup"""
    
    close_bt = ObjectProperty(None)
    tab_area = ObjectProperty(None)

    def __init__(self, table_name, **kwargs):

        Builder.load_file("kv/stats.kv")

        BoxLayout.__init__(self, **kwargs)
        self.orientation = "vertical"

        # Zbudowanie obszaru zakładek
        self.level1 = LevelTab(nr=1, table=table_name)
        self.level2 = LevelTab(nr=2, table=table_name)
        self.level3 = LevelTab(nr=3, table=table_name)

        self.tab_area = TabbedPanel(default_tab=self.level1, do_default_tab=False, tab_pos="top_mid", tab_height=50, tab_width=Window.width * 0.8 // 3 - 10)

        self.tab_area.add_widget(self.level1)
        self.tab_area.add_widget(self.level2)
        self.tab_area.add_widget(self.level3)

        self.close_bt = Button(text="Zamknij", size_hint_y=0.1)

        self.add_widget(self.tab_area)
        self.add_widget(self.close_bt)
示例#6
0
class VariableDescriptions(Widget):

    def tab_info(self):
        self.pbuilder = self.parent.parent
        self.description_tab = TabbedPanel()
        particle_info = TabbedPanelHeader(text = 'Particle')
        behavior_info = TabbedPanelHeader(text = 'Behavior')
        color_info = TabbedPanelHeader(text = 'Color')
        particle_info.font_size = self.size[0]*.28
        behavior_info.font_size = self.size[0]*.28
        color_info.font_size = self.size[0]*.28
        particle_info.content = RstDocument(source="param_descriptions/ParticleTab.rst")
        behavior_info.content = RstDocument(source="param_descriptions/BehaviorTab.rst")
        color_info.content = RstDocument(source="param_descriptions/ColorTab.rst")
        particle_info.scroll_distance = 2
        particle_info.scroll_timeout = 500
        behavior_info.scroll_distance = 2
        behavior_info.scroll_timeout = 500
        color_info.scroll_distance = 2
        color_info.scroll_timeout = 500
        self.description_tab.default_tab = particle_info
        self.description_tab.tab_width = self.size[0]*4.36
        self.description_tab.tab_height = self.size[1]*.7
        self.description_tab.add_widget(particle_info)
        self.description_tab.add_widget(behavior_info)
        self.description_tab.add_widget(color_info)
        self.description_popup = Popup(title="Variable Descriptions", content = self.description_tab, size_hint = (.8,.8), on_open=self._popup_opened, on_dismiss=self._popup_dismissed)
        self.description_popup.open()

    def _popup_opened(self, instance):
        self.pbuilder.demo_particle.pause()

    def _popup_dismissed(self, instance):
        self.pbuilder.demo_particle.resume()
示例#7
0
def main_base_menu(build_place):
    scatter = ScatterLayout()
    menu = building.MenuLayout()
    inside_menu = building.InsideMenuLayout()
    main_box = BoxLayout(orientation='horizontal')
    left_box = BoxLayout(orientation='vertical', size_hint_x=.35)
    right_box = BoxLayout(size_hint_x=.65)
    icon_bottom_box = BoxLayout(size_hint=(.9, .8))
    icon_layout = BoxLayout(size_hint_y=.4)  # pos_hint=({'top': 1})

    # Вывод производства ресурсов
    stat_res = res_generation('main_base')

    # Добавление вкладок Здания
    tb = TabbedPanel(do_default_tab=False, tab_width=130)
    base_e = TabbedPanelItem(text='Энергия')
    base_e.content = base_energy()
    base_f = TabbedPanelItem(text='Пища')
    base_f.content = base_food()
    tb.add_widget(base_e)
    tb.add_widget(base_f)

    icon_bottom_box.add_widget(stat_res)
    icon_layout.add_widget(Image(source='data/images/buildings/main-base.png'))
    left_box.add_widget(icon_layout)
    left_box.add_widget(icon_bottom_box)
    right_box.add_widget(tb)
    main_box.add_widget(left_box)
    main_box.add_widget(right_box)
    inside_menu.add_widget(main_box)
    close_b = building.CloseMenuButton(build_place, scatter)
    menu.add_widget(inside_menu)
    menu.add_widget(close_b)
    scatter.add_widget(menu)
    return scatter
示例#8
0
文件: main.py 项目: jcc242/gastracker
    def __init__(self, **kwargs):
        super(DataScreen, self).__init__(**kwargs)
        tab = TabbedPanel()

        self.th_chart_head = TabbedPanelHeader(text='Chart')
        tab.default_tab_text = 'Table'

        self.list_adapter = ListAdapter(data=[],
                                        args_converter=self.argsc,
                                        cls=TableItemView,
                                        selection_mode='single',
                                        allow_empty_selection=True)
        self.list_adapter.bind(on_selection_change=self.selection_changed)
        
        list_view = ListView(adapter=self.list_adapter)

        self.th_chart_head.content = GraphView()
        tab.default_tab_content = TableView(list_view)

        tab.add_widget(self.th_chart_head)

        button = Button(text='Add',size_hint_y=None,height=dp(50))
        button.bind(on_release=self.addItem)
        
        layout = BoxLayout(orientation='vertical')
        layout.add_widget(tab)
        layout.add_widget(button)
        self.add_widget(layout)
示例#9
0
    def create_tabbed_menu(self):
        tabbed_menu = TabbedPanel(size_hint=(None, 1),
                                  size=(200, 0),
                                  pos_hint={
                                      'left': 1,
                                      'top': 1
                                  },
                                  do_default_tab=False,
                                  border=(0, 0, 0, 0),
                                  tab_pos='top_mid',
                                  tab_width=200)
        # Color panel
        with tabbed_menu.canvas.before:
            tabbed_menu.rect = Image(source=BKGD_DCHRC,
                                     allow_stretch=True,
                                     keep_ratio=False,
                                     size_hint=(1, 1))
        tabbed_menu.bind(pos=self.update_rect, size=self.update_rect)

        tabbed_menu.preset_tab = HoverTab(text='Presets',
                                          background_normal=TAB_DCHRC[0],
                                          background_down=TAB_DCHRC[1])
        tabbed_menu.add_widget(tabbed_menu.preset_tab)
        self.panel_layout.add_widget(tabbed_menu)
        return tabbed_menu
示例#10
0
class CharcterTab(TabbedPanelItem):
    def __init__(self, text, font_size=FONT_MEDIUM, *args, **kwargs):
        super(CharcterTab, self).__init__(font_size=font_size, *args, **kwargs)

        self.text = text

        # Non player characters
        content = BoxLayout(orientation='vertical')
        self.add_widget(content)

        # Character sheets
        self.character_sheets = TabbedPanel(do_default_tab=False,
                                            tab_width=200,
                                            tab_height=100)

        content.add_widget(self.character_sheets)
        # self.character_sheets.add_widget(CharacterActionsTab(self))

    def load_characters(self, cls):
        for character in session.query(cls).all():
            self.add_character(character)

    def add_character(self, character):
        character = session.merge(character)
        session.commit()
        self.character_sheets.add_widget(CharacterSheet(character))

    def new_character(self, name):
        self.add_character(Character(name=name))
示例#11
0
    def button_options(self):
        print("options pressed")
        app = App.get_running_app()
        cont = GridLayout(cols=1)
        # retrieve audio outputs / soundcards from audioengine class
        out_list = app.root.ae.get_outputs()
        print(out_list)

        # combine out_list, add to output selector
        for x, y in zip(*out_list):
            # intentional error to remember where left off
            b = Button(id="{}".format(y), text="{} {}".format(x, y))
            b.bind(on_press=self.audio_opts_button_callback)
            cont.add_widget(b)
        for x in self.children:
            print(x)

        tp = TabbedPanel(do_default_tab=False)

        # audio tab
        th_audio = TabbedPanelItem(text="Audio")
        th_audio.content = GridLayout()
        th_audio.add_widget(cont)

        # files tab
        th_files = TabbedPanelItem(text="Files")
        th_files.add_widget(Button(text="files tab content"))
        tp.add_widget(th_audio)
        tp.add_widget(th_files)

        popup = Popup(title='Options',
                      content=tp,
                      size_hint=(None, None),
                      size=(800, 800))
        popup.open()
    def __init__(self, **kwargs):
        super(ButtonApp, self).__init__(**kwargs)

        tmp_btn = HoverButton(text='BUTTON 1',
                              size_hint=(None, None),
                              size=(200, 60),
                              color=(0, 1, 0, 1),
                              font_size=dp(20),
                              on_press=self.do_sum)
        tmp_btn2 = HoverButton(text='BUTTON 2',
                               size_hint=(None, None),
                               pos=(50, 100),
                               size=(200, 60),
                               color=(0, 1, 0, 1),
                               font_size=dp(30),
                               on_press=self.do_sum_2)

        self.fl = FloatLayout()

        self.bl = BoxLayout()
        self.bl.add_widget(tmp_btn)
        self.bl.add_widget(tmp_btn2)

        tabs = TabbedPanel()
        tabs.do_default_tab = False
        tab1 = HoverTabs(text='TAB 1')
        tab3 = HoverTabs(text='TAB 2', on_press=self.tab2_func)
        tab4 = HoverTabs(text='TAB 3')

        tab3.add_widget(self.bl)
        tabs.add_widget(tab1)
        tabs.add_widget(tab3)
        tabs.add_widget(tab4)
        tabs.default_tab = tab1
        self.fl.add_widget(tabs)
示例#13
0
 def build(self):
     self.icon = 'diceSmall.png'
     mainPanel = TabbedPanel()
     mainPanel.default_tab_text = 'Dice Roll'
     
     mainPanel.add_widget(self.tabProbabilityTesting())
     mainPanel.default_tab_content = self.tabDiceRoll()
     return mainPanel
示例#14
0
    def build(self):
        tab_panel = TabbedPanel()
        tab_panel.do_default_tab = False
        tab_panel.add_widget(self.make_server_tab())
        tab_panel.add_widget(self.make_client_tab())
        tab_panel.set_def_tab(tab_panel.tab_list[1])

        return tab_panel
示例#15
0
class CharacterRulesScreen(Screen):
    """Screen with TabbedPanel for all the character-rulebooks"""
    engine = ObjectProperty()
    character = ObjectProperty()
    toggle = ObjectProperty()

    def _get_rulebook(self, rb):
        return {
            'character': self.character.rulebook,
            'avatar': self.character.avatar.rulebook,
            'character_thing': self.character.thing.rulebook,
            'character_place': self.character.place.rulebook,
            'character_portal': self.character.portal.rulebook
        }[rb]

    def finalize(self, *args):
        assert not hasattr(self, '_finalized')
        if not (
            self.engine and self.toggle and self.character
        ):
            Clock.schedule_once(self.finalize, 0)
            return
        self._tabs = TabbedPanel(do_default_tab=False)
        for rb, txt in (
                ('character', 'character'),
                ('avatar', 'avatar'),
                ('character_thing', 'thing'),
                ('character_place', 'place'),
                ('character_portal', 'portal')
        ):
            tab = TabbedPanelItem(text=txt)
            setattr(self, '_{}_tab'.format(rb), tab)
            box = RulesBox(
                engine=self.engine,
                rulebook=self._get_rulebook(rb),
                entity=self.character,
                toggle=self.toggle
            )
            tab.add_widget(box)
            self._tabs.add_widget(tab)
        self.add_widget(self._tabs)
        self._finalized = True

    def on_character(self, *args):
        if not hasattr(self, '_finalized'):
            self.finalize()
            return
        for rb in (
            'character', 'avatar', 'character_thing',
            'character_place', 'character_portal'
        ):
            tab = getattr(self, '_{}_tab'.format(rb))
            tab.content.entity = self.character
            tab.content.rulebook = self._get_rulebook(rb)
示例#16
0
    def build(self):
        root = TabbedPanel(do_default_tab=False)
        tab32 = TabbedPanelHeader(text="Binary 32")
        tab64 = TabbedPanelHeader(text="Binary 64")
        tab32.content = IEEE754Converter(number_of_bits=32)
        tab64.content = IEEE754Converter(number_of_bits=64) 
       
        root.add_widget(tab32)
        root.add_widget(tab64)

        return root
示例#17
0
    def build(self):
        self.title = 'Converter'
        tabs = TabbedPanel(do_default_tab=False)
        th = TabbedPanelHeader(text='Audio')
        th.content = self.GetAudioConversionUI()
        th1 = TabbedPanelHeader(text='Video')
        th1.content = self.GetVideoConversionUI()

        tabs.add_widget(th)
        tabs.add_widget(th1)

        return tabs
示例#18
0
def generate_GUI(menus):
    app_gui = TabbedPanel()
    app_gui.clear_tabs()
    app_gui.orientation = "vertical"
    app_gui.do_default_tab = False
    app_gui.tab_width = 150

    for menu_key, sub_menu in menus.items():
        main_menu = TabbedPanelHeader(text=menu_key)
        scroll_pane = ScrollView()
        scroll_pane.scroll_type = ['bars', 'content']
        scroll_pane.bar_pos_y = 'left'
        scroll_pane.bar_width = 6
        scroll_pane.do_scroll_y = True
        scroll_pane.do_scroll_x = False
        scroll_pane.scroll_y = 1

        menu_grid = GridLayout(cols=1, spacing=2, size_hint_y=None)
        menu_grid.orientation = "vertical"
        menu_grid.padding = 10
        menu_grid.row_default_height = 1
        menu_height = 0

        print(">>>" + menu_key)
        for sub_menu_key, items in sub_menu.items():
            menu_grid.add_widget(
                Label(text="     " + sub_menu_key, size_hint=(None, None), font_size=14, halign="left",
                      valign="middle"))
            print("\t" + sub_menu_key)
            for option in items:

                if "Name" in option:
                    print("\t\t" + option["Name"])
                    btn = Button(text=option["Name"], size_hint=(0.1, None), background_color=(0.2, 1, 1, 0.8))
                    btn.bind(on_press=lambda x: webbrowser.open(option["URL"]))
                else:
                    print("\t\t" + "<EMPTY>")
                    btn = Button(text="<EMPTY>", size_hint=(0.1, None), background_color=(0.2, 1, 1, 0.8))
                    btn.bind(on_press=lambda x: webbrowser.open(option["URL"]))
                btn.width = 250
                btn.height = 50
                menu_grid.add_widget(btn)
                menu_height += 80
            menu_height += 51
        menu_grid.height = menu_height
        scroll_pane.add_widget(menu_grid)
        main_menu.content = scroll_pane
        main_menu.orientation = "vertical"

        # Adding headers to main layout
        app_gui.add_widget(main_menu)
    return app_gui
示例#19
0
class HomeScreen(BoxLayout):
    """Home screen will have tabs at top and status at bottom"""
    def __init__(self, **kwargs):
        """Initialize the class"""
        super(HomeScreen, self).__init__(**kwargs)
        self.orientation = 'vertical'

        self.status_layout = StatusLayout(size_hint=(1, .1))
        self.tabs = TabbedPanel()
        app = App.get_running_app()
        app.tabs = self.tabs

        settings_header = TabbedPanelHeader(text='Assistant\nSettings')
        settings_header.content = AppSettings(status_layout=self.status_layout)
        self.tabs.add_widget(settings_header)
        self.tabs.default_tab = settings_header

        tab_settings_header = TabbedPanelHeader(text='Tablet\nSettings')
        tab_settings_header.content = TabletSettings(
            status_layout=self.status_layout)
        self.tabs.add_widget(tab_settings_header)

        templates_header = TabbedPanelHeader(text='Templates')
        templates_header.content = Templates()
        self.tabs.add_widget(templates_header)

        splash_header = TabbedPanelHeader(text='Splash\nScreens')
        splash_header.content = Splash()
        self.tabs.add_widget(splash_header)

        my_files_header = TabbedPanelHeader(text='My Files')
        my_files_header.content = MyFiles()
        #        self.tabs.add_widget(my_files_header)

        friendly_files_header = TabbedPanelHeader(text='My Files')
        friendly_files_header.content = FriendlyMyFiles()
        self.tabs.add_widget(friendly_files_header)

        self.app_controller = AppController(
            settings_header.content.config_layout,
            tab_settings_header.content.config_layout,
            self.status_layout,
            my_files_header.content,
            friendly_files_header.content,
        )

        self.add_widget(self.tabs)

        self.buttons = ButtonRowLayout(self.app_controller, size_hint=(1, .1))
        self.add_widget(self.buttons)

        self.add_widget(self.status_layout)
示例#20
0
文件: main.py 项目: stdgn/kivy-tr
	def build(self):
	    sekmeli_panel = TabbedPanel()
	    
	    sekmeli_panel.default_tab.text="İlk Sekme"
	    
	    sekmeli_panel.default_tab.content=Label(text="Sekmeli Panel'in İlk sayfası")
	    
	    for i, isim in enumerate(('Dilek', 'Fatih', 'Melike')):
	        sekme=TabbedPanelHeader(text='Sekme %d' % (i+1))
	        sekme.content=Label(text="Bu sekmenin sahibi: %s" % isim)
	        sekmeli_panel.add_widget(sekme)
	    
	    return sekmeli_panel
示例#21
0
    def __init__(self, monster, font_size=FONT_MEDIUM, *args, **kwargs):
        super(MonsterSheet, self).__init__(font_size=font_size,
                                           *args,
                                           **kwargs)

        self.monster = monster
        self.text = monster.name

        details = TabbedPanel(do_default_tab=False,
                              tab_width=350,
                              tab_height=80)

        details.add_widget(StatTab(monster))

        self.add_widget(details)
示例#22
0
 def __init__(self, screenmanager, **kwargs):
     super(GraphScreen, self).__init__(**kwargs)
     #Set screenmanager
     sm = screenmanager
     #Set master layout
     layout = BoxLayout(spacing=10)
     #Create tabpanel
     tabs = TabbedPanel()
     #Add tabs
     speedTab = TabbedPanelItem(text='Speed')
     speedTab.content = Label(text='Speed')
     backTab = TabbedPanelItem(text='Back')
     tabs.add_widget(speedTab)
     tabs.add_widget(backTab)
     layout.add_widget(tabs)
     self.add_widget(layout)
示例#23
0
    def build(self):
        self.availablePorts = listSerialPorts()
        if len(self.availablePorts) == 0:
            self.availablePorts.append("----")
        
        tabbedPannel = TabbedPanel(do_default_tab=False)
        
        # Connection Tab
        self.connectionTab = TabbedPanelItem(text="Connection")
        
        self.layout1 = BoxLayout(orientation='vertical', spacing=10, padding=(200, 200))
        self.connectionTab.add_widget(self.layout1)
        
        self.lblSerialSettings = Label(text="Connection settings")
        self.layout1.add_widget(self.lblSerialSettings)
        
        self.dlBaudrate = Spinner(values = ["57600", "115200", "230400", "460800", "921600"],
                                  text = "115200")
        self.layout1.add_widget(self.dlBaudrate)
        
        self.dlPort = Spinner(values = self.availablePorts,
                              text = self.availablePorts[0])
        self.layout1.add_widget(self.dlPort)
        
        self.btnConnect = Switch()
        self.btnConnect.bind(active = self.connect)
        
        self.layout1.add_widget(self.btnConnect)
        
        # Graph tab
        self.graphTab = TabbedPanelItem(text = "Graph")
#         self.layout2 = BoxLayout(orientation='vertical', spacing=10, padding=(200, 200))
#         self.graphTab.add_widget(self.layout2)
        
        graph = Graph(xlabel='X', ylabel='Y', x_ticks_minor=5,
        x_ticks_major=25, y_ticks_major=1,
        y_grid_label=True, x_grid_label=True, padding=5,
        x_grid=True, y_grid=True, xmin=-0, xmax=100, ymin=-1, ymax=1)
        plot = MeshLinePlot(color=[1, 1, 0, 1])
        plot.points = [(x, sin(x / 10.)) for x in range(0, 101)]
        graph.add_plot(plot)
        self.graphTab.add_widget(graph)
        
        
        tabbedPannel.add_widget(self.connectionTab)
        tabbedPannel.add_widget(self.graphTab)
        return tabbedPannel
示例#24
0
class AfWidget(GridLayout):
    def __init__(self, **kwargs):
        self.p = PyAudio()
        self.rows = 1
        self.cols = 1
        GridLayout.__init__(self, **kwargs)

        self.mainPanel = TabbedPanel()
        print "WIDTH", self.width
        self.mainPanel.default_tab_text = "AF Output Devices"

        self.add_widget(self.mainPanel)
        self.inputPanel = TabbedPanelHeader(text="AF Input Devices")
        self.inputPanel.content = AfInputManager()
        self.mainPanel.add_widget(self.inputPanel)
        self.mainPanel.tab_width = 200
        #topLayout = BoxLayout(orientation = "vertical")

        #topLayout.add_widget(Label(text="Input device", ))
        #self.inputDevs = Spinner(text = "Select input")
        #topLayout.add_widget(self.inputDevs)

        #topLayout.add_widget(Label(text="Output device", ))
        #self.outputDevs = Spinner(text = "Select output")
        #topLayout.add_widget(self.outputDevs)

        #self.updateSoundDevices()
        #self.add_widget(topLayout)

    def updateSoundDevices(self):
        api_cnt = self.p.get_host_api_count()
        dev_cnt = self.p.get_device_count()
        inputs = []
        outputs = []
        print "Number of API's", api_cnt, "Number of sound devices", dev_cnt
        for i in range(dev_cnt):
            d = self.p.get_device_info_by_index(i)
            if d['maxInputChannels'] > 0:
                inputs.append(d['name'])
            if d['maxOutputChannels'] > 0:
                outputs.append(d['name'])

        print "inputs", inputs
        print "outputs", outputs
        self.inputDevs.values = inputs
        self.outputDevs.values = outputs
示例#25
0
class CharacterRulesScreen(Screen):
    """Screen with TabbedPanel for all the character-rulebooks"""
    engine = ObjectProperty()
    character = ObjectProperty()
    toggle = ObjectProperty()

    def _get_rulebook(self, rb):
        return {
            'character': self.character.rulebook,
            'avatar': self.character.avatar.rulebook,
            'character_thing': self.character.thing.rulebook,
            'character_place': self.character.place.rulebook,
            'character_portal': self.character.portal.rulebook
        }[rb]

    def finalize(self, *args):
        assert not hasattr(self, '_finalized')
        if not (self.engine and self.toggle and self.character):
            Clock.schedule_once(self.finalize, 0)
            return
        self._tabs = TabbedPanel(do_default_tab=False)
        for rb, txt in (('character', 'character'), ('avatar', 'avatar'),
                        ('character_thing',
                         'thing'), ('character_place',
                                    'place'), ('character_portal', 'portal')):
            tab = TabbedPanelItem(text=txt)
            setattr(self, '_{}_tab'.format(rb), tab)
            box = RulesBox(engine=self.engine,
                           rulebook=self._get_rulebook(rb),
                           entity=self.character,
                           toggle=self.toggle)
            tab.add_widget(box)
            self._tabs.add_widget(tab)
        self.add_widget(self._tabs)
        self._finalized = True

    def on_character(self, *args):
        if not hasattr(self, '_finalized'):
            self.finalize()
            return
        for rb in ('character', 'avatar', 'character_thing', 'character_place',
                   'character_portal'):
            tab = getattr(self, '_{}_tab'.format(rb))
            tab.content.entity = self.character
            tab.content.rulebook = self._get_rulebook(rb)
示例#26
0
class MonsterTab(TabbedPanelItem):
    def __init__(self, text, font_size=FONT_MEDIUM, *args, **kwargs):
        super(MonsterTab, self).__init__(font_size=font_size, *args, **kwargs)

        self.text = text

        # Non player monsters
        content = BoxLayout(orientation='vertical')
        self.add_widget(content)

        # Monster sheets
        self.monster_sheets = TabbedPanel(do_default_tab=False,
                                          tab_width=150,
                                          tab_height=100)

        def add_monster(button):
            popup = AddMonsterPopup(self)
            popup.open()

        buttons = BoxLayout(orientation='horizontal', size_hint=(1, .1))

        new_monster = Button(text='+', on_press=add_monster)
        refresh = Button(text='refresh',
                         on_press=lambda x: self.load_monsters())
        buttons.add_widget(new_monster)
        buttons.add_widget(refresh)

        content.add_widget(buttons)
        content.add_widget(self.monster_sheets)
        self.load_monsters()

    def load_monsters(self):
        # existing = {panel.text for panel in self.monster_sheets.}
        monsters = sorted(session.query(MonsterInstance).all(),
                          key=lambda monster: monster.name)
        for monster in monsters:
            self.add_monster(monster)

    def add_monster(self, monster):
        monster = session.merge(monster)
        session.commit()
        self.monster_sheets.add_widget(MonsterSheet(monster))

    def new_monster(self, name):
        self.add_monster(Monster(name=name))
示例#27
0
    def create_sheet(self):
        character_sheet = TabbedPanel(
            tab_pos='top_mid',
            size_hint=(.85,.85),
            pos_hint={'center_x': .5, 'center_y': .5},
            do_default_tab=False)
        general_tab = GeneralTab(
            font_name='src/fonts/Enchanted_Land.otf',
            font_size=24)

        self.panes.append(general_tab)

        attributes_tab = AttributesTab(
            font_name='src/fonts/Enchanted_Land.otf',
            font_size=24)
        self.panes.append(attributes_tab)

        skills_tab = SkillsTab(
            font_name='src/fonts/Enchanted_Land.otf',
            font_size=24)
        self.panes.append(skills_tab)

        weapon_tab = WeaponTab(
            font_name='src/fonts/Enchanted_Land.otf',
            font_size=24)
        self.panes.append(weapon_tab)

        armor_tab = ArmorTab(
            font_name='src/fonts/Enchanted_Land.otf',
            font_size=24)
        self.panes.append(armor_tab)

        spells_tab = self.create_spells()
        self.panes.append(spells_tab)

        character_sheet.add_widget(general_tab)
        character_sheet.add_widget(attributes_tab)
        #NOTE ADD FEATS TO SKILLS
        character_sheet.add_widget(skills_tab)
        character_sheet.add_widget(weapon_tab)
        character_sheet.add_widget(armor_tab)
        character_sheet.add_widget(spells_tab)

        return character_sheet
示例#28
0
    def __init__(self, text, font_size=FONT_MEDIUM, *args, **kwargs):
        super(SoundsTab, self).__init__(font_size=font_size, *args, **kwargs)

        self.text = text

        # Non player characters
        content = BoxLayout(orientation='vertical')
        self.add_widget(content)

        category_tabs = TabbedPanel(do_default_tab=False,
                                    tab_width=200,
                                    tab_height=80)

        categories = {x[0] for x in os.walk(SOUNDS_DIR)} - {SOUNDS_DIR}
        print(categories)
        for category in categories:
            category_tabs.add_widget(SoundCategoryTab(category))

        content.add_widget(category_tabs)
示例#29
0
文件: Cours.py 项目: bubux29/snsm
 def __init__(self, parentscm, nom_cours, **kwargs):
     self.nom_cours = nom_cours
     self.parentscm = parentscm
     super(CoursConsultationEvaluations, self).__init__(**kwargs)
     nb = TabbedPanel(cols=1, spacing=5, padding=5, do_default_tab=False)
     self.add_widget(nb)
     liste_groupes = formation_db.trouver_groupes_par_cours([nom_cours])
     liste_modules = formation_db.trouver_modules_par_cours(
         formation_db.trouver_cours([nom_cours]))
     self.liste_obj_recap = list()
     for gr in liste_groupes:
         ce = ConsultationEvaluationsGroupe(parentscm,
                                            liste_modules,
                                            gr.participants,
                                            text=gr.__str__())
         nb.add_widget(ce)
         self.liste_obj_recap.append(ce)
     retour = TabbedPanelHeader(text='Retour')
     retour.bind(on_release=self.retour)
     nb.add_widget(retour)
      def build(self):
          tb_panel= TabbedPanel()

          #Create text tab          
          th_text_head = TabbedPanelHeader(text='Text tab')
          th_text_head.content= Label(text='This is my text content')

          #Create image tab
          th_img_head= TabbedPanelHeader(text='Image tab')
          th_img_head.content= Image(source='sample.jpg',pos=(400, 100), size=(400, 400))

          #Create button tab
          th_btn_head = TabbedPanelHeader(text='Button tab')
          th_btn_head.content= Button(text='This is my button',font_size=20)

          tb_panel.add_widget(th_text_head)
          tb_panel.add_widget(th_img_head)
          tb_panel.add_widget(th_btn_head)          

          return tb_panel
示例#31
0
    def __init__(self, **kwargs):
        super(TabbedPanelApp, self).__init__(**kwargs)
        self.cols =1
        tb_panel= TabbedPanel()
        
        th_text_head = TabbedPanelHeader(text='Text tab')
        th_text_head.content= Label(text='Un text')
 
        th_img_head= TabbedPanelHeader(text='Image tab')
        th_img_head.content= Image(source='nature4.jpg',pos=(400, 100), size=(400, 400))
 
        th_btn_head = TabbedPanelHeader(text='Button tab')
        th_btn_head.content= Button(text='Acesta este un buton',font_size=20,
                                    size_hint=(0.8, 0.8))
        
        tb_panel.add_widget(th_text_head)
        tb_panel.add_widget(th_img_head)
        tb_panel.add_widget(th_btn_head)         
 
        self.add_widget(tb_panel)
示例#32
0
    def create_sheet(self):
        character_sheet = TabbedPanel(tab_pos='top_mid',
                                      size_hint=(.85, .85),
                                      pos_hint={
                                          'center_x': .5,
                                          'center_y': .5
                                      },
                                      do_default_tab=False)
        general_tab = GeneralTab(font_name='src/fonts/Enchanted_Land.otf',
                                 font_size=24)

        self.panes.append(general_tab)

        attributes_tab = AttributesTab(
            font_name='src/fonts/Enchanted_Land.otf', font_size=24)
        self.panes.append(attributes_tab)

        skills_tab = SkillsTab(font_name='src/fonts/Enchanted_Land.otf',
                               font_size=24)
        self.panes.append(skills_tab)

        weapon_tab = WeaponTab(font_name='src/fonts/Enchanted_Land.otf',
                               font_size=24)
        self.panes.append(weapon_tab)

        armor_tab = ArmorTab(font_name='src/fonts/Enchanted_Land.otf',
                             font_size=24)
        self.panes.append(armor_tab)

        spells_tab = self.create_spells()
        self.panes.append(spells_tab)

        character_sheet.add_widget(general_tab)
        character_sheet.add_widget(attributes_tab)
        #NOTE ADD FEATS TO SKILLS
        character_sheet.add_widget(skills_tab)
        character_sheet.add_widget(weapon_tab)
        character_sheet.add_widget(armor_tab)
        character_sheet.add_widget(spells_tab)

        return character_sheet
示例#33
0
    def build_play_screen(self):
        play_screen = Screen(name='play')
        self.sm.add_widget(play_screen)

        tab_names = self.layout_names
        self.layouts = {}

        tb_panel = TabbedPanel(do_default_tab=False,
                               tab_width=Window.width / len(tab_names))
        play_screen.add_widget(tb_panel)

        for layout_name in self.layout_names:
            layout = BoxLayout(orientation='vertical')
            self.layouts[layout_name] = layout
            self.add_audio_to_layout(layout_name)

            tabitem = TabbedPanelItem(text=layout_name)
            tabitem.add_widget(layout)
            tb_panel.add_widget(tabitem)

        return
示例#34
0
文件: dash.py 项目: x4rMa/Dash
	def build(self):
        # App is built as a tabbed panel with three tabs:
        # Navigation, Status, and Media. These allow quick
        # access to the things you actually want to do in
        # a car without excessive UI navigation.
		tp = TabbedPanel()
		tp.do_default_tab = False
		tp.tab_pos = 'bottom_mid'
		tp.tab_width = Window.width / 3

		nav = TabbedPanelHeader(text='Nav')
		status = TabbedPanelHeader(text='Status')
		media = TabbedPanelHeader(text='Media')
		
		tp.add_widget(nav)
		tp.add_widget(status)
		tp.add_widget(media)

		#nav.content = Label(text = 'Nav system goes here')
		#status.content = Label(text = 'Performance, health, and eco stats go here')
		#media.content = Label(text = 'Media player goes here')

        # Each tab's content is implemented in a tab above.
		nav.content = KVMaps()
		status.content = Performance()
		media.content = MusicPlayer()
		return tp
示例#35
0
    def build(self):
        tb_panel = TabbedPanel(tab_width=Window.size[0] / 4)
        screen_layout = BoxLayout(padding=10,
                                  orientation="horizontal",
                                  size_hint=(.7, 1))
        tb_panel.default_tab_text = 'Login'

        #Create text tab
        th_text_head = TabbedPanelHeader(id='one', text='Screen1')
        th_text_head.content = test1().test()
        #tb_panel.Screen1_tab_content = self.test()

        #Create image tab
        th_img_head = TabbedPanelHeader(text='Screen2')
        th_img_head.content = Image(source='sample.jpg',
                                    pos=(400, 100),
                                    size=(400, 400))

        #Create button tab
        th_btn_head = TabbedPanelHeader(text='Screen3')
        th_btn_head.content = Button(text='This is my button',
                                     font_size=20,
                                     size_hint_x=0.5,
                                     size_hint_y=0.5)

        th_text2_head = TabbedPanelHeader(text='Screen4')
        th_text2_head.content = Label(text='This is my text content')

        tb_panel.add_widget(th_text_head)
        tb_panel.add_widget(th_img_head)
        tb_panel.add_widget(th_btn_head)
        tb_panel.add_widget(th_text2_head)

        return tb_panel
示例#36
0
      def build(self):
          tb_panel= TabbedPanel(tab_width=Window.size[0]/4)
          screen_layout = BoxLayout(padding=10, orientation="horizontal", size_hint=(.7, 1))
          tb_panel.default_tab_text = 'Login'
          
          #Create text tab
          th_text_head = TabbedPanelHeader(id='one',text='Screen1')
          th_text_head.content = test1().test()
          #tb_panel.Screen1_tab_content = self.test()
          
          #Create image tab
          th_img_head= TabbedPanelHeader(text='Screen2')
          th_img_head.content= Image(source='sample.jpg',pos=(400, 100), size=(400, 400))
 
          #Create button tab
          th_btn_head = TabbedPanelHeader(text='Screen3')
          th_btn_head.content= Button(text='This is my button',font_size=20, size_hint_x=0.5, 
                                      size_hint_y=0.5)
 
          th_text2_head = TabbedPanelHeader(text='Screen4')
          th_text2_head.content= Label(text='This is my text content')

          
          tb_panel.add_widget(th_text_head)
          tb_panel.add_widget(th_img_head)
          tb_panel.add_widget(th_btn_head) 
          tb_panel.add_widget(th_text2_head)
            
          return tb_panel
示例#37
0
class TestSet1Window(BoxLayout):
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.tp_main = TabbedPanel()
        ti_pandas = TabbedPanelItem(id="ti_pandas", text = "pandas" )
        ti_list = TabbedPanelItem(id="ti_list", text = "list")
        ti_numpy = TabbedPanelItem(id="ti_numpy", text = "numpy array")

        self.qt_pandas = QzTable(id="qt_pandas")
        self.qt_list = QzTable(id="qt_list")
        self.qt_array = QzTable(id="qt_array")

        self.df_data = pd.read_csv("height_weight.csv")
        self.l_data = list()
        v = 10.0
        for y in range(1,1000,1):
            row = list()
            for x in range(0,50,1):
                v= v+ 10
                row.append(v)
            self.l_data.append(row)

        self.a_data = np.array(self.l_data)
        self.qt_pandas.data = self.df_data
        self.qt_list.data = self.l_data
        self.qt_array.data = self.a_data

        #Layout
        self.add_widget(self.tp_main)
        self.tp_main.add_widget(ti_pandas)
        ti_pandas.add_widget(self.qt_pandas)
        self.tp_main.add_widget(ti_list)
        ti_list.add_widget(self.qt_list)
        self.tp_main.add_widget(ti_numpy)
        ti_numpy.add_widget(self.qt_array)
示例#38
0
    def build(self):
        tp = TabbedPanel(do_default_tab=False)
        overviewTab = TabbedPanelHeader(text='Overview')
        gameTab = TabbedPanelHeader(text='Game')
        imageTab = TabbedPanelHeader(text='Images')
        soundTab = TabbedPanelHeader(text='Sounds')
        tp.add_widget(overviewTab)

        overviewTab.content = overviewContent()

        c = gameContent()
        if c:
            tp.add_widget(gameTab)
            gameTab.content = c

        c = picturesContent()
        if c:
            tp.add_widget(imageTab)
            scroll = ScrollView(size_hint=(1, None),
                                size=(tp.width, Window.height - tp.height),
                                bar_width=10,
                                scroll_type=['bars', 'content'])
            scroll.add_widget(c)
            imageTab.content = scroll

        c = soundsContent()
        if c:
            tp.add_widget(soundTab)
            scroll = ScrollView(size_hint=(1, None),
                                size=(tp.width, Window.height - tp.height),
                                bar_width=10,
                                scroll_type=['bars', 'content'])
            scroll.add_widget(c)
            soundTab.content = scroll

        #layout.bind(size=self._update_rect, pos=self._update_rect)

        #addScreenInfo(tree, screen)
        #addPictures(tree, pictures)
        #addSounds(tree, sounds)
        #addExecutables(tree, executables)

        #root = ScrollView(size_hint=(1, None), size=(Window.width, Window.height), bar_width=10, scroll_type=['bars', 'content'])
        #root.add_widget(tree)

        #gameTab.add_widget(root)

        return tp
示例#39
0
    def __init__(self, **kwargs):
        super(TabbedPanelApp, self).__init__(**kwargs)
        self.cols = 1
        tb_panel = TabbedPanel()

        th_text_head = TabbedPanelHeader(text='Text tab')
        th_text_head.content = Label(text='Un text')

        th_img_head = TabbedPanelHeader(text='Image tab')
        th_img_head.content = Image(source='nature4.jpg',
                                    pos=(400, 100),
                                    size=(400, 400))

        th_btn_head = TabbedPanelHeader(text='Button tab')
        th_btn_head.content = Button(text='Acesta este un buton',
                                     font_size=20,
                                     size_hint=(0.8, 0.8))

        tb_panel.add_widget(th_text_head)
        tb_panel.add_widget(th_img_head)
        tb_panel.add_widget(th_btn_head)

        self.add_widget(tb_panel)
示例#40
0
文件: ui.py 项目: timeofview/pytest
    def build(self):
        height = 800
        width = 1200

        settings_layout = GridLayout(cols=2)

        self.my_controller = Controller()

        self.settings_table = TableSettings(self.my_controller)
        settings_layout.add_widget(self.settings_table.get_table())
        add_button = Button(text='add', size_hint=(.09, .005))
        add_button.bind(on_press=self.add_setting)
        save_and_run = GridLayout(cols=2)
        save_button = Button(text='Save', size_hint=(.09, .005))
        save_button.bind(on_press=self.save_settings)
        run_button = Button(text='Run', size_hint=(.09, .005))
        run_button.bind(on_press=self.run_settings)
        save_and_run.add_widget(save_button)
        save_and_run.add_widget(run_button)
        settings_layout.add_widget(add_button)
        settings_layout.add_widget(save_and_run)
        settings = TabbedPanelItem(text='settings')
        settings.add_widget(settings_layout)
        tp = TabbedPanel()
        tp.add_widget(settings)

        groups_layout = GridLayout()
        groups = TabbedPanelItem(text='groups')
        groups.add_widget(groups_layout)

        tp.add_widget(groups)

        tp.set_def_tab(settings)
        Window.clearcolor = (.43, .43, .43, .01)
        Window.size = (width, height)

        return tp
示例#41
0
        def build(self):
            tp = TabbedPanel(do_default_tab=False)
            tab0 = TabbedPanelItem(text='First Tab')

            box = BoxLayout(orientation='horizontal', padding=5)
            xw0 = XWrapChromium('http://news.ycombinator.com')

            box.add_widget(xw0)

            b = Button(text='Randomize Site')
            b.bind(on_press=lambda inst: xw0.chromote.tabs[0].set_url(
                random.choice(random_sites)))
            box.add_widget(b)
            tab0.add_widget(box)

            tp.add_widget(tab0)

            tab1 = TabbedPanelItem(text='Other Panel')
            new_box = BoxLayout(orientation='vertical', padding=12)
            xw1 = XWrapChromium('http://codewaffle.com/')
            xw2 = XWrapChromium('http://eventual.games')

            b2 = Button(text='Random Sites')

            def randomize_xw12(*args, **kwargs):
                xw1.chromote.tabs[0].set_url(random.choice(random_sites))
                xw2.chromote.tabs[0].set_url(random.choice(random_sites))

            b2.bind(on_press=randomize_xw12)

            new_box.add_widget(xw1)
            new_box.add_widget(b2)
            new_box.add_widget(xw2)
            tab1.add_widget(new_box)
            tp.add_widget(tab1)

            return tp
示例#42
0
class MainGrid(GridLayout):
    def __init__(self, queue, runs_len, **kwargs):
        super(MainGrid, self).__init__(**kwargs)

        self.queue = queue
        self.runs_len = runs_len
        self.cores = []
        self.tabs = []

        self.cols = 1

        self.tabbedPanel = TabbedPanel()
        self.tabbedPanel.do_default_tab = False
        self.add_widget(self.tabbedPanel)

        Clock.schedule_interval(self.update_info, 0.1)

    def update_info(self, dt):

        if not self.queue.empty():
            cores = [tab.process for tab in self.tabs]
            element = self.queue.get()
            process, model = element["model"]

            if process not in cores:
                new_tab = TabWithInfo(process, self.runs_len)
                new_tab.text = f"Process {len(cores) + 1}"

                self.tabs.append(new_tab)
                self.tabbedPanel.add_widget(new_tab)
                self.tabbedPanel.switch_to(new_tab)

            current_tab = list(
                filter(lambda x: x.process == process, self.tabs))[0]

            current_tab.updateTab(element)
示例#43
0
    def build(self):

        btn_animate = Button(
            text='animate', on_press=self.animate, size_hint=(0.4, 0.2))

        set_T = Slider(min=10, max=20, value=12)
        set_T.bind(value=self.set_T)

        root = TabbedPanel(do_default_tab=False)

        # cracking panel
        cracking_panel = TabbedPanelHeader(text='Cracking')
        cracking_panel.content = BoxLayout(orientation='vertical')
        cracking_panel.content.add_widget(self.cracking_wid)
        cracking_panel.content.add_widget(btn_animate)

        # cb panel
        cb_panel = TabbedPanelHeader(text='CB')
        cb_panel.content = BoxLayout()
        cb_panel.content.add_widget(self.cb_wid)
        cb_panel.content.add_widget(set_T)

        # matrix panel
        #matrix_panel = TabbedPanelHeader(text='Matrix')
        #matrix_panel = GridLayout()

        # curve panel
        btn_plot = Button(
            text='Plot', on_press=self.plot_eps_sig, size_hint=(0.4, 0.2))
        curve_panel = TabbedPanelHeader(text='Curve')
        curve_panel.content = BoxLayout(orientation='vertical')
        curve_panel.content.add_widget(self.curve_wid)
        curve_panel.content.add_widget(btn_plot)
        # curve_panel.content.add_widget(wid1)

        root.add_widget(cb_panel)
        # root.add_widget(matrix_panel)
        root.add_widget(cracking_panel)
        root.add_widget(curve_panel)

        return root
示例#44
0
    def __init__(self):
        super(MyWidget, self).__init__()
        
        self.cos_table = CosTable([(0,0), (100,1), (1000,.25), (8191,0)])
        self.osc_out = Osc(table=self.cos_table, freq=220)

        # For each element of the GUI, make sure to
        # 1. Create a unique reference attached to this object for
        #   future manipulation. e.g. self.main_box = main_box after you've
        #   created a BoxLayout called main_box

        # Interesting things about Kivy UI programming:
        # 1. y starts counting from bottom left
        # 2. set size_hint to '[None, None]' for all new widgets if defining
        #       the size and manually

        # MAIN LAYOUT
        main_layout = FloatLayout(size=[800,600], orientation='horizontal')
        self.main_layout = main_layout
        self.add_widget(main_layout)

        # TABS WITH GAME CONTROL
        # Tabbed panel for music, settings, network
        # Y-position of tabbed panel depends on tab height!
        tabs = TabbedPanel(tab_width=50, size=[160, 480], pos=[0, 120],
                           size_hint=(None, None))
        self.tabs = tabs
        main_layout.add_widget(tabs)

        # Music tab
        music_button = Button(text="Music things")
        tabs.default_tab_content = music_button
        tabs.default_tab.text = "Music"

        # Network tab
        network_tab = TabbedPanelHeader(text="Net")
        tabs.add_widget(network_tab)
        network_layout = BoxLayout(orientation="vertical", padding=10)
        server_button = Button(text="Start server")
        ip_label = Label(text="Your IP is\n123.234.456.789");
        client_label = Label(text="Connect to server: ");
        server_ip_input = TextInput(text="Enter server IP")
        network_layout.add_widget(server_button)
        network_layout.add_widget(ip_label)
        network_layout.add_widget(client_label)
        network_layout.add_widget(server_ip_input)
        network_tab.content = network_layout

        # Global tab
        global_tab = TabbedPanelHeader(text="Global")
        tabs.add_widget(global_tab)
        global_button = Button(text="Global things")
        global_tab.content = global_button
        # END TABS

        # RIGHT-SIDE LAYOUT: NOTES GRID AND PLAYBACK UI
        music_layout = FloatLayout(size=[640, 600], pos=[161, 0],
                                   size_hint=[None, None])
        self.music_layout = music_layout
        main_layout.add_widget(music_layout)

        # NOTES GRID
        # Right now Kivy isn't really paying attention to button size and
        # padding. Later on, we'll fix this with a FloatLayout
        note_rows = note_cols = 8
        padding_between = 5
        note_grid = GridLayout(size=[640, 480], pos=[161, 121], 
                               size_hint=[None, None], rows=note_rows, 
                               cols=note_cols, padding=padding_between)
        music_layout.add_widget(note_grid)

        edge_padding = 30

        grid_start_x = note_grid.x + edge_padding
        grid_end_x = note_grid.right - edge_padding
        grid_start_y = note_grid.y + edge_padding
        grid_end_y = note_grid.top - edge_padding
        notes_matrix = []

        note_width = grid_end_x - grid_start_x - padding_between * \
                    (note_rows - 1)
        note_height = grid_end_y - grid_start_y - padding_between * \
                      (note_rows - 1)

        # Adding a rectangle to test playback indicator
        self.playback_indicator = Rectangle(pos=[161,121], size=[75, 480])
        self.playback_canvas = Canvas()
        playback_widget = Widget()
        self.playback_canvas.add(self.playback_indicator)
        self.playback_canvas.opacity = .5    
        playback_widget.canvas = self.playback_canvas
        music_layout.add_widget(playback_widget)


        for row in range(0, note_rows):
            for col in range(0, note_cols):
                new_id = str(row) + "," + str(col)
                new_button = ToggleButton(text=new_id, id=new_id, 
                                          width=note_width, 
                                          height=note_height)
                active_color = (1, 0, 0, 1)
                new_button.background_color = active_color
                new_button.bind(on_press=self.play_note)
                note_grid.add_widget(new_button)
        
        # PLAYBACK BUTTONS
        playback = Button(text="For playback", size=[640, 120], 
                          size_hint=[None, None], pos=[161, 0])
        music_layout.add_widget(playback)
示例#45
0
class BandLay(BoxLayout):
    def __init__(self, **kwargs):
        super(BandLay, self).__init__(**kwargs)

        self.tab_item = TabbedPanel()
        self.tab_item.do_default_tab = False
        self.tab_item.tab_height = 20

        list_bands = []
        if site.equipment == 'ADU06':
            list_bands = ['A', 'B', 'F', 'C', 'D']
        elif site.equipment == 'ADU07':
            list_bands = ['65536H', '4096H', '128H', '4H']

        for band in list_bands:
            tab_item = TabbedPanelItem()
            tab_item.text = band
            self.tab_item.add_widget(tab_item)

            list_file_pplt = self.search_pplt_file(band)
            site.files_plot[band] = list_file_pplt

            self.grid_lay = ScrollBox()

            i = 0
            for file_pplt_select in site.files_plot[band]:

                self.grid_lay.ids.grid.add_widget(file_pplt_select)
                print(file_pplt_select.obj_pplt.name)
                i += 1

            if band == '65536H' or band == '4096H':
                self.grid_lay.ids.grid.size_hint_x = None
                self.grid_lay.ids.grid.width = int(i / 3 * 300)
            else:
                self.grid_lay.ids.grid.size_hint_x = None
                self.grid_lay.ids.grid.width = int(i/3 * 250)

            tab_item.add_widget(self.grid_lay)
        self.add_widget(self.tab_item)


        print(project.path_file_ppmt)











    def search_pplt_file(self, band):

        list_path_band_pplt = glob.glob('PampaMT/file_pplt/' + site.name + '/*' + band + '*')
        list_path_band_pplt = sorted(list_path_band_pplt)

        list_file_pplt = []
        for path_file_ppmt in list_path_band_pplt:
            arq_pplt = open(path_file_ppmt, 'rb')
            file_pplt = pickle.load(arq_pplt)
            arq_pplt.close()

            file_pplt_select = FilePPLTSelect(object_pplt=file_pplt)

            if file_pplt.active_file == True:
                file_pplt_select.select()


            list_file_pplt.append(file_pplt_select)

        return list_file_pplt
示例#46
0
	def build(self):
	#*******ROOTWIDGET*******
		layout = GridLayout(rows=2)		
	#*******SUB-WIDGETS*******
		layoutTop = GridLayout(cols=3,rows=1)#SUB-WIDGET-1
		layoutTop.size_hint = (1, 0.1)
		layoutMid = FloatLayout()#SUB-WIDGET-2
		layoutMid.size_hint = (1, 1)
		
	#*******CONTENT-OF-SUB-WIDGET-1*******	
		menubtn = Button(text='Menu')
		menubtn.size_hint = (0.1, 0.1)
		head = Label(text='PRO-FORMA',size_hint_y = None,size_hint_x=None, width=200)
		head.size_hint = (0.8, 0.1)
		backbtn = Button(text='Drop')
		backbtn.size_hint = (0.1, 0.1)
		#dropbtn = Button()
	#*******CONTENT-OF-SUB-WIDGET-2*******
		tp_panel = TabbedPanel()
		tp_panel.default_tab_text = "Global News"	
		
		layoutnews = GridLayout(rows=2)
		upperlayout = GridLayout(cols=3, pos_hint ={'center_x': .5, 'center_y': .5},row_force_default=True, row_default_height=40, size_hint_y=None, height = 50, size_hint_x=1)
		lowerlayout = GridLayout(row=1)
		
		upperlayout.add_widget(Button(text='S', size_hint=(0.1, None)))
		upperlayout.add_widget(TextInput(text='search', size_hint=(0.8, None), focus=True, multiline=False))
		upperlayout.add_widget(Button(text='settings', size_hint=(0.1, None)))
		
		lowerlayout.add_widget(Label())
		
		layoutnews.add_widget(upperlayout)
		layoutnews.add_widget(lowerlayout)
		tp_panel.default_tab_content = layoutnews
		
		#*******TAB1*******	
		th_tab1 = TabbedPanelHeader(text = 'Pro-Forma')
		#*******SCROLLABILITY-WIDGET*******
		scroll = ScrollView(size_hint=(1, None), size=(800, 1000))
		
		mainlayout = GridLayout(cols = 1, spacing = 10, size_hint_y=None, size_hint_x=1)
		mainlayout.bind(minimum_height=mainlayout.setter('height'))
		#*******LAYOUT-FOR-PROPERTY-INFORMATION*******
		layouttab1 = GridLayout(cols=2,rows=6, pos_hint ={'center_x': .5, 'center_y': .5},row_force_default=True, row_default_height=40, size_hint_y=None, height = 250, size_hint_x=1)
		#*******LAYOUT-FOR-UNIT-MIX*******
		layoutmix = GridLayout(cols=4, pos_hint ={'center_x': .5, 'center_y': .5},row_force_default=True, row_default_height=40,size_hint_y=None, height = 80)
		#*******LAYOUT-FOR-EXPENSES*******
		layoutexpense = GridLayout(cols=2, pos_hint ={'center_x': .5, 'center_y': .5},row_force_default=True, row_default_height=40, size_hint_y=None, height = 960)
		#*******LAYOUT-FOR-ACCOUNTS*******
		layoutacc = GridLayout(cols=2, pos_hint ={'center_x': .5, 'center_y': .5},row_force_default=True, row_default_height=40,size_hint_y=None, height = 240)
		#*******CONTENT1*****
		mainlayout.add_widget(Label(text='Property Information',size_hint=(None, 1)))
		#*******CONTENT2*******
		layouttab1.add_widget(Label(text= 'Property Name', font_size=15, size_hint=(0.4, None)))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle',size_hint=(0.6, None),multiline=False, focus=True))
		layouttab1.add_widget(Label(text= 'Property Address', font_size=15, size_hint=(0.4, None)))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle',size_hint=(0.6, None),multiline=False, focus=True))
		layouttab1.add_widget(Label(text= 'Town/City', font_size=15, size_hint=(0.4, None)))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle',size_hint=(0.6, None),multiline=False, focus=True))
		layouttab1.add_widget(Label(text= 'Asking Price', font_size=15, size_hint=(0.4, None)))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle',size_hint=(0.6, None),multiline=False, focus=True))
		layouttab1.add_widget(Label(text= 'Total Units', font_size=15, size_hint=(0.4, None)))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle',size_hint=(0.6, None),multiline=False, focus=True))
		layouttab1.add_widget(Label(text= 'Square Footage', font_size=15, size_hint=(0.4, None)))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle',size_hint=(0.6, None),multiline=False, focus=True))
		mainlayout.add_widget(layouttab1)
		#*******CONTENT3*******
		mainlayout.add_widget(Label(text='Unit Mix',size_hint_x=None, width=200, size_hint_y=None, height=50))
		#*******CONTENT4*******
		layoutmix.add_widget(Label(text='# of Units'))
		layoutmix.add_widget(Label(text='Unit Type'))
		layoutmix.add_widget(Label(text='SquareFeet'))
		layoutmix.add_widget(Label(text='Monthly Rent'))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		mainlayout.add_widget(layoutmix)
		#*******CONTENT7*******
		mainlayout.add_widget(Label(text='Accounts',size_hint_x=None, width=200, size_hint_y=None, height=50))
		#*******CONTENT7*******
		layoutacc.add_widget(Label(text='Purchase Price'))
		layoutacc.add_widget(TextInput(text='Input'))
		layoutacc.add_widget(Label(text='Deposit'))
		layoutacc.add_widget(TextInput(text='Input'))
		layoutacc.add_widget(Label(text='Loan Amount'))
		layoutacc.add_widget(TextInput(text='Input'))
		layoutacc.add_widget(Label(text='Annual Interest'))
		layoutacc.add_widget(TextInput(text='Input'))
		layoutacc.add_widget(Label(text='Period'))
		layoutacc.add_widget(TextInput(text='Input'))
		layoutacc.add_widget(Label(text='Total Cash Outlay'))
		layoutacc.add_widget(TextInput(text='Input'))
		mainlayout.add_widget(layoutacc)
		#*******CONTENT5*******
		mainlayout.add_widget(Label(text='Expenses',size_hint_x=None, width=200, size_hint_y=None, height=50))
		#*******CONTENT6*******
		layoutexpense.add_widget(Label(text='Accounting'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15,))
		layoutexpense.add_widget(Label(text='Advertising'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Bank Charges'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Electricity'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Gas'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Security'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='All insurance'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Permits and fees'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Maintenance'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Trash Pick-up'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='All other'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		mainlayout.add_widget(layoutexpense)
		#*******CALLING-MAINLAYOUT-IN-TAB1*******
		scroll.add_widget(mainlayout)
		th_tab1.content = scroll
		tp_panel.add_widget(th_tab1)
		
		#___*******TAB3*******___#
		th_tab3 = TabbedPanelHeader(text = 'Saved Reports')
		tp_panel.add_widget(th_tab3)
	
	#*******ADDING-CONTENTS-OF-SUB-WIDGETS*******
		layoutTop.add_widget(menubtn)
		layoutTop.add_widget(head)
		layoutTop.add_widget(backbtn)
		layoutMid.add_widget(tp_panel)
	#*******ADDING-CONTENTS-OF-ROOT-WIDGET*******
		layout.add_widget(layoutTop)
		layout.add_widget(layoutMid)
	#*******CALLING-THE-ROOT-WIDGET*******	
		return layout
示例#47
0
 def build(self):
     TabbedPanel.add_widget(btntest)
     return Toolbar()
示例#48
0
    def build_layout(self):
        box_base = BoxLayout(orientation="vertical", padding=0)
        
        ctrl_box_haut = BoxLayout(orientation="horizontal", padding=10, size_hint_y=None)
        
        # Nom de l'individu
        ctrl_label = Label(text="[color=000000][size=28][b]%s[/b][/size][/color]" % self.dictIndividu["nomComplet"], markup=True, size_hint_y=None)
        ctrl_box_haut.add_widget(ctrl_label)
        
		# Photo
        photo = self.dictIndividu["photo"]
        if photo == None :
            if self.dictIndividu["IDcivilite"] == 1 : photo = UTILS_Images.GetTextureFromFichier("images/homme.png")
            if self.dictIndividu["IDcivilite"] in (2, 3) : photo = UTILS_Images.GetTextureFromFichier("images/femme.png")
            if self.dictIndividu["IDcivilite"] == 4 : photo = UTILS_Images.GetTextureFromFichier("images/garcon.png")
            if self.dictIndividu["IDcivilite"] == 5 : photo = UTILS_Images.GetTextureFromFichier("images/fille.png")
            
        if photo != None :
            ctrl_image = Image(texture=photo, size_hint_x=None)
            ctrl_box_haut.add_widget(ctrl_image)
		
        box_base.add_widget(ctrl_box_haut)
        
        # Onglets
        ctrl_onglets = TabbedPanel(do_default_tab=False, padding=10, tab_pos='top_left') # Vertical=left_bottom
        box_base.add_widget(ctrl_onglets)
		
        liste_onglets = [
            {"code":"messages", "titre":u"Messages"},
            {"code":"identite", "titre":u"Identité"},
            {"code":"liens", "titre":u"Liens"},
            {"code":"coordonnees", "titre":u"Coordonnées"},
            {"code":"scolarite", "titre":u"Scolarité"},
            {"code":"activites", "titre":u"Activités"},
            {"code":"medical", "titre":u"Médical"},
            ]

        for dictOnglet in liste_onglets :
            onglet = TabbedPanelItem(id=dictOnglet["code"], text=dictOnglet["titre"])
            doc = RstDocument(text=self.GetTexteOnglet(dictOnglet["code"]))
            onglet.add_widget(doc)
            ctrl_onglets.add_widget(onglet)

        # Barre d'état
        grid = GridLayout(cols=3, row=1, row_force_default=True, row_default_height=30, spacing=(5, 5), padding=10, size_hint=(1, None), height=50)
        grid.canvas.before.add(Color(0.128, 0.128, 0.128))

        def redraw(self, args):
            grid.bg_rect.size = self.size
            grid.bg_rect.pos = self.pos
        with grid.canvas.before:
            grid.bg_rect = Rectangle(pos=grid.pos, size=grid.size)
        grid.bind(pos=redraw, size=redraw)
        
        #ctrl_bouton = Button(id="consommations", text="Consommations", width=200, size_hint=(None, None))
        #grid.add_widget(ctrl_bouton)

        box_base.add_widget(grid)
        
        # Finalisation du layout
        self.add_widget(box_base)
示例#49
0
文件: gui.py 项目: tnason/NetSeq
    def __init__(self, app, music_player):
        """Create main GUI

        Arguments:
        parent -- parent application to this widget
        music_player -- audio generator for full application
        network -- network client and server handler

        """

        # Initialize Tkinter, and instruct it hide root window
        self.tk_root = Tkinter.Tk()
        self.tk_root.withdraw()

        # Perform widget initializations
        super(GUI, self).__init__()

        # OVERALL STRUCTURE
        WINDOW_WIDTH = 800
        WINDOW_HEIGHT = 600
        OUTER_PADDING = 20

        # Set default parameters to be used in accurately loading an
        # initial state to the GUI
        self.app = app
        self.music_player = music_player
        self.track_id = MusicPlayer.WAVETABLE_A
        self.popup_count = 0

        # Turn off multi-touch in this GUI
        Config.set('input', 'mouse', 'mouse,disable_multitouch')

        # Determine image directory
        IMAGE_DIR = system.get_images_dir()

        # For dynamic GUI coloring
        self.TRACK_COLORS = [[.7, .4, .9, 1.0], 
                             [.6, .9, .4, 1.0], 
                             [.8, .5, .3, 1.0]]
        self.colorables = []

        # Create widget for the main layout. This will be added separately
        # from each of our popup windows
        self.main_layout = NSWidget()
        self.add_widget(self.main_layout)

        # BUTTON GRID
        NOTE_BUTTON_WIDTH = 48
        NOTE_BUTTON_HEIGHT = 48
        NOTE_BUTTON_PADDING = 7
        ROW_LABEL_WIDTH = 54
        ROW_LABEL_HEIGHT = NOTE_BUTTON_HEIGHT
        ROW_LABEL_FONT_SIZE = 10
        NOTE_BUTTON_ROWS = MusicPlayer.NUM_ROWS
        NOTE_BUTTON_COLS = MusicPlayer.NUM_COLS

        GRID_WIDTH = NOTE_BUTTON_PADDING + ROW_LABEL_WIDTH + \
                     NOTE_BUTTON_PADDING + (NOTE_BUTTON_COLS * 
                     (NOTE_BUTTON_WIDTH + NOTE_BUTTON_PADDING))
        GRID_HEIGHT = NOTE_BUTTON_PADDING + (NOTE_BUTTON_ROWS * 
                      (NOTE_BUTTON_HEIGHT + NOTE_BUTTON_PADDING))
        GRID_X = OUTER_PADDING
        GRID_Y = WINDOW_HEIGHT - OUTER_PADDING - GRID_HEIGHT

        PLAYHEAD_WIDTH = NOTE_BUTTON_WIDTH + 4
        PLAYHEAD_HEIGHT = GRID_HEIGHT
        PLAYHEAD_OPACITY = .5
        PLAYHEAD_COLOR = Color(1.0, 1.0, 1.0)

        # Playhead
        playhead_widget = Widget()
        playhead_canvas = Canvas()
        playhead_canvas.add(PLAYHEAD_COLOR)
        playhead = Rectangle(size=[PLAYHEAD_WIDTH, PLAYHEAD_HEIGHT])
        playhead_canvas.add(playhead)
        playhead_canvas.opacity = PLAYHEAD_OPACITY
        playhead_widget.canvas = playhead_canvas
        self.main_layout.add_widget(playhead_widget)
        self.playhead = playhead

        # For each row, create labels and notes
        self.row_labels = []
        self.note_buttons = []

        row_top = GRID_Y + GRID_HEIGHT - NOTE_BUTTON_PADDING

        for row in range(0, NOTE_BUTTON_ROWS):
            col_x = GRID_X + NOTE_BUTTON_PADDING

            # Make label for row
            row_label = Label(text=str(row), width=ROW_LABEL_WIDTH, 
                              height=ROW_LABEL_HEIGHT, 
                              text_size=[ROW_LABEL_WIDTH, ROW_LABEL_HEIGHT],
                              font_size=ROW_LABEL_FONT_SIZE, halign='center',
                              valign='middle')
            row_label.x = col_x
            row_label.top = row_top
            self.main_layout.add_widget(row_label)
            self.row_labels.append(row_label)

            col_x = col_x + ROW_LABEL_WIDTH + NOTE_BUTTON_PADDING
            
            # Create all buttons for row
            row_notes = []
            for col in range(0, NOTE_BUTTON_COLS):
                col_button = NSToggleButton(width=NOTE_BUTTON_WIDTH,
                                          height=NOTE_BUTTON_HEIGHT)
                col_button.id = 'row' + str(row) + ',col' + str(col)
                col_button.x = col_x
                col_button.top = row_top
                col_button.bind(on_press=self.trigger_note)
                row_notes.append(col_button)
                self.main_layout.add_widget(col_button)
                self.colorables.append(col_button)
                col_x = col_x + NOTE_BUTTON_WIDTH + NOTE_BUTTON_PADDING
                
            self.note_buttons.append(row_notes)
            row_top = row_top - NOTE_BUTTON_PADDING - NOTE_BUTTON_HEIGHT

        # Set playhead start position
        leftmost_note = self.note_buttons[0][0]
        playhead_x = leftmost_note.center_x - (PLAYHEAD_WIDTH / 2)
        playhead_y = GRID_Y
        self.playhead.pos = [playhead_x, playhead_y]

        # PLAYBACK MENU
        PLAYBACK_X = OUTER_PADDING
        PLAYBACK_Y = OUTER_PADDING
        PLAYBACK_WIDTH = GRID_WIDTH
        PLAYBACK_HEIGHT = WINDOW_HEIGHT - OUTER_PADDING - GRID_HEIGHT - \
                          OUTER_PADDING - OUTER_PADDING
        PLAYBACK_CENTER_Y = PLAYBACK_Y + (PLAYBACK_HEIGHT / 2)
        PLAYBACK_TOP = PLAYBACK_Y + PLAYBACK_HEIGHT

        PLAY_BUTTON_WIDTH = 48
        PLAY_BUTTON_HEIGHT = 48
        PLAYALL_BUTTON_WIDTH = 60
        PLAYALL_BUTTON_HEIGHT = PLAY_BUTTON_HEIGHT / 2
        PLAYALL_BUTTON_FONT_SIZE = 8
        PLAYALL_BUTTON_TEXT_SIZE = [PLAYALL_BUTTON_WIDTH, 
                                    PLAYALL_BUTTON_HEIGHT]
        PAGE_BUTTON_WIDTH = 20
        PAGE_BUTTON_HEIGHT = 30
        NUM_PAGE_BUTTONS = MusicPlayer.NUM_PAGES
        PAGE_LABEL_WIDTH = (PAGE_BUTTON_WIDTH * NUM_PAGE_BUTTONS)
        PAGE_LABEL_HEIGHT = 20
        PAGE_LABEL_FONT_SIZE = 10
        PAGE_LABEL_OFFSET = 5
        TRACK_BUTTON_WIDTH = 48
        TRACK_BUTTON_HEIGHT = 48
        NUM_TRACK_BUTTONS = MusicPlayer.NUM_TRACKS
        NUM_PLAYBACK_ELEMENTS = 4
        TRACK_LABEL_WIDTH = TRACK_BUTTON_WIDTH * NUM_TRACK_BUTTONS
        TRACK_LABEL_HEIGHT = PAGE_LABEL_HEIGHT
        TRACK_LABEL_FONT_SIZE = PAGE_LABEL_FONT_SIZE
        TRACK_LABEL_TEXT_SIZE = [TRACK_LABEL_WIDTH, TRACK_LABEL_HEIGHT]
        TRACK_LABEL_OFFSET = PAGE_LABEL_OFFSET

        PLAYBACK_PADDING = (PLAYBACK_WIDTH - (PAGE_BUTTON_WIDTH * 
                            NUM_PAGE_BUTTONS) - (PLAY_BUTTON_WIDTH) - 
                            (TRACK_BUTTON_WIDTH * NUM_TRACK_BUTTONS) - 
                            PLAYALL_BUTTON_WIDTH) / (NUM_PLAYBACK_ELEMENTS + 1)
        
        # Play/pause button
        PLAY_BUTTON_X = PLAYBACK_X + PLAYBACK_PADDING
        # TODO: add a border for this button
        play_button = ToggleButton(width=PLAY_BUTTON_WIDTH, 
                             height=PLAY_BUTTON_HEIGHT)
        play_button.bind(on_press=self.play_pause)
        play_button.background_normal = \
            os.path.join(IMAGE_DIR, "media-playback-start-4.png")
        play_button.background_down = \
            os.path.join(IMAGE_DIR, "media-playback-pause-4.png")
        play_button.x = PLAY_BUTTON_X
        play_button.center_y = PLAYBACK_CENTER_Y
        self.play_button = play_button
        self.main_layout.add_widget(play_button)
        self.colorables.append(play_button)

        # Buttons to play one page or all
        one_page_button = NSToggleButton(width=PLAYALL_BUTTON_WIDTH,
                                       height=PLAYALL_BUTTON_HEIGHT,
                                       text='One page',
                                       text_size=PLAYALL_BUTTON_TEXT_SIZE,
                                       font_size=PLAYALL_BUTTON_FONT_SIZE,
                                       halign='center', valign='middle')
        one_page_button.bind(on_press=self.play_one_page)
        one_page_button.x = play_button.right + PLAYBACK_PADDING
        one_page_button.top = PLAYBACK_CENTER_Y + PLAYALL_BUTTON_HEIGHT
        self.one_page_button = one_page_button
        self.main_layout.add_widget(one_page_button)
        self.colorables.append(one_page_button)

        all_pages_button = NSToggleButton(width=PLAYALL_BUTTON_WIDTH,
                                        height=PLAYALL_BUTTON_HEIGHT,
                                        text='All pages', 
                                        text_size=PLAYALL_BUTTON_TEXT_SIZE,
                                        font_size=PLAYALL_BUTTON_FONT_SIZE,
                                        halign='center', valign='middle')
        all_pages_button.bind(on_press=self.play_all_pages)
        all_pages_button.x = one_page_button.x
        all_pages_button.top = PLAYBACK_CENTER_Y
        self.all_pages_button = all_pages_button
        self.main_layout.add_widget(all_pages_button)
        self.colorables.append(all_pages_button)
        
        if music_player.play_all == False:
            one_page_button.state = 'down'
            all_pages_button.state = 'normal'
        elif music_player.play_all == True:
            one_page_button.state = 'normal'
            all_pages_button.state = 'down'

        # Page selection buttons
        self.page_buttons = []
        page_buttons = []
        page_label = Label(text='Page Select', text_size=[PAGE_LABEL_WIDTH, 
                           PAGE_LABEL_HEIGHT], font_size=PAGE_LABEL_FONT_SIZE,
                           width=PAGE_LABEL_WIDTH, height=PAGE_LABEL_HEIGHT,
                           halign='center', valign='middle')
        page_button_x = all_pages_button.right + PLAYBACK_PADDING
        page_label.x = page_button_x
        page_label.top = PLAYBACK_CENTER_Y - (PAGE_BUTTON_HEIGHT / 2) - \
                         PAGE_LABEL_OFFSET
        self.main_layout.add_widget(page_label)
        for page_index in range(0, NUM_PAGE_BUTTONS):
            page_id = 'page' + str(page_index)
            page_button = NSToggleButton(width=PAGE_BUTTON_WIDTH,
                                       height=PAGE_BUTTON_HEIGHT, id=page_id)
            page_button.bind(on_press=self.select_page)
            page_button.x = page_button_x
            page_button.center_y = PLAYBACK_CENTER_Y
            page_buttons.append(page_button)
            self.main_layout.add_widget(page_button)
            self.colorables.append(page_button)
            page_button_x += PAGE_BUTTON_WIDTH

        self.page_buttons = page_buttons

        # Select the current music player's page with the GUI
        page_buttons[music_player.page_index].state = 'down'

        # Track selection buttons
        TRACK_BUTTON_FONT_SIZE = 10
        TRACK_BUTTON_TEXT_SIZE = [TRACK_BUTTON_WIDTH, TRACK_BUTTON_HEIGHT]
        
        track_text = ["Bass", "Lead", "Drum"]
        track_buttons = []
        self.track_buttons = []
        track_button_x = page_buttons[len(page_buttons) - 1].right + \
                         PLAYBACK_PADDING
        for track_index in range(0, NUM_TRACK_BUTTONS):
            track_id = 'track' + str(track_index)
            track_button = NSToggleButton(text=track_text[track_index],
                                        width=TRACK_BUTTON_WIDTH, 
                                        height=TRACK_BUTTON_HEIGHT, id=track_id,
                                        text_size=TRACK_BUTTON_TEXT_SIZE,
                                        font_size=TRACK_BUTTON_FONT_SIZE,
                                        halign='center', valign='middle')
            track_button.bind(on_press=self.select_track)
            track_button.x = track_button_x
            track_button.center_y = PLAYBACK_CENTER_Y
            track_buttons.append(track_button)
            self.main_layout.add_widget(track_button)
            track_button_x += TRACK_BUTTON_WIDTH
        
        self.track_buttons = track_buttons        
    
        # Select the current track in the GUI
        track_buttons[self.track_id].state = 'down'

        leftmost_track_button = self.track_buttons[0]

        track_label = Label(text='Instrument Select', 
                           text_size=TRACK_LABEL_TEXT_SIZE,
                           font_size=TRACK_LABEL_FONT_SIZE,
                           width=TRACK_LABEL_WIDTH, 
                           height=TRACK_LABEL_HEIGHT,
                           halign='center', valign='middle')
        track_label.x = leftmost_track_button.x
        track_label.top = leftmost_track_button.y - TRACK_LABEL_OFFSET
        # self.main_layout.add_widget(track_label)

        # SETTINGS TABS
        TABS_X = OUTER_PADDING + GRID_WIDTH + OUTER_PADDING
        TABS_Y = GRID_Y
        TABS_WIDTH = WINDOW_WIDTH - OUTER_PADDING - GRID_WIDTH - \
                     OUTER_PADDING - OUTER_PADDING
        TABS_HEIGHT = GRID_HEIGHT
        
        # Element is button, label, etc. Section is vertical group of elements
        TAB_SECTION_PADDING = 20
        TAB_ELEMENT_PADDING = 10

        # Note: it's a good idea to make these tabs the size of our icons,
        # which is 48x48
        TAB_HEADER_WIDTH = 48
        TAB_HEADER_HEIGHT = TAB_HEADER_WIDTH
        TAB_HEADER_FONT_SIZE = 20
        SECTION_LABEL_FONT_SIZE = 16
        SECTION_LABEL_WIDTH = TABS_WIDTH - TAB_SECTION_PADDING * 2
        SECTION_LABEL_HEIGHT = 30
        SECTION_LABEL_TEXT_SIZE = [SECTION_LABEL_WIDTH, SECTION_LABEL_HEIGHT]
        ELEMENT_LABEL_FONT_SIZE = 10
        ELEMENT_LABEL_WIDTH = TABS_WIDTH - TAB_ELEMENT_PADDING * 2
        ELEMENT_LABEL_HEIGHT = 20
        ELEMENT_LABEL_TEXT_SIZE = [ELEMENT_LABEL_WIDTH, ELEMENT_LABEL_HEIGHT]
        TAB_CONTENT_HEIGHT = TABS_HEIGHT - TAB_HEADER_HEIGHT
        TAB_CONTENT_TOP = TABS_Y + TAB_CONTENT_HEIGHT

        # Create main tabbed panel
        tabs = TabbedPanel(tab_width=TAB_HEADER_WIDTH, 
                           tab_height=TAB_HEADER_HEIGHT, width=TABS_WIDTH, 
                           height=TABS_HEIGHT)
        tabs.x = TABS_X
        tabs.y = TABS_Y
        self.main_layout.add_widget(tabs)
        self.tabs = tabs

        # Music tab (default)
        music_tab_content = Widget(width=TABS_WIDTH, height=TAB_CONTENT_HEIGHT)
        tabs.default_tab_content = music_tab_content
        tabs.default_tab.text = ""
        # TODO: make these paths absolute?
        tabs.default_tab.background_normal = \
            os.path.join(IMAGE_DIR, "audio-keyboard.png")
        print "@@ default tab bg: ", tabs.default_tab.background_normal
        tabs.default_tab.background_down = \
            os.path.join(IMAGE_DIR, "audio-keyboard-down.png")

        # Global music options
        global_music_label = Label(text='Global', 
                                   font_size=SECTION_LABEL_FONT_SIZE,
                                   width=SECTION_LABEL_WIDTH, 
                                   height=SECTION_LABEL_HEIGHT,
                                   text_size=SECTION_LABEL_TEXT_SIZE,
                                   halign='center', valign='middle')
        global_music_label.center_x = tabs.center_x
        global_music_label.top = TAB_CONTENT_TOP - TAB_SECTION_PADDING
        music_tab_content.add_widget(global_music_label)
        
        MUSIC_SLIDER_WIDTH = TABS_WIDTH - 40
        MUSIC_SLIDER_HEIGHT = 20

        # Note: these sliders buttons have a predefined height, so we are a
        # slave to that height for positioning the sliders
        global_volume_slider = NSSlider(min=MusicPlayer.MIN_VOLUME, 
                                        max=MusicPlayer.MAX_VOLUME,
                                        value=music_player.global_volume,
                                        orientation='horizontal',
                                        height=MUSIC_SLIDER_HEIGHT,
                                        width=MUSIC_SLIDER_WIDTH)
        global_volume_slider.bind(on_touch_move=self.change_global_volume)
        global_volume_slider.center_x = tabs.center_x
        global_volume_slider.top = global_music_label.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(global_volume_slider)
        self.global_volume_slider = global_volume_slider
        self.colorables.append(global_volume_slider)

        global_volume_label = Label(text='Volume',
                                    font_size=ELEMENT_LABEL_FONT_SIZE,
                                    width=ELEMENT_LABEL_WIDTH,
                                    height=ELEMENT_LABEL_HEIGHT,
                                    text_size=ELEMENT_LABEL_TEXT_SIZE,
                                    halign='center', valign='middle')
        global_volume_label.center_x = tabs.center_x
        global_volume_label.top = global_volume_slider.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(global_volume_label)
        
        global_tempo_slider = NSSlider(min=MusicPlayer.MIN_TEMPO, 
                                       max=MusicPlayer.MAX_TEMPO,
                                       value=music_player.tempo,
                                       orientation='horizontal',
                                       height=MUSIC_SLIDER_HEIGHT,
                                       width=MUSIC_SLIDER_WIDTH)
        global_tempo_slider.bind(on_touch_move=self.change_global_tempo)
        global_tempo_slider.center_x = tabs.center_x
        global_tempo_slider.top = global_volume_label.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(global_tempo_slider)
        self.global_tempo_slider = global_tempo_slider
        self.colorables.append(global_tempo_slider)

        global_tempo_label = Label(text='Tempo',
                                   font_size=ELEMENT_LABEL_FONT_SIZE,
                                   width=ELEMENT_LABEL_WIDTH,
                                   height=ELEMENT_LABEL_HEIGHT,
                                   text_size=ELEMENT_LABEL_TEXT_SIZE,
                                   halign='center', valign='middle')
        global_tempo_label.center_x = tabs.center_x
        global_tempo_label.top = global_tempo_slider.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(global_tempo_label)

        # Instrument settings
        track_music_label = Label(text='Instrument', 
                                  font_size=SECTION_LABEL_FONT_SIZE,
                                  width=SECTION_LABEL_WIDTH, 
                                  height=SECTION_LABEL_HEIGHT,
                                  text_size=SECTION_LABEL_TEXT_SIZE,
                                  halign='center', valign='middle')
        track_music_label.center_x = tabs.center_x
        track_music_label.top = global_tempo_label.y - TAB_SECTION_PADDING
        music_tab_content.add_widget(track_music_label)
        
        track_volume_initial = music_player.get_volume(self.track_id)
        track_volume_slider = NSSlider(min=MusicPlayer.MIN_VOLUME, 
                                       max=MusicPlayer.MAX_VOLUME,
                                       value=track_volume_initial,
                                       orientation='horizontal',
                                       height=MUSIC_SLIDER_HEIGHT,
                                       width=MUSIC_SLIDER_WIDTH)
        track_volume_slider.bind(on_touch_move=self.change_track_volume)
        track_volume_slider.center_x = tabs.center_x
        track_volume_slider.top = track_music_label.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(track_volume_slider)
        self.track_volume_slider = track_volume_slider
        self.colorables.append(track_volume_slider)

        track_volume_label = Label(text='Volume',
                                   font_size=ELEMENT_LABEL_FONT_SIZE,
                                   width=ELEMENT_LABEL_WIDTH,
                                   height=ELEMENT_LABEL_HEIGHT,
                                   text_size=ELEMENT_LABEL_TEXT_SIZE,
                                   halign='center', valign='middle')
        track_volume_label.center_x = tabs.center_x
        track_volume_label.top = track_volume_slider.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(track_volume_label)
        
        track_reverb_initial = music_player.get_reverb(self.track_id)
        track_reverb_slider = NSSlider(min=MusicPlayer.MIN_REVERB,
                                       max=MusicPlayer.MAX_REVERB,
                                       value=track_reverb_initial,
                                       orientation='horizontal',
                                       height=MUSIC_SLIDER_HEIGHT,
                                       width=MUSIC_SLIDER_WIDTH)
        track_reverb_slider.bind(on_touch_move=self.change_track_reverb)
        track_reverb_slider.center_x = tabs.center_x
        track_reverb_slider.top = track_volume_label.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(track_reverb_slider)
        self.track_reverb_slider = track_reverb_slider
        self.colorables.append(track_reverb_slider)

        track_reverb_label = Label(text='Reverb',
                                   font_size=ELEMENT_LABEL_FONT_SIZE,
                                   width=ELEMENT_LABEL_WIDTH,
                                   height=ELEMENT_LABEL_HEIGHT,
                                   text_size=ELEMENT_LABEL_TEXT_SIZE,
                                   halign='center', valign='middle')
        track_reverb_label.center_x = tabs.center_x
        track_reverb_label.top = track_reverb_slider.y - TAB_ELEMENT_PADDING
        music_tab_content.add_widget(track_reverb_label)

        # Network tab
        network_tab = TabbedPanelHeader()
        network_tab.text = ""
        network_tab.background_normal = \
            os.path.join(IMAGE_DIR, "network-wired-2.png")
        network_tab.background_down = \
            os.path.join(IMAGE_DIR, "network-wired-2-down.png")
        tabs.add_widget(network_tab)
        
        TEXT_INPUT_HEIGHT = 30
        PORT_INPUT_WIDTH = 70
        IP_INPUT_WIDTH = TABS_WIDTH - TAB_SECTION_PADDING - \
                         PORT_INPUT_WIDTH - TAB_ELEMENT_PADDING - \
                         TAB_SECTION_PADDING
        PORT_LABEL_TEXT_SIZE = [PORT_INPUT_WIDTH, ELEMENT_LABEL_HEIGHT]
        IP_LABEL_TEXT_SIZE = [IP_INPUT_WIDTH, ELEMENT_LABEL_HEIGHT]
        NETWORK_BUTTON_WIDTH = TABS_WIDTH - TAB_SECTION_PADDING * 2
        NETWORK_BUTTON_HEIGHT = 80
        NETWORK_BUTTON_FONT_SIZE = 16
        NETWORK_BUTTON_TEXT_SIZE = [NETWORK_BUTTON_WIDTH, NETWORK_BUTTON_HEIGHT]

        SERVER_PORT_TEXT = 'Server Port'
        SERVER_IP_TEXT = 'Server IP Address'
        network_tab_content = Widget(width=TABS_WIDTH, height=TAB_CONTENT_HEIGHT)
        network_tab.content = network_tab_content

        # Server input labels
        server_port_label = Label(text=SERVER_PORT_TEXT, 
                                  width=PORT_INPUT_WIDTH,
                                  height=ELEMENT_LABEL_HEIGHT,
                                  text_size=PORT_LABEL_TEXT_SIZE,
                                  font_size=ELEMENT_LABEL_FONT_SIZE)
        server_port_label.top = TAB_CONTENT_TOP - TAB_SECTION_PADDING
        server_port_label.x = TABS_X + TAB_SECTION_PADDING
        network_tab_content.add_widget(server_port_label)

        server_ip_label = Label(text=SERVER_IP_TEXT, 
                                  width=IP_INPUT_WIDTH,
                                  height=ELEMENT_LABEL_HEIGHT,
                                  text_size=IP_LABEL_TEXT_SIZE,
                                  font_size=ELEMENT_LABEL_FONT_SIZE)
        server_ip_label.top = server_port_label.top
        server_ip_label.x = server_port_label.right + TAB_ELEMENT_PADDING
        network_tab_content.add_widget(server_ip_label)

        # Server startup input
        server_port_input = NSTextInput(text='', 
                                        width=PORT_INPUT_WIDTH,
                                        height=TEXT_INPUT_HEIGHT,
                                        multiline=False)
        server_port_input.bind(focus=self.select_text_input)
        server_port_input.original_text = SERVER_PORT_TEXT
        server_port_input.x = server_port_label.x
        server_port_input.top = server_port_label.y - TAB_ELEMENT_PADDING
        network_tab_content.add_widget(server_port_input)
        self.server_port_input = server_port_input

        server_ip_input = NSTextInput(text='',
                                      width=IP_INPUT_WIDTH,
                                      height=TEXT_INPUT_HEIGHT,
                                      multiline=False)
        server_ip_input.bind(focus=self.select_text_input)
        server_ip_input.original_text=SERVER_IP_TEXT
        server_ip_input.x = server_ip_label.x
        server_ip_input.top = server_port_input.top
        network_tab_content.add_widget(server_ip_input)
        self.server_ip_input = server_ip_input

        server_start_button = NSDisableButton(text='Start server', 
                                     width=NETWORK_BUTTON_WIDTH,
                                     height=NETWORK_BUTTON_HEIGHT,
                                     text_size=NETWORK_BUTTON_TEXT_SIZE,
                                     font_size=NETWORK_BUTTON_FONT_SIZE,
                                     halign='center', valign='middle')
        server_start_button.bind(on_press=self.start_server)
        server_start_button.center_x = tabs.center_x
        server_start_button.top = server_ip_input.y - TAB_ELEMENT_PADDING
        network_tab_content.add_widget(server_start_button)
        self.server_start_button = server_start_button

        join_server_button = NSDisableButton(text='Join server',
                                    width=NETWORK_BUTTON_WIDTH,
                                    height=NETWORK_BUTTON_HEIGHT,
                                    text_size=NETWORK_BUTTON_TEXT_SIZE,
                                    font_size=NETWORK_BUTTON_FONT_SIZE,
                                    halign='center', valign='middle')
        join_server_button.bind(on_press=self.ask_join_server)
        join_server_button.x = server_start_button.x
        join_server_button.top = server_start_button.y - TAB_ELEMENT_PADDING
        network_tab_content.add_widget(join_server_button)
        self.join_server_button = join_server_button

        end_connection_button = NSDisableButton(text='End connection',
                                       width=NETWORK_BUTTON_WIDTH,
                                       height=NETWORK_BUTTON_HEIGHT,
                                       text_size=NETWORK_BUTTON_TEXT_SIZE,
                                       font_size=NETWORK_BUTTON_FONT_SIZE,
                                       halign='center', valign='middle')
        end_connection_button.bind(on_press=self.ask_end_connection)
        end_connection_button.disable()
        end_connection_button.x = server_start_button.x
        end_connection_button.top = join_server_button.y - TAB_ELEMENT_PADDING
        network_tab_content.add_widget(end_connection_button)
        self.end_connection_button = end_connection_button
        
        # System options tab
        system_tab = TabbedPanelHeader()
        system_tab.background_normal = \
            os.path.join(IMAGE_DIR, "media-floppy.png")
        system_tab.background_down = \
            os.path.join(IMAGE_DIR, "media-floppy-down.png")
        tabs.add_widget(system_tab)

        system_tab_content = Widget(width=TABS_WIDTH, height=TAB_CONTENT_HEIGHT)
        system_tab.content = system_tab_content

        NUM_SYSTEM_BUTTONS = 3
        SYSTEM_BUTTON_PADDING = 20
        SYSTEM_BUTTON_FONT_SIZE = 24
        SYSTEM_BUTTON_WIDTH = TABS_WIDTH - SYSTEM_BUTTON_PADDING * 2
        SYSTEM_BUTTON_HEIGHT = (TAB_CONTENT_HEIGHT - SYSTEM_BUTTON_PADDING *
                               (NUM_SYSTEM_BUTTONS + 1)) / NUM_SYSTEM_BUTTONS
        SYSTEM_BUTTON_TEXT_SIZE = [SYSTEM_BUTTON_WIDTH, SYSTEM_BUTTON_HEIGHT]

        # Load button
        load_button = NSDisableButton(text='Load', width=SYSTEM_BUTTON_WIDTH,
                                      height=SYSTEM_BUTTON_HEIGHT,
                                      text_size=SYSTEM_BUTTON_TEXT_SIZE,
                                      font_size=SYSTEM_BUTTON_FONT_SIZE,
                                      halign='center', valign='middle')
        load_button.bind(on_press=self.load_file)
        load_button.center_x = tabs.center_x
        load_button.top = TAB_CONTENT_TOP - SYSTEM_BUTTON_PADDING
        system_tab_content.add_widget(load_button)
        self.load_button = load_button

        # Save button
        save_button = NSDisableButton(text='Save', width=SYSTEM_BUTTON_WIDTH,
                                      height=SYSTEM_BUTTON_HEIGHT,
                                      text_size=SYSTEM_BUTTON_TEXT_SIZE,
                                      font_size=SYSTEM_BUTTON_FONT_SIZE,
                                      halign='center', valign='middle')
        save_button.bind(on_press=self.save_file)
        save_button.center_x = tabs.center_x
        save_button.top = load_button.y - SYSTEM_BUTTON_PADDING
        system_tab_content.add_widget(save_button)        

        # Quit button
        quit_button = NSDisableButton(text='Quit', width=SYSTEM_BUTTON_WIDTH,
                                      height=SYSTEM_BUTTON_HEIGHT,
                                      text_size=SYSTEM_BUTTON_TEXT_SIZE, 
                                      font_size=SYSTEM_BUTTON_FONT_SIZE,
                                      halign='center', valign='middle')
        quit_button.bind(on_press=self.request_exit)
        quit_button.center_x = tabs.center_x
        quit_button.top = save_button.y - SYSTEM_BUTTON_PADDING
        system_tab_content.add_widget(quit_button)        

        # APPLICATION TITLE
        TITLE_WIDTH = TABS_WIDTH
        TITLE_HEIGHT = 50
        TITLE_TEXT_SIZE = [TITLE_WIDTH, TITLE_HEIGHT]
        TITLE_FONT_SIZE = 30
        SUBTITLE_WIDTH = TITLE_WIDTH
        SUBTITLE_HEIGHT = 30
        SUBTITLE_TEXT_SIZE = [SUBTITLE_WIDTH, SUBTITLE_HEIGHT]
        SUBTITLE_FONT_SIZE = 15
        TITLE_X = TABS_X

        title_label = Label(text='NetSeq', width=TITLE_WIDTH,
                            height=TITLE_HEIGHT, halign='center', 
                            valign='middle', text_size=TITLE_TEXT_SIZE,
                            font_size=TITLE_FONT_SIZE)
        title_label.top = PLAYBACK_TOP
        title_label.x = TITLE_X
        self.main_layout.add_widget(title_label)

        subtitle_label = Label(text='Music with Friends',
                               width=SUBTITLE_WIDTH,
                               height=SUBTITLE_HEIGHT,  
                               text_size=SUBTITLE_TEXT_SIZE,
                               font_size=SUBTITLE_FONT_SIZE,
                               halign='center', valign='middle')
        subtitle_label.top = title_label.y
        subtitle_label.x = TITLE_X
        self.main_layout.add_widget(subtitle_label)

        # Finishing steps
        self.set_color(self.track_id)
        self.reload_row_labels()
示例#50
0
	def build(self):
	#*******ROOTWIDGET*******
		layout = GridLayout(rows=2)		
	#*******SUB-WIDGETS*******
		layoutTop = GridLayout(cols=3,rows=1)#SUB-WIDGET-1
		layoutTop.size_hint = (1, 0.1)
		layoutMid = GridLayout(cols=1, size_hint_x=1)#SUB-WIDGET-2
	#*******CONTENT-OF-SUB-WIDGET-1*******	
		backbtn = Button()
		title = Label(text = 'Pro-Forma App', font_size = '20sp', pos = (0,300), size_hint_y = None,size_hint_x=None, width=200, halign ='right', valign='middle')
		title.size_hint = (None, 0.1)
		dropbtn = Button()
	#*******CONTENT-OF-SUB-WIDGET-2*******
		tp_panel = TabbedPanel()
		tp_panel.default_tab_text = "Login Tab"	
		#*******TAB1*******	
		th_tab1 = TabbedPanelHeader(text = 'Pro-Forma')
		#*******MAIN-LAYOUT-FOR-TAB1*******
		mainlayout = GridLayout(cols=1, spacing=10)
		#*******LAYOUT-FOR-PROPERTY-INFORMATION*******
		layouttab1 = GridLayout(cols=2,rows=6, pos_hint ={'center_x': .5, 'center_y': .5},row_force_default=True, row_default_height=40)
		#*******LAYOUT-FOR-UNIT-MIX*******
		layoutmix = GridLayout(cols=4, pos_hint ={'center_x': .5, 'center_y': .5},row_force_default=True, row_default_height=40)
		#*******LAYOUT-FOR-EXPENSES*******
		layoutexpense = GridLayout(cols=2)
		#*******LAYOUT-FOR-ACCOUNTS*******
		
		#*******CONTENT1*******
		mainlayout.add_widget(Label(text='Property Information',size_hint_y=None, height=50))
		#*******CONTENT2*******
		layouttab1.add_widget(Label(text= 'Property Name', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Property Address', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Town/City', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Asking Price', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Total Units', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Square Footage', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		mainlayout.add_widget(layouttab1)
		#*******CONTENT3*******
		mainlayout.add_widget(Label(text='Unit Mix',size_hint_x=None, width=200, size_hint_y=None, height=50))
		#*******CONTENT4*******
		layoutmix.add_widget(Label(text='# of Units'))
		layoutmix.add_widget(Label(text='Unit Type'))
		layoutmix.add_widget(Label(text='SquareFeet'))
		layoutmix.add_widget(Label(text='Monthly Rent'))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		mainlayout.add_widget(layoutmix)
		#*******CONTENT5*******
		mainlayout.add_widget(Label(text='Expenses',size_hint_x=None, width=200, size_hint_y=None, height=50))
		#*******CONTENT6*******
		layoutexpense.add_widget(Label(text='Accounting'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Advertising'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Bank Charges'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Electricity'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Gas'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Security'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='All insurance'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Permits and fees'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Maintenance'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Trash Pick-up'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='All other'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		mainlayout.add_widget(layoutexpense)
		#*******CONTENT7*******
		mainlayout.add_widget(Label(text='Accounts'))
		#*******CONTENT7*******
		#*******SCOLLABILITY*******
		#*******CALLING-MAINLAYOUT-IN-TAB1*******
		th_tab1.content = mainlayout
		
		#___*******TAB2*******___#
		th_tab2 = TabbedPanelHeader(text = 'Info. Tab')
	 	
		#___*******TAB3*******___#
		th_tab3 = TabbedPanelHeader(text = 'Due Deligence')
		
		#___*******TAB4*******___#
		th_tab4 = TabbedPanelHeader(text = 'Saved Reports')
		
	#*******CALLING-TABS-TO-tp_panel*******
		tp_panel.add_widget(th_tab1)
		tp_panel.add_widget(th_tab2)
		tp_panel.add_widget(th_tab3)
		tp_panel.add_widget(th_tab4)	
	#*******ADDING-CONTENTS-OF-SUB-WIDGETS*******
		layoutTop.add_widget(backbtn)
		layoutTop.add_widget(title)
		layoutTop.add_widget(dropbtn)
		layoutMid.add_widget(tp_panel)
	#*******ADDING-CONTENTS-OF-ROOT-WIDGET*******
		layout.add_widget(layoutTop)
		layout.add_widget(layoutMid)
	#*******CALLING-THE-ROOT-WIDGET*******	
		return layout
示例#51
0
    def build(self):
        tab_panel= TabbedPanel()
        tab_panel.do_default_tab = False
        tab_panel.tab_width = 150
        tab_panel.tab_height = 30

        th_playlist = TabbedPanelHeader(text='Playlist Playout')
        th_playlist.content = Label(text='UI to create a playlist rundown')

        th_generic_live = TabbedPanelHeader(text='Generic Live Event')
        th_generic_live.content = Label(text='UI for running random live events')

        th_news = TabbedPanelHeader(text='News Broadcast')
        th_news.content = Label(text='UI for running a live news broadcast')

        th_worship = TabbedPanelHeader(text='Worship')
        th_worship.content= Label(text='UI for running praise & worships')

        th_football = TabbedPanelHeader(text='Football')
        th_football.content= Label(text='UI for running a football match')

        th_volleyball = TabbedPanelHeader(text='Volleyball')
        th_volleyball.content= Label(text='UI for running a volleyball match')

        tab_panel.add_widget(th_playlist)
        tab_panel.add_widget(th_generic_live)
        tab_panel.add_widget(th_news)
        tab_panel.add_widget(th_worship)
        tab_panel.add_widget(th_football)
        tab_panel.add_widget(th_volleyball)

        tab_panel.default_tab = th_playlist

        return tab_panel
示例#52
0
	def build(self):
#*******THE-ROOT-WIDGET******
		root = GridLayout(cols=1, rows=2, spacing=10)	
#*******CHILDREN-OF-ROOT-WIDGET******
		layouttop = GridLayout(cols=3, rows=1)
		layouttop.size_hint = (1, 0.1)
		layoutmid = GridLayout(cols=1, spacing=10)
	#******CHILDREN-OF-LAYOUTTOP******
		menubtn = Button()
		menubtn.size_hint = (0.1, 0.1)
		head = Label(text='PRO-FORMA',size_hint_y = None,size_hint_x=None, width=200)
		head.size_hint = (0.8, 0.1)
		backbtn = Button()
		backbtn.size_hint = (0.1, 0.1)
	#******CHILDREN-OF-LAYOUTMID******
		tp_panel = TabbedPanel()
		#___*******TAB1*****************************___#
		th_tab1 = TabbedPanelHeader(text = 'Info. Tab')	
		
		layoutinfo = GridLayout(rows=2)
		layoutinfo.add_widget(Label(text='Powered by kivy'))
	#*******CALLING-SUB-WIDGETS-TAB2******	
		th_tab1.content = layoutinfo
		tp_panel.add_widget(th_tab1)
		
		#___*******TAB2*****************************___#
		th_tab2 = TabbedPanelHeader(text = 'Pro-Forma')
		#******children-of-tab1******
		scroll = ScrollView(size_hint=(None, None), size=(800, 1000), pos_hint={'center_x':1,'center_y':1})
		
		mainlayout = GridLayout(cols = 1, spacing = 10, size_hint_y=None)
		mainlayout.bind(minimum_height=mainlayout.setter('height'))
			#children-of-main-layout
		layouttab1 = GridLayout(cols=2, pos_hint ={'center_x': 1, 'center_y': 1},row_force_default=True, row_default_height=40, size_hint_y=None, height = 250)
		layoutmix = GridLayout(cols=4, pos_hint ={'center_x': 1, 'center_y': 1},row_force_default=True, row_default_height=40 ,size_hint_y=None, height = 80)
		layoutexpense = GridLayout(cols=2, pos_hint ={'center_x': 1, 'center_y': 1},row_force_default=True, row_default_height=40, size_hint_y=None, height = 1000)
		layoutacc = GridLayout(cols=1, pos_hint ={'center_x': 1, 'center_y': 1},row_force_default=True, row_default_height=40, size_hint_y=None, height = 250)
		#******CONTENT1*******
		mainlayout.add_widget(Label(text='Property Information',size_hint_y=None, height=50))
		#*******CONTENT2*******
		layouttab1.add_widget(Label(text= 'Property Name', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Property Address', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Town/City', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Asking Price', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Total Units', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		layouttab1.add_widget(Label(text= 'Square Footage', size_hint_x=None, width=200,size_hint_y=None, height=50, font_size='20sp'))
		layouttab1.add_widget(TextInput(text='input', font_size=15, halign ='left', valign='middle'))
		mainlayout.add_widget(layouttab1)
		#*******CONTENT3*******
		mainlayout.add_widget(Label(text='Unit Mix',size_hint_x=None, width=200, size_hint_y=None, height=50))
		#*******CONTENT4*******
		layoutmix.add_widget(Label(text='# of Units'))
		layoutmix.add_widget(Label(text='Unit Type'))
		layoutmix.add_widget(Label(text='SquareFeet'))
		layoutmix.add_widget(Label(text='Monthly Rent'))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		layoutmix.add_widget(TextInput(text='Input', font_size=15))
		mainlayout.add_widget(layoutmix)
		#*******CONTENT5*******
		mainlayout.add_widget(Label(text='Expenses',size_hint_x=None, width=200, size_hint_y=None, height=50))
		#*******CONTENT6*******
		layoutexpense.add_widget(Label(text='Accounting'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Advertising'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Bank Charges'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Electricity'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Gas'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Security'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='All insurance'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Permits and fees'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Maintenance'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='Trash Pick-up'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		layoutexpense.add_widget(Label(text='All other'))
		layoutexpense.add_widget(TextInput(text='Input', font_size=15))
		mainlayout.add_widget(layoutexpense)
		#*******CONTENT7*******
		mainlayout.add_widget(Label(text='Accounts',size_hint_x=None, width=200, size_hint_y=None, height=50))	
		#*******CONTENT8layoutacc
		layoutacc.add_widget(Label(text='Select your financing type'))
		mainlayout.add_widget(layoutacc)
	#*******CALLING-SUB-WIDGETS-TAB2******
		scroll.add_widget(mainlayout)
		th_tab2.content = scroll
		tp_panel.add_widget(th_tab2)
		
		#___*******TAB3*******___#
		th_tab3 = TabbedPanelHeader(text = 'Saved Reports')
	#*******CALLING-SUB-WIDGETS-TAB3******
		tp_panel.add_widget(th_tab3)
		
#******CALLING-WIDGETS******
		layouttop.add_widget(menubtn)
		layouttop.add_widget(head)
		layouttop.add_widget(backbtn)		
		
		layoutmid.add_widget(tp_panel)
			
		root.add_widget(layouttop)
		root.add_widget(layoutmid)
#******RETURN-ROOT******
		return root		
示例#53
0
class RulesView(Widget):
    """The view to edit a rule

    Presents three tabs, one each for trigger, prereq, and action. Each has a
    deckbuilder in it with a column of used functions and a column of unused actions.

    """
    engine = ObjectProperty()
    rulebook = ObjectProperty()
    entity = ObjectProperty()
    rule = ObjectProperty(allownone=True)

    def on_rule(self, *args):
        """Make sure to update when the rule changes"""
        if self.rule is None:
            return
        self.rule.connect(self._listen_to_rule)

    def _listen_to_rule(self, rule, **kwargs):
        if rule is not self.rule:
            rule.disconnect(self._listen_to_rule)
            return
        if 'triggers' in kwargs:
            self.pull_triggers()
        if 'prereqs' in kwargs:
            self.pull_prereqs()
        if 'actions' in kwargs:
            self.pull_actions()

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.finalize()

    def finalize(self, *args):
        """Add my tabs"""
        if not self.canvas:
            Clock.schedule_once(self.finalize, 0)
            return

        deck_builder_kwargs = {
            'pos_hint': {'x': 0, 'y': 0},
            'starting_pos_hint': {'x': 0.05, 'top': 0.95},
            'card_size_hint': (0.3, 0.4),
            'card_hint_step': (0, -0.1),
            'deck_x_hint_step': 0.4
        }

        self._tabs = TabbedPanel(
            size=self.size,
            pos=self.pos,
            do_default_tab=False
        )
        self.bind(
            size=self._tabs.setter('size'),
            pos=self._tabs.setter('pos')
        )
        self.add_widget(self._tabs)

        for functyp in 'trigger', 'prereq', 'action':
            tab = TabbedPanelItem(text=functyp.capitalize())
            setattr(self, '_{}_tab'.format(functyp), tab)
            self._tabs.add_widget(getattr(self, '_{}_tab'.format(functyp)))
            builder = DeckBuilderView(**deck_builder_kwargs)
            setattr(self, '_{}_builder'.format(functyp), builder)
            builder.bind(decks=getattr(self, '_trigger_push_{}s'.format(functyp)))
            scroll_left = DeckBuilderScrollBar(
                size_hint_x=0.01,
                pos_hint={'x': 0, 'y': 0},
                deckbuilder=builder,
                deckidx=0,
                scroll_min=0
            )
            setattr(self, '_scroll_left_' + functyp, scroll_left)
            scroll_right = DeckBuilderScrollBar(
                size_hint_x=0.01,
                pos_hint={'right': 1, 'y': 0},
                deckbuilder=builder,
                deckidx=1,
                scroll_min=0
            )
            setattr(self, '_scroll_right_' + functyp, scroll_right)
            layout = FloatLayout()
            setattr(self, '_{}_layout'.format(functyp), layout)
            tab.add_widget(layout)
            layout.add_widget(builder)
            layout.add_widget(scroll_left)
            layout.add_widget(scroll_right)
            layout.add_widget(
                Label(
                    text='Used',
                    pos_hint={'center_x': 0.1, 'center_y': 0.98},
                    size_hint=(None, None)
                )
            )
            layout.add_widget(
                Label(
                    text='Unused',
                    pos_hint={'center_x': 0.5, 'center_y': 0.98},
                    size_hint=(None, None)
                )
            )
            self.bind(rule=getattr(self, '_trigger_pull_{}s'.format(functyp)))

    def get_functions_cards(self, what, allfuncs):
        """Return a pair of lists of Card widgets for used and unused functions.

        :param what: a string: 'trigger', 'prereq', or 'action'
        :param allfuncs: a sequence of functions' (name, sourcecode, signature)

        """
        if not self.rule:
            return [], []
        rulefuncnames = getattr(self.rule, what+'s')
        unused = [
            Card(
                ud={
                    'type': what,
                    'funcname': name,
                    'signature': sig
                },
                headline_text=name,
                show_art=False,
                midline_text=what.capitalize(),
                text=source
            )
            for (name, source, sig) in allfuncs if name not in rulefuncnames
        ]
        used = [
            Card(
                ud={
                    'type': what,
                    'funcname': name,
                },
                headline_text=name,
                show_art=False,
                midline_text=what.capitalize(),
                text=str(getattr(getattr(self.engine, what), name))
            )
            for name in rulefuncnames
        ]
        return used, unused

    def set_functions(self, what, allfuncs):
        """Set the cards in the ``what`` builder to ``allfuncs``

        :param what: a string, 'trigger', 'prereq', or 'action'
        :param allfuncs: a sequence of triples of (name, sourcecode, signature) as taken by my
        ``get_function_cards`` method.

        """
        setattr(getattr(self, '_{}_builder'.format(what)), 'decks', self.get_functions_cards(what, allfuncs))

    def _pull_functions(self, what):
        return self.get_functions_cards(what, list(map(self.inspect_func, getattr(self.engine, what)._cache.items())))

    def pull_triggers(self, *args):
        """Refresh the cards in the trigger builder"""
        self._trigger_builder.decks = self._pull_functions('trigger')
    _trigger_pull_triggers = trigger(pull_triggers)

    def pull_prereqs(self, *args):
        """Refresh the cards in the prereq builder"""
        self._prereq_builder.decks = self._pull_functions('prereq')
    _trigger_pull_prereqs = trigger(pull_prereqs)

    def pull_actions(self, *args):
        """Refresh the cards in the action builder"""
        self._action_builder.decks = self._pull_functions('action')
    _trigger_pull_actions = trigger(pull_actions)

    def inspect_func(self, namesrc):
        """Take a function's (name, sourcecode) and return a triple of (name, sourcecode, signature)"""
        (name, src) = namesrc
        glbls = {}
        lcls = {}
        exec(src, glbls, lcls)
        assert name in lcls
        func = lcls[name]
        return name, src, signature(func)

    def update_builders(self, *args):
        for attrn in '_trigger_builder', '_prereq_builder', '_action_builder':
            if not hasattr(self, attrn):
                dbg('RulesView: no {}'.format(attrn))
                Clock.schedule_once(self.update_builders, 0)
                return
        self._trigger_builder.clear_widgets()
        self._prereq_builder.clear_widgets()
        self._action_builder.clear_widgets()
        if self.rule is None:
            dbg('RulesView: no rule')
            return
        if hasattr(self, '_list'):
            self._list.redata()
        self.pull_triggers()
        self.pull_prereqs()
        self.pull_actions()
    _trigger_update_builders = trigger(update_builders)

    def _upd_unused(self, what):
        """Make sure to have exactly one copy of every valid function in the
        "unused" pile on the right.

        Doesn't read from the database.

        :param what: a string, 'trigger', 'prereq', or 'action'

        """
        builder = getattr(self, '_{}_builder'.format(what))
        updtrig = getattr(self, '_trigger_upd_unused_{}s'.format(what))
        builder.unbind(decks=updtrig)
        funcs = OrderedDict()
        cards = list(self._action_builder.decks[1])
        cards.reverse()
        for card in cards:
            funcs[card.ud['funcname']] = card
        for card in self._action_builder.decks[0]:
            if card.ud['funcname'] not in funcs:
                funcs[card.ud['funcname']] = card.copy()
        unused = list(funcs.values())
        unused.reverse()
        builder.decks[1] = unused
        builder.bind(decks=updtrig)

    def upd_unused_actions(self, *args):
        self._upd_unused('action')
    _trigger_upd_unused_actions = trigger(upd_unused_actions)

    def upd_unused_triggers(self, *args):
        self._upd_unused('trigger')
    _trigger_upd_unused_triggers = trigger(upd_unused_triggers)

    def upd_unused_prereqs(self, *args):
        self._upd_unused('prereq')
    _trigger_upd_unused_prereqs = trigger(upd_unused_prereqs)

    def _push_funcs(self, what):
        if not self.rule:
            Logger.debug("RulesView: not pushing {} for lack of rule".format(what))
            return
        funcs = [
            card.ud['funcname'] for card in
            getattr(self, '_{}_builder'.format(what)).decks[0]
        ]
        funlist = getattr(self.rule, what+'s')
        if funlist != funcs:
            setattr(self.rule, what+'s', funcs)

    def push_actions(self, *args):
        self._push_funcs('action')
    _trigger_push_actions = trigger(push_actions)

    def push_prereqs(self, *args):
        self._push_funcs('prereq')
    _trigger_push_prereqs = trigger(push_prereqs)

    def push_triggers(self, att, *args):
        self._push_funcs('trigger')
    _trigger_push_triggers = trigger(push_triggers)
示例#54
0
class MainBox(BoxLayout):
    '''
    Mainbox class
    '''

    def __init__(self, **kwargs):
        '''
        Init main class ui
        '''
        super(MainBox, self).__init__(**kwargs)
        self.f_size = '15sp'

        # Shape Widget
        self.shape = Shape(size_hint=(0.7, 1))
        self.add_widget(self.shape)

        # Right Menu
        self.panel = TabbedPanel(size_hint=(0.3, 1), do_default_tab=False)
        self.tab_param = TabbedPanelItem(text='Parameters')
        self.tab_color = TabbedPanelItem(text='Shape')
        self.tab_color_bg = TabbedPanelItem(text='Background')
        self.tab_export = TabbedPanelItem(text='Export')
        self.panel.add_widget(self.tab_param)
        self.panel.add_widget(self.tab_color)
        self.panel.add_widget(self.tab_color_bg)
        self.panel.add_widget(self.tab_export)

        self.menu_right = RightMenu(
            padding=15,
            orientation="vertical")

        # Switch mode line
        self.box_switch = BoxLayout(orientation='horizontal')
        self.mode_label = Label(
            text="Line mode",
            font_size=self.f_size,
            markup=True)
        self.box_switch.add_widget(self.mode_label)
        self.switch_mode = Switch(active=False)
        self.switch_mode.bind(active=self.on_switch)
        self.box_switch.add_widget(self.switch_mode)
        self.menu_right.add_widget(self.box_switch)

        # Size value
        self.box_size = BoxLayout(orientation='horizontal')
        self.size_label = Label(
            text="Shape size",
            font_size=self.f_size,
            markup=True)
        self.size_label_value = Label(
            text=str(self.shape.shape_size),
            font_size=self.f_size,
            markup=True)
        self.box_size.add_widget(self.size_label)
        self.box_size.add_widget(self.size_label_value)
        self.slider_shape_size = Slider(
            min=self.shape.property('shape_size').get_min(self.shape),
            max=self.shape.property('shape_size').get_max(self.shape),
            value=self.shape.shape_size, step=1)
        self.slider_shape_size.bind(value=self.change_shape_size)
        self.menu_right.add_widget(self.box_size)
        self.menu_right.add_widget(self.slider_shape_size)

        # Width point or line
        self.box_stroke = BoxLayout(orientation='horizontal')
        self.wdth_label = Label(
            text="Stroke width",
            font_size=self.f_size,
            markup=True)
        self.wdth_label_value = Label(
            text=str(self.shape.wdth),
            font_size=self.f_size,
            markup=True)
        self.box_stroke.add_widget(self.wdth_label)
        self.box_stroke.add_widget(self.wdth_label_value)
        self.slider_wdth = Slider(
            min=self.shape.property('wdth').get_min(self.shape),
            max=self.shape.property('wdth').get_max(self.shape),
            value=self.shape.wdth, step=1)
        self.slider_wdth.bind(value=self.change_wdth)
        self.menu_right.add_widget(self.box_stroke)
        self.menu_right.add_widget(self.slider_wdth)

        # a value
        self.box_a = BoxLayout(orientation='horizontal')
        self.a_label = Label(
            text="Param a ",
            font_size=self.f_size,
            markup=True)
        self.a_label_value = Label(
            text=str(self.shape.a),
            font_size=self.f_size,
            markup=True)
        self.box_a.add_widget(self.a_label)
        self.box_a.add_widget(self.a_label_value)
        self.slider_a = Slider(
            min=self.shape.property('a').get_min(self.shape),
            max=self.shape.property('a').get_max(self.shape),
            value=self.shape.a)
        self.slider_a.bind(value=self.change_a)
        self.menu_right.add_widget(self.box_a)
        self.menu_right.add_widget(self.slider_a)

        # b value
        self.box_b = BoxLayout(orientation='horizontal')
        self.b_label = Label(
            text="Param b ",
            font_size=self.f_size,
            markup=True)
        self.b_label_value = Label(
            text=str(self.shape.b),
            font_size=self.f_size,
            markup=True)
        self.box_b.add_widget(self.b_label)
        self.box_b.add_widget(self.b_label_value)
        self.slider_b = Slider(
            min=self.shape.property('b').get_min(self.shape),
            max=self.shape.property('b').get_max(self.shape),
            value=self.shape.b)
        self.slider_b.bind(value=self.change_b)
        self.menu_right.add_widget(self.box_b)
        self.menu_right.add_widget(self.slider_b)

        # m value
        self.box_m = BoxLayout(orientation='horizontal')
        self.m_label = Label(
            text="Param m ",
            font_size=self.f_size,
            markup=True)
        self.m_label_value = Label(
            text=str(self.shape.m),
            font_size=self.f_size,
            markup=True)
        self.box_m.add_widget(self.m_label)
        self.box_m.add_widget(self.m_label_value)
        self.slider_m = Slider(
            min=self.shape.property('m').get_min(self.shape),
            max=self.shape.property('m').get_max(self.shape),
            value=self.shape.m)
        self.slider_m.bind(value=self.change_m)
        self.menu_right.add_widget(self.box_m)
        self.menu_right.add_widget(self.slider_m)

        # n1 value
        self.box_n1 = BoxLayout(orientation='horizontal')
        self.n1_label = Label(
            text="Param n1 ",
            font_size=self.f_size,
            markup=True)
        self.n1_label_value = Label(
            text=str(self.shape.n1),
            font_size=self.f_size,
            markup=True)
        self.box_n1.add_widget(self.n1_label)
        self.box_n1.add_widget(self.n1_label_value)
        self.slider_n1 = Slider(
            min=self.shape.property('n1').get_min(self.shape),
            max=self.shape.property('n1').get_max(self.shape),
            value=self.shape.n1)
        self.slider_n1.bind(value=self.change_n1)
        self.menu_right.add_widget(self.box_n1)
        self.menu_right.add_widget(self.slider_n1)

        # n2 value
        self.box_n2 = BoxLayout(orientation='horizontal')
        self.n2_label = Label(
            text="Param n2 ",
            font_size=self.f_size,
            markup=True)
        self.n2_label_value = Label(
            text=str(self.shape.n2),
            font_size=self.f_size,
            markup=True)
        self.box_n2.add_widget(self.n2_label)
        self.box_n2.add_widget(self.n2_label_value)
        self.slider_n2 = Slider(
            min=self.shape.property('n2').get_min(self.shape),
            max=self.shape.property('n2').get_max(self.shape),
            value=self.shape.n2)
        self.slider_n2.bind(value=self.change_n2)
        self.menu_right.add_widget(self.box_n2)
        self.menu_right.add_widget(self.slider_n2)

        # n3 value
        self.box_n3 = BoxLayout(orientation='horizontal')
        self.n3_label = Label(
            text="Param n3 ",
            font_size=self.f_size,
            markup=True)
        self.n3_label_value = Label(
            text=str(self.shape.n3),
            font_size=self.f_size,
            markup=True)
        self.box_n3.add_widget(self.n3_label)
        self.box_n3.add_widget(self.n3_label_value)
        self.slider_n3 = Slider(
            min=self.shape.property('n3').get_min(self.shape),
            max=self.shape.property('n3').get_max(self.shape),
            value=self.shape.n3)
        self.slider_n3.bind(value=self.change_n3)
        self.menu_right.add_widget(self.box_n3)
        self.menu_right.add_widget(self.slider_n3)

        # Nb points
        self.box_nbp = BoxLayout(orientation='horizontal')
        self.nbp_label = Label(
            text="Points number ",
            font_size=self.f_size,
            markup=True)
        self.nbp_label_value = Label(
            text=str(self.shape.nbp),
            font_size=self.f_size,
            markup=True)
        self.box_nbp.add_widget(self.nbp_label)
        self.box_nbp.add_widget(self.nbp_label_value)
        self.slider_nbp = Slider(
            min=self.shape.property('nbp').get_min(self.shape),
            max=self.shape.property('nbp').get_max(self.shape),
            value=self.shape.nbp, step=2)
        self.slider_nbp.bind(value=self.change_nbp)
        self.menu_right.add_widget(self.box_nbp)
        self.menu_right.add_widget(self.slider_nbp)

        # Percent
        self.box_percent = BoxLayout(orientation='horizontal')
        self.percent_label = Label(
            text="Percent ",
            font_size=self.f_size,
            markup=True)
        self.percent_label_value = Label(
            text=str(self.shape.percent),
            font_size=self.f_size,
            markup=True)
        self.box_percent.add_widget(self.percent_label)
        self.box_percent.add_widget(self.percent_label_value)
        self.slider_percent = Slider(
            min=self.shape.property('percent').get_min(self.shape),
            max=self.shape.property('percent').get_max(self.shape),
            value=self.shape.percent, step=1)
        self.slider_percent.bind(value=self.change_percent)
        self.menu_right.add_widget(self.box_percent)
        self.menu_right.add_widget(self.slider_percent)

        # Travel
        self.box_travel = BoxLayout(orientation='horizontal')
        self.travel_label = Label(
            text="Travel ",
            font_size=self.f_size,
            markup=True)
        self.travel_label_value = Label(
            text=str(self.shape.travel),
            font_size=self.f_size,
            markup=True)
        self.box_travel.add_widget(self.travel_label)
        self.box_travel.add_widget(self.travel_label_value)
        self.slider_travel = Slider(
            min=self.shape.property('travel').get_min(self.shape),
            max=self.shape.property('travel').get_max(self.shape),
            value=self.shape.travel, step=2)
        self.slider_travel.bind(value=self.change_travel)
        self.menu_right.add_widget(self.box_travel)
        self.menu_right.add_widget(self.slider_travel)

        # ColorPicker for Shape
        self.picker = ColorPicker()
        self.picker.bind(color=self.on_color)

        # ColorPicker for background
        self.picker_bg = ColorPicker()
        self.picker_bg.bind(color=self.on_color_bg)

        # Export svg button
        self.export_button = Button(text='Export', size_hint=(1, 0.15))
        self.export_button.bind(on_press=self.export)

        # Tab packs
        self.tab_param.add_widget(self.menu_right)
        self.tab_color.add_widget(self.picker)
        self.tab_color_bg.add_widget(self.picker_bg)
        self.tab_export.add_widget(self.export_button)
        self.add_widget(self.panel)

        # Popups
        self.pop_export = Popup(
            title="Export file",
            content=Label(text="File exported"),
            size_hint=(None, None),
            size=(640, 240))

    def change_wdth(self, *args):
        '''
        Change stroke width
        '''
        self.shape.wdth = self.slider_wdth.value
        self.wdth_label_value.text = str(self.slider_wdth.value)

    def on_switch(self, *args):
        '''
        Switch mode line or point
        '''
        self.shape.line = self.switch_mode.active

    def on_color(self, *args):
        '''
        Shape color
        '''
        self.shape.color = self.picker.hex_color

    def on_color_bg(self, *args):
        '''
        Shape background color
        '''
        self.shape.bg_color = self.picker_bg.hex_color

    def change_shape_size(self, *args):
        '''
        Shape size
        '''
        self.shape.shape_size = self.slider_shape_size.value
        self.size_label_value.text = str(self.slider_shape_size.value)

    def change_a(self, *args):
        '''
        a value
        '''
        self.shape.a = self.slider_a.value
        self.a_label_value.text = str(self.slider_a.value)

    def change_b(self, *args):
        '''
        b value
        '''
        self.shape.b = self.slider_b.value
        self.b_label_value.text = str(self.slider_b.value)

    def change_m(self, *args):
        '''
        m value
        '''
        self.shape.m = self.slider_m.value
        self.m_label_value.text = str(self.slider_m.value)

    def change_n1(self, *args):
        '''
        n1 value
        '''
        self.shape.n1 = self.slider_n1.value
        self.n1_label_value.text = str(self.slider_n1.value)

    def change_n2(self, *args):
        '''
        n2 value
        '''
        self.shape.n2 = self.slider_n2.value
        self.n2_label_value.text = str(self.slider_n2.value)

    def change_n3(self, *args):
        '''
        n3 value
        '''
        self.shape.n3 = self.slider_n3.value
        self.n3_label_value.text = str(self.slider_n3.value)

    def change_nbp(self, *args):
        '''
        point number
        '''
        self.shape.nbp = self.slider_nbp.value
        self.nbp_label_value.text = str(self.slider_nbp.value)

    def change_percent(self, *args):
        '''
        Percent value
        '''
        self.shape.percent = self.slider_percent.value
        self.percent_label_value.text = str(self.slider_percent.value)

    def change_travel(self, *args):
        '''
        Travel number
        '''
        self.shape.travel = self.slider_travel.value
        self.travel_label_value.text = str(self.slider_travel.value)

    def export(self, *args):
        '''
        Export to svg file
        '''
        document = svgwrite.Drawing(filename='export.svg', debug=True)
        tmp = [(float("%.4g" % e)) for e in self.shape.path]
        # Export polygon
        if self.shape.line:
            svg_path = coupled(tmp)
            document.add(document.polygon(points=svg_path))
        else:  # Export points
            svg_path = coupled(coupled(tmp))
            for elem in svg_path:
                document.add(document.line(
                    start=elem[0],
                    end=elem[1]
                ))
        document.save()
        self.shape.export_to_png('export.png')
        self.pop_export.open()