Example #1
0
    def __init__(self, *args, **kwargs):
        ## BOTTOM_LABELS = [[u"▲"], [u"▼"], [u"◀"], [u"▶"], ["volume", "pan", "send", "device"], ["shift"]]
        GridLayout.__init__(self, cols=9, rows=10)  # chuck all the controls into one grid
        self.note_buttons = {}
        self.control_sliders = {}

        scene_ids = xrange(82, 90).__iter__()
        for row in xrange(7, -1, -1):
            for col in xrange(0, 8):
                # first 8 cols are clip launchers
                note = (row * 8) + col
                self.add_widget(self.create_button("clip_launch_%d" % note, note))

            # last column is scene launch
            note = next(scene_ids)
            self.add_widget(self.create_button("scene_launch_%d" % row, note))

        # row 8 - control buttons and shift
        for i, note in enumerate(xrange(64, 72)):
            self.add_widget(self.create_button("control_%d" % i, note))

        self.add_widget(self.create_button("shift", 98))

        # row 9 - sliders
        for i, note in enumerate(xrange(48, 57)):
            self.add_widget(self.create_slider("slider_%d" % i, note))
Example #2
0
    def __init__(self, parent, titleheader="Title", message="Message", options={"OK": ""}, size=(400, 400)):

        def popup_callback(instance):
            "callback for button press"
            self.retvalue = instance.text
            self.popup.dismiss()

        self.parent = parent
        self.retvalue = None
        self.titleheader = titleheader
        self.message = message
        self.options = options
        self.size = size
        box = GridLayout(orientation='vertical', cols=1)
        box.add_widget(Label(text=self.message, font_size=16))
        b_list = []
        buttonbox = BoxLayout(orientation='horizontal')
        for b in self.options:
            b_list.append(Button(text=b, size_hint=(1,.35), font_size=20))
            b_list[-1].bind(on_press=popup_callback)
            buttonbox.add_widget(b_list[-1])
        box.add_widget(buttonbox)
        self.popup = Popup(title=titleheader, content=box, size_hint=(None, None), size=self.size)
        self.popup.open()
        self.popup.bind(on_dismiss=self.OnClose)
    def __init__(self, **kwargs):
        self._buttons = {}

        super(PlaygroundSizeView, self).__init__(**kwargs)

        for title, values in self.default_sizes:
            grid = GridLayout(rows=4)

            def sort_sizes(item):
                return item[1][1] * item[1][0]

            values = sorted(values, key=sort_sizes, reverse=True)
            for name, size in values:
                btn = ToggleButton(text='', markup=True)
                btntext = ('%s\n[color=777777][size=%d]%dx%d[/size][/color]' %
                           (name, btn.font_size * 0.8, size[0], size[1]))
                btn.text = btntext
                btn.bind(on_press=partial(self.set_size, size))
                grid.add_widget(btn)
                self._buttons[name] = btn

            item = AccordionItem(title=title)
            item.add_widget(grid)
            self.accordion.add_widget(item)

        self.accordion.select(self.accordion.children[-1])

        self.update_buttons()
Example #4
0
 def clickSendDivision(self):
     """
         called by clicking on <Send Division>
         assigns division to mat
     """
     
     try:
         box = GridLayout(orientation='vertical', height='130sp', cols=2, spacing=10, padding=5, size_hint=(1,None))
         scroll = ScrollView()
         scroll.add_widget(box)
         popup = Popup(title ='Select where to send division', content = scroll,
                       size_hint = (None, None), size=(500, 500))
         mList = ["Mat_1","Mat_2","Mat_3","Mat_4","Mat_5","Mat_6"]
         for i in sorted(mList):
             txt = i.replace("_"," ")
             btn = OSButton(text=txt, title='select where to send division',
                             identity = i, on_press=self.sendDivision, on_release=popup.dismiss)
             box.add_widget(btn)
         
         h = 0
         n = len(box.children)
         for c in box.children: h += c.height
         box.height = (h/2 + n*5)
         
         popup.open()
     except Exception as e: print "{} exception: {}".format(self, e)
Example #5
0
	def render_distribuite(self,tab):
		self.dist_layout = GridLayout(cols=2)
		self.Blayout=BoxLayout(orientation='vertical')
		self.Blayout.size_hint=( 1, 1)
		btnDistr=Button(text='Start Distribuite',size_hint=(1, .1))
		btnDistr.bind(on_press=self.start_dist)
		self.btnReckivy=ToggleButton(text='Choose recipes for Kivy Launcher',size_hint=(1, .1))
		self.btnReckivy.bind(on_release=self.select_kivy_rec)

		self.recipe_layout = GridLayout(cols=4)
		thedir=os.path.join(self.py4a_path,'recipes')
		recipes=[ name for name in os.listdir(thedir) if os.path.isdir(os.path.join(thedir, name)) ]
		for r in recipes:
			t=ToggleButton(text=r)
			t.bind(state=self.add_remove)
			self.recipe_layout.add_widget(t)
		self.Blayout.add_widget(btnDistr)
		self.Blayout.add_widget(self.btnReckivy)
		self.Blayout.add_widget(self.recipe_layout)




		self.dist_layout.add_widget(self.Blayout)
		self.dist_layout.add_widget(self.kvc)


		tab.add_widget(self.dist_layout)
Example #6
0
    def show_view_list_path(self, *args, **kwargs):
        
        self.clear_widgets()
        color = ColorLayout()
        boxl = BoxLayout(orientation= 'vertical',anchor_y= "top")
        grid = GridLayout(cols=1, size_hint_y=None)
        grid.bind(minimum_height=grid.setter('height')) 
        scroll = ScrollView(size_hint=(None, None))
        scroll.size = (Window.width, Window.height)
        scroll.center = Window.center
        #2 Space added but button go back ocuppies space and first value hidden.
        l_space = MultiLineLabel(text='',font_size="16dp", background_color=(255,255,255,255), markup=True)
        grid.add_widget(l_space)
        l_space = MultiLineLabel(text='',font_size="16dp", background_color=(255,255,255,255), markup=True)
        grid.add_widget(l_space)
        
        for i in args[0]:
            text = '[color=333333]'+'  '+i['text'] + '[/color]'+'  '
            #~ l = MultiLineLabel(text=text,font_size="16dp",markup=True)
            l = MultiLineLabel(text=text,font_size="16dp", background_color=(255,255,255,255), markup=True)
            i['stations'] and l.bind(on_press = partial(self.show_list_stations, i['stations'],args[0]))
            grid.add_widget(l)
            
        button_back = Button(text="Go Back", auto_dismiss=False, size_hint=(None, None), pos_hint= {'center_x':.5, 'center_y':.7})
        button_back.height="50dp"
        button_back.width="100dp"
        button_back.bind(on_press = lambda widget: self.show_option_view())

        scroll.add_widget(grid)
        boxl.add_widget(scroll)
        boxl.add_widget(button_back)
        color.add_widget(boxl)
        self.add_widget(color)
Example #7
0
	def __init__(self, **kwargs):
		super(ProgrammerView, self).__init__(**kwargs)

		grid = GridLayout()
		grid.cols= 2
		precode = open('function_file', 'r+')
		commands = [line for line in precode]
		usercode = open('user_file', 'r+')
		
		v2 = UserCodeDisplay(usercode.read())
		
		v1 = FunctionList(commands)
		
		grid.add_widget(v1)

		grid.add_widget(v2)

		grid.add_widget(Label(text= 'CODE BLOCKS', size_hint=(1,.05)))
		grid.add_widget(Label(text= 'USER PROGRAM', size_hint=(1,.05)))

		self.add_widget(grid)

		def on_touch_down(self, touch, *args):
			super(ProgrammerView, self).on_touch_down(touch)
	

		def on_touch_move(self, touch):
			pass

		def on_touch_up(self, touch):
			pass
Example #8
0
	def mail_pop(self):
		"""Popup with features to mail timesheet """

		f=FloatLayout()
		global popup2
		popup2 = Popup(title='Mail Timesheet',content=f,
		size_hint=(1.0, 0.6), size=(400, 400))
		g=GridLayout(cols=1,row_force_default=True,
					 row_default_height=40,pos_hint={'center_x':.5})
		global msg
		msg=Label(text="ENTER AN EMAIL ID")
		global mail_id
		mail_id=TextInput(write_tab=False)
		g.add_widget(msg)
		g.add_widget(mail_id)
		btn1=Button(text='MAIL',size_hint=(0.2,0.1),
					pos=(popup2.width-350,popup2.height-250) )
		btn1.bind(on_press=(MyApp.mail_timesheet))
		btn2=Button(text='CLOSE',size_hint=(0.2,0.1),
					pos=(popup2.width-50,popup2.height-250))
		f.add_widget(btn1)
		f.add_widget(btn2)
		f.add_widget(g)
		popup2.open()
		btn2.bind(on_press=popup2.dismiss)
    def askInfo(self,requiredInfo):
        #the button size is wrong on my laptop but right on the tablet so
        close=Button(text='Add')
        cancel=Button(text='Cancel')

        buttonGrid=GridLayout(cols=2,size_hint_y=.5)
        buttonGrid.add_widget(close)
        buttonGrid.add_widget(cancel)
        content=StackLayout(spacing=5)
        valueList=[]#empty list that gets filled with the inputs' getValue functions
        for x,y in requiredInfo:
            content.add_widget(Label(text=x,size_hint=(None,None),size=(50,32)))

            if y.split()[0]=='text':    #v if it's length 1, then it isn't a list
                tmpWidget=_RetrievableText(len(y.split())-1,multiline=False,size_hint=(None,None),
                        write_tab=False,size=(100,32))
                #^ height 32 bc font size defaults to 10 and y padding defaults to 12
                valueList.append(tmpWidget.getValue)
                content.add_widget(tmpWidget)

            elif y.split()[0]=='int':
                tmpWidget=_RetrievableText(len(y.split())-1,multiline=False,input_type='number',
                        write_tab=False,size_hint=(None,None),size=(100,32))
                #^ height 32 bc font size defaults to 10 and y padding defaults to 12
                valueList.append(tmpWidget.getValue)
                content.add_widget(tmpWidget)
        #buttonGrid.height=.5*content.height #size_hint_y=.5 should do this but i guess not
        content.add_widget(buttonGrid)
        self.askPane=Popup(title='Get Info',content=content,size_hint=(.5,None),
            height=1.5*content.height,
                auto_dismiss=False,)#on_dismiss=lambda x: self._setInfo(valueList))
        close.bind(on_release=lambda x: self._setInfo(valueList,False))#askPane.dismiss)
        cancel.bind(on_release=lambda x: self._setInfo(valueList,True))
        self.askPane.open()
Example #10
0
 def initialize(self):
     '''
     INITIALIZING GUI COMPONENTS
     '''
     #just for faster testing
     self.file_text_input.text = ""
  
     #initializing node_params scrollview and layout
     self.node_params_layout = GridLayout(cols=2,spacing=10, size_hint_y=None)
     self.node_params_layout.bind(minimum_height=self.node_params_layout.setter('height'))
     
     self.node_params_root = ScrollView(size_hint=(None, None), 
                                        size=(self.params_width,self.params_height),
                                        bar_width=5,
                                        bar_color=[.3,.3,.9,.5],
                                        do_scroll_x=False,
                                        )        
     self.node_params_root.add_widget(self.node_params_layout)
     #initializing edge_params scrollview and layout
     self.edge_params_layout = GridLayout(cols=2,spacing=10,size_hint_y=None)
     self.edge_params_layout.bind(minimum_height=self.edge_params_layout.setter('height'))
     self.edge_params_root = ScrollView(size_hint=(None, None), 
                                        size=(self.params_width-20,self.params_height),
                                        bar_width=5,
                                        bar_color=[.3,.3,.9,.5],
                                        do_scroll_x=False)        
     self.edge_params_root.add_widget(self.edge_params_layout)
     
     #adding params widgets
     self.params_boxlayout.add_widget(self.node_params_root)
     self.params_boxlayout.add_widget(self.edge_params_root)
Example #11
0
class FileWidget(BoxLayout):
    """

    """

    def __init__(self, action_callback, cancel_callback, action_text):
        """

        :return:
        """
        BoxLayout.__init__(self, orientation="vertical")

        self.file_chooser = FileChooserIconView(size_hint=(1,0.7), on_submit=self.update_file_input)
        self.file_input = TextInput()
        self.action_button = Button(text=action_text, on_press=action_callback)
        self.cancel_button = Button(text="Cancel", on_press=cancel_callback)

        self.horizontal_layout = GridLayout(cols=3, row_force_default=True, row_default_height=40, size_hint=(1, 0.055))
        self.horizontal_layout.add_widget(self.file_input)
        self.horizontal_layout.add_widget(self.action_button)
        self.horizontal_layout.add_widget(self.cancel_button)

        self.add_widget(self.file_chooser)
        self.add_widget(self.horizontal_layout)

    def update_file_input(self, instance, selection, touch):
        self.file_input.text = selection[0]
Example #12
0
class ViewListScreen(MyScreen):
    def __init__(self, **kwargs):
        super(ViewListScreen, self).__init__(**kwargs)
        self.sv = ScrollView()
        self.content_box.add_widget(self.sv)



        self.list_grid = GridLayout(cols = 1,
                                size_hint_y = None,
                                orientation = 'vertical')
        self.sv.add_widget(self.list_grid)

        self.bind(on_pre_enter= self.prepare_yourself)
    
    def prepare_yourself(self,*args):
        
        self.list_grid.clear_widgets()

        c_list = App.get_running_app().root.current_list
        self.list_grid.height = len(c_list)*40 #HARDCODE

        for e,spell in enumerate(c_list):
            spell['button_card'].id = str(e)
            self.list_grid.add_widget(spell['button_card'])
Example #13
0
    def __init__(self, **kwargs):
        super(DemoBox, self).__init__(**kwargs)
        self.orientation = "vertical"
        self.buckets = 0
        self.garbage = 0
        self.funct = 0
        self.tracker = TextInput(text=str(self.buckets))
        self.tracker.size_hint = (1, .1)
        self.add_widget(self.tracker)
        buttons = GridLayout(cols=4)
        self.add_widget(buttons)
        butts = []
        for i in range(10):
            butts.append(str(i))
        butts.append("+")
        butts.append("-")
        butts.append("*")
        butts.append("/")
        butts.append("=")
        butts.append("clear")
        for butt in butts:
            b = Button(text=str(butt))
            b.bind(on_press=self.press)
            buttons.add_widget(b)

        self.symbolFunctions = {
            "+":self.adder,
            "-":self.minuser,
            "=":self.equals,
            "*":self.multiplyer,
            "/":self.divider,
            "clear":self.numclear
        }
Example #14
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)
Example #15
0
 def build(self):
     number_of_rows = 20
     grid = GridLayout(rows = number_of_rows)
     for i in range(number_of_rows):
         for j in range(number_of_rows):
             grid.add_widget(ChangingBackgroundColor())
     return grid
Example #16
0
	def __init__(self):
		ScrollView.__init__(self, size_hint=(None, None), size=(1000, 1000), pos=(0, 0))
		layout = GridLayout(cols=1, spacing=0, size_hint_y=None)
		for i in range(30):
			btn = Button(text=str(i), size_hint_y=None, height=200)
			layout.add_widget(btn)
		self.add_widget(layout)
Example #17
0
    def setup(self):
        # Get the layout
        self.config = self.loadLayout()

        # We'll want to keep a list of all the letter objects
        self.letters = []

        # Create a grid layout that's the right size
        grid = GridLayout(cols=self.config.COLS)

        # Loop over the letters
        for ltr in self.config.LAYOUT:

            # Create a letter object
            word = WordClockLetter(text=ltr,
                                   size=self.config.SIZE,
                                   font_size=self.config.FONTSIZE,
                                   colour=self.colour)

            # add it to our list...
            grid.add_widget(word)

            # ...and to the grid layout
            self.letters.append(word)

        # Clear the screen
        self.clear_widgets()

        # add the clock layout
        self.add_widget(grid)
Example #18
0
    def build(self):
		layout = GridLayout(cols=2)
		inner_layout = GridLayout(rows=2)
		
		#right hand top widget
		#inner_layout.add_widget(Button(text='Hello 1')) 
		#inner_layout.add_widget(Image(source='locked.png'))
		#wimg = Image(source = "locked.png")
		wimg = DoorStatus()
		wimg.source = "locked.png"
		inner_layout.add_widget(wimg)
		#wimg.source = "unlocked.png" #changes the image, no need to reload here, maybe elsewhere
		
		#right hand bottom widget
		#inner_layout.add_widget(Button(text='World 1')) 
		wlab = Label(text = "Nearby devices: \nBadge 1337\nBadge 2")
		#wlab.halign = 'right' #aligns text, but not widget position
		#wlab.valign = 'top'
		
		#wlab = NearDevices()
		inner_layout.add_widget(wlab)
		
		el = EventLog()
		#st = ScrollView()
		#st.add_widget(el)
		Clock.schedule_interval(el.update, 60.0 / 60.0)
		#layout.add_widget(el) #top level left widget
		layout.add_widget(el)
		layout.add_widget(inner_layout) #top level right widget
		return layout
Example #19
0
 def __init__(self, **kwargs):
     super(FavoriteScreen, self).__init__(**kwargs)
     mainLayout = BoxLayout(orientation='vertical')
     #add title
     title = Label(text=sw.getCurrentTitel()[:40],font_size=40,size_hint_y=0.07,size_hint_x=1)
     #title.text_size = title.size
     #add favorites
     layout = GridLayout(cols=3, size_hint_y=0.2,anchor_y='top')
     stations = sw.getRadioFavorites()
     for station in stations:
         button = Button(text=station['title'][:10],id=str(sw.getRadioFavoriteID(station)), size_hint_x=0.2, font_size=40)
         button.bind(on_press=self.SetRadioStation)
         layout.add_widget(button)
         
     #add controls    
     layout2 = GridLayout(cols=3, size_hint_y=0.2, anchor_y='top')
     button = Button(text='<<',id='back', size_hint_x=0.2, font_size=70)
     button.bind(on_press=self.PlayPauseSkip)
     layout2.add_widget(button)
     button = Button(text='||',id='playPause', size_hint_x=0.2, font_size=70)
     if sw.getPlayPauseState() == 0:
         button.text = ">"
     button.bind(on_press=self.PlayPauseSkip)
     layout2.add_widget(button)
     button = Button(text='>>',id='forward', size_hint_x=0.2, font_size=70)
     button.bind(on_press=self.PlayPauseSkip)
     layout2.add_widget(button)
     mainLayout.add_widget(title)
     mainLayout.add_widget(layout)
     mainLayout.add_widget(layout2)
     self.add_widget(mainLayout)
Example #20
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
	def build(self):
		layout= GridLayout(cols=2)
		layout.add_widget(Label(text="Investment Ammount", halign='left'))
		pass
		btn = Button(text="Calculate", on_press=self.calculate)
		layout.add_widget(btn)
		return layout
Example #22
0
    def displayNames(self, dt):
        nameLayout = GridLayout( cols=3,
                                 row_force_default=True,
                                 row_default_height=100,
                                 size_hint_x=0.6, size_hint_y=0.2,
                                 pos_hint={'x': 0.2, 'y': 0.2} )
        gusButton = Button( text="Gus", color=[0,0,0,0],
                            background_color=[0,0,0,0] )
        chrisButton = Button( text="Chris", color=[0,0,0,0],
                              background_color=[0,0,0,0] )
        pattyButton = Button( text="Patty", color=[0,0,0,0],
                              background_color=[0,0,0,0] )
        
        gusButtonAnim = Animation( background_color=const.GUS_COLOR, color=[1,1,1,1], 
                                   transition=AnimationTransition.in_out_quad )
        chrisButtonAnim = Animation( background_color=const.CHRIS_COLOR, color=[1,1,1,1],
                                     transition=AnimationTransition.in_out_quad )
        pattyButtonAnim = Animation( background_color=const.PATTY_COLOR, color=[1,1,1,1],
                                     transition=AnimationTransition.in_out_quad )
        gusButtonAnim.start(gusButton)
        chrisButtonAnim.start(chrisButton)
        pattyButtonAnim.start(pattyButton)

        nameLayout.add_widget(gusButton)
        nameLayout.add_widget(chrisButton)
        nameLayout.add_widget(pattyButton)
        self.f.add_widget(nameLayout)
Example #23
0
	def showEvents(self):

		main_layout = GridLayout(cols=1,rows=1) 
		
		refresh_payload={'client_id': '80436600272-vbpjaklvfvgg7ucdvtnt1i4jrdbtmkq8.apps.googleusercontent.com', 'client_secret':'FHymJpeQ2CDpGda0cJhwtwkc','refresh_token':'1/-IqWcFhBST23F4hBBd-3Twgk7cBwyRsrF28jAjMPpcU', 'grant_type':'refresh_token'}
		refresh_request=requests.post('https://www.googleapis.com/oauth2/v3/token',data=refresh_payload)
		print refresh_request.json()['access_token']
		access_token_payload={'access_token':refresh_request.json()['access_token']}
		
		calendar_list_request=requests.get('https://www.googleapis.com/calendar/v3/users/me/calendarList', params=access_token_payload)
		
		calendars=calendar_list_request.json()['items']
		
		event_request=requests.get('https://www.googleapis.com/calendar/v3/calendars/'+calendars[0]['id'] +'/events',params=access_token_payload)


		events=event_request.json()['items']
		todos=[]
		for i in range(0,len(events)):
			 todos.append(events[i]['summary'])
		list_view = ListView(item_strings=todos)

		main_layout.add_widget(list_view)

		self.view.add_widget(main_layout)

		self.view.open()
 def build(self):
     layout = GridLayout(rows=2, cols=2)
     layout.add_widget(VirtualJoystick())
     layout.add_widget(VirtualJoystick())
     layout.add_widget(VirtualJoystick())
     layout.add_widget(VirtualJoystick())
     return layout
Example #25
0
 def _key_handler(self, instance, KEY, *args):   # Reakce na stisk systémové klávesy OS Android
     print "Key: {0}".format(KEY)
     if KEY == 1001:
         if self.sm.current not in ('MainMenuScreen', 'GameScreen'):
             if self.sm.current == "SettingsScreen":
                 self.sm.get_screen("SettingsScreen").dropdown.dismiss()
             self.sm.current_screen.prev()
         else:
             if self.sm.current == 'MainMenuScreen':
                 text = self.L.STR_POPUP_EXIT
                 title = self.L.STR_POPUP_EXIT_TITLE
                 yes_callback = self.popupStop
             else:
                 text = self.L.STR_POPUP_DISCONNECT
                 title = self.L.STR_POPUP_DISCONNECT_TITLE
                 yes_callback = self.popupDisconnect
             content = BoxLayout(orientation='vertical')
             content.add_widget(Label(text=text, font_name='font/Roboto-Regular.ttf', font_size='14dp'))
             buttons = GridLayout(cols=2, rows=1, spacing=10, size_hint=(1, .3))
             yes = Button(text=self.L.STR_YES)
             yes.bind(on_press=yes_callback)
             no = Button(text=self.L.STR_NO)
             buttons.add_widget(yes)
             buttons.add_widget(no)
             content.add_widget(buttons)
             self.popupExit = Popup(title=title, size_hint=(.7,.3), content=content, auto_dismiss=False)
             no.bind(on_press=self.popupExit.dismiss)
             self.popupExit.open()
     elif KEY == 1002:
         self.dispatch('on_pause')
     elif KEY == 1004:
         self.dispatch('on_pause')
Example #26
0
    def build(self):
        # create the buttons in the bottom row
	self.b1 = Button(text="Page 1")
	self.b2 = Button(text="Page 2")
	self.b3 = Button(text="Page 3")  
	self.b4 = Button(text="Page 4")
        # bind the buttons to the callback function
	self.b1.bind(on_press=self.button_press) 
	self.b2.bind(on_press=self.button_press) 
	self.b3.bind(on_press=self.button_press) 
	self.b4.bind(on_press=self.button_press) 

        # create a layout to hold the buttons
	self.buttons = GridLayout(spacing=5, rows=1)
	self.buttons.add_widget(self.b1)
	self.buttons.add_widget(self.b2)
	self.buttons.add_widget(self.b3)
	self.buttons.add_widget(self.b4)
	self.buttons.size_hint = (1,0.1)

        # create a layout to hold page content
	self.content = BoxLayout()

        # create the main layout
	self.window = GridLayout(rows=2)
	self.window.add_widget(self.content)
	self.window.add_widget(self.buttons)
	
        # on startup, load the first page 
	self.build_page(1)	

	return self.window
class TopBar(Widget):
    __grid = None  # type: GridLayout

    def __init__(self, height: int, **kwargs):
        super(TopBar, self).__init__(**kwargs)
        topBack = Image()
        topBack.color = [0, 0, 0, 1]
        topBack.width = Window.size[0]
        topBack.height = height
        self.add_widget(topBack)

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

    def clear_buttons(self):
        for child in self.__grid.children:
            self.__grid.remove_widget(child)

    def add_buttons(self, buttons):
        for index in range(0, len(buttons)):
            btn = buttons[index]  # type: Button
            self.__grid.add_widget(btn, self.__grid.cols - 1 - index)
				def _on_test_connect( self ) :
							"""

							:return:
							"""


							layout = GridLayout( orientation = 'horizontal' ,
											  cols = 1 ,
											  background_color = [0,0,0,0])
							action_bar = Builder.load_string( self._retr_resource( 'dlg_action_bar_3' ) )
							layout.add_widget( action_bar )
							img = Image( source = './image/kafka-logo.png' , size_hint_y = .15)
							scroll = ScrollView( id = 'scrlv' )
							grid = GridLayout( cols=1 , orientation = 'horizontal' , size_hint_y = None , size=(400 , 500 ) )
							grid.add_widget( img  )
							vx =  TextInput(
											text = '',
											background_color = [0,0,0,0] ,
											foreground_color =  [1,1,1,1] ,
											multiline = True ,
											font_size =  16 ,
											readonly =  True  )
							#vx.height = max( (len(vx._lines)+1) * vx.line_height, scroll.height )
							grid.add_widget( vx )
							scroll.add_widget( grid )
							layout.add_widget( scroll )

							popup = screen.ConsolePopup( title='kafka connect' , content = layout )
							b = popup.content.children[1].children[0].children[0]
							b.text = 'test connect'
							b.bind( on_press = lambda a:self._show_info( vx ) )
							popup.open()
Example #29
0
 def clickJoinFighter(self):
     """
         called by clicking on <Move Fighter>
     """
     try:
         box = GridLayout(orientation='vertical', height='130sp', cols=2, spacing=10, padding=5, size_hint=(1,None))
         scroll = ScrollView()
         scroll.add_widget(box)
         popup = Popup(title ='Select where to send division', content = scroll,
                       size_hint = (None, None), size=(600, 600))
         dList = []
         divs = db.execute('SELECT DivisionID FROM Event')
         for d in divs:
             did = d[0]
             if did not in dList and did != self.div: 
                 dList.append(did)
         
         for i in sorted(dList):
             txt = i.replace(";","\n")
             txt = txt.replace("_"," ")
             btn = OSButton(text=txt, title='select where to move fighter', height=('60sp'), size_hint=(1, None),
                             identity = i, on_press=self.joinFighter, on_release=popup.dismiss)
             box.add_widget(btn)
         
         h = 0
         n = len(box.children)
         for c in box.children: h += c.height
         box.height = (h/2 + n*5)
         
         popup.open()
     except Exception as e: print "{} exception: {}".format(self, e)
    def build(self):
        #self.activePixels.bind(self.pixelValChange)

        boxLayout = BoxLayout(orientation='vertical')

        topLayer = BoxLayout( orientation="horizontal", size_hint=(1, .1), padding=4)

        self.maximumPixelsTXT = TextInput(hint_text="Maximum Pixels",text="5", size_hint=(0.2, 1))
        self.nameTXT = TextInput(hint_text="Image Name" , size_hint=(0.2, 1))

        self.currentActiveLBL = Label(text="0",size_hint=(0.2, 1))
        self.saveBttn = Button(text="Save",size_hint=(0.2, 1), on_press=self.saveImage)
        self.clearBttn = Button(text="Clear",size_hint=(0.2, 1),on_press=self.clearBttnFn)

        topLayer.add_widget(self.maximumPixelsTXT)
        topLayer.add_widget(self.nameTXT)
        topLayer.add_widget(self.currentActiveLBL)
        topLayer.add_widget(self.saveBttn )
        topLayer.add_widget(self.clearBttn)


        boxLayout.add_widget(topLayer)

        gridLayout = GridLayout(cols=self.cols, padding=10,  size_hint=(1, 2) )

        for i in range(80*4):
            nb = Button()
            self.bttns.append(nb)
            nb.bind(on_press=self.pressPixelButton)
            gridLayout.add_widget(nb)

        boxLayout.add_widget(gridLayout)

        return boxLayout
Example #31
0
    def __init__(self, dataList, title):
        self.name = "readonlytable"
        super(ReadOnlyTable, self).__init__()
        self.dataList = dataList
        parent_layout = FloatLayout()
        self.title = str(title)
        scroll_layout = ScrollView(size_hint=(1, None),
                                   size=(Window.width, Window.height))
        scroll_layout.bind(size=self._update_rect, pos=self._update_rect)
        table_layout = GridLayout(cols=len(dataList[0]) + 1,
                                  size_hint_y=None,
                                  spacing=5)
        table_layout.bind(minimum_height=table_layout.setter('height'))
        # table_layout.bind(size=self._update_rect, pos=self._update_rect)
        length = len(dataList[0])

        #
        # for record in dataList:
        #
        #     for p, column in enumerate(record):
        #         if len(str(column)) > sizes[p]:
        #             sizes[p] = len(str(column)) + 3
        self.company = Button(text='Back|',
                              color=(0, 0, 0, 1),
                              background_color=(0, 0, 0, 0),
                              font_size=20,
                              on_press=self.back,
                              pos_hint={
                                  'center_x': 0.12,
                                  'center_y': 0.95
                              })
        table_layout.add_widget(self.company)

        table_layout.add_widget(
            Label(
                text="KAKABOKA",
                size_hint_y=None,
                color=(0, 0, 0, 1),
                font_size=20,
            ))
        table_layout.add_widget(
            Label(text="Sales",
                  size_hint_y=None,
                  height=50,
                  color=(0, 0, 0, 1),
                  font_size=20))
        table_layout.add_widget(
            Button(text="Show stats",
                   size_hint_y=None,
                   height=50,
                   font_size=10,
                   on_press=self.stats))

        self.show_tip_btn = Button(text="Tip Summary",
                                   size_hint_y=None,
                                   size_hint=(0.2, None),
                                   height=50,
                                   font_size=16,
                                   on_press=self.show_tip_details)
        table_layout.add_widget(self.show_tip_btn)

        forsales = dataList[1:]
        total_sale = 0
        for d in forsales:
            total_sale = total_sale + float(d[5])
        #table_layout.add_widget(Label(text="", size_hint_y=None, height=50))
        table_layout.add_widget(
            Label(text="",
                  size_hint_y=None,
                  height=50,
                  color=(0, 0, 0, 1),
                  font_size=15))
        self.show_details_btn = Button(text="    Sales\nSummary",
                                       size_hint_y=None,
                                       size_hint=(0.2, None),
                                       height=50,
                                       font_size=16,
                                       on_press=self.show_sale_details)
        table_layout.add_widget(self.show_details_btn)
        i = 0
        while i < length - 6:
            table_layout.add_widget(Label(text="", size_hint_y=None,
                                          height=50))
            i = i + 1

        dataList[0].reverse()
        for i, row_data in enumerate(dataList[0]):
            t = Label(text=row_data,
                      size_hint_y=None,
                      height=40,
                      color=(0, 0, 0, 1))
            table_layout.add_widget(t, index=i)

        dataList = dataList[1:]

        table_layout.add_widget(Label(text=""))
        self.dataList = dataList
        for row_n, row_data in enumerate(dataList):
            row_data.reverse()
            row_data.append("")
            for i, row in enumerate(row_data):
                new_row = row_data
                t = Label(text=str(row),
                          size_hint_y=None,
                          font_size=14,
                          pos_hint={"x_center": 0.9},
                          height=40,
                          color=(0, 0, 0, 1))
                if i <= length - 1:

                    table_layout.add_widget(t, index=i)

                    def changeText(event, data):

                        new_row[i] = data
                        print(data)

                    t.bind(text=changeText)
                else:
                    btn = Label(text="",
                                size_hint_y=None,
                                height=40,
                                color=(0, 0, 0, 1))

                    def updateRecord(self):
                        print("Record to be updated : ")

                        db = InventoryDB()
                        data = db.getInventoryRecodeByBarcode(
                            barcode=new_row[5])[0]
                        data.id = new_row[5]
                        data.barcode = new_row[5]
                        data.price = float(3)
                        # data.itemname = itemname
                        # data.manufacturer = manufacturer
                        # data.quantity = quantity
                        data.category = str(new_row[0])
                        print(row_data)

                    btn.bind(on_press=updateRecord)

                    table_layout.add_widget(btn)

        with scroll_layout.canvas.before:
            base_folder = os.path.dirname(__file__)
            image_path = os.path.join(base_folder, 'background.png')
            self.rect = Rectangle(source=image_path,
                                  size=scroll_layout.size,
                                  pos=scroll_layout.pos)

        scroll_layout.add_widget(table_layout)
        self.add_widget(scroll_layout)

        self.add_widget(parent_layout)
Example #32
0
    def account_balance_box(self):
        box = GridLayout()
        box.cols = 3

        m = self.ctrl.model
        total_balance = m.total_balance(m.get_data())

        # Heading:
        box.add_widget(Label(text="Name"))
        box.add_widget(Label(text="Balance"))
        box.add_widget(Label(text="% of total"))
        for acc in m.accounts:
            # Calculate account balance
            balance = m.account_balance(acc, m.get_data())
            balance_str = f"{balance:.2f} {m.CURRENCY}"
            percentage = (balance / total_balance)*100
            percentage_str = f"{percentage:.2f} %"

            acc_label = Label(text=acc)
            balance_label = Label(text=balance_str)
            percentage_label = Label(text=percentage_str)

            box.add_widget(acc_label)
            box.add_widget(balance_label)
            box.add_widget(percentage_label)
        return box
Example #33
0
        def build(self):
            layout1 = GridLayout(cols=4, spacing=10, size_hint=(None, None))
            layout1.bind(minimum_height=layout1.setter('height'),
                         minimum_width=layout1.setter('width'))
            for i in range(40):
                btn = Button(text=str(i),
                             size_hint=(None, None),
                             size=(200, 100))
                layout1.add_widget(btn)
            scrollview1 = ScrollView(bar_width='2dp', smooth_scroll_end=10)
            scrollview1.add_widget(layout1)

            layout2 = GridLayout(cols=4, spacing=10, size_hint=(None, None))
            layout2.bind(minimum_height=layout2.setter('height'),
                         minimum_width=layout2.setter('width'))
            for i in range(40):
                btn = Button(text=str(i),
                             size_hint=(None, None),
                             size=(200, 100))
                layout2.add_widget(btn)
            scrollview2 = ScrollView(scroll_type=['bars'],
                                     bar_width='9dp',
                                     scroll_wheel_distance=100)
            scrollview2.add_widget(layout2)

            root = GridLayout(cols=2)
            root.add_widget(scrollview1)
            root.add_widget(scrollview2)
            return root
Example #34
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        # self.user_list = ['join']
        # Window.color = (0,3,0,1)

        with self.canvas:

            # Color(.234, .456, .678, .9)  # set the colour

            # Seting the size and position of canvas
            self.rect = Rectangle(source='back2.jpg',
                                  pos=self.center,
                                  size=self.size)

            # Update the canvas as the screen size change
            self.bind(pos=self.update_rect, size=self.update_rect)

        self.cols = 1
        self.rows = 2

        # self.side_but = Button(text='cool')
        self.history = ScrollableLabel(height=Window.size[1] * 0.9,
                                       size_hint_y=None)
        self.history_recv = ScrollableLabel(height=Window.size[1] * 0.9,
                                            size_hint_y=None)
        # self.add_widget(self.side_but)
        side_bar = GridLayout(cols=3)
        self.box = BoxLayout(orientation='vertical')
        self.box.size_hint_x = .4

        # user_list = self.set_arr()
        # if len(user_list) > 0:
        # stack = Stack()

        # for i in stack.stk:
        self.side_label = MyLabel(text='Joined',
                                  pos=(20, 20),
                                  size_hint=(1, 0.5))

        self.side_label.text = user_list[0].upper()
        self.side_label.text = self.side_label.text
        self.side_label.font_size = '25sp'
        self.side_label.color = [0.41, 0.42, 0.74, 1]
        # self.side_label.text_size = (6,4)
        self.box.add_widget(self.side_label)
        # else:
        #     label = MyLabel(
        #             text="Joined Users",
        #             pos=(20, 20),
        #             size_hint=(1, 0.5))

        #     box.add_widget(label)

        # with label.canvas:
        #     Color(0, 1, 0, 0.25)
        #     Rectangle(pos=label.pos, size=label.size)

        side_bar.add_widget(self.box)
        side_bar.add_widget(self.history)
        side_bar.add_widget(self.history_recv)
        self.add_widget(side_bar)  #########################################

        self.new_message = TextInput(width=Window.size[0] * 0.8,
                                     size_hint_x=None,
                                     multiline=False)
        self.send = Button(text="Send", background_color=(0, 0, 255, 0.8))
        # self.send.halign = 'right'
        # self.send.size = 80,50
        # self.send.size_hint = None,None
        self.send.bind(on_press=self.send_message)

        bottom_line = GridLayout(cols=2,
                                 row_force_default=True,
                                 row_default_height=40)
        bottom_line.size_hint_y = .07
        bottom_line.add_widget(self.new_message)
        bottom_line.add_widget(self.send)

        # bottom_line = FloatLayout()
        # bottom

        self.add_widget(
            bottom_line)  ############################################

        Window.bind(on_key_down=self.on_key_down)

        Clock.schedule_once(self.focus_text_input, 1)
        socket_client.start_listening(self.incoming_message, show_error)
        self.bind(size=self.adjust_fields)
Example #35
0
    def __init__(self, **kwargs):
        super(Traffic, self).__init__(**kwargs)

        #result view tree
        self.root.view = BoxLayout(size_hint_x=3.5, orientation="vertical")
        view = self.root.view
        view.console = TextInput(readonly=True, size_hint_y=6.5, text="")
        view.input = TextInput(multiline=False, size_hint_y=0.5)
        view.input.bind(on_text_validate=self.ev_sendmsg)
        #associate with "view"
        view.add_widget(view.console)
        view.add_widget(view.input)

        #GUI's tree
        self.root.gui = BoxLayout(size_hint_x=6.5, orientation="vertical")
        gui = self.root.gui
        #make UI--button
        btn = gui.buttonBox = GridLayout(size_hint_y=2.5,
                                         cols=4,
                                         rows=2,
                                         spacing=12,
                                         padding=15)
        btn.oprate1 = Button(text="blue")
        btn.oprate2 = Button(text="red")
        btn.oprate3 = Button(text="yelow")
        btn.oprate4 = Button(text="wait")
        btn.oprate5 = Button(text="blue")
        btn.oprate6 = Button(text="red")
        btn.oprate7 = Button(text="yelow")
        btn.oprate8 = Button(text="wait")

        btn.oprate1.bind(on_press=self.ev_pushbtn)
        btn.oprate2.bind(on_press=self.ev_pushbtn)
        btn.oprate3.bind(on_press=self.ev_pushbtn)

        btn.add_widget(btn.oprate1)
        btn.add_widget(btn.oprate2)
        btn.add_widget(btn.oprate3)
        btn.add_widget(btn.oprate4)
        btn.add_widget(btn.oprate5)
        btn.add_widget(btn.oprate6)
        btn.add_widget(btn.oprate7)
        btn.add_widget(btn.oprate8)

        #make UI--slider
        sl = gui.sliderBox = BoxLayout(size_hint_y=2)
        sl.enpty = Label(size_hint_x=0.5)
        sl.slider = Slider(size_hint_x=7, min=0, max=100, value=25)
        sl.slider.bind(on_touch_move=self.ev_slider,
                       on_touch_up=self.ev_slider)

        sl.box = BoxLayout(size_hint_x=2.5, padding=(30, 50, 30, 50))
        sl.button = Button(text=format(sl.slider.value))
        sl.button.bind(on_press=self.btnev_sendmsg)
        sl.box.add_widget(sl.button)

        sl.add_widget(sl.enpty)
        sl.add_widget(sl.slider)
        sl.add_widget(sl.box)

        gui.enpty = Label(size_hint_y=4, text="test")

        oprate = gui.opbutton = BoxLayout(size_hint_y=1.5,
                                          padding=15,
                                          orientation="horizontal")
        oprate.enpty = Label()
        oprate.undo = Button(text="UNDO")
        oprate.reset = Button(text="RESET")
        oprate.run = Button(text="RUN")

        oprate.reset.bind(on_press=self.ev_pushbtn)
        oprate.undo.bind(on_press=self.ev_pushbtn)

        oprate.add_widget(oprate.enpty)
        oprate.add_widget(oprate.undo)
        oprate.add_widget(oprate.reset)
        oprate.add_widget(oprate.run)

        #To gui add any tree
        gui.add_widget(gui.buttonBox)
        gui.add_widget(gui.sliderBox)
        gui.add_widget(gui.enpty)
        gui.add_widget(gui.opbutton)

        #associate with root
        self.root.add_widget(gui)
        self.root.add_widget(view)
Example #36
0
class GUI(BoxLayout):
    """This class is devoted to create GUI and handle the actions"""

    #variable for converter class
    converter = None

    loadfile = ObjectProperty(None)
    selected_file = None
    path = None
    path_only = None
    lgf_name = None
    lgf_nfo = None

    node_params_root = None
    node_params_layout = None
    edge_params_root = None
    edge_params_layout = None

    params_width = Window.width / 2
    params_height = Window.height / 2.6

    #GUI node_params dictionary for the found node params list
    #by means of this, we can easily check after clicking Convert button that what should be
    #written in the lemon file and how
    node_params_to_write = dict()
    #and the same for edges
    edge_params_to_write = dict()

    #link costs' checkbox
    found_cost_cb = None
    random_cost_cb = None
    unit_cost_cb = None

    symmetric_cost_cb = None

    #convert button
    #     convert_button = None
    lemon_req = "USE AS LEMON REQUIRES"

    def initialize(self):
        '''
        INITIALIZING GUI COMPONENTS
        '''
        #just for faster testing
        self.file_text_input.text = ""

        #initializing node_params scrollview and layout
        self.node_params_layout = GridLayout(cols=2,
                                             spacing=10,
                                             size_hint_y=None)
        self.node_params_layout.bind(
            minimum_height=self.node_params_layout.setter('height'))

        self.node_params_root = ScrollView(
            size_hint=(None, None),
            size=(self.params_width, self.params_height),
            bar_width=5,
            bar_color=[.3, .3, .9, .5],
            do_scroll_x=False,
        )
        self.node_params_root.add_widget(self.node_params_layout)
        #initializing edge_params scrollview and layout
        self.edge_params_layout = GridLayout(cols=2,
                                             spacing=10,
                                             size_hint_y=None)
        self.edge_params_layout.bind(
            minimum_height=self.edge_params_layout.setter('height'))
        self.edge_params_root = ScrollView(size_hint=(None, None),
                                           size=(self.params_width - 20,
                                                 self.params_height),
                                           bar_width=5,
                                           bar_color=[.3, .3, .9, .5],
                                           do_scroll_x=False)
        self.edge_params_root.add_widget(self.edge_params_layout)

        #adding params widgets
        self.params_boxlayout.add_widget(self.node_params_root)
        self.params_boxlayout.add_widget(self.edge_params_root)

    def dismiss_popup(self):
        """
        This dismisses popups
        """
        self._popup.dismiss()

    def show_load(self):
        """
        show load file dialog
        """
        content = LoadDialog(load=self.load, cancel=self.dismiss_popup)
        self._popup = Popup(title="Load file",
                            content=content,
                            size_hint=(0.9, 0.9))
        self._popup.open()

    def load(self, path, filename):
        """
        this will load the file and dismiss the dialog
        """

        try:
            self.selected_file = filename[0]
            self.file_text_input.text = self.selected_file
            self.dismiss_popup()
            #             print "Selected file",self.selected_file
            #getting the path and the filename separately

            basename = os.path.basename(self.selected_file)
            path = os.path.abspath((self.selected_file))

            #             print "Basename",basename
            self.path_only = path[:(len(path) - len(basename))]
            basename = str(
                os.path.splitext(os.path.basename(self.selected_file))[0])
            #With these variable will shown where the new lgf and nfo file is saved
            self.lgf_name = self.path_only + basename + ".lgf"
            self.lgf_nfo = self.path_only + basename + ".nfo"

#             print self.path_only
#             print self.lgf_name
#             print self.lgf_nfo

        except IndexError as ie:
            print("Something made a boo-boo...try again", str(ie))
            self.dismiss_popup()
            self.show_popup(
                "ERROR",
                "Somehow I couldn't load the file:\nCheck the permissions or move it to other place"
            )

    def analyze(self):
        '''
        This function analyzes the read gml file
        '''
        self.converter = Converter(self.file_text_input.text)
        self.converter.set_reference(self.console_log)

        #clear console log
        self.console_log.text = ""
        #check that selected file is existing
        if (self.converter.read_file() != False):

            self.node_param_label.text = "Found node params (#{})".format(
                str(len(self.converter.node_params)))
            self.edge_param_label.text = "Found edge params (#{})".format(
                str(len(self.converter.edge_params)))

            #removing previously added widgets
            self.node_params_layout.clear_widgets()
            self.edge_params_layout.clear_widgets()

            ##### ---=========== NODE PARAMS PART    =====------- ######
            #adding the two column names
            self.node_params_layout.add_widget(Label(text="",
                                                     font_size="12sp"))
            self.node_params_layout.add_widget(Label(text="",
                                                     font_size="12sp"))
            self.node_params_layout.add_widget(
                Label(text="Property name in [b]GML[/b]",
                      font_size="14sp",
                      markup=True))
            self.node_params_layout.add_widget(
                Label(text="Property name in [b]LGF[/b]",
                      font_size="14sp",
                      markup=True))

            #adding found paramters to the related params widgets
            for i in self.converter.node_params:
                #LEMON uses label for ids
                if (str(i) == "id"):
                    textinput = TextInput(text="label",
                                          multiline=False,
                                          size_hint_x=0.6,
                                          size_hint_y=None,
                                          height=28,
                                          font_size=12,
                                          readonly=True,
                                          foreground_color=[.9, .1, .1, 1],
                                          background_color=[.7, .7, .7, 1])
                elif (str(i) == "label"):
                    textinput = TextInput(text="name",
                                          multiline=False,
                                          size_hint_x=0.6,
                                          size_hint_y=None,
                                          height=28,
                                          font_size=12,
                                          readonly=True,
                                          foreground_color=[.9, .1, .1, 1],
                                          background_color=[.7, .7, .7, 1])
                else:
                    textinput = TextInput(text=str(i).lower(),
                                          multiline=False,
                                          size_hint_x=0.6,
                                          size_hint_y=None,
                                          height=28,
                                          font_size=12)

                self.node_params_to_write[str(i)] = textinput

#             print(self.node_params_to_write)
            for i in self.node_params_to_write:
                if (self.converter.node_params[i] != len(
                        self.converter.nodes)):
                    label_text = "[b][color=ffff00]" + str(
                        i) + "[/color][/b] --->"
                else:
                    label_text = "[b]" + str(i) + "[/b] --->"
                label = Label(text=label_text,
                              size_hint_x=0.4,
                              size_hint_y=None,
                              height=28,
                              font_size="12sp",
                              markup=True)
                self.node_params_layout.add_widget(label)
                self.node_params_layout.add_widget(
                    self.node_params_to_write[i])
            ##### ---======= END OF NODE PARAMS PART =====------- ######

            ##### ---=========== EDGE PARAMS PART    =====------- ######
            #adding the two column names
            self.edge_params_layout.add_widget(Label(text="",
                                                     font_size="12sp"))
            self.edge_params_layout.add_widget(Label(text="",
                                                     font_size="12sp"))
            self.edge_params_layout.add_widget(
                Label(text="Property name in [b]GML[/b]",
                      font_size="14sp",
                      markup=True))
            self.edge_params_layout.add_widget(
                Label(text="Property name in [b]LGF[/b]",
                      font_size="14sp",
                      markup=True))

            #adding found paramters to the related params widgets
            for i in self.converter.edge_params:
                #LEMON uses label for ids
                if ((str(i) == "source") or (str(i) == "target")):
                    textinput = TextInput(text=self.lemon_req,
                                          multiline=False,
                                          size_hint_x=0.6,
                                          size_hint_y=None,
                                          height=28,
                                          font_size=12,
                                          readonly=True,
                                          foreground_color=[.9, .1, .1, 1],
                                          background_color=[.7, .7, .7, 1])
                elif ((str(i) == "id") or (str(i) == "label")):
                    textinput = TextInput(text="name",
                                          multiline=False,
                                          size_hint_x=0.6,
                                          size_hint_y=None,
                                          height=28,
                                          font_size=12)
                else:
                    textinput = TextInput(text=str(i).lower(),
                                          multiline=False,
                                          size_hint_x=0.6,
                                          size_hint_y=None,
                                          height=28,
                                          font_size=12)

                self.edge_params_to_write[str(i)] = textinput
            for i in self.edge_params_to_write:
                if (self.converter.edge_params[i] != len(
                        self.converter.edges)):
                    label_text = "[b][color=ffff00]" + str(
                        i) + "[/color][/b] --->"
                else:
                    label_text = "[b]" + str(i) + "[/b] --->"
                label = Label(text=label_text,
                              size_hint_x=0.4,
                              size_hint_y=None,
                              height=28,
                              font_size="12sp",
                              markup=True)
                self.edge_params_layout.add_widget(label)
                self.edge_params_layout.add_widget(
                    self.edge_params_to_write[i])

            #adding checkboxes for link costs
            self.found_cost_cb = CheckBox(size_hint=(.9, None),
                                          group="link_costs",
                                          height=12,
                                          active=True)
            #             found_cost_cb.bind(active=self.on_checkbox_active)
            self.random_cost_cb = CheckBox(size_hint=(.9, None),
                                           group="link_costs",
                                           height=12)
            #             random_cost_cb.bind(active=self.on_checkbox_active)
            self.unit_cost_cb = CheckBox(size_hint=(.9, None),
                                         group="link_costs",
                                         height=12)
            #             unit_cost_cb.bind(active=self.on_checkbox_active)

            #adding checkboxes to GUI
            self.edge_params_layout.add_widget(
                Label(text="Found link costs", halign="justify"))
            self.edge_params_layout.add_widget(self.found_cost_cb)
            self.edge_params_layout.add_widget(
                Label(text="Random[1,100] link costs", halign="justify"))
            self.edge_params_layout.add_widget(self.random_cost_cb)
            self.edge_params_layout.add_widget(
                Label(text="Unit link costs", halign="justify"))
            self.edge_params_layout.add_widget(self.unit_cost_cb)

            #adding symmetric link costs option to GUI
            self.symmetric_cost_cb = CheckBox(size_hint=(.9, None),
                                              height=14,
                                              paddint=10,
                                              active=True)
            self.edge_params_layout.add_widget(Label(text="",
                                                     font_size="14sp"))
            self.edge_params_layout.add_widget(Label(text="",
                                                     font_size="14sp"))
            self.edge_params_layout.add_widget(
                Label(text="Use symmetric costs"))
            self.edge_params_layout.add_widget(self.symmetric_cost_cb)
#             self.edge_params_layout.add_widget(Label(text="(Lemon DiGraph)",size_hint=(None,None),height=8))

##### ---======= END OF EDGE PARAMS PART =====------- ######
#

        else:
            #             self.show_popup("ERROR", "Unable to read file: {}".format(self.file_text_input.text))
            self.show_popup("ERROR", self.converter.error_msg)

#     def on_checkbox_active(self,checkbox,value):
#
#         print value

    def dummy(self):
        print("GML2LGF converter gui started")

    def convert(self):
        """This function checks whether everything was set and read correctly,
        and then calls Converter class' dedicated functions to write out
        the new LGF file"""

        #checking that analyze button was pressed and some gml file was already loaded
        if isinstance(self.converter, Converter):
            #OK, we can do convert now, all necessary stuff was created and file was read

            status = dict()
            print("CONVERT")
            if (self.found_cost_cb.active):
                status["cost"] = "found"
            elif (self.random_cost_cb.active):
                status["cost"] = "random"
            elif (self.unit_cost_cb.active):
                status["cost"] = "unit"
            else:
                self.show_popup("ERROR",
                                "Somehow the type of costs was not selected")

            status["symmetric"] = False
            if (self.symmetric_cost_cb.active):
                status["symmetric"] = True

            #HERE we call the Converter class' function to finalize the results
            node_params_to_write_with_given_paramname = dict()
            for i in self.node_params_to_write:
                if (self.node_params_to_write[i].text != ""):
                    node_params_to_write_with_given_paramname[
                        i] = self.node_params_to_write[i].text

            #HERE we get the set parameters for the edges
            edge_params_to_write_with_given_paramname = dict()
            for i in self.edge_params_to_write:
                if (self.edge_params_to_write[i].text != self.lemon_req):
                    edge_params_to_write_with_given_paramname[
                        i] = self.edge_params_to_write[i].text

            self.converter.write_out_results(
                status, node_params_to_write_with_given_paramname,
                edge_params_to_write_with_given_paramname)

            self.show_popup(
                "DONE", "The new .lgf and .nfo file is created\n" +
                str(self.lgf_name) + "\n" + str(self.lgf_nfo))


#             print "The new .lgf and .nfo file is created\n"+str(self.lgf_name)+"\n"+str(self.lgf_nfo)
        else:
            print("No file was loaded and analyze --- do it first")
            self.show_popup(
                "ERROR", "No GML file was loaded and analyzed\n DO IT FIRST!")

    def show_popup(self, *args):
        """This functions shows a Kivy Popup window"""

        popup = Popup(title=args[0],
                      content=Label(text=args[1]),
                      size_hint=(None, None),
                      size=(Window.width - 50, Window.height - 50),
                      separator_color=[247 / 255., 1 / 255., 1 / 255., 1.],
                      title_size='24sp')
        popup.open()

    def get_filetext_input(self):
        """reads the text of the file input text_field"""
        return self.file_txt_input

    def close(self):
        """Default close event to main window"""
        exit()
Example #37
0
    def __init__(self, dataList, title):
        self.name = "editabletable"
        super(EditableTable, self).__init__()
        parent_layout = FloatLayout()
        self.title = str(title)
        scroll_layout = ScrollView(size_hint=(1, None),
                                   size=(Window.width, Window.height))
        scroll_layout.bind(size=self._update_rect, pos=self._update_rect)
        table_layout = GridLayout(cols=len(dataList[0]) + 1,
                                  size_hint_y=None,
                                  spacing=5)
        table_layout.bind(minimum_height=table_layout.setter('height'))
        # table_layout.bind(size=self._update_rect, pos=self._update_rect)
        length = len(dataList[0])

        self.company = Button(text='Back|',
                              color=(0, 0, 0, 1),
                              background_color=(0, 0, 0, 0),
                              font_size=20,
                              on_press=self.back,
                              pos_hint={
                                  'center_x': 0.12,
                                  'center_y': 0.95
                              })
        table_layout.add_widget(self.company)
        # self.company.bind(on_press=lambda m: print("hello"))
        table_layout.add_widget(
            Label(
                text="KAKABOKA",
                size_hint_y=None,
                color=(0, 0, 0, 1),
                font_size=20,
            ))
        i = 0
        while i < length - 1:
            table_layout.add_widget(Label(text="", size_hint_y=None,
                                          height=50))
            i = i + 1
        dataList[0].reverse()
        for i, row_data in enumerate(dataList[0]):
            t = Label(text=row_data,
                      size_hint_y=None,
                      height=40,
                      color=(0, 0, 0, 1))
            table_layout.add_widget(t, index=i)
        table_layout.add_widget(Label(text=""))
        dataList = dataList[1:]

        for row_n, row_data in enumerate(dataList):
            row_data.reverse()
            row_data.append("")
            for i, row in enumerate(row_data):
                new_row = row_data
                t = TextInput(hint_text=str(row),
                              text=str(row),
                              disabled=True,
                              size_hint_y=None,
                              height=40,
                              multiline=False)
                if i <= length - 1:

                    table_layout.add_widget(t, index=i)

                    def changeText(event, data):

                        new_row[i] = data
                        print(data)

                    t.bind(text=changeText)
                else:
                    btn = Button(text="Edit", size_hint_y=None, height=40)
                    btn.barcode_prop = StringProperty()
                    btn.category_prop = StringProperty()
                    btn.barcode_prop = row_data[5]
                    btn.category_prop = row_data[0]
                    btn.bind(on_press=self.updateRecord)
                    table_layout.add_widget(btn)

        with scroll_layout.canvas.before:
            base_folder = os.path.dirname(__file__)
            image_path = os.path.join(base_folder, 'background.png')
            self.rect = Rectangle(source=image_path,
                                  size=scroll_layout.size,
                                  pos=scroll_layout.pos)

        scroll_layout.add_widget(table_layout)
        self.add_widget(scroll_layout)

        self.add_widget(parent_layout)
class MyGridLayout(GridLayout):
	# Initialize infinite keywords
	def __init__(self, **kwargs):
		# Call grid layout constructor
		super(MyGridLayout, self).__init__(**kwargs)

		# Set columns
		self.cols = 1

		# Set default size of cols and rows
		self.row_force_default=True
		self.row_default_height=120
		self.col_force_default=True
		self.col_default_width=100

		# Create a second gridlayout
		self.top_grid = GridLayout(
			row_force_default=True,
			row_default_height=40,
			col_force_default=True,
			col_default_width=100
			)
		# Set number of columns in our new top_grid
		self.top_grid.cols = 2




		# Add widgets
		self.top_grid.add_widget(Label(text="Name: "))
		# Add Input Box
		self.name = TextInput(multiline=True)
		self.top_grid.add_widget(self.name)

		self.top_grid.add_widget(Label(text="Favorite Pizza: "))
		# Add Input Box
		self.pizza = TextInput(multiline=False)
		self.top_grid.add_widget(self.pizza)

		self.top_grid.add_widget(Label(text="Favorite Color: "))
		# Add Input Box
		self.color = TextInput(multiline=False)
		self.top_grid.add_widget(self.color)

		# Add the new top_grid to our app
		self.add_widget(self.top_grid)



		# Create a Submit Button
		self.submit = Button(text="Submit", 
			font_size=32,
			size_hint_y = None,
			height=50,
			size_hint_x = None,
			width=200
			)
		# Bind the button
		self.submit.bind(on_press=self.press)
		self.add_widget(self.submit)

	def press(self, instance):
		name = self.name.text
		pizza = self.pizza.text
		color = self.color.text

		#print(f'Hello {name}, you like {pizza} pizza, and your favorite color is {color}!')
		# Print it to the screen
		self.add_widget(Label(text=f'Hello {name}, you like {pizza} pizza, and your favorite color is {color}!'))

		# Clear the input boxes
		self.name.text = ""
		self.pizza.text = ""
		self.color.text = ""
Example #39
0
    def Start(self, uTitle, aOptions, fktCallBack):
        """ starts selection """
        self.fktCallBack = fktCallBack
        # create the popup
        content = GridLayout(cols=1, spacing='5dp')
        scrollview = ScrollView(do_scroll_x=False,
                                bar_width='10dp',
                                scroll_type=['bars', 'content'])
        scrollcontent = GridLayout(cols=1,
                                   spacing='5dp',
                                   size_hint=(None, None))
        scrollcontent.bind(minimum_height=scrollcontent.setter('height'))
        self.oPopup = popup = Popup(content=content,
                                    title=ReplaceVars(uTitle),
                                    size_hint=(0.5, 0.9),
                                    auto_dismiss=False)

        #we need to open the popup first to get the metrics
        popup.open()
        #Add some space on top
        content.add_widget(Widget(size_hint_y=None, height=dp(2)))
        # add all the options
        for option in aOptions:
            if hasattr(option, "Name"):
                name = option.Name
            else:
                name = option.Type
            btn = Button(text=name,
                         size=(popup.width, dp(30)),
                         size_hint=(None, None))
            btn.bind(on_release=self.On_Value)
            btn.oDBRef = option
            scrollcontent.add_widget(btn)

        # finally, add a cancel button
        scrollview.add_widget(scrollcontent)
        content.add_widget(scrollview)
        content.add_widget(SettingSpacer())
        btn = Button(text=ReplaceVars('$lvar(5009)'),
                     size=(popup.width, dp(50)),
                     size_hint=(0.9, None))
        btn.bind(on_release=popup.dismiss)
        content.add_widget(btn)
Example #40
0
class TabbedCEFBrowser(GridLayout):
    def __init__(self, urls=["http://www.rentouch.ch"], *largs, **dargs):
        super(TabbedCEFBrowser, self).__init__(cols=1, *largs, **dargs)
        gl = GridLayout(rows=1, size_hint=(1, None), height=controls_size)
        self.current_tab = None
        self.__tab_bar_scroll = ScrollView(size_hint=(1, 1))
        self.__tab_bar_grid = GridLayout(rows=1, size_hint=(None, 1))
        self.__tab_bar_grid.bind(
            minimum_width=self.__tab_bar_grid.setter("width"))
        last_tab = None
        for url in urls:
            this_tab = TabbedCEFBrowserTab(self, url, url)
            this_tab.last_tab = last_tab
            self.__tab_bar_grid.add_widget(this_tab)
            last_tab = this_tab
        self.current_tab = last_tab
        self.__tab_bar_scroll.add_widget(self.__tab_bar_grid)
        self.__tab_bar_scroll.bind(height=self.__tab_bar_grid.setter("height"))
        gl.add_widget(self.__tab_bar_scroll)
        self.__tab_bar_new = Button(text="+",
                                    font_size=controls_size / 2,
                                    size_hint=(None, 1),
                                    width=controls_size)
        self.__tab_bar_new.bind(on_press=self._on_new_tab)
        gl.add_widget(self.__tab_bar_new)
        self.__control_bar_grid = GridLayout(rows=1,
                                             size_hint=(1, None),
                                             height=controls_size)
        self._back_button = Button(text="<",
                                   font_size=controls_size / 2,
                                   size_hint=(None, 1),
                                   width=controls_size)
        self._back_button.bind(on_press=self._on_back_press)
        self._forward_button = Button(text=">",
                                      font_size=controls_size / 2,
                                      size_hint=(None, 1),
                                      width=controls_size)
        self._forward_button.bind(on_press=self._on_forward_press)
        self._url_input = TextInput(text="http://",
                                    font_size=controls_size / 2,
                                    size_hint=(1, 1),
                                    multiline=False)
        self._url_input.bind(focus=self._on_url_focus)
        self._url_input.bind(on_text_validate=self._on_url_validate)
        self._load_button = Button(text="Go",
                                   font_size=controls_size / 2,
                                   size_hint=(None, 1),
                                   width=controls_size)
        self._load_button.bind(on_press=self._on_load_button)
        self.__control_bar_grid.add_widget(self._back_button)
        self.__control_bar_grid.add_widget(self._forward_button)
        self.__control_bar_grid.add_widget(self._url_input)
        self.__control_bar_grid.add_widget(self._load_button)
        self._current_browser = CEFBrowser()
        self.add_widget(gl)
        self.add_widget(self.__control_bar_grid)
        self.add_widget(self._current_browser)
        self.select_first_tab()

    def _focus_url_input(self, *largs):
        self._url_input.focus = True

    def _on_new_tab(self, but):
        self.add_tab(TabbedCEFBrowserTab(self, "http://google.com", "Google"))
        Clock.schedule_once(self._focus_url_input, 0)

    def _on_back_press(self, back_button):
        self._current_browser.go_back()

    def _on_forward_press(self, forward_button):
        self._current_browser.go_forward()

    def _on_url_focus(self, url_input, new_focus):
        if new_focus:

            def fn(*largs):
                url_input.select_all()

            Clock.schedule_once(fn, 0)
            self._load_button.text = "Go"
        else:
            url_input.text = self._current_browser.url
            self._load_button.text = \
                "x" if self._current_browser.is_loading else "r"

    def _on_url_validate(self, url_input):
        self._current_browser.url = self._url_input.text

    def _on_load_button(self, load_button):
        if self._url_input.focus:
            self._current_browser.url = self._url_input.text
        elif self._current_browser.is_loading:
            self._current_browser.stop_loading()
        else:
            self._current_browser.reload()

    def select_first_tab(self):
        for tab in self.__tab_bar_grid.children:
            tab.select()
            break

    @property
    def tabs(self):
        return self.__tab_bar_grid.children

    def add_tab(self, new_tab):
        self.__tab_bar_grid.add_widget(new_tab)
        new_tab.select()

    def remove_tab(self, remove_tab):
        self.__tab_bar_grid.remove_widget(remove_tab)
        self.current_tab = remove_tab.last_tab
        remove_tab.last_tab.select()

    def _set_tab(self, new_tab):
        if self.current_tab != new_tab:
            ct = self.current_tab
            tmp = ct
            while tmp:
                if tmp.last_tab == new_tab:
                    tmp.last_tab = new_tab.last_tab
                tmp = tmp.last_tab
            new_tab.last_tab = ct
            self.current_tab = new_tab
        try:
            self._current_browser.unbind(url=self._url_input_set_text)
        except:
            pass
        Clock.schedule_once(
            functools.partial(self._old_tab_remove_keyboard,
                              self._current_browser))
        self.remove_widget(self._current_browser)
        self._url_input.text = new_tab.url
        self._current_browser = new_tab.cef_browser
        self.add_widget(self._current_browser)
        self._current_browser.bind(url=self._url_input_set_text)

    def _url_input_set_text(self, browser, url):
        self._url_input.text = url
        if self._url_input.focus:
            self._url_input.select_all()

    def _old_tab_remove_keyboard(self, browser, *largs):
        print("old_tab_remove_keyboard", browser)
        browser.focus = False
Example #41
0
        yesButton.bind(on_release=self.exitProgram)
        noButton.bind(on_release=quitPop.dismiss)

        quitLay.add_widget(yesButton)
        quitLay.add_widget(noButton)
        quitLay.add_widget(confirmationLabel)

        quitPop.open()


#Builder.load_file('display.kv')
Window.clearcolor = (0.1, 0.1, 0.1, 1)  # (WHITE)
# ////////////////////////////////////////////////////////////////
# //					 CREATE GRID/ACTORS						//
# ////////////////////////////////////////////////////////////////
grid = GridLayout(id='grid', cols=9, rows=9, padding=15, spacing=1.5)
bg = Image(source='BG.jpg', size_hint=[1, 1])
for i in range(0, grid.cols * grid.rows):
    b = Actor(id='actor' + str(i + 1),
              source='ICON_Transparent.png',
              size_hint=[None, None])
    grid.add_widget(b)

main = MainScreen(name='main')
main.add_widget(bg)
main.add_widget(grid)
sm.add_widget(main)
screen = Screen(name="Winner")
youWinner = Image(source='winner.jpg')
screen.add_widget(youWinner)
loserScreen = Screen(name="Loser")
 def __init__(self):
     layout = GridLayout(cols=3)
Example #43
0
    def build(self):
        main = BoxLayout(orientation='vertical', height=800)
        grid = GridLayout(cols=1)
        title = Label(text='ytDl', size_hint_y=None, height=200, font_size=150)
        songLabel = Label(text='Song:', size_hint_y=None, height=150, font_size=100)
        artistLabel = Label(text='Artist:',  size_hint_y=None, height=150, font_size=100)
        song = TextInput(multiline=False, size_hint_y=None, height=100, font_size=80)
        artist = TextInput(multiline=False, size_hint_y=None, height=100, font_size=80)
        download = Button(text='Download', size_hint_y=None, height=100, font_size=80)

        grid.add_widget(title)
        grid.add_widget(songLabel)
        grid.add_widget(song)
        grid.add_widget(artistLabel)
        grid.add_widget(artist)
        grid.add_widget(download)
        main.add_widget(grid)

        return main
Example #44
0
    def build(self):
        layout = GridLayout(cols=3,
                            spacing=30,
                            padding=30,
                            row_default_height=150)

        # Make the background gray:
        with layout.canvas.before:
            Color(.2, .2, .2, 1)
            self.rect = Rectangle(size=(800, 600), pos=layout.pos)

        # Instantiate the various Widgets
        labelTemp = Label(text="[size=30]Temperatur: " + "--" + "C[/size]",
                          markup=True)
        labelHum = Label(text="[size=30]Luftfeuchtigkeit: " + "--" +
                         "%[/size]",
                         markup=True)
        labelQual = Label(text="[size=30]Luftqualitaet: " + "--" + "[/size]",
                          markup=True)
        btnShisha = ToggleButton(text="Shisha Modus An/Aus")
        btnShisha.bind(on_press=press_callback)
        btnMan = ToggleButton(text="Manueller Modus An/Aus")
        btnMan.bind(on_press=press_callback)
        btnStart = ToggleButton(text="Motor An/Aus")
        btnStart.bind(on_press=press_callback)

        # Add the Widgets to the Layout
        layout.add_widget(labelTemp)
        layout.add_widget(labelHum)
        layout.add_widget(labelQual)
        layout.add_widget(btnShisha)
        layout.add_widget(btnMan)
        layout.add_widget(btnStart)

        # Schedule update of Sensordata
        Clock.schedule_interval(self.sensorupdate, 1.0 / 10.0)

        return layout
Example #45
0
class EditBlockPage(BoxLayout):
    def __init__(self, **kwargs):
        super(EditBlockPage, self).__init__(**kwargs)
        self.orientation = "vertical"
        self.previous_screen = ""

        # Title "Add/Edit Block" at top of page
        self.title = Label(text="Add/Edit Block", font_size=25)
        self.title.size_hint_y = None
        self.title.height = 58
        self.add_widget(self.title)

        # Float layout for form
        self.form = GridLayout(cols=2)
        self.form.size_hint_y = None
        self.form.height = 550
        self.add_widget(self.form)

        # Dropdown Selection
        label = Label(text="Work/Break:", font_size=20)
        self.form.add_widget(label)

        self.dropdown = DropDown()

        for item in ["Work", "Break"]:
            btn = Button(text=item, size_hint_y=None, height=38)
            btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
            self.dropdown.add_widget(btn)

        anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.dropbutton = Button(text='SELECT', size_hint_y=None, height=44)
        self.dropbutton.bind(on_release=self.dropdown.open)
        self.dropdown.bind(
            on_select=lambda instance, x: setattr(self.dropbutton, 'text', x))
        anchor.add_widget(self.dropbutton)
        self.form.add_widget(anchor)

        # Start Date
        self.form.add_widget(Label(text="Start Date:", font_size=20))
        self.start_date = DatePicker(size_hint_y=None, height=60)
        self.start_date_anchor = AnchorLayout(anchor_x='center',
                                              anchor_y='center')
        self.start_date_anchor.add_widget(self.start_date)
        self.form.add_widget(self.start_date_anchor)

        # Start Time
        self.form.add_widget(Label(text="Start Time:", font_size=20))
        self.start_time = TimePicker(size_hint_y=None, height=60)
        self.start_time_anchor = AnchorLayout(anchor_x='center',
                                              anchor_y='center')
        self.start_time_anchor.add_widget(self.start_time)
        self.form.add_widget(self.start_time_anchor)

        # End Date
        self.form.add_widget(Label(text="End Date:", font_size=20))
        self.end_date = DatePicker(size_hint_y=None, height=60)
        self.end_date_anchor = AnchorLayout(anchor_x='center',
                                            anchor_y='center')
        self.end_date_anchor.add_widget(self.end_date)
        self.form.add_widget(self.end_date_anchor)

        # End Time
        self.form.add_widget(Label(text="End Time:", font_size=20))
        self.end_time = TimePicker(size_hint_y=None, height=60)
        self.end_time_anchor = AnchorLayout(anchor_x='center',
                                            anchor_y='center')
        self.end_time_anchor.add_widget(self.end_time)
        self.form.add_widget(self.end_time_anchor)

        # Buttons
        # self.button1 = Button(text="Add Tasks", font_size=20)
        # self.button1.bind(on_press=self.button1_act)
        # self.add_widget(self.button1)

        self.button2 = Button(text="Specialized Denylist", font_size=20)
        self.button2.bind(on_press=self.button2_act)
        self.add_widget(self.button2)

        self.button3 = Button(text="Submit", font_size=20)
        self.button3.bind(on_press=self.button3_act)
        self.add_widget(self.button3)

        self.special_denylist = None
        self.block = None

    # Button 1 - Add Tasks
    def button1_act(self, instance):
        pass

    # Button 2 - Specialized Denylist - go to Denylist screen
    def button2_act(self, instance):
        if self.block == None or self.block.denylist == None:
            self.special_denylist = deepcopy(db.get_denylist())
            nag_bot_app.denylist_page.gen_list(
                specialized=self.special_denylist)
        else:
            nag_bot_app.denylist_page.gen_list(specialized=self.block.denylist)
        nag_bot_app.screen_manager.transition.direction = 'left'
        nag_bot_app.screen_manager.current = "Denylist"
        nag_bot_app.denylist_page.previous_screen = "Edit Block"
        pass

    # Button 3 - Submit - add Block, return to previous screen
    def button3_act(self, instance):
        # add Block
        if self.dropbutton.text != "SELECT":
            start_date = self.start_date.text.split('.')
            start_time = self.start_time.text.split(':')
            end_date = self.end_date.text.split('.')
            end_time = self.end_time.text.split(':')

            for x in range(3):
                start_date[x] = int(start_date[x])
                start_time[x] = int(start_time[x])
                end_date[x] = int(end_date[x])
                end_time[x] = int(end_time[x])

            type = self.dropbutton.text
            start = datetime.datetime(start_date[2], start_date[0],
                                      start_date[1], start_time[0],
                                      start_time[1], start_time[1])
            end = datetime.datetime(end_date[2], end_date[0], end_date[1],
                                    end_time[0], end_time[1], end_time[1])

            try:
                if self.block != None:
                    print("Editing block")
                    db.edit_block(self.block.id, type, start, end)
                    db.save()
                    if self.block.denylist == None:
                        self.block.denylist = self.special_denylist
                else:
                    block = db.add_block(type, start, end)
                    block.denylist = self.special_denylist
                    db.save()
                    print("Block Added")
            except EndBeforeStart:
                win32api.MessageBox(
                    0, '''NagBot: Cannot have block end before it starts.
                    The block will not be added.''', 'End Before Start',
                    0x00001000)
            except OverlapsExisting:
                win32api.MessageBox(
                    0, '''NagBot: The block you are attempting to add overlaps
                    with an existing block. The block will not be
                    added.''', 'Overlaps Existing', 0x00001000)

        # return to previous screen
        nag_bot_app.schedule_page.gen_schedule()
        if self.block != None:
            nag_bot_app.to_do_page.update_block(self.block)

        nag_bot_app.screen_manager.transition.direction = 'right'
        nag_bot_app.screen_manager.current = self.previous_screen
        nag_bot_app.screen_manager.get_screen(
            self.previous_screen).previous_screen = "Edit Block"

    # reset form
    def reset(self, date):
        self.block = None
        self.dropbutton.text = "SELECT"

        self.start_date_anchor.remove_widget(self.start_date)
        self.start_date = DatePicker(size_hint_y=None, height=60, date=date)
        self.start_date_anchor.add_widget(self.start_date)

        self.end_date_anchor.remove_widget(self.end_date)
        self.end_date = DatePicker(size_hint_y=None, height=60, date=date)
        self.end_date_anchor.add_widget(self.end_date)

    def edit_block(self, block):
        self.block = block
        self.dropbutton.text = block.type

        self.start_time.text = block.start.strftime("%H:%M:%S")
        self.end_time.text = block.end.strftime("%H:%M:%S")

        start_date = datetime.date(block.start.year, block.start.month,
                                   block.start.day)
        self.start_date_anchor.remove_widget(self.start_date)
        self.start_date = DatePicker(size_hint_y=None,
                                     height=60,
                                     date=start_date)
        self.start_date_anchor.add_widget(self.start_date)

        end_date = datetime.date(block.end.year, block.end.month,
                                 block.end.day)
        self.end_date_anchor.remove_widget(self.end_date)
        self.end_date = DatePicker(size_hint_y=None, height=60, date=end_date)
        self.end_date_anchor.add_widget(self.end_date)
 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)
Example #47
0
class AddTaskPage(BoxLayout):
    def __init__(self, **kwargs):
        super(AddTaskPage, self).__init__(**kwargs)
        self.orientation = "vertical"
        self.previous_screen = ""

        self.block = None

        # Title "Add Task" at top of page
        self.title = Label(text="Add Task", font_size=25)
        self.title.size_hint_y = None
        self.title.height = 58
        self.add_widget(self.title)

        # main form inside GridLayout
        self.form = GridLayout(cols=2)
        self.form.size_hint_y = None
        self.form.height = 600
        self.add_widget(self.form)

        label = Label(text="Name:", font_size=20)
        self.form.add_widget(label)
        self.name = TextInput(font_size=20)
        self.form.add_widget(self.name)

        label = Label(text="Priority:", font_size=20)
        self.form.add_widget(label)

        self.dropdown = DropDown()

        for item in ["High", "Med", "Low"]:
            btn = Button(text=item, size_hint_y=None, height=80)
            btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
            self.dropdown.add_widget(btn)

        anchor = AnchorLayout(anchor_x='center', anchor_y='center')
        self.dropbutton = Button(text='SELECT', size_hint_y=None, height=100)
        self.dropbutton.bind(on_release=self.dropdown.open)
        self.dropdown.bind(
            on_select=lambda instance, x: setattr(self.dropbutton, 'text', x))
        anchor.add_widget(self.dropbutton)
        self.form.add_widget(anchor)

        # additional space fill with labels
        for x in range(4):
            self.form.add_widget(Label())

        # Button
        self.button1 = Button(text="Done", font_size=20)
        self.button1.bind(on_press=self.button1_act)
        self.add_widget(self.button1)

    def set_block(self, block):
        self.block = block

    def button1_act(self, instance):
        # provided form is filled out
        if self.name.text != "" and self.dropbutton.text != "SELECT":
            db.add_task(self.block.id, self.name.text, self.dropbutton.text)
            db.save()

        nag_bot_app.to_do_page.update()

        nag_bot_app.screen_manager.transition.direction = 'right'
        nag_bot_app.screen_manager.current = "To Do List"

        self.name.text = ""
        self.dropbutton.text = "SELECT"
Example #48
0
    def __init__(self, **kwargs):
        super(EditBlockPage, self).__init__(**kwargs)
        self.orientation = "vertical"
        self.previous_screen = ""

        # Title "Add/Edit Block" at top of page
        self.title = Label(text="Add/Edit Block", font_size=25)
        self.title.size_hint_y = None
        self.title.height = 58
        self.add_widget(self.title)

        # Float layout for form
        self.form = GridLayout(cols=2)
        self.form.size_hint_y = None
        self.form.height = 550
        self.add_widget(self.form)

        # Dropdown Selection
        label = Label(text="Work/Break:", font_size=20)
        self.form.add_widget(label)

        self.dropdown = DropDown()

        for item in ["Work", "Break"]:
            btn = Button(text=item, size_hint_y=None, height=38)
            btn.bind(on_release=lambda btn: self.dropdown.select(btn.text))
            self.dropdown.add_widget(btn)

        anchor = AnchorLayout(anchor_x='center', anchor_y='top')
        self.dropbutton = Button(text='SELECT', size_hint_y=None, height=44)
        self.dropbutton.bind(on_release=self.dropdown.open)
        self.dropdown.bind(
            on_select=lambda instance, x: setattr(self.dropbutton, 'text', x))
        anchor.add_widget(self.dropbutton)
        self.form.add_widget(anchor)

        # Start Date
        self.form.add_widget(Label(text="Start Date:", font_size=20))
        self.start_date = DatePicker(size_hint_y=None, height=60)
        self.start_date_anchor = AnchorLayout(anchor_x='center',
                                              anchor_y='center')
        self.start_date_anchor.add_widget(self.start_date)
        self.form.add_widget(self.start_date_anchor)

        # Start Time
        self.form.add_widget(Label(text="Start Time:", font_size=20))
        self.start_time = TimePicker(size_hint_y=None, height=60)
        self.start_time_anchor = AnchorLayout(anchor_x='center',
                                              anchor_y='center')
        self.start_time_anchor.add_widget(self.start_time)
        self.form.add_widget(self.start_time_anchor)

        # End Date
        self.form.add_widget(Label(text="End Date:", font_size=20))
        self.end_date = DatePicker(size_hint_y=None, height=60)
        self.end_date_anchor = AnchorLayout(anchor_x='center',
                                            anchor_y='center')
        self.end_date_anchor.add_widget(self.end_date)
        self.form.add_widget(self.end_date_anchor)

        # End Time
        self.form.add_widget(Label(text="End Time:", font_size=20))
        self.end_time = TimePicker(size_hint_y=None, height=60)
        self.end_time_anchor = AnchorLayout(anchor_x='center',
                                            anchor_y='center')
        self.end_time_anchor.add_widget(self.end_time)
        self.form.add_widget(self.end_time_anchor)

        # Buttons
        # self.button1 = Button(text="Add Tasks", font_size=20)
        # self.button1.bind(on_press=self.button1_act)
        # self.add_widget(self.button1)

        self.button2 = Button(text="Specialized Denylist", font_size=20)
        self.button2.bind(on_press=self.button2_act)
        self.add_widget(self.button2)

        self.button3 = Button(text="Submit", font_size=20)
        self.button3.bind(on_press=self.button3_act)
        self.add_widget(self.button3)

        self.special_denylist = None
        self.block = None
Example #49
0
    def __init__(self, **kwargs):
        super(GameWindow, self).__init__(**kwargs)
        self.cols = 1
        self.rows = 2

        self.GameWindow1 = GridLayout()
        self.GameWindow1.cols = 1
        self.GameWindow1.rows = 3

        self.GameWindow1.add_widget(
            Label(text="COMPUTER DEALER",
                  font_size=20,
                  color=(0, 1, 1, 1),
                  halign="center",
                  valign="center"))

        self.GameWindow2 = GridLayout()
        self.GameWindow2.cols = 7
        self.GameWindow2.rows = 1

        self.GameWindow2.add_widget(Label(text=""))

        self.compCardImage1 = Image(source=imagePath + "blue_back.png")
        self.GameWindow2.add_widget(self.compCardImage1)

        self.compCardImage2 = Image(source=imagePath + "blue_back.png")
        self.GameWindow2.add_widget(self.compCardImage2)

        self.compCardImage3 = Image(source=imagePath + "blue_back.png")
        self.GameWindow2.add_widget(self.compCardImage3)

        self.compCardImage4 = Image(source=imagePath + "blue_back.png")
        self.GameWindow2.add_widget(self.compCardImage4)

        self.compCardImage5 = Image(source=imagePath + "blue_back.png")
        self.GameWindow2.add_widget(self.compCardImage5)

        self.GameWindow2.add_widget(Label(text=""))

        self.GameWindow3 = GridLayout()
        self.GameWindow3.cols = 1
        self.GameWindow3.rows = 1

        self.GameWindow4 = GridLayout()
        self.GameWindow4.cols = 1
        self.GameWindow4.rows = 3

        self.GameWindow5 = GridLayout()
        self.GameWindow5.cols = 7
        self.GameWindow5.rows = 1

        self.GameWindow5.add_widget(Label(text=""))

        self.playerCardImage1 = Image(source=imagePath + "blue_back.png")
        self.GameWindow5.add_widget(self.playerCardImage1)

        self.playerCardImage2 = Image(source=imagePath + "blue_back.png")
        self.GameWindow5.add_widget(self.playerCardImage2)

        self.playerCardImage3 = Image(source=imagePath + "blue_back.png")
        self.GameWindow5.add_widget(self.playerCardImage3)

        self.playerCardImage4 = Image(source=imagePath + "blue_back.png")
        self.GameWindow5.add_widget(self.playerCardImage4)

        self.playerCardImage5 = Image(source=imagePath + "blue_back.png")

        self.GameWindow5.add_widget(self.playerCardImage5)
        self.GameWindow5.add_widget(Label(text=""))

        self.GameWindow6 = GridLayout()
        self.GameWindow6.cols = 1
        self.GameWindow6.rows = 1

        self.GameWindow6.add_widget(
            Label(text="PLAYER",
                  font_size=20,
                  color=(0, 1, 1, 1),
                  halign="center",
                  valign="center"))

        self.GameWindow7 = GridLayout()
        self.GameWindow7.cols = 7
        self.GameWindow7.rows = 1

        self.GameWindow7.add_widget(Label(text=""))

        self.GameWindow7.add_widget(Label(text=""))

        self.hitButton = Button(text="HIT",
                                font_size=20,
                                background_color=(0, 1, 1, 1))
        self.GameWindow7.add_widget(self.hitButton)

        self.GameWindow7.add_widget(Label(text=""))

        self.stayButton = Button(text="STAY",
                                 font_size=20,
                                 background_color=(0, 1, 1, 1))
        self.GameWindow7.add_widget(self.stayButton)

        self.GameWindow7.add_widget(
            Label(text="TOTAL :",
                  font_size=20,
                  color=(0, 1, 1, 1),
                  halign="center",
                  valign="center"))

        self.PlayerTotalLabel = Label(text="0",
                                      font_size=20,
                                      color=(0, 1, 1, 1),
                                      halign="center",
                                      valign="center")
        self.GameWindow7.add_widget(self.PlayerTotalLabel)

        self.add_widget(self.GameWindow1)
        self.GameWindow1.add_widget(self.GameWindow2)
        self.GameWindow1.add_widget(self.GameWindow3)

        self.add_widget(self.GameWindow4)
        self.GameWindow4.add_widget(self.GameWindow5)
        self.GameWindow4.add_widget(self.GameWindow6)
        self.GameWindow4.add_widget(self.GameWindow7)

        #initialization
        deck = Deck()
        deck.shuffle()
        #playerCoins = Coins()
        playing = True

        playerHandList = []
        compHandList = []

        #creating starting status of the game
        playerHand = Hand()
        playerHand.addCard(deck.deal())
        playerHand.addCard(deck.deal())

        compHand = Hand()
        compHand.addCard(deck.deal())
        compHand.addCard(deck.deal())

        #appending starting cards into respective lists
        for i in playerHand.cards:
            playerHandList.append(str(i))
        for i in compHand.cards:
            compHandList.append(str(i))

        #displaying starting cards in gui
        self.playerCardImage1.source = imagePath + playerHandList[0]
        self.playerCardImage2.source = imagePath + playerHandList[1]
        self.compCardImage1.source = imagePath + compHandList[0]

        #Displaying value of cards in gui
        self.PlayerTotalLabel.text = str(playerHand.value)

        #function for displaying result in pop up window
        def displayResult():

            #resetting bet screen
            self.parent.clear_widgets()
            #self.parent.add_widget(Factory.GameWindow(name = "Game"))
            self.parent.add_widget(Factory.NewBetWindow(name="newBet"))

            #changing screen for displaying game result
            self.parent.current = "newBet"

            pw = PopupWindow()

            #setting the text of popup window label according to the game result
            if playerHand.value > 21:
                playerCoins.lose()

                playerHandList1 = ", ".join(playerHandList)
                compHandList1 = ", ".join(compHandList)

                pw.popupLabel.text = "PLAYER BUSTS!" + "\nYour coins: " + str(
                    playerCoins.total
                ) + "\n\nPlayer's hand value = " + str(
                    playerHand.value
                ) + "\n" + playerHandList1 + "\n(Greater than 21!)" + "\n\nComputer's hand value is = " + str(
                    compHand.value) + "\n" + compHandList1

            elif compHand.value > 21:
                playerCoins.win()

                playerHandList1 = ", ".join(playerHandList)
                compHandList1 = ", ".join(compHandList)

                pw.popupLabel.text = "COMPUTER BUSTS!" + "\nYour coins: " + str(
                    playerCoins.total
                ) + "\n\nPlayer's hand value = " + str(
                    playerHand.value
                ) + "\n" + playerHandList1 + "\n\nComputer's hand value is = " + str(
                    compHand.value
                ) + "\n" + compHandList1 + "\n(Greater than 17!)"

            elif compHand.value > playerHand.value:
                playerCoins.lose()

                playerHandList1 = ", ".join(playerHandList)
                compHandList1 = ", ".join(compHandList)

                pw.popupLabel.text = "COMPUTER WINS!" + "\nYour coins: " + str(
                    playerCoins.total
                ) + "\n\nPlayer's hand value = " + str(
                    playerHand.value
                ) + "\n" + playerHandList1 + "\n\nComputer's hand value is = " + str(
                    compHand.value) + "\n" + compHandList1

            elif compHand.value < playerHand.value:
                playerCoins.win()

                playerHandList1 = ", ".join(playerHandList)
                compHandList1 = ", ".join(compHandList)

                pw.popupLabel.text = "PLAYER WINS!" + "\nYour coins: " + str(
                    playerCoins.total
                ) + "\n\nPlayer's hand value = " + str(
                    playerHand.value
                ) + "\n" + playerHandList1 + "\n\nComputer's hand value is = " + str(
                    compHand.value) + "\n" + compHandList1

            #setting the contents of popup window
            popupWindow = Popup(title="RESULT",
                                content=pw,
                                size_hint=(None, None),
                                size=(400, 400))
            popupWindow.open()

        #function for asking for another card if player clicks HIT button
        def hitFunction(instance):
            #new card added in player's hand object (background)
            playerHand.addCard(deck.deal())

            #appending newly added card in player's hand list
            for i in playerHand.cards:
                if str(i) not in playerHandList:
                    playerHandList.append(str(i))
            playerHand.adjustForAce()

            #Displaying value of cards in gui
            self.PlayerTotalLabel.text = str(playerHand.value)

            #adding new cards to player's hand in gui
            if len(playerHandList) == 3:
                self.playerCardImage3.source = imagePath + playerHandList[2]
                self.compCardImage2.source = imagePath + compHandList[1]
                time.sleep(1)

            elif len(playerHandList) == 4:
                self.playerCardImage4.source = imagePath + playerHandList[3]
                time.sleep(1)

            elif len(playerHandList) == 5:
                self.playerCardImage5.source = imagePath + playerHandList[4]
                time.sleep(1)

            #printing all details/logs on consol
            print("HIT button pressed!")
            print("Player's cards:", playerHandList)
            print("Player's total:", playerHand.value)
            print("Computer's cards:", compHandList)
            print("Computer's total:", compHand.value)

            #checking if game ends or not
            if playerHand.value > 21 or compHand.value > 21 or compHand.value > playerHand.value or compHand.value < playerHand.value:
                displayResult()

        #function for playing computer's hand if  player clicks stay
        def stayFunction(instance):
            #if player isn't busted then adding a card to computer's hand
            if playerHand.value <= 21:
                self.compCardImage2.source = imagePath + compHandList[1]
                time.sleep(1)

                #while compHand.value < 17:
                while True:

                    #new card added in computers's hand object (background)
                    compHand.addCard(deck.deal())

                    #appending newly added card in computer's hand list
                    for i in compHand.cards:
                        if str(i) not in compHandList:
                            compHandList.append(str(i))
                        compHand.adjustForAce()

                    #adding new cards to computer's hand in gui
                    #self.compCardImage2.source = imagePath + compHandList[1]
                    time.sleep(1)

                    if len(compHandList) == 3:
                        self.compCardImage3.source = imagePath + compHandList[2]
                        time.sleep(1)

                    elif len(compHandList) == 4:
                        self.compCardImage4.source = imagePath + compHandList[3]
                        time.sleep(1)

                    elif len(compHandList) == 5:
                        self.compCardImage5.source = imagePath + compHandList[4]
                        time.sleep(1)

                    time.sleep(1)
                    #printing all details/logs on consol
                    print("STAY button pressed!")
                    print("Player's cards:", playerHandList)
                    print("Player's total:", playerHand.value)
                    print("Computer's cards:", compHandList)
                    print("Computer's total:", compHand.value)

                    if playerHand.value > 21 or compHand.value > 21 or compHand.value > playerHand.value or compHand.value < playerHand.value:
                        break

            time.sleep(1)
            #checking if game ends or not
            if playerHand.value > 21 or compHand.value > 21 or compHand.value > playerHand.value or compHand.value < playerHand.value:
                displayResult()

        #binding buttons with functions
        self.hitButton.bind(on_press=hitFunction)
        self.stayButton.bind(on_press=stayFunction)
Example #50
0
class DenylistPage(BoxLayout):
    def __init__(self, **kwargs):
        super(DenylistPage, self).__init__(**kwargs)
        self.orientation = "vertical"
        self.previous_screen = ""

        self.specialized = None
        self.ui_to_item = {}

        # Title "Denylist" at top of page
        self.title = Label(text="Denylist", font_size=25)
        self.title.size_hint_y = None
        self.title.height = 58
        self.add_widget(self.title)

        # Scrolling area for denylist
        self.scroll = ScrollView()
        self.scroll.size_hint_y = None
        self.scroll.height = 500
        self.add_widget(self.scroll)

        # Denylist content
        self.list = GridLayout(cols=3)
        self.list.size_hint_y = None
        self.list.height = 500
        self.scroll.add_widget(self.list)

        self.gen_list()

        # Buttons
        self.button1 = Button(text="Add to Denylist", font_size=20)
        self.button1.bind(on_press=self.button1_act)
        self.add_widget(self.button1)

        self.button2 = Button(text="Done", font_size=20)
        self.button2.bind(on_press=self.button2_act)
        self.add_widget(self.button2)

    def gen_list(self, specialized=None):
        self.list.clear_widgets()

        self.specialized = specialized
        # Denylist content
        if specialized == None:
            self.denylist = db.get_denylist()
        else:
            self.denylist = specialized
        self.ui_to_item = {}

        if len(self.denylist.items) > 5:
            self.list.height = 100 * len(self.denylist.items)

        def on_checkbox_active(checkbox, value):
            item = self.ui_to_item[checkbox]
            keywords = ", ".join(item.keywords)
            if value:
                item.active = True
            else:
                item.active = False

        for item in self.denylist.items:
            checkbox = CheckBox(active=item.active)
            self.ui_to_item[checkbox] = item
            checkbox.bind(active=on_checkbox_active)
            self.list.add_widget(checkbox)
            keywords = Label(text=", ".join(item.keywords), font_size=20)
            self.list.add_widget(keywords)

            remove = Button(text="Remove", font_size=20)
            self.ui_to_item[remove] = item
            remove.bind(on_press=self.remove_item)
            self.list.add_widget(remove)

    def remove_item(self, instance):
        item = self.ui_to_item[instance]
        db.remove_denylist(item.id)
        db.save()
        self.gen_list(specialized=self.specialized)

    # Button1 - Add to Denylist
    def button1_act(self, instance):
        nag_bot_app.edit_denylist_page.specialized = self.denylist
        nag_bot_app.screen_manager.transition.direction = 'left'
        nag_bot_app.screen_manager.current = "Edit Denylist"
        nag_bot_app.edit_denylist_page.previous_screen = "Denylist"

    # Button 2 - Done - go back to previous page
    def button2_act(self, instance):
        nag_bot_app.screen_manager.transition.direction = 'right'
        nag_bot_app.screen_manager.current = self.previous_screen
        nag_bot_app.screen_manager.get_screen(
            self.previous_screen).previous_screen = "Denylist"
class MyGrid(GridLayout):
    def __init__(self, **kwargs):
        super(MyGrid, self).__init__(**kwargs)
        self.cols = 1

        self.inside = GridLayout()
        self.inside.cols = 2

        self.inside.add_widget(Label(text="First Name: "))
        self.name = TextInput(multiline=False)
        self.inside.add_widget(self.name)

        self.inside.add_widget(Label(text="Last Name: "))
        self.lastName = TextInput(multiline=False)
        self.inside.add_widget(self.lastName)

        self.inside.add_widget(Label(text="Email: "))
        self.email = TextInput(multiline=False)
        self.inside.add_widget(self.email)

        self.add_widget(self.inside)

        self.submit = Button(text='Submit', font_size=40)
        self.submit.bind(on_press=self.pressed)
        self.add_widget(self.submit)

    def pressed(self, instance):
        name = self.name.text
        last = self.lastName.text
        email = self.email.text

        print('Name: ', name, '\nLast Name: ', last, '\nEmail: ', email)
        self.name.text = ''
        self.lastName.text = ''
        self.email.text = ''
Example #52
0
class ToDoListPage(BoxLayout):
    def __init__(self, **kwargs):
        super(ToDoListPage, self).__init__(**kwargs)
        self.orientation = "vertical"
        self.previous_screen = ""

        self.block = None

        # Block label at top of page
        self.label = Button(text="", font_size=20)
        self.label.size_hint_y = None
        self.label.height = 58
        self.add_widget(self.label)

        # Title "To Do List" under label - left aligned
        self.title = Label(text="To Do List",
                           font_size=25,
                           halign="left",
                           valign="middle",
                           padding=(10, 0))
        self.title.bind(size=self.title.setter('text_size'))
        self.title.size_hint_y = None
        self.title.height = 58
        self.add_widget(self.title)

        # Scrolling area for list
        self.scroll = ScrollView()
        self.scroll.size_hint_y = None
        self.scroll.height = 400
        self.add_widget(self.scroll)

        # ToDoList content
        self.list = GridLayout(cols=3)
        self.list.size_hint_y = None
        self.list.height = 400
        self.scroll.add_widget(self.list)

        # Buttons
        self.button1 = Button(text="Add Task", font_size=20)
        self.button1.bind(on_press=self.button1_act)
        self.add_widget(self.button1)

        self.button2 = Button(text="Edit Work Block", font_size=20)
        self.button2.bind(on_press=self.button2_act)
        self.add_widget(self.button2)

        self.button3 = Button(text="Done", font_size=20)
        self.button3.bind(on_press=self.button3_act)
        self.add_widget(self.button3)

    def update_block(self, block):
        self.block = block
        self.update()

    def update(self):
        # update the Block label at top of page
        self.label.text = self.block.type
        self.label.text += self.block.start.strftime(" %m/%d/%Y %I:%M %p")
        self.label.text += self.block.end.strftime(" - %I:%M %p")

        if self.block.type == "Work":
            self.label.background_color = [1, 0, 0, 1]  # red RGBA

        elif self.block.type == "Break":
            self.label.background_color = [0, 1, 0, 1]  # green RGBA

        # update the actual list
        self.list.clear_widgets()
        self.ui_to_task = {}

        tasks = db.get_tasks(self.block.id)

        if len(tasks) > 5:
            self.list.height = 100 * len(tasks)

        def on_checkbox_active(checkbox, value):
            task = self.ui_to_task[checkbox]
            if value:
                task.completed = True
            else:
                task.competed = False

        # generate list
        for priority in ["High", "Med", "Low"]:
            for task in tasks:
                if task.priority == priority:
                    checkbox = CheckBox(active=task.completed)
                    self.ui_to_task[checkbox] = task
                    checkbox.bind(active=on_checkbox_active)
                    self.list.add_widget(checkbox)
                    description = Label(text=task.description, font_size=20)
                    self.list.add_widget(description)

                    remove = Button(text="Remove", font_size=20)
                    self.ui_to_task[remove] = task
                    remove.bind(on_press=self.remove_task)
                    self.list.add_widget(remove)

    def remove_task(self, button):
        task = self.ui_to_task[button]
        db.remove_task(self.block.id, task.id)
        db.save()
        self.update()

    # Button 1 - Add Task
    def button1_act(self, instance):
        nag_bot_app.add_task_page.set_block(self.block)
        nag_bot_app.screen_manager.transition.direction = 'left'
        nag_bot_app.screen_manager.current = "Add Task"
        nag_bot_app.add_task_page.previous_screen = "To Do List"

    # Button 2 - Edit Work Block
    def button2_act(self, instance):
        nag_bot_app.edit_block_page.edit_block(self.block)

        nag_bot_app.screen_manager.transition.direction = 'down'
        nag_bot_app.screen_manager.current = "Edit Block"
        nag_bot_app.edit_block_page.previous_screen = "To Do List"

    # Button 3 - Done
    def button3_act(self, instance):
        nag_bot_app.screen_manager.transition.direction = 'down'
        nag_bot_app.screen_manager.current = self.previous_screen
        nag_bot_app.screen_manager.get_screen(
            self.previous_screen).previous_screen = "To Do List"
Example #53
0
class Board(GridLayout):
    """docstring for Board"""
    def __init__(self, **kwargs):
        super(Board, self).__init__(**kwargs)

        self.cols = 1

        # Create rows, cols, mines layout
        self.input_layout = GridLayout(cols=6, rows=1)
        self.lblRow = Label(text="Rows: ",
                            size_hint=(None, None),
                            width=64,
                            height=32)
        self.txtRow = TextInput(text="",
                                size_hint=(None, None),
                                width=32,
                                height=32,
                                multiline=False)
        self.lblCol = Label(text="Cols: ",
                            size_hint=(None, None),
                            width=64,
                            height=32)
        self.txtCol = TextInput(text="",
                                size_hint=(None, None),
                                width=32,
                                height=32,
                                multiline=False)
        self.lblMine = Label(text="Mines: ",
                             size_hint=(None, None),
                             width=64,
                             height=32)
        self.txtMine = TextInput(text="",
                                 size_hint=(None, None),
                                 width=32,
                                 height=32,
                                 multiline=False)

        self.input_layout.add_widget(self.lblRow)
        self.input_layout.add_widget(self.txtRow)
        self.input_layout.add_widget(self.lblCol)
        self.input_layout.add_widget(self.txtCol)
        self.input_layout.add_widget(self.lblMine)
        self.input_layout.add_widget(self.txtMine)
        self.add_widget(self.input_layout)

        # Create button OK
        self.Ok_layout = GridLayout(cols=1)
        self.btnOk = Button(text="Let's go!", size_hint=(0.2, None), height=32)
        self.btnOk.bind(on_press=self.check_input)
        self.Ok_layout.add_widget(self.btnOk)
        self.add_widget(self.Ok_layout)

        # Create board layout

    def genMines(self, rows, cols, mines):
        result = [[0 for i in range(rows)] for j in range(cols)]
        # Generate mines
        arr_mines = []
        while len(arr_mines) != mines:
            x = randint(0, rows - 1)
            y = randint(0, cols - 1)
            if [x, y] not in arr_mines:
                arr_mines.append([x, y])
        # Add mines into board
        for x, y in arr_mines:
            result[x][y] = MINE

        # Add numbers around the mines
        getNeighbour = lambda x, y: [[x - 1, y - 1], [x - 1, y], [
            x - 1, y + 1
        ], [x, y + 1], [x + 1, y + 1], [x + 1, y], [x + 1, y - 1], [x, y - 1]]

        get_num_of_mine = lambda a, x, y: sum(
            [1 for i, j in getNeighbour(x, y) if a[i][j] == MINE])

        tmp_r = np.pad(result, pad_width=1, mode='constant', constant_values=0)

        # Save padding position
        padd = [[0, y] for y in range(cols + 2)]
        for y in range(cols + 2):
            padd.append([rows + 1, y])
        for x in range(rows + 2):
            padd.append([x, 0])
            padd.append([x, cols + 1])

        # Calc number of mines around the mines
        for x, y in arr_mines:
            arr_nei = getNeighbour(x, y)
            # Because we add padding => we need to map pos from original to padding by plus 1
            for i, j in arr_nei:
                if (tmp_r[i + 1][j + 1] == 0) and ([
                        i + 1, j + 1
                ] not in padd) and (tmp_r[i + 1][j + 1] != MINE):
                    tmp_r[i + 1][j + 1] = get_num_of_mine(tmp_r, i + 1, j + 1)

        ret = []
        print(tmp_r)
        for e in tmp_r[1:-1]:
            ret.append(e[1:cols + 1].tolist())
        return ret

    # Callback functions
    def check_input(self, even):
        if re.match(
                r'^([\s\d]+)$',
                str(self.txtRow.text) + str(self.txtCol.text) +
                str(self.txtMine.text)) == None:
            pop = Popup(
                title="Error!",
                content=Label(text="Incorrect input! Please check again!"),
                size_hint=(None, None),
                size=(200, 200))
            pop.open()
        else:
            irow = int(self.txtRow.text)
            icol = int(self.txtCol.text)
            imine = int(self.txtMine.text)
            self.board_layout = GridLayout(rows=irow, cols=icol)

            board = self.genMines(irow, icol, imine)
            for i in range(irow):
                for j in range(icol):
                    btn = Cell()
                    btn.num = board[i][j]
                    if (board[i][j] == MINE):
                        btn.is_mine = 1
                    btn.bind(on_press=self.open_cell)
                    self.board_layout.add_widget(btn)
            self.add_widget(self.board_layout)

    def open_cell(self, instance):
        if instance.is_mine == 1:
            instance.text = "BOM"
        else:
            instance.text = str(instance.num)
            instance.disabled = True
Example #54
0
class GameScreen(Screen):
    def __init__(self, game, **kwargs):
        super(GameScreen, self).__init__(**kwargs)
        self.game = game

        self.game_layout = GridLayout(cols=7, rows=7)

        for y in range(6):
            for x in range(7):
                self.game_layout.add_widget(
                    Button(background_color=(255, 255, 255, 1.0)))

        # if ((self.game.mode == 1) or (self.game.mode == 0)):
        for i in range(7):
            self.game_layout.add_widget(
                Button(text=str(i), on_press=self.update_and_repaint))
        # else: # cpu vs cpu
        # 	self.game_layout.add_widget(Button(text="Make Moves", on_press=self.cpu_v_cpu_update))

        self.add_widget(self.game_layout)

    def repaint_board(self):
        self.game_layout.clear_widgets()

        for y in range(5, -1, -1):
            for x in range(7):
                if (self.game.board[x][y] == "red"):
                    self.game_layout.add_widget(
                        Button(background_color=(255, 0, 0, 1.0)))
                elif (self.game.board[x][y] == "yellow"):
                    self.game_layout.add_widget(
                        Button(background_color=(255, 255, 0, 1.0)))
                else:
                    self.game_layout.add_widget(
                        Button(background_color=(255, 255, 255, 1.0)))

        if ((self.game.mode == 1) or (self.game.mode == 0)):
            for i in range(7):
                self.game_layout.add_widget(
                    Button(text=str(i), on_press=self.update_and_repaint))
        else:  # cpu vs cpu
            self.game_layout.add_widget(
                Button(text="Make Moves", on_press=self.cpu_v_cpu_update))

    def update_and_repaint(self, instance):
        if (self.game.mode == 0):
            status = self.game.updateBoard(int(instance.text))
            if ((status == "won") or (status == "draw")):
                self.repaint_board()
                return

            self.repaint_board()

        elif (self.game.mode == 1):
            status1 = self.game.updateBoard(int(instance.text))
            if ((status1 == "won") or (status1 == "draw")):
                self.repaint_board()
                return

            self.repaint_board()

            #cpu_move_num = mode_controller.human_vs_cpu(self.game)
            cpu_move_num = Heuristics.rando()
            status2 = self.game.updateBoard(cpu_move_num)
            if ((status2 == "won") or (status2 == "draw")):
                self.repaint_board()
                return

            self.repaint_board()

    def cpu_v_cpu_update(self, instance):

        cpu1_move_num = mode_controller.cpu1(self.game)

        status = self.game.updateBoard(cpu1_move_num)
        if ((status == "red won") or (status == "yellow won")
                or (status == "draw")):
            self.repaint_board()
            return

        cpu2_move_num = mode_controller.cpu2(self.game)

        status = self.game.updateBoard(cpu2_move_num)
        if ((status == "red won") or (status == "yellow won")
                or (status == "draw")):
            self.repaint_board()
            return

        self.repaint_board()
Example #55
0
    def build(self):
        box = BoxLayout()
        box.orientation = 'vertical'

        navigation_bar = CupertinoNavigationBar()
        navigation_bar.size_hint_y = 0.15

        title = CupertinoLabel()
        title.text = 'Symbols'
        title.bold = True
        title.pos_hint = {'center': (0.5, 0.5)}

        scrollview = CupertinoScrollView()

        layout = GridLayout()
        layout.cols = 1
        layout.spacing = 15
        layout.padding = 15
        layout.size_hint_y = None
        layout.bind(minimum_height=layout.setter('height'))

        navigation_bar.add_widget(title)

        scrollview.add_widget(layout)

        with open(root_path + 'symbols.json', 'r') as json:
            symbols = load(json)

        for s in symbols:
            cell = BoxLayout()
            cell.orientation = 'horizontal'
            cell.size_hint_y = None
            cell.height = 20

            symbol = CupertinoSymbol()
            symbol.symbol = s
            symbol.color = 0, 0, 0, 1
            symbol.size_hint_x = 0.3

            name = CupertinoLabel()
            name.text = s
            name.halign = 'left'
            name.bind(size=name.setter('text_size'))

            cell.add_widget(symbol)
            cell.add_widget(name)

            layout.add_widget(cell)

        box.add_widget(navigation_bar)
        box.add_widget(scrollview)

        return box
Example #56
0
    def show_property(self, instance, value, key=None, index=-1, *l):
        # normal call: (tree node, focus, )
        # nested call: (widget, prop value, prop key, index in dict/list)
        if value is False:
            return

        content = None
        if key is None:
            # normal call
            nested = False
            widget = instance.widget
            key = instance.key
            prop = widget.property(key)
            value = getattr(widget, key)
        else:
            # nested call, we might edit subvalue
            nested = True
            widget = instance
            prop = None

        dtype = None

        if isinstance(prop, AliasProperty) or nested:
            # trying to resolve type dynamically
            if type(value) in (str, str):
                dtype = 'string'
            elif type(value) in (int, float):
                dtype = 'numeric'
            elif type(value) in (tuple, list):
                dtype = 'list'

        if isinstance(prop, NumericProperty) or dtype == 'numeric':
            content = TextInput(text=str(value) or '', multiline=False)
            content.bind(
                text=partial(self.save_property_numeric, widget, key, index))
        elif isinstance(prop, StringProperty) or dtype == 'string':
            content = TextInput(text=value or '', multiline=True)
            content.bind(
                text=partial(self.save_property_text, widget, key, index))
        elif (isinstance(prop, ListProperty)
              or isinstance(prop, ReferenceListProperty)
              or isinstance(prop, VariableListProperty) or dtype == 'list'):
            content = GridLayout(cols=1, size_hint_y=None)
            content.bind(minimum_height=content.setter('height'))
            for i, item in enumerate(value):
                button = Button(text=repr(item), size_hint_y=None, height=44)
                if isinstance(item, Widget):
                    button.bind(
                        on_release=partial(self.highlight_widget, item, False))
                else:
                    button.bind(on_release=partial(self.show_property, widget,
                                                   item, key, i))
                content.add_widget(button)
        elif isinstance(prop, OptionProperty):
            content = GridLayout(cols=1, size_hint_y=None)
            content.bind(minimum_height=content.setter('height'))
            for option in prop.options:
                button = ToggleButton(
                    text=option,
                    state='down' if option == value else 'normal',
                    group=repr(content.uid),
                    size_hint_y=None,
                    height=44)
                button.bind(
                    on_press=partial(self.save_property_option, widget, key))
                content.add_widget(button)
        elif isinstance(prop, ObjectProperty):
            if isinstance(value, Widget):
                content = Button(text=repr(value))
                content.bind(on_release=partial(self.highlight_widget, value))
            elif isinstance(value, Texture):
                content = Image(texture=value)
            else:
                content = Label(text=repr(value))

        elif isinstance(prop, BooleanProperty):
            state = 'down' if value else 'normal'
            content = ToggleButton(text=key, state=state)
            content.bind(on_release=partial(self.save_property_boolean, widget,
                                            key, index))

        self.content.clear_widgets()
        if content:
            self.content.add_widget(content)
Example #57
0
    def on_touch_down(self, touch):
        if self.disabled and self.collide_point(*touch.pos):
            return True
        return super(Popup, self).on_touch_down(touch)


if __name__ == '__main__':
    from kivy.base import runTouchApp
    from kivy.uix.button import Button
    from kivy.uix.label import Label
    from kivy.uix.gridlayout import GridLayout
    from kivy.core.window import Window

    # add popup
    content = GridLayout(cols=1)
    content_cancel = Button(text='Cancel', size_hint_y=None, height=40)
    content.add_widget(Label(text='This is a hello world'))
    content.add_widget(content_cancel)
    popup = Popup(title='Test popup',
                  size_hint=(None, None),
                  size=(256, 256),
                  content=content,
                  disabled=True)
    content_cancel.bind(on_release=popup.dismiss)

    layout = GridLayout(cols=3)
    for x in range(9):
        btn = Button(text=str(x))
        btn.bind(on_release=popup.open)
        layout.add_widget(btn)
Example #58
0
 def setting(self):
     box = GridLayout(cols=2)
     box.add_widget(Label(text="IpAddress: ", bold=True))
     self.st = TextInput(id="serverText")
     box.add_widget(self.st)
     box.add_widget(Label(text="Port: ", bold=True))
     self.pt = TextInput(id="portText")
     box.add_widget(self.pt)
     btn = Button(text="Set", bold=True)
     btn.bind(on_press=self.settingProcess)
     box.add_widget(btn)
     self.popup = Popup(title='Settings', content=box, size_hint=(.6, .4))
     self.popup.open()
Example #59
0
class MainScreen(Screen, Widget):
    def __init__(self, **kwargs):
        super(MainScreen, self).__init__(**kwargs)
        bl = BoxLayout(orientation = "vertical")
        self.grid = GridLayout(cols = 3, rows = 3, spacing = spac, padding = pad, size_hint = (1, 1-h_up-h_down))
        self.btn = Button(text = "", background_color = (.4, .5, 1, 1), on_press = self.end, font_size = 0.4*width/16)
        self.step = "X"
        self.popup = Popup(title = "The end of game", content = self.btn , size_hint = (.4, .2))
        self.lbl_stat = Label(text = "Turn: X!", font_size = int(width/14), size_hint = (1, h_up), color = (0,0,0,1))
        self.field = [["*", "*", "*"], ["*", "*", "*"], ["*", "*", "*"]]
        self.win = False
        self.winner = ""
        self.listt = []
        self.free_fields = 9
        self.free_fields = 9
        if width_btn_field >= height_btn_field:
            font = height_btn_field / 1.5
        else:
            font = width_btn_field / 1.5
        for i in range(9):
            btnn = Button( on_press = self.presss, color = (0,0,0,1),\
 font_size = font, background_color = (1,1,1,0))
            self.listt.append(btnn)
            self.grid.add_widget(btnn)
        bl.add_widget(self.lbl_stat)
        bl.add_widget(self.grid)
        bl.add_widget(DownPanelWidget(size_hint = (1, h_down)))
        self.add_widget(BackgroundWidget())
        self.add_widget(bl)
    def presss(self, instance):
        if instance.text == "":#Validation of clear
            # Next figure
            # instance.text = self.step
            n = self.listt.index(instance)
            if instance.text == "":  # Validation of clear
                self.free_fields -= 1
                # Next figure
                instance.text = self.step
                if self.step == "X":
                    instance.color = (.25, .6, 1, 1)
                else:
                    instance.color = (0, 0, 0, 1)

                n = self.listt.index(instance)




            '''This will insert into list.'''
            if n <= 2:
                self.field[0][n] = self.step
            elif 2 < n <= 5:
                self.field[1][n-3] = self.step
            else:
                self.field[2][n-6] = self.step
            print(self.field)
            if self.step == "X":

                self.step = "O"
                self.lbl_stat.text = "Turn: " + self.step
            else:
                self.step = "X"
                self.lbl_stat.text = "Turn: " + self.step

            #Has somebody already won?
            for i in range(3):
                print(i)
                if self.field[0][i] == self.field[1][i] == self.field[2][i] != "*":#Check horizontal
                    self.win = True
                    winner = self.field[0][i]

                elif self.field[i][0] == self.field[i][1] == self.field[i][2] != "*":#Check vertical
                    self.win = True
                    winner = self.field[i][0]

            if self.field[0][0] == self.field[1][1] == self.field[2][2] != "*"\
            or self.field[0][2] == self.field[1][1] == self.field[2][0] != "*":
                self.win = True
                winner = self.field[1][1]
            #If someone won
            if self.win:
                self.btn.text = "The winner is " + winner
                history = json.load(open("history.json"))
                tm = list(map(str, localtime()))
                while len(history)>= 12:
                    history.pop(len(history)-1)
                for i in range(1, 5):
                    if int(tm[i]) < 10:
                        tm[i] = "0" + tm[i]
                history.insert(0, ["Winner: " + winner, self.field, tm[1]+"."+tm[2]+", "+tm[3]+":"+tm[4]])
                with open("history.json", "w") as file:
                    file.write(json.dumps(history))
                self.popup.open()
                self.field = [["*", "*", "*"], ["*", "*", "*"], ["*", "*", "*"]]
                self.step = "X"
                self.win = False
                for i in self.listt:
                    i.text = ""
                self.free_fields = 9

            elif self.free_fields == 0:#Draw
                tm = list(map(str, localtime()))
                self.btn.text = "Draw"
                history = json.load(open("history.json"))
                while len(history)>= 12:
                    history.pop(len(history)-1)
                for i in range(1,5):
                    if int(tm[i]) < 10:
                        tm[i] = "0"+tm[i]
                history.insert(0, ["Draw", self.field, tm[1]+"."+tm[2]+", "+tm[3]+":"+tm[4]])
                with open("history.json", "w") as file:
                    file.write(json.dumps(history))
                self.popup.open()
                self.field = [["*", "*", "*"], ["*", "*", "*"], ["*", "*", "*"]]
                self.step = "X"
                self.win = False
                for i in self.listt:
                    i.text = ""
                self.free_fields = 9

        else:
            pass
    def end(self, instance):
        self.popup.dismiss()
        for i in self.listt:
            i.text = ""
        self.free_fields = 9
Example #60
0
    def cria_box(self, *args):
        notas = [
            self.red1, self.red2, self.red3, self.red4, self.qtd, self.prova,
            self.rec
        ]

        notas = [float(valor) for valor in notas]
        media = calcula_media_trimestral(notas[0], notas[1], notas[2],
                                         notas[3], notas[4], notas[5],
                                         notas[6])

        box_integral = GridLayout(cols=2, spacing=3, size_hint=(1, 0.9))

        box_redacoes = BoxLayout(orientation='vertical')
        box_avaliacoes = BoxLayout(orientation='vertical')

        lbl_red1 = Label(
            text=
            f'[size=45]{self.red1}[/size][size=40][sub]Redação 1[/sub][/size]',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            markup=True)
        lbl_red2 = Label(
            text=
            f'[size=45]{self.red2}[/size][size=40][sub]Redação 2[/sub][/size]',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            font_size=25,
            markup=True)
        lbl_red3 = Label(
            text=
            f'[size=45]{self.red3}[/size][size=40][sub]Redação 3[/sub][/size]',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            font_size=25,
            markup=True)
        lbl_red4 = Label(
            text=
            f'[size=45]{self.red4}[/size][size=40][sub]Redação 4[/sub][/size]',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            font_size=25,
            markup=True)
        lbl_part = Label(
            text=
            f'[size=45]{self.part}[/size][size=40][sub]Participação[/sub][/size]',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            font_size=25,
            markup=True)
        lbl_qtd = Label(
            text=
            f'[size=45]{self.qtd}[/size][size=40][sub]Redações feitas[/sub][/size]',
            halign='center',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            font_size=25,
            markup=True)
        lbl_prova = Label(
            text=
            f'[size=45]{self.prova}[/size][size=40][sub]Prova[/sub][/size]',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            font_size=25,
            markup=True)
        lbl_rec = Label(
            text=
            f'[size=45]{self.rec}[/size][size=40][sub]Recuperação[/sub][/size]',
            color=(0, 0, 0, 1),
            font_name='Fonts/AmaticSC-Bold.ttf',
            font_size=25,
            markup=True)

        labels_reds = [lbl_red1, lbl_red2, lbl_red3, lbl_red4]
        if float(self.rec) > 0:
            labels_avaliacoes = [lbl_prova, lbl_rec]
        else:
            labels_avaliacoes = [lbl_prova]
        labels_part = [lbl_part, lbl_qtd]

        for label in labels_reds:
            box_redacoes.add_widget(label)

        for label in labels_avaliacoes:
            box_avaliacoes.add_widget(label)

        for label in labels_part:
            box_avaliacoes.add_widget(label)

        if float(media) >= 7:
            aprovacao = 'APROVADO(A)'
            color = '#F24894'
        else:
            aprovacao = 'REPROVADO(A)'
            color = '#FA6900'

        titulo = Label(
            text=
            f'[font=Fonts/AmaticSC-Bold.ttf]{self.trimestre}º trimestre[/font]    [size=14][color={color}]{aprovacao}[/size]',
            color=(0, 0, 0, 1),
            size_hint=(1, 0.1),
            valign='middle',
            pos_hint={'center': 1},
            font_size=45,
            markup=True)

        self.add_widget(titulo)
        box_integral.add_widget(box_redacoes)
        box_integral.add_widget(box_avaliacoes)
        self.add_widget(box_integral)

        return self