Ejemplo n.º 1
0
        def subscroll(self):
            """
            opens scroll list of substitute characters in a popup
            """
            for btn in SMApp.teamlist:
                if btn.state == 'down':
                    SMApp.nameOff = btn
                    btn.state = 'normal'

      
            curs.execute('SELECT * FROM Subs')
            layout2 = GridLayout(cols=2, spacing=10, size_hint_y=None)
            layout2.bind(minimum_height=layout2.setter('height'))
            for row in curs:
                btn = ToggleButton(text=str(row[0]), size_hint_y=None, height=40)
                if row[1] == 1:
                    btn.background_color = (0.5, 1, 0.9, 1)
                layout2.add_widget(btn)
                btn.bind(on_press=subChar)
                SMApp.sublist.append(btn)
                lbl = Label(text=str(row[2]), size_hinty=None, height=40)
                layout2.add_widget(lbl)
            root = ScrollView(size_hint=(None, None), size=(400, 400))
            root.add_widget(layout2)
            SMApp.popup2 = Popup(content=root, size=(7, 10), size_hint=(0.55, 0.8), title="list of subs")

            SMApp.popup2.open()
Ejemplo n.º 2
0
        def subscroll(self):
            """
            opens scroll list of substitute characters in a popup
            """
            for btn in SMApp.teamlist:
                if btn.state == 'down':
                    SMApp.nameOff = btn
                    btn.state = 'normal'

            curs.execute('SELECT * FROM Subs')
            layout2 = GridLayout(cols=2, spacing=10, size_hint_y=None)
            layout2.bind(minimum_height=layout2.setter('height'))
            for row in curs:
                btn = ToggleButton(text=str(row[0]),
                                   size_hint_y=None,
                                   height=40)
                if row[1] == 1:
                    btn.background_color = (0.5, 1, 0.9, 1)
                layout2.add_widget(btn)
                btn.bind(on_press=subChar)
                SMApp.sublist.append(btn)
                lbl = Label(text=str(row[2]), size_hinty=None, height=40)
                layout2.add_widget(lbl)
            root = ScrollView(size_hint=(None, None), size=(400, 400))
            root.add_widget(layout2)
            SMApp.popup2 = Popup(content=root,
                                 size=(7, 10),
                                 size_hint=(0.55, 0.8),
                                 title="list of subs")

            SMApp.popup2.open()
Ejemplo n.º 3
0
 def build_bouton(self, nom, couleur, i):
     b = ToggleButton(text=nom, background_normal="", background_down="")
     b.nom = nom
     b.index = i
     b.couleur = couleur
     b.background_color = b.couleur + (1, )
     b.bind(on_release=self.courbe_visibility)
     return b
Ejemplo n.º 4
0
 def load(self):
    curs.execute('SELECT * FROM Team')
    layout = GridLayout(cols=2, spacing=10, size_hint_y=None)
    layout.bind(minimum_height=layout.setter('height'))
    for row in curs:
        btn = ToggleButton(text=str(row[0]), size_hint_y=None, height=40)
        btn.bind(on_press=self.popupfunc)
        if row[1] == 1:
            btn.background_color = (0.5, 1, 0.9, 1)
        SMApp.teamlist.append(btn)
        layout.add_widget(btn)
        lbl = Label(text=str(row[2]), size_hinty=None, height=40)
        layout.add_widget(lbl)
    root1.add_widget(layout)
    self.add_widget(root1)
Ejemplo n.º 5
0
 def load(self):
     curs.execute('SELECT * FROM Team')
     layout = GridLayout(cols=2, spacing=10, size_hint_y=None)
     layout.bind(minimum_height=layout.setter('height'))
     for row in curs:
         btn = ToggleButton(text=str(row[0]), size_hint_y=None, height=40)
         btn.bind(on_press=self.popupfunc)
         if row[1] == 1:
             btn.background_color = (0.5, 1, 0.9, 1)
         SMApp.teamlist.append(btn)
         layout.add_widget(btn)
         lbl = Label(text=str(row[2]), size_hinty=None, height=40)
         layout.add_widget(lbl)
     root1.add_widget(layout)
     self.add_widget(root1)
Ejemplo n.º 6
0
    def __init__(self, **kwargs):
        super(SettingsScreen, self).__init__(**kwargs)

        self.last_press = 0.0  # Used for double click detection

        size_win = Window.size
        s = float(size_win[1]) / 720
        std_h = int(size_win[1] / 22.)  #int(0.075 * size_win[1])
        btn_h = int(size_win[1] / 8.)

        main_l = GridLayout(cols=1,
                            padding=25,
                            spacing=50,
                            size_hint=(None, None),
                            size=Window.size,
                            pos_hint={
                                'center_x': 0.5,
                                'center_y': 0.5
                            })
        #main_l.bind(minimum_height=main_l.setter('height'))

        colors = [list(c) + [1] for c in standard_color_theme()]

        # The color selection
        color_label = Label(text='COLOR THEME',
                            font_size=40 * s,
                            size_hint_y=None,
                            height=std_h,
                            color=colors[8])
        main_l.add_widget(color_label)

        color_dropdown = DropDown()
        tn = ['Random'] + theme_names
        st = [[(0.8, 0.8, 0.8)] * 5 + [(0.1, 0.1, 0.1)] * 4
              ] + sequential_themes

        color_select_btn = Button(text='Random',
                                  size_hint_y=None,
                                  height=btn_h,
                                  font_size=40 * s,
                                  color=list(st[0][7]) + [1.0])
        color_select_btn.background_color = list(st[0][4]) + [1.0]
        color_select_btn.background_normal = ''
        color_select_btn.background_down = ''

        color_select_btn.bind(on_release=color_dropdown.open)
        color_dropdown.bind(
            on_select=lambda instance, x: setattr(color_select_btn, 'text', x))

        for name, theme in zip(tn, st):
            theme_btn = Button(text=name,
                               size_hint_y=None,
                               height=btn_h,
                               font_size=40 * s,
                               color=list(theme[7]) + [1.0])
            theme_btn.background_color = list(theme[4]) + [1.0]
            theme_btn.background_normal = ''
            theme_btn.background_down = ''

            theme_btn.bind(
                on_release=lambda btn: color_dropdown.select(btn.text))
            theme_btn.bind(on_release=lambda btn: setattr(
                color_select_btn, 'background_color', btn.background_color))
            theme_btn.bind(on_release=lambda btn: setattr(
                color_select_btn, 'color', btn.color))
            color_dropdown.add_widget(theme_btn)

        self.color_select_btn = color_select_btn
        main_l.add_widget(self.color_select_btn)

        # Disable prediction
        btn = ToggleButton(text='STANDARD MODE',
                           on_press=self.change_prediction,
                           size_hint_y=None,
                           height=btn_h,
                           font_size=40 * s,
                           color=colors[0])
        btn.background_color = colors[5]
        btn.background_normal = ''
        btn.background_down = ''
        main_l.add_widget(btn)

        # Reset highscore
        btn = Button(text='RESET HIGHSCORE (double tap)',
                     on_press=self.reset_highscore,
                     size_hint_y=None,
                     height=btn_h,
                     font_size=40 * s,
                     color=colors[0])
        btn.background_color = (0.6, 0.1, 0.1, 1.0)
        btn.background_normal = ''
        btn.background_down = ''
        main_l.add_widget(btn)

        # Credits
        credits = Label(text='CODE & ART: Oliver Dressler',
                        font_size=40 * s,
                        size_hint_y=None,
                        height=std_h,
                        color=colors[8])
        main_l.add_widget(credits)

        # Return btn
        btn = Button(text='return',
                     on_press=self.return_to_main,
                     size_hint_y=None,
                     height=btn_h,
                     font_size=40 * s,
                     color=colors[0])
        btn.background_color = colors[5]
        btn.background_normal = ''
        btn.background_down = ''
        main_l.add_widget(btn)
        self.add_widget(main_l)
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
    def add_member_list(self, _id, _name, _kivy=None, _msg=None):
        if _kivy is None:
            _kivy = self
        if _id in self.chat_record.keys():
            # 已经存在的聊天,只需要修改顺序和颜色
            # 新消息提醒,按钮底色变红
            for i in self.ids.member_list.children:
                # i 是boxlayout
                if i.children[0]._id == _id:
                    # 将新消息放在最前 ,children[0]为一个,没考虑永久置顶的因素
                    self.ids.member_list.remove_widget(i)
                    self.ids.member_list.add_widget(i)

                    # 将新消息底色标黄
                    if _name not in self.mute_array:
                        i.children[0].background_color = [2, 2, 0, 1]
                    return i
        else:
            # 不存在的聊天,需要新增
            self.member_item_count = self.member_item_count + 1
            if _id[0:2] == '@@':
                _icon_path = os.path.join('group', _name, 'icon', 'main.jpg')
            else:
                _icon_path = os.path.join('client', _name, 'icon', 'main.jpg')

            _hint = (self.member_item_height -
                     10) / self.kivy_config_layout['LayoutSize']['left_size']
            MemberList_ToggleButton_Image = AsyncImage(
                source=_icon_path,
                nocache=True,
                size_hint_x=_hint,
                size_hint_y=None,
                size=[self.member_item_height, self.member_item_height])

            MemberList_ToggleButton = ToggleButton(
                text=_name,
                height=self.member_item_height,
                group='cmcc',
                size_hint_x=1 - _hint,
                size_hint_y=None,
                valign='top')
            MemberList_ToggleButton.texture_update()
            MemberList_ToggleButton.text_size = [
                self.kivy_config_layout['LayoutSize']['left_size'] -
                self.member_item_height - 10, self.member_item_height - 10
            ]
            MemberList_ToggleButton._id = _id
            MemberList_ToggleButton.bind(on_release=self.member_list_change)
            if _name not in self.mute_array:
                MemberList_ToggleButton.background_color = [2, 2, 0, 1]

            _box = BoxLayout(size_hint_x=1,
                             size_hint_y=None,
                             height=self.member_item_height,
                             padding=[0, 5, 0, 5])

            _box.add_widget(MemberList_ToggleButton_Image)
            _box.add_widget(MemberList_ToggleButton)
            self.ids.member_list.add_widget(_box)

            self.chat_record.update({_id: None})

            if self.member_list_current is None:
                self.member_list_current = MemberList_ToggleButton

            return MemberList_ToggleButton