Exemplo n.º 1
0
    def finished_init(self, winner_index):
        """
        游戏结束的初始化
        """
        # 初始化标签
        self.finished_label = widget.Label(parent=self.screen)
        self.finished_label.initialization(
            x=100,
            y=300,
            text="Winner: " + self.game_player_list[winner_index].name,
            font=self.font1,
            color=pygame.Color('red'))

        # 初始化按钮
        self.finishe_button = widget.PushButton(parent=self.screen)
        self.finishe_button.initialization(x=630,
                                           y=550,
                                           text="Ok",
                                           font=self.font1,
                                           font_color=pygame.Color('yellow'),
                                           bg_color=pygame.Color('blue'))
Exemplo n.º 2
0
    def __init__(self, canvas, name, color, index, display, trackables):
        self.listeners = []

        self.canvas = canvas
        self.name = name
        self.color = color
        self.text_color = Gcolor.darken(self.color.mix(self.color.WHITE, 0.5),
                                        0.1)
        self.text = self.FONT.render(name, True, self.text_color)
        self.index = index
        self.display = self.gjoin(display)

        widget_list = [widget.Label(self.name, self.color)]
        '''
        if self.ptype == "Camera":
            widget_list+= [
                widget.Scrollbar("Lock on", self.color, trackable[1], False, gsignal.ACTION, trackable) ]
        '''

        #TODO: consertar esta desgraça de gambiarra que estou fazendo:
        Panel.DEBUGAUDIOTRACK = trackables

        self.active = False
        self.mouse_over = False
        self.busy = False
        self.tick = 0
        self.tick2 = 0

        if self.name == "Audio":
            widget_list += [
                widget.Scrollbar("Track:", self.color,
                                 Panel.DEBUGAUDIOTRACK.tracknames, True,
                                 Panel.DEBUGAUDIOTRACK),
                widget.StaticGraph(self.color, [-1, 1],
                                   ["Tempo", "Intensidade"],
                                   Panel.DEBUGAUDIOTRACK.trackablegraph,
                                   Panel.DEBUGAUDIOTRACK), None, None, None,
                None,
                widget.Scrollbar("Display:",
                                 self.color,
                                 Panel.DEBUGAUDIOTRACK.displaymode,
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.SELECT2),
                widget.BoundButton('Play', self.color, Panel.DEBUGAUDIOTRACK,
                                   gsignal.ACTION)
            ]

        if self.name == "Recording":
            widget_list += [
                widget.DynamicGraph2(self.color, [-1, 1],
                                     ["Tempo", "Intensidade"],
                                     Panel.DEBUGAUDIOTRACK), None, None, None,
                None,
                widget.BoundButton('Record', self.color, Panel.DEBUGAUDIOTRACK,
                                   gsignal.ACTION2),
                widget.Scrollbar("Display:",
                                 self.color,
                                 Panel.DEBUGAUDIOTRACK.displaymode,
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.SELECT2),
                widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK,
                                   gsignal.SAVE)
            ]

        if self.name == "Modulation":
            widget_list += [
                widget.Scrollbar("Track:", self.color,
                                 Panel.DEBUGAUDIOTRACK.tracknames, True,
                                 Panel.DEBUGAUDIOTRACK),
                widget.StaticGraph(self.color, [-1, 1],
                                   ["Tempo", "Intensidade"],
                                   Panel.DEBUGAUDIOTRACK.trackablegraph,
                                   Panel.DEBUGAUDIOTRACK), None, None, None,
                None,
                widget.Scrollbar("Display:",
                                 self.color,
                                 Panel.DEBUGAUDIOTRACK.displaymode,
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.SELECT2),
                widget.Scrollbar("Set as:",
                                 self.color,
                                 gsignal.Trackable(["Signal", "Carrier"]),
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.SELECT4),
                widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK,
                                   gsignal.ACTION3)
            ]

        if self.name == "Demodulation":
            widget_list += [
                widget.Scrollbar("Track:", self.color,
                                 Panel.DEBUGAUDIOTRACK.tracknames, True,
                                 Panel.DEBUGAUDIOTRACK),
                widget.StaticGraph(self.color, [-1, 1],
                                   ["Tempo", "Intensidade"],
                                   Panel.DEBUGAUDIOTRACK.trackablegraph,
                                   Panel.DEBUGAUDIOTRACK), None, None, None,
                None,
                widget.Scrollbar("Display:",
                                 self.color,
                                 Panel.DEBUGAUDIOTRACK.displaymode,
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.SELECT2),
                widget.Scrollbar("Break in: ",
                                 self.color,
                                 Panel.DEBUGAUDIOTRACK.breakin,
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.NOACT),
                widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK,
                                   gsignal.ACTION5)
            ]

        if self.name == "Add Waves":
            widget_list += [
                widget.Scrollbar("Track:", self.color,
                                 Panel.DEBUGAUDIOTRACK.tracknames, True,
                                 Panel.DEBUGAUDIOTRACK),
                widget.StaticGraph(self.color, [-1, 1],
                                   ["Tempo", "Intensidade"],
                                   Panel.DEBUGAUDIOTRACK.trackablegraph,
                                   Panel.DEBUGAUDIOTRACK), None, None, None,
                None,
                widget.Scrollbar("Display:",
                                 self.color,
                                 Panel.DEBUGAUDIOTRACK.displaymode,
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.SELECT2),
                widget.Scrollbar("Set as:",
                                 self.color,
                                 gsignal.Trackable(
                                     ["First Signal", "Second Signal"]),
                                 True,
                                 Panel.DEBUGAUDIOTRACK,
                                 signal=gsignal.SELECT4),
                widget.BoundButton('Save', self.color, Panel.DEBUGAUDIOTRACK,
                                   gsignal.ACTION4)
            ]
        '''
        if self.ptype == "Erase":
            widget1= widget.BoundButton("Confirm", self.color, tracable, gsignal.DELETE, )
            widget2= widget.Scrollbar("Erase", self.color, trackable[0], False, gsignal.ACTION, widget1)
            widget_list+= [ widget2, widget1 ]
        '''

        #if self.ptype == "Create":
        #    widget_list+= [

        self.banner = Banner(self.text, self.color,
                             pygame.Surface((Banner.WIDTH, Banner.HEIGTH)))

        self.body = self.gjoin(
            Body(self.text, self.text_color, self.color, widget_list))
Exemplo n.º 3
0
    def game_init(self):
        """
        游戏状态下的初始化函数
        """
        # 初始化游戏的各个类
        sp.Player.initialization()
        sp.Token.initialization()
        sp.Card.initialization()
        sp.Noble.initialization()
        sp.CardChanger.initialization()

        # 初始化玩家的位置
        self.game_player_pos = [[10, 110], [830, 110], [10, 340], [830, 340]]
        # 初始化玩家列表
        self.game_player_list = []
        for index in range(4):
            game_player = sp.Player(parent=self.screen,
                                    name="",
                                    x=self.game_player_pos[index][0],
                                    y=self.game_player_pos[index][1])
            self.game_player_list.append(game_player)

        # 初始化贵族的位置
        self.game_noble_pos = [[200, 30], [285, 30], [370, 30], [455, 30],
                               [540, 30]]
        # 初始化贵族
        self.game_noble_list = []
        for index in range(5):
            game_noble = sp.Noble(parent=self.screen,
                                  x=self.game_noble_pos[index][0],
                                  y=self.game_noble_pos[index][1])
            self.game_noble_list.append(game_noble)

        # 初始化筹码的位置
        self.game_token_pos = [[200, 130], [305, 130], [410, 130], [515, 130],
                               [620, 130], [725, 130]]
        # 初始化筹码
        self.game_token_list = []
        for index in range(6):
            game_token = sp.Token(parent=self.screen,
                                  color=index,
                                  x=self.game_token_pos[index][0],
                                  y=self.game_token_pos[index][1])
            self.game_token_list.append(game_token)

        # 初始化卡牌的位置
        self.game_card_pos = [[[305, 240], [410, 240], [515, 240], [620, 240]],
                              [[305, 405], [410, 405], [515, 405], [620, 405]],
                              [[305, 570], [410, 570], [515, 570], [620, 570]]]
        # 初始化卡牌
        self.game_card_list = []
        for level in range(3):
            # 三种不同的卡片
            card_level = []
            for card_index in range(4):
                # 每种卡片有4张
                card = sp.Card(parent=self.screen,
                               x=self.game_card_pos[level][card_index][0],
                               y=self.game_card_pos[level][card_index][1])
                card_level.append(card)
            self.game_card_list.append(card_level)

        # 初始化标签
        self.game_label = []
        for index in range(12):
            self.game_label.append(widget.Label(parent=self.screen))
        # 初始化4个玩家标签
        self.game_label[0].initialization(x=10,
                                          y=90,
                                          text="Player 1",
                                          font=self.font1,
                                          color=pygame.Color('blue'))
        self.game_label[1].initialization(x=830,
                                          y=90,
                                          text="Player 2",
                                          font=self.font1,
                                          color=pygame.Color('blue'))
        self.game_label[2].initialization(x=10,
                                          y=320,
                                          text="Player 3",
                                          font=self.font1,
                                          color=pygame.Color('blue'))
        self.game_label[3].initialization(x=830,
                                          y=320,
                                          text="Player 4",
                                          font=self.font1,
                                          color=pygame.Color('blue'))
        # 初始化noble标签
        self.game_label[4].initialization(x=200,
                                          y=10,
                                          text="Noble",
                                          font=self.font1,
                                          color=pygame.Color('blue'))
        # 初始化token标签
        self.game_label[5].initialization(x=200,
                                          y=110,
                                          text="Token",
                                          font=self.font1,
                                          color=pygame.Color('blue'))
        # 初始化3种card的数量标签
        self.game_label[6].initialization(x=200,
                                          y=310,
                                          text="Level 1: ",
                                          font=self.font1,
                                          color=pygame.Color('green'))
        self.game_label[7].initialization(x=200,
                                          y=475,
                                          text="Level 2: ",
                                          font=self.font1,
                                          color=pygame.Color('green'))
        self.game_label[8].initialization(x=200,
                                          y=640,
                                          text="Level 3: ",
                                          font=self.font1,
                                          color=pygame.Color('green'))
        # 初始化指示自己姓名的标签
        self.game_label[9].initialization(x=10,
                                          y=10,
                                          text="I am " + self.game_myName,
                                          font=self.font1,
                                          color=pygame.Color('red'))
        # 初始化游戏轮次指示器
        self.game_label[10].initialization(x=10,
                                           y=40,
                                           text=" ",
                                           font=self.font1,
                                           color=pygame.Color('green'))
        # 初始化提示器
        self.game_label[11].initialization(x=830,
                                           y=10,
                                           text="Hint:",
                                           font=self.font1,
                                           color=pygame.Color('green'))

        # 初始化轮次
        self.game_turn = 0
        # 初始化自己的轮次
        self.game_my_turn_num = 0
        # 初始化过程控制器
        try:
            # 进行这样的try是为了防止房间发来的当前回合信息比游戏开始信息来的更早而重置了game_my_turn的值
            if self.game_my_turn == True:
                pass
        except AttributeError:
            # 初始化是否是自己的回合的指示器
            self.game_my_turn = False
            # 初始化提示器状态
            self.game_hint_state = -1
        # 初始化操作指示器
        self.game_operation = 0
        # 初始化筹码选择器
        self.game_token_cart = []
        # 初始化卡牌选择器
        self.game_card_cart = []

        # 初始化按钮
        self.game_button_list = []
        for index in range(6):
            self.game_button_list.append(widget.PushButton(parent=self.screen))
        # 初始化“take 3”按钮
        self.game_button_list[0].initialization(
            x=1030,
            y=380,
            text="Take 3",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化“take 2”按钮
        self.game_button_list[1].initialization(
            x=1030,
            y=410,
            text="Take 2",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化“reserve”按钮
        self.game_button_list[2].initialization(
            x=1030,
            y=440,
            text="Reserve",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化“change”按钮
        self.game_button_list[3].initialization(
            x=1030,
            y=470,
            text="Change",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化“skip”按钮
        self.game_button_list[4].initialization(
            x=1030,
            y=500,
            text="Skip",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化“Confirm”按钮
        self.game_button_list[5].initialization(
            x=1030,
            y=530,
            text="Confirm",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))

        # 初始化换牌器
        self.game_card_changer = sp.CardChanger(parent=self.screen,
                                                pos=[725, 570])
Exemplo n.º 4
0
    def connection_init(self):
        """
        这个函数是用来对服务器连接阶段可视化窗口需要用到的变量进行初始化的
        """
        # 文本框
        self.connection_text_field = [
            widget.TextField(self.screen),
            widget.TextField(self.screen)
        ]
        # 初始化第1个文本框(地址文本框)
        self.connection_text_field[0].initialization(
            x=200,
            y=50,
            width=150,
            height=30,
            status_x=400,
            status_y=50,
            max_len=16,
            eff_in=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'],
            font=self.font1,
            cursor_width=5)
        # 初始化第2个文本框(端口文本框)
        self.connection_text_field[1].initialization(
            x=200,
            y=100,
            width=150,
            height=30,
            status_x=400,
            status_y=100,
            max_len=16,
            eff_in=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
            font=self.font1,
            cursor_width=5)

        # 文字标签
        self.connection_label = [
            widget.Label(self.screen),
            widget.Label(self.screen)
        ]
        # 初始化地址输入提示词
        self.connection_label[0].initialization(x=50,
                                                y=50,
                                                text="host address:",
                                                font=self.font1,
                                                color=pygame.Color("blue"))
        # 初始化端口输入提示词
        self.connection_label[1].initialization(x=50,
                                                y=100,
                                                text="port number:",
                                                font=self.font1,
                                                color=pygame.Color("blue"))

        # 按钮
        self.connection_button = [
            widget.PushButton(self.screen),
            widget.PushButton(self.screen)
        ]
        # 初始化确认按钮
        self.connection_button[0].initialization(
            x=150,
            y=250,
            text="Confirm",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化与取消按钮
        self.connection_button[1].initialization(
            x=250,
            y=250,
            text="Cancel",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
Exemplo n.º 5
0
    def room_init(self):
        """
        当客户端处于房间状态时的初始化函数
        """
        # 房间号
        self.room_num = ""
        # 玩家列表控件
        self.room_player_list = []
        # 玩家准备状态
        self.room_ready = False

        # 房间号标签
        self.room_label_list = []
        for index in range(14):
            self.room_label_list.append(widget.Label(self.screen))
        # 房间号指示标签
        self.room_label_list[0].initialization(x=50,
                                               y=50,
                                               text="Room #",
                                               font=self.font1,
                                               color=pygame.Color('blue'))
        # 房间号标签
        self.room_label_list[1].initialization(x=150,
                                               y=50,
                                               text="",
                                               font=self.font1,
                                               color=pygame.Color('blue'))
        # 玩家显示标签
        for p_index in range(4):
            # player标签
            self.room_label_list[2 + 3 * p_index + 0].initialization(
                x=50,
                y=100 + 50 * p_index,
                text="player:",
                font=self.font1,
                color=pygame.Color('blue'))
            # 玩家名称标签
            self.room_label_list[2 + 3 * p_index + 1].initialization(
                x=150,
                y=100 + 50 * p_index,
                text="",
                font=self.font1,
                color=pygame.Color('red'))
            # 准备标签
            self.room_label_list[2 + 3 * p_index + 2].initialization(
                x=300,
                y=100 + 50 * p_index,
                text="",
                font=self.font1,
                color=pygame.Color('green'))

        # 按钮控件
        self.room_button_list = []
        for index in range(2):
            self.room_button_list.append(widget.PushButton(self.screen))
        # 准备按钮
        self.room_button_list[0].initialization(
            x=150,
            y=350,
            text='Ready',
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 退出按钮
        self.room_button_list[1].initialization(
            x=250,
            y=350,
            text='Quit',
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
Exemplo n.º 6
0
    def room_allocation_init(self):
        """
        房间分配的初始化函数
        """
        # 按钮
        self.room_allocation_button = []
        for index in range(4):
            self.room_allocation_button.append(widget.PushButton(self.screen))
        # 初始化确定按钮
        self.room_allocation_button[0].initialization(
            x=150,
            y=300,
            text="Confirm",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化取消按钮
        self.room_allocation_button[1].initialization(
            x=250,
            y=300,
            text="Quit",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化选项卡中的Create按钮
        self.room_allocation_button[2].initialization(
            x=50,
            y=50,
            text="Create",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))
        # 初始化选项卡中的Join按钮
        self.room_allocation_button[3].initialization(
            x=130,
            y=50,
            text="Join",
            font=self.font1,
            font_color=pygame.Color('yellow'),
            bg_color=pygame.Color('blue'))

        # 初始化选项卡
        # 选项卡的选中状态 0:Create, 1:Join
        self.tab_combo_status = 0

        # 文字标签
        self.room_allocation_label = []
        for index in range(4):
            self.room_allocation_label.append(widget.Label(self.screen))
        # 设置人数标签
        self.room_allocation_label[0].initialization(
            x=50,
            y=100,
            text="Player # (2~4)",
            font=self.font1,
            color=pygame.Color('blue'))
        # 设置房间号码标签
        self.room_allocation_label[1].initialization(
            x=50,
            y=100,
            text="Room # (4 digits)",
            font=self.font1,
            color=pygame.Color('blue'))
        # 设置房间密码标签
        self.room_allocation_label[2].initialization(
            x=50,
            y=150,
            text="Password (6 digits)",
            font=self.font1,
            color=pygame.Color('blue'))
        # 设置用户名标签
        self.room_allocation_label[3].initialization(
            x=50,
            y=200,
            text="User Name",
            font=self.font1,
            color=pygame.Color('blue'))

        # 文本框
        self.room_allocation_text_field = []
        for index in range(4):
            self.room_allocation_text_field.append(
                widget.TextField(self.screen))
        # 初始化第1个文本框(玩家数量)
        self.room_allocation_text_field[0].initialization(
            x=250,
            y=100,
            width=100,
            height=30,
            status_x=380,
            status_y=100,
            max_len=1,
            eff_in=['2', '3', '4'],
            font=self.font1,
            cursor_width=5)
        # 初始化第2个文本框(房间名称)
        self.room_allocation_text_field[1].initialization(
            x=250,
            y=100,
            width=100,
            height=30,
            status_x=380,
            status_y=100,
            max_len=4,
            eff_in=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
            font=self.font1,
            cursor_width=5)
        # 初始化第3个文本框(房间密码)
        self.room_allocation_text_field[2].initialization(
            x=250,
            y=150,
            width=100,
            height=30,
            status_x=380,
            status_y=150,
            max_len=6,
            eff_in=['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],
            font=self.font1,
            cursor_width=5)
        # 初始化第4个文本框(用户名)
        self.room_allocation_text_field[3].initialization(
            x=250,
            y=200,
            width=100,
            height=30,
            status_x=380,
            status_y=200,
            max_len=8,
            eff_in=[
                '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b',
                'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
                'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
                'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
                'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X',
                'Y', 'Z'
            ],
            font=self.font1,
            cursor_width=5)
Exemplo n.º 7
0
    def __init__(self, canvas, ptype, color, index, listener):

        self.canvas = canvas
        self.ptype = ptype
        self.color = color
        self.text_color = Gcolor.darken(self.color.mix(self.color.WHITE, 0.5),
                                        0.1)
        self.text = self.FONT.render(ptype, True, self.text_color)
        self.index = index
        self.listener = listener

        widget_list = [widget.Label(self.ptype, self.color)]

        if self.ptype == "Camera":
            from celestial_cluster import CelestialCluster
            from perspective import Perspective
            widget_list += [
                widget.Scrollbar("Lock on", self.color,
                                 CelestialCluster.cluster, False,
                                 gsignal.ACTION, Perspective)
            ]

        elif self.ptype == "Graph":
            from celestial_cluster import CelestialCluster
            widget_list += [
                widget.Scrollbar("Measure", self.color,
                                 CelestialCluster.word_list, True,
                                 gsignal.WATCH0, CelestialCluster),
                widget.Scrollbar("Between", self.color,
                                 CelestialCluster.cluster, False,
                                 gsignal.WATCH1, CelestialCluster),
                widget.Scrollbar("And", self.color, CelestialCluster.cluster,
                                 False, gsignal.WATCH2, CelestialCluster),
                widget.DynamicGraph(self.color, CelestialCluster), None, None,
                None, None
            ]

        elif self.ptype == "Erase":
            from celestial_cluster import CelestialCluster
            widget1 = widget.BoundButton(
                "Confirm",
                self.color,
                CelestialCluster,
                gsignal.DELETE,
            )
            widget2 = widget.Scrollbar("Erase", self.color,
                                       CelestialCluster.cluster, False,
                                       gsignal.ACTION, widget1)
            widget_list += [widget2, widget1]
        #if self.ptype == "Create":
        #    widget_list+= [

        self.banner = Banner(self.text, self.color,
                             pygame.Surface((Banner.WIDTH, Banner.HEIGTH)))
        self.body = Body(self.text, self.text_color, self.color, widget_list)

        self.active = False
        self.mouse_over = False
        self.busy = False
        self.tick = 0
        self.tick2 = 0
Exemplo n.º 8
0
    def todo_item(self,
                  todo_id=None,
                  title=None,
                  description=None,
                  is_done=None,
                  is_important=None):
        """New item window."""
        window_subtitle = "New Item"
        save_btn = widget.Button("button_blue", "Save")
        header_btns = {save_btn: "left"}
        if todo_id is not None:
            del_btn = widget.Button("button_red", "Delete")
            del_btn.on_click(self.__action.del_item, *(self, "del", todo_id))
            header_btns.update({del_btn: "left"})
            window_subtitle = "Edit Item"

        window = widget.Window("Main", "MTodo", window_subtitle, 500, 480,
                               header_btns, False)
        self.__windows["todo_item"] = window
        box = widget.Box("new_data", True)
        switch_box = widget.Box("switch_data", True)

        title_text = widget.Input("title", "Title", False)
        title_text.set_text(title)

        description_text = widget.Input("description", "Description", True)
        description_text.set_text(description)

        is_done_switch = widget.Switch("is_done")
        is_done_switch.set_value(is_done)
        is_done_label = widget.Label("is_done_label", "Is done")
        is_done_box = widget.Box("is_done_data", False)

        is_important_switch = widget.Switch("is_important")
        is_important_switch.set_value(is_important)
        is_important_label = widget.Label("is_important_label", "Is Important")
        is_important_box = widget.Box("is_important_data", False)

        is_done_box.join(is_done_label, True, True)
        is_done_box.join(is_done_switch)

        is_important_box.join(is_important_label, True, True)
        is_important_box.join(is_important_switch)

        box.join(title_text)
        box.join(description_text)
        switch_box.join(is_important_box)
        switch_box.join(is_done_box)

        if todo_id is None:
            save_btn.on_click(
                self.__action.add_item,
                *(self, "save", title_text, description_text, is_done_switch,
                  is_important_switch))
        else:
            save_btn.on_click(
                self.__action.edit_item,
                *(self, "save", todo_id, title_text, description_text,
                  is_done_switch, is_important_switch))
        window.join(box)
        window.join(switch_box)
        window.render()
Exemplo n.º 9
0
 def log(self, text):
     self.container.append(widget.Label("> " + text, 0, 0))