def __init__(self, app, game_controller, user_interaction, *args,
                 **kwargs):
        super().__init__(*args, **kwargs)
        '''
        params:-
            app : Visualliser : Object that has spawned this one
            game_controller : Game assigned to this board
            user_interaction : bool : True if you want the user to be able to interact with the visuals else False
        '''
        self.cols = 2

        board_grid = GridLayout()

        self.app = app
        self.game_controller = game_controller

        # will hold all squares created by below function for later callback
        self.squares = []

        board_map = game_controller.get_map()

        # Makes a vertical board
        board_grid.cols = board_map._size[0]
        board_grid.rows = board_map._size[1] * board_map._size[2]

        # Loops through all map coords
        for z, y, x in loops(range(board_map._size[2]),
                             range(board_map._size[1]),
                             range(board_map._size[0])):

            current = board_map.get_gridpoi(x, y, z)

            temp = Square(app, game_controller, x, y, z)
            temp.update_square(x, y, z, current)
            self.squares.append(temp)

            board_grid.add_widget(temp)

        self.add_widget(board_grid)

        if user_interaction:
            attack_board_ui = GridLayout()
            attack_board_ui.size_hint_x = None
            attack_board_ui.width = 50

            attack_board_ui.cols = len(board_map._get_attack_board_array()[0])
            attack_board_ui.rows = len(board_map._get_attack_board_array())

            for y, x in loops(
                    range(len(board_map._get_attack_board_array())),
                    range(len(board_map._get_attack_board_array()[0]))):

                temp = Square(app, game_controller, x, y, 'AttackBoard')
                attack_board_ui.add_widget(temp)

            self.add_widget(attack_board_ui)
Esempio n. 2
0
    def __init__(self):
        super(AttributeViewer, self).__init__()
        self.Name = Label()
        self.Category = Label(text="")

        self.cols = 1
        self.rows = 6

        Spheres = GridLayout()
        Spheres.rows = 1
        Spheres.cols = 4
        self.coloredSpheres = {
            "oligos": Sphere(Spheres),
            "fructose": Sphere(Spheres),
            "polyols": Sphere(Spheres),
            "lactose": Sphere(Spheres)
        }
        Spheres.add_widget(self.coloredSpheres['oligos'])
        Spheres.add_widget(self.coloredSpheres['fructose'])
        Spheres.add_widget(self.coloredSpheres['polyols'])
        Spheres.add_widget(self.coloredSpheres['lactose'])

        subtitles = Label(text="oligos/fructose/polyols/lactose")

        self.add_widget(self.Name)
        self.add_widget(self.Category)
        self.add_widget(Label())
        self.add_widget(Label(text="Content:"))
        self.add_widget(subtitles)
        self.add_widget(Spheres)
Esempio n. 3
0
 def test_gridlayout_get_max_widgets_with_rows_cols(self):
     gl = GridLayout()
     gl.rows = 5
     gl.cols = 3
     expected = 15
     value = gl.get_max_widgets()
     self.assertEqual(expected, value)
Esempio n. 4
0
    def on_enter(self):
        gen = Generator()
        edit_grid = GridLayout()
        edit_grid.cols = 4
        edit_grid.rows = 4
        edit_grid.padding = 10
        for key in gen.lst:
            box = BoxLayout()
            box.orientation = 'vertical'
            box.padding = 10

            label = Label()
            label.text = key
            label.size_hint = (1, .25)

            text_input = EditorText()
            text_input.multiline = True
            text_input.text = self.get_values(gen.lst[key])
            text_input.id = key

            button = Button(text='Submit')
            button.size_hint = (1, .25)
            button.bind(on_press=text_input.update_item)

            box.add_widget(label)
            box.add_widget(text_input)
            box.add_widget(button)
            edit_grid.add_widget(box)

        button = Button()
        button.text = 'Done'
        button.size_hint = (1, .25)
        button.bind(on_press=self.load_art_tools_main)
        edit_grid.add_widget(button)
        self.add_widget(edit_grid)
Esempio n. 5
0
    def setup(self):
        self.cols = 1
        self.rows = 2

        self.turn_label = Label(text='[b]Turn:[/b] [color='+ self.player_color[self.game.turn] + ']' \
        + self.player_name[self.game.turn] + '[/color]', markup=True)

        self.turn_label.font_size = 48

        inner_layout = GridLayout()
        inner_layout.rows = 3
        inner_layout.cols = 3
        inner_layout.padding = (8, 8)

        for x in range(3):
            for y in range(3):
                self.button_matrix[x][y] = Button(
                    text="" + str(self.game.board_matrix[x][y]),
                    font_size=48,
                    markup=True)
                if self.game.board_matrix[x][y] != "-":
                    # Player 2 (AI) can have already placed his first move
                    self.button_matrix[x][
                        y].text = '[b][color=' + self.player_color[
                            2] + ']' + self.player_symbol[2] + '[/color][/b]'

                self.button_matrix[x][y].bind(
                    on_press=partial(self.button_pressed, x, y))
                inner_layout.add_widget(self.button_matrix[x][y])
        self.add_widget(self.turn_label)
        inner_layout.size_hint = (2.5, 2)
        self.add_widget(inner_layout)
Esempio n. 6
0
	def setup(self):
		self.cols = 1
		self.rows = 2
		
		title_label = Label (text='[b]Forza[/b] [color=ff3333]4[/color]', markup=True)
		title_label.font_size = 42
		
		inner_layout = GridLayout()
		inner_layout.rows = 3
		inner_layout.cols = 3
		inner_layout.padding = (16, 16)
		
		single_button = Button(text = "[b]SinglePlayer[/b]", markup=True)
		single_button.font_size = 24
		single_button.bind(on_press=partial (start_game, 1))
	
		multi_button = Button(text = "[b]MultiPlayer[/b]", markup=True)
		multi_button.font_size = 24
		multi_button.bind(on_press=partial (start_game, 2))
			
		exit_button = Button(text = "[b]Exit[/b]", markup=True)
		exit_button.font_size = 24
		exit_button.bind(on_press=close_app)

		self.add_widget(title_label)
		inner_layout.add_widget(Label())
		inner_layout.add_widget(Label())
		inner_layout.add_widget(Label())
		inner_layout.add_widget(single_button)
		inner_layout.add_widget(multi_button)
		inner_layout.add_widget(exit_button)
		inner_layout.add_widget(Label())
		inner_layout.add_widget(Label())
		inner_layout.add_widget(Label())
		self.add_widget(inner_layout)
Esempio n. 7
0
    def open_private(self, instance):
        self.popup = Popup(title="Private Lobby")
        self.popup.size = (40, 40)

        content = GridLayout()
        self.popup.content = content
        content.cols = 2
        content.rows = 3
        content.padding = 100

        self.name_input = TextInput(multiline=False)
        self.name_label = Label(text="Name:")
        content.add_widget(self.name_label)
        content.add_widget(self.name_input)

        self.room_id_input = TextInput(multiline=False)
        self.room_label = Label(text="Room Code:")
        content.add_widget(self.room_label)
        content.add_widget(self.room_id_input)

        content.add_widget(Button(text="Back", on_press=self.popup.dismiss))

        # send name and room id to server to join lobby
        content.add_widget(
            Button(text="Join Private Lobby",
                   on_press=lambda event: send_msg(
                       self.client_socket,
                       Message(TAG='LOBBYREQUEST',
                               name=self.name_input.text,
                               roomid=self.room_id_input.text))))

        self.popup.open()
Esempio n. 8
0
 def test_gridlayout_get_max_widgets_with_rows_cols(self):
     gl = GridLayout()
     gl.rows = 5
     gl.cols = 3
     expected = 15
     value = gl.get_max_widgets()
     self.assertEqual(expected, value)
    def addButtonRow(self):
        buttonRow=GridLayout()
        buttonRow.rows=1

        sortingAlphabetBtn=Button(text="Sort Alphabet")
        sortingAlphabetBtn.on_press=self.sortingAlphabet
        buttonRow.add_widget(sortingAlphabetBtn)

        refreshBtn=Button(text="Refresh")
        refreshBtn.on_press=self.refresh
        buttonRow.add_widget(refreshBtn)

        addNewStockBtn=Button(text="Add/Edit Stock")
        addNewStockBtn.on_press=self.addNewStock
        buttonRow.add_widget(addNewStockBtn)

        removeStockButton=Button(text="Remove Stock")
        removeStockButton.on_press=self.removeStock
        buttonRow.add_widget(removeStockButton)

        # sectorStockButton=Button(text="Sector Sort")
        # sectorStockButton.on_press=self.sectorSort
        # buttonRow.add_widget(sectorStockButton)

        self.add_widget(buttonRow)
Esempio n. 10
0
 def build(self):
     bigLay = GridLayout()
     bigLay.cols = 4
     bigLay.rows = 2
     a = pushy()
     for i in range(0, 4):
         x = plinthBox()
         bigLay.add_widget(x)
     bigLay.add_widget(a)
     return bigLay
    def addTitleRow(self):
        titleRowArray=["Ticker","Shares","Avg Cost","Last Closing","Return"]
        tempWidget=GridLayout(size_hint=(1,1))
        tempWidget.rows=1

        for entry in titleRowArray:
            tempLabel=Label(text=entry,bold=True,underline=True,color=[.69,.61,.85,1])
            tempWidget.add_widget(tempLabel)


        self.add_widget(tempWidget)
 def create_set_del_bloc(self, id):
     button_block = GridLayout()
     button_block.cols = 2
     button_block.rows = 1
     set_button = Button(text="Set", id=id)
     set_button.bind(on_press=lambda a: self.parent.display_set_item_menu(
         set_button.id))
     del_button = Button(text="Del", id=id)
     del_button.bind(on_press=lambda a: self.del_item(del_button.id))
     button_block.add_widget(set_button)
     button_block.add_widget(del_button)
     return button_block
Esempio n. 13
0
 def error_popup(self):
     '''creates a popup widget prompting user to enter a valid integer to countine to all methods page'''
     
     content = GridLayout()
     content.rows = 2
     popup_text = Label(text='Please enter a  valid number to continue')
     close_button = Button(text='Close')
     content.add_widget(popup_text)
     content.add_widget(close_button)
     popup = Popup(title='Shoe size', content=content, size_hint=(.4, .4))
     close_button.bind(on_release = popup.dismiss)
     popup.open()
Esempio n. 14
0
    def buildList(self, b=None):

        self.clear_widgets()

        wordsObj = Word()

        obj = WordUseage().getCounts()
        words = sorted(wordsObj.readFindString(self.qString))

        for wordTemp in words:

            word = wordsObj.getRowByWord(wordTemp)
            row = GridLayout()
            row.rows = 1
            row.height = 40
            row.size_hint_y = None

            row.add_widget(
                Label(text=f'{word["word"]}', size_hint_y=None, height=40))

            countValue = 0
            if word['id'] in obj.keys():
                countValue = obj[word['id']]
            t = 0
            if WordWeighting().wightingExists(word['id']):
                t = WordWeighting().get(word['id'])['value_id']

            textbox = TextInput(text=str(t),
                                size_hint_y=None,
                                height=40,
                                size_hint_x=None,
                                width=30,
                                multiline=False)

            textbox.wordId = word['id']

            textbox.bind(text=self.changeWeighting)

            row.add_widget(
                Label(text=str(countValue), size_hint_y=None, height=40))

            row.add_widget(textbox)

            btn = Button(text=f'delete',
                         size_hint_y=None,
                         height=40,
                         on_press=self.deleteCb)
            btn.rowId = word['id']
            btn.word = word['word']

            row.add_widget(btn)
            self.add_widget(row)
Esempio n. 15
0
    def settings(self):

        settings_grid = GridLayout()
        settings_grid.rows = 8
        settings_grid.size_hint = (1,1)

        settings_grid.add_widget(Label(text="Clear hosts list.", color=(0,0,0,1), size_hint=(None,1)))
        settings_grid.add_widget(Button(text="Clear", color=(0,0,0,1), size_hint=(None,None),height=10, on_release= lambda a: self.on_button_click()))
        settings_grid.add_widget(Label(text="This is place for future settings", color=(0,0,0,1)))
        settings_grid.add_widget(Label(text="This is place for future settings", color=(0,0,0,1)))
        settings_grid.add_widget(Label(text="This is place for future settings", color=(0,0,0,1)))
        
        self.add_widget(settings_grid)
Esempio n. 16
0
	def setup(self):
		self.cols = 1
		self.rows = 3
		
		self.turn_label = Label(text='[b]Turn:[/b] [color='+ self.player_color[self.game.turn] + ']' \
		+ self.player_name[self.game.turn] + '[/color]', markup=True)
		
		self.turn_label.font_size = 48
		
		inner_layout = GridLayout()
		inner_layout.rows = 6
		inner_layout.cols = 7
		inner_layout.padding = (8, 8)
		
		for row in range(6):
			for col in range(7):
				self.label_matrix[row][col] = Label(text=str(self.game.board_matrix[row][col]), font_size = 48, markup = True)
				if self.game.board_matrix[row][col] != "-":
					# Player 2 (AI) can have already placed his first move
					self.label_matrix[row][col].text = '[b][color=' + self.player_color[2] +']' + self.player_symbol[2] + '[/color][/b]'
				
				#self.button_matrix[x][y].bind(on_press=partial (self.button_pressed, x, y))
				inner_layout.add_widget(self.label_matrix[row][col])
		
		self.add_widget(self.turn_label)
		inner_layout.size_hint=(2.5, 2)
		self.add_widget(inner_layout)

		# Row of Button, one for each column
		button_row_layout = GridLayout()
		button_row_layout.rows = 1
		button_row_layout.cols = 7 
		for col in range(7):
			button = Button(text="[b]O[/b]", font_size = 40, markup = True)
			button.bind(on_press=partial(self.button_pressed, col))	
			button_row_layout.add_widget(button)	

		button_row_layout.size_hint=(0.5, 0.5)
		self.add_widget(button_row_layout)
Esempio n. 17
0
    def __init__(self): #A second argument '**kwargs' can be added here, but not needed.
        super(GUIlayout, self).__init__() #The same here.

        #Two layouts are going to be used. A 'small' one (a GridLayout named 'seclayout') that is going to contain the buttons,
        #and a 'big' one (a BoxLayout referred by 'self') that is going to contain the canvas and the small layout.
        self.orientation = 'vertical'
        self.spacing = (5,5)

        self.xdat=[]           #List with the measured values.

        #The small layout and its parameters.
        seclayout = GridLayout()
        seclayout.rows = 2
        seclayout.cols = 3
        seclayout.size_hint_y = .2 #The percentage of the big layout in the y direction that this layout covers.
        #This is for the canvas to be bigger than the buttons.
        seclayout.row_force_default = True
        seclayout.row_default_height = 50

        #Buttons
        self.measurebutton = Button(text="Measure!")
        self.measurebutton.bind(on_press=lambda x: self.measure(canvas,1,wavefun)) #Lambda x: in order to send arguments to the function and avoid
        seclayout.add_widget(self.measurebutton)                           #"TypeError: <lambda>() takes 0 positional arguments but 1 was given"

        self.measure10button = Button(text="Measure x10")
        self.measure10button.bind(on_press=lambda x: self.measure(canvas,10,wavefun))
        seclayout.add_widget(self.measure10button)

        self.measure100button = Button(text="Measure x100")
        self.measure100button.bind(on_press=lambda x: self.measure(canvas,100,wavefun))
        seclayout.add_widget(self.measure100button)

        self.PDFbutton = Button(text="Check!")
        self.PDFbutton.bind(on_press=lambda x:self.showPDF(canvas))
        seclayout.add_widget(self.PDFbutton)

        self.clearbutton = Button(text="Clear")
        self.clearbutton.bind(on_press=lambda x: self.clearall(canvas))
        seclayout.add_widget(self.clearbutton)

        self.add_widget(seclayout) #The small layout is attached to the big layout as a usual widget.

        canvas = FigureCanvasKivyAgg(f)
        self.add_widget(canvas)
        #self. because it is attached to the big layout.

        #Setting plot things that are shared by PDF and histogram.
        a.set_title('Measurements histogram')
        a.set_xlabel('x')
        a.set_ylabel('Frequency')
        a.axis([-L/2., L/2., 0., 1.])
Esempio n. 18
0
    def build(self):
        layout = GridLayout()
        layout.cols = 7
        layout.rows = 2
        with layout.canvas.before:
            Color(0.1, 0.1, 0.1, 1)
            self.rect = Rectangle(size=(1900, 1200), pos=layout.pos)

        x = [13, 7, 33, 16, 37, 40]
        a = PlinthBox()
        for i in x:
            exec("butt{} = ButtTest(num={}, lay=layout)".format(i, i))
            exec("Clock.schedule_interval(butt{}.update, 1.0/10.0)".format(i))
            exec("a.add_widget(butt{})".format(i))
        layout.add_widget(a)

        self.add_space(layout)

        y = [24, 21, 23, 19, 11, 12]
        b = PlinthBox()
        for i in y:
            exec("butt{} = ButtTest(num={}, lay=layout)".format(i, i))
            exec("Clock.schedule_interval(butt{}.update, 1.0/10.0)".format(i))
            exec("b.add_widget(butt{})".format(i))
        layout.add_widget(b)

        self.add_space(layout)

        w = [18, 29, 26, 22, 31, 36]
        c = PlinthBox()
        for i in w:
            exec("butt{} = ButtTest(num={}, lay=layout)".format(i, i))
            exec("Clock.schedule_interval(butt{}.update, 1.0/10.0)".format(i))
            exec("c.add_widget(butt{})".format(i))
        layout.add_widget(c)

        self.add_space(layout)

        z = [8, 15, 38, 35, 32, 10]
        d = PlinthBox()
        for i in z:
            exec("butt{} = ButtTest(num={}, lay=layout)".format(i, i))
            exec("Clock.schedule_interval(butt{}.update, 1.0/10.0)".format(i))
            exec("d.add_widget(butt{})".format(i))
        layout.add_widget(d)

        buttons = SocialShareButton()
        layout.add_widget(buttons)
        return layout
Esempio n. 19
0
 def pop6(self): #First Event popup
     print 'popup6 called'
     box3 = GridLayout() #same as pop4
     box3.cols = 1
     box3.rows = 3
     box3label1 = Label(text = event3data1, font_name = 'Lato', color = (0,0,0,0), font_size = 28)
     box3.add_widget(box3label1)
     animationpop6label = Animation(color = (1,1,1,1), d = 4, t = 'in_out_quad')
     animationpop6label.start(box3label1)
     popup = Popup(title=event3long, content = box3,size_hint=(.6,.05),
                   title_size = 25, title_font = 'Lato', separator_color = (1,1,1,0),
                   title_color = (0,0,0,0))
     animationpopup6 = Animation(title_color = (1,1,1,1), d=2, t = 'in_out_quad', size_hint = (.6,.4))
     animationpopup6.start(popup)
     popup.open()
Esempio n. 20
0
 def pop4(self): #First Event popup
     print 'popup4 called'
     box1 = GridLayout() #create a grid layout that can contain multiple widgets to be added directly to popup
     box1.cols = 1
     box1.rows = 2
     box1label1 = Label(text = event1data1, font_name = 'Lato', color = (0,0,0,0), font_size = 28)
     box1.add_widget(box1label1)
     animationpop4label = Animation(color = (1,1,1,1), d = 4, t = 'in_out_quad')
     animationpop4label.start(box1label1)
     popup = Popup(title=event1long, content = box1 ,size_hint=(.6,.05),
                   title_size = 25, title_font = 'Lato', separator_color = (1,1,1,0),
                   title_color = (0,0,0,0))
     animationpopup4 = Animation(title_color = (1,1,1,1), d=2, t = 'in_out_quad', size_hint = (.6,.4))
     animationpopup4.start(popup)
     popup.open()
Esempio n. 21
0
    def win_lose(self, win):
        self.popup = Popup(title="Private Lobby")
        self.popup.size = (40, 40)

        content = GridLayout()
        self.popup.content = content
        content.cols = 1
        content.rows = 2
        result = "LOSE"
        if (win):
            result = "WIN"

        content.add_widget(Label(text="YOU " + result))

        content.add_widget(Button(text="Back", on_press=self.popup.dismiss))

        self.popup.open()
Esempio n. 22
0
    def add_stats(self):
        # Create the widget where the buttons for generating stats will be
        statButtons = GridLayout()
        statButtons.rows = 3
        statButtons.cols = 3

        # Create the printPowerRankings button
        self.printPowerRankingsButton = Button(text="View Power Rankings")
        statButtons.add_widget(self.printPowerRankingsButton)
        self.printPowerRankingsButton.bind(on_release=self.printPowerRankings)

        # Create the printLuckIndex button
        self.printLuckIndexButton = Button(text="View Luck Index")
        statButtons.add_widget(self.printLuckIndexButton)
        self.printLuckIndexButton.bind(on_release=self.printLuckIndex)

        # Create the printExpectedStandings button
        self.printExpectedStandingsButton = Button(
            text="View Expected Standings")
        statButtons.add_widget(self.printExpectedStandingsButton)
        self.printExpectedStandingsButton.bind(
            on_release=self.printExpectedStandings)

        # Create the printWeeklyStats button
        self.printWeeklyStatsButton = Button(text="View Weekly Awards")
        statButtons.add_widget(self.printWeeklyStatsButton)
        self.printWeeklyStatsButton.bind(on_release=self.printWeeklyStats)

        # Create the printCurrentStandings button
        self.printCurrentStandingsButton = Button(
            text="View Current Standnigs")
        statButtons.add_widget(self.printCurrentStandingsButton)
        self.printCurrentStandingsButton.bind(
            on_release=self.printCurrentStandings)

        self.infoAndStats.add_widget(statButtons)

        # Create a location for stats to be stored later
        self.statsTable = GridLayout()
        self.add_widget(self.statsTable)
        self.statsTable.row_default_height = 20  # Set the default height of each row to 20 px
        self.statsTable.row_force_default = True
        return
Esempio n. 23
0
    def __init__(self, *args, **kwargs):
        super(MainScreen, self).__init__(**kwargs)
        btnTexts = OrderedDict()
        btnTexts["Start Game"] = self.start_game
        btnTexts["Resume Game"] = self.resume_game
        btnTexts["Settings"] = self.settings
        btnTexts["Help"] = self.show_help

        layout = GridLayout()
        layout.rows = len(btnTexts)
        layout.cols = 3
        for btn in btnTexts:
            label = Label()
            layout.add_widget(label)
            button = Button(text=str(btn))
            button.bind(on_release=btnTexts[btn])
            layout.add_widget(button)
            label = Label()
            layout.add_widget(label)
        self.add_widget(layout)
Esempio n. 24
0
    def deleteCb(self, inst):

        self.popup = Popup(
            title='are you sure you want to delete {}'.format(inst.word),
            size_hint=(None, None),
            size=(400, 200),
        )

        g = GridLayout()
        g.rows = 1

        delBtn = Button(
            text='Delete',
            on_press=lambda i: self.deleteWord([inst.rowId])  # noqa E501
        )

        g.add_widget(delBtn)
        g.add_widget(Button(text="Cancel", on_press=self.popup.dismiss))

        self.popup.content = g
        self.popup.open()
Esempio n. 25
0
    def open_public(self, instance):
        self.popup = Popup(title="Public Lobby")
        content = GridLayout()
        self.popup.content = content
        content.cols = 2
        content.rows = 2
        content.padding = 100
        content.add_widget(Label(text="Name:"))

        self.name_input = TextInput(multiline=False)
        content.add_widget(self.name_input)
        content.add_widget(Button(text="Back", on_press=self.popup.dismiss))

        # send name to server for verification when clicked
        content.add_widget(
            Button(
                text="Join Public Lobby",
                on_press=lambda event: send_msg(
                    self.client_socket,
                    Message(TAG='LOBBYREQUEST', name=self.name_input.text))))

        self.popup.open()
    def __init__(self, height: int, backCallback: callable, homeCallback: callable, **kwargs):
        super(BottomBar, self).__init__(**kwargs)

        bottomBack = Image()
        bottomBack.color = [0, 0, 0, 1]
        bottomBack.width = Window.size[0]
        bottomBack.height = height
        self.add_widget(bottomBack)

        btnGrid = GridLayout()
        btnGrid.cols = 5
        btnGrid.rows = 1
        btnGrid.width = Window.size[0]
        btnGrid.height = height
        self.add_widget(btnGrid)

        btnBack = Button(text="Back")
        btnBack.bind(on_press=lambda instance: backCallback())
        btnGrid.add_widget(btnBack, 0)

        btnHome = Button(text="Home")
        btnHome.bind(on_press=lambda instance: homeCallback())
        btnGrid.add_widget(btnHome, 1)
Esempio n. 27
0
    def build(self):
        primary_window = GridLayout()
        primary_window.cols = 1
        primary_window.rows = 3

        name = LabelB(text='Team De Soto Currency Converter',
                      bcolor=[0.2, 0.3, 0.1, 1],
                      font_size=60,
                      italic=True)
        primary_window.add_widget(name)

        second_window = GridLayout()
        second_window.cols = 3
        second_window.rows = 1
        dropdown = CustomDropDown()
        button_1 = Button(text='Starting Currency', font_size=30)
        button_1.bind(on_release=dropdown.open)
        dropdown.bind(
            on_select=lambda instance, x: setattr(button_1, 'text', x))
        second_window.add_widget(button_1)

        # value = LabelB(text='Enter value here: ', bcolor=[0.2, 0.3, 0.1, 1])
        inside_window = GridLayout()
        inside_window.cols = 1
        inside_window.rows = 3
        inside_blank1 = LabelB(text='', bcolor=[0.2, 0.3, 0.1, 1])
        inside_blank2 = LabelB(text='', bcolor=[0.2, 0.3, 0.1, 1])
        value = CustomTextInput()
        inside_window.add_widget(inside_blank1)
        inside_window.add_widget(value)
        inside_window.add_widget(inside_blank2)
        second_window.add_widget(inside_window)

        dropdown2 = CustomDropDown()
        button_two = Button(text='Convert to:', font_size=30)
        button_two.bind(on_release=dropdown2.open)
        dropdown2.bind(
            on_select=lambda instance, x: setattr(button_two, 'text', x))
        second_window.add_widget(button_two)

        primary_window.add_widget(second_window)

        third_window = GridLayout()
        third_window.cols = 2
        third_window.rows = 3
        blank1 = LabelB(text='', bcolor=[0.2, 0.3, 0.1, 1])
        blank2 = LabelB(text='', bcolor=[0.2, 0.3, 0.1, 1])
        calc_button = Button(text='Press here to convert')

        # insert when pressed code here
        def callback(
            instance
        ):  # I don't know what instance is but the API says to use it.
            amount = float(value.text)
            original = button_1.text
            convert_to = button_two.text
            money = Currency(original, convert_to, amount)
            number = money.convert()
            # number = float(value.text) * 2.5
            results_label.text = "{:,.2f} {}s".format(number, convert_to)

        calc_button.bind(on_press=callback)
        results_label = LabelB(text='Conversion will show up here',
                               bcolor=[0.2, 0.3, 0.1, 1],
                               font_size=30)
        blank3 = LabelB(text='', bcolor=[0.2, 0.3, 0.1, 1])
        blank4 = LabelB(text='', bcolor=[0.2, 0.3, 0.1, 1])

        third_window.add_widget(blank1)
        third_window.add_widget(blank2)
        third_window.add_widget(calc_button)
        third_window.add_widget(results_label)
        third_window.add_widget(blank3)
        third_window.add_widget(blank4)
        primary_window.add_widget(third_window)
        return primary_window
Esempio n. 28
0
    def __init__(self, **kwargs):
        super(LoginScreen, self).__init__(**kwargs)

        self.modifier = 0
        self.number_of_dices = 1
        self.type_dice = 0
        self.registro = 0
        self.orientation = "vertical"
        self.calculo_resultado = 0
        self.mod_is_negative = 1
        self.cb_list = []
        self.critical = ""

        Window.bind(on_key_up=self.read_key)

        # Añadiendo Widgets

        cuadricula_inicial = GridLayout()
        cuadricula_inicial.cols = 9
        cuadricula_inicial.rows = 2
        self.add_widget(cuadricula_inicial)

        # añadiendo primera cara textos y checkboxes

        for i in DICES:
            cuadricula_inicial.add_widget(Label(text="1d{0}".format(i), size_hint=(1, None), font_size=14, height=20))

        for i in DICES:
            cb = CheckBox(group=True, color=(255, 0, 0, 3), id=str(i))
            cb.bind(active=self.update_type_dice)
            cuadricula_inicial.add_widget(cb)
            self.cb_list.append(cb)

        # Segunda Caja:

        caja_de_modificadores = BoxLayout(orientation="horizontal")
        self.add_widget(caja_de_modificadores)

        # 2.1
        caja_num = StackLayout()
        caja_de_modificadores.add_widget(caja_num)
        caja_num.add_widget(Label(text="Dice Number", size_hint=(0.5, 0.5)))
        caja_num.add_widget(change_num)
        change_num.bind(text=self.input_number)
        caja_num.add_widget(lista_num)
        lista_num.bind(text=self.cuantas_lanzadas)

        # 2.2
        caja_mod = StackLayout()
        caja_de_modificadores.add_widget(caja_mod)
        caja_mod.add_widget(Label(text="Modifier", size_hint=(0.5, 0.4)))
        caja_mod.add_widget(change_mod)
        change_mod.bind(text=self.input_modifier)
        caja_mod.add_widget(Label(text="Negativo", size_hint=(0.5, 0.3)))
        self.cb_negative = CheckBox(size_hint=(0.5, 0.3))
        caja_mod.add_widget(self.cb_negative)
        self.cb_negative.bind(active=self.negative_modifier)
        caja_mod.add_widget(lista_mod)
        lista_mod.bind(text=self.cuanto_es_modificador)

        # 2.3
        self.btn = Button(text="Lanzar", font_size=18, )
        self.btn.bind(on_press=self.lanzar_dados)
        caja_de_modificadores.add_widget(self.btn)

        # Tercera caja

        self.resultado = Label(text="Esperando Lanzamiento de dados", color=(1, 0, 0, 0.8))
        self.add_widget(self.resultado)

        # Cuarta caja

        self.lista_registro = RV()
        self.add_widget(self.lista_registro)
Esempio n. 29
0
 def test_gridlayout_get_max_widgets_cols_None(self):
     gl = GridLayout()
     gl.rows = 1
     expected = None
     value = gl.get_max_widgets()
     self.assertEqual(expected, value)
Esempio n. 30
0
    def __init__(self, **kwargs):
        super(FontConstructor, self).__init__(spacing=5, **kwargs)

        self.orientation = 'vertical'
        self.width = 30

        # end of self init

        def initialize_workspace_with_size(rows, cols, matrix=None):
            global frames, buttons, current_frame
            for button_row in buttons:
                for button in button_row:
                    pixels.remove_widget(button)
            pixels.cols = cols
            pixels.rows = rows
            if matrix:
                frames = matrix
            else:
                frames = [np.zeros((rows, cols), dtype=np.uint8)]
            buttons = []
            current_frame = 0
            frame_label.text = f'Frame: {current_frame}'
            for i in range(0, rows):
                button_row = []
                for j in range(0, cols):
                    btn = ToggleButton()
                    button_row.append(btn)
                    btn.row = i
                    btn.column = j
                    btn.bind(on_press=process_matrix_changes)
                    pixels.add_widget(btn)
                buttons.append(button_row)

        def load_callback(instance):
            global frames
            frames = list(np.load(filename_input.text + '.npy'))
            print(frames)
            initialize_workspace_with_size(*frames[0].shape, matrix=frames)
            # print(frames[0].shape)
            update_buttons()

        def save_callback(instance):
            np.save(filename_input.text, frames)
            print(frames)

        def new_file_callback(instance):
            global cols, rows
            cols = int(size_w_input.text)
            rows = int(size_h_input.text)
            initialize_workspace_with_size(rows, cols)
            popup.dismiss()

        content = BoxLayout(orientation='vertical')
        size_holder = BoxLayout(orientation='horizontal', size_hint_max_y=40)
        content.add_widget(size_holder)
        size_label_x = Label(text="Columns:")
        size_holder.add_widget(size_label_x)
        size_w_input = TextInput(text=str(cols),
                                 multiline=False,
                                 size_hint_max_x=40)
        size_holder.add_widget(size_w_input)
        size_label_y = Label(text="Rows:")
        size_holder.add_widget(size_label_y)
        size_h_input = TextInput(text=str(rows),
                                 multiline=False,
                                 size_hint_max_x=40)
        size_holder.add_widget(size_h_input)
        button_holder = BoxLayout(orientation='horizontal', size_hint_max_y=40)
        content.add_widget(button_holder)
        create_button = Button(text='Create', on_press=new_file_callback)
        button_holder.add_widget(create_button)

        popup = Popup(title='Select size',
                      content=content,
                      size_hint=(0.8, 0.5),
                      auto_dismiss=False)

        menu = BoxLayout(orientation='horizontal',
                         size_hint=(1, 0.1),
                         spacing=3)
        self.add_widget(menu)

        new_file_button = Button(text="New file", on_press=popup.open)
        menu.add_widget(new_file_button)

        save_button = Button(text="Save", on_press=save_callback)
        menu.add_widget(save_button)

        load_button = Button(text="Load", on_press=load_callback)
        menu.add_widget(load_button)

        cancel_button = Button(text='Cancel', on_press=popup.dismiss)
        button_holder.add_widget(cancel_button)

        # -----

        pixels = GridLayout(spacing=1)
        pixels.cols = cols
        pixels.rows = rows
        pixels.width = pixels.cols * 2
        self.add_widget(pixels)

        settings = BoxLayout(spacing=2,
                             orientation='horizontal',
                             size_hint=(1, 0.1))
        self.add_widget(settings)

        filename_input = TextInput(text='matrix', multiline=False)
        settings.add_widget(filename_input)

        def update_buttons():
            for i in range(0, rows):
                for j in range(0, cols):
                    if frames[current_frame][i][j] == 1:
                        buttons[i][j].state = 'down'
                    else:
                        buttons[i][j].state = 'normal'

        def add_frame(instance):
            # frames.append(np.zeros((7, 11), dtype=np.uint8))
            frames.append(frames[current_frame].copy())
            next_frame(instance)

        def rem_frame(instance):
            frames.pop(current_frame)

        def next_frame(instance):
            global current_frame
            if current_frame != len(frames) - 1:
                current_frame += 1
                frame_label.text = f'Frame: {current_frame}'
                update_buttons()

        def prev_frame(instance):
            global current_frame
            if current_frame != 0:
                current_frame -= 1
                frame_label.text = f'Frame: {current_frame}'
                update_buttons()

        frame_label = Label(text=f'Frame: {current_frame}')
        settings.add_widget(frame_label)
        prev_frame_button = Button(text='<<',
                                   size_hint_max_x=30,
                                   on_press=prev_frame)
        settings.add_widget(prev_frame_button)
        next_frame_button = Button(text='>>',
                                   size_hint_max_x=30,
                                   on_press=next_frame)
        settings.add_widget(next_frame_button)
        add_frame_button = Button(text='+',
                                  size_hint_max_x=30,
                                  on_press=add_frame)
        settings.add_widget(add_frame_button)
        remove_frame_button = Button(text='-',
                                     size_hint_max_x=30,
                                     on_press=rem_frame)
        settings.add_widget(remove_frame_button)

        def process_matrix_changes(instance):
            if instance.state == 'down':
                frames[current_frame][instance.row][instance.column] = 1
            else:
                frames[current_frame][instance.row][instance.column] = 0

        for i in range(0, rows):
            button_row = []
            for j in range(0, cols):
                btn = ToggleButton()
                button_row.append(btn)
                btn.row = i
                btn.column = j
                btn.bind(on_press=process_matrix_changes)
                pixels.add_widget(btn)
            buttons.append(button_row)

        # ----

        def print_debug(instance):
            print(np.asarray(frames))
            print("------------------")

        def translate_right(instance):
            frames[current_frame] = np.roll(frames[current_frame], 1, axis=1)
            update_buttons()

        def translate_left(instance):
            frames[current_frame] = np.roll(frames[current_frame], -1, axis=1)
            update_buttons()

        def translate_up(instance):
            frames[current_frame] = np.roll(frames[current_frame], -1, axis=0)
            update_buttons()

        def translate_down(instance):
            frames[current_frame] = np.roll(frames[current_frame], 1, axis=0)
            update_buttons()

        # status = BoxLayout(orientation='horizontal', size_hint=(1, 0.1), spacing=1)
        # self.add_widget(status)

        btn_left = Button(text='<-',
                          size_hint_max_x=30,
                          on_press=translate_left)
        settings.add_widget(btn_left)

        btn_right = Button(text='->',
                           size_hint_max_x=30,
                           on_press=translate_right)
        settings.add_widget(btn_right)

        btn_up = Button(text='/\\', size_hint_max_x=30, on_press=translate_up)
        settings.add_widget(btn_up)

        btn_down = Button(text='\/',
                          size_hint_max_x=30,
                          on_press=translate_down)
        settings.add_widget(btn_down)
Esempio n. 31
0
 def test_gridlayout_get_max_widgets_cols_None(self):
     gl = GridLayout()
     gl.rows = 1
     expected = None
     value = gl.get_max_widgets()
     self.assertEqual(expected, value)