コード例 #1
0
    def __init__(self, **kwargs):
        super(MapLayout, self).__init__(**kwargs)

        self.mainContainer = RelativeLayout(size_hint=(None, None), size=mainWindowSize)
        self.mainContainer.currentSize = self.currentSize
        self.mainContainer.sizeOption = self.sizeOption

        self.filterContainer = RelativeLayout(size_hint=(None, None), size=mainWindowSize)

        self.mapBound = ScrollView(size_hint=(None, None), size=mainWindowSize)

        self.MapArray = []
        self.MapArray.append(Image(source="peta/content/Base Map 1.png", allow_stretch=True))
        self.MapArray.append(Image(source="peta/content/Base Map 2.png", allow_stretch=True))
        self.MapArray.append(Image(source="peta/content/Base Map 3.png", allow_stretch=True))

        self.FilterArray = []
        self.FilterArray.append(Image(source="peta/content/peta-batas-wilayah.png", allow_stretch=True, opacity=0.5))
        self.FilterArray.append(Image(source="peta/content/peta-jalan.png", allow_stretch=True, opacity=0.5))
        self.FilterArray.append(Image(source="peta/content/peta-air-bersih.png", allow_stretch=True, opacity=0.6))
        self.FilterArray.append(Image(source="peta/content/peta-gorong-gorong.png", allow_stretch=True, opacity=0.5))
        self.FilterArray.append(Image(source="peta/content/peta-sarana-publik.png", allow_stretch=True, opacity=0.9))

        self.filterContainer.add_widget(self.FilterArray[0])

        self.mainContainer.add_widget(self.MapArray[0])
        self.mainContainer.add_widget(self.filterContainer)

        self.mapBound.add_widget(self.mainContainer)
コード例 #2
0
ファイル: layer.py プロジェクト: TimSC/kivmap
	def __init__(self, **args):
		RelativeLayout.__init__(self, **args)
		self.lastTouch = None
		self.tiles = {}
		self.viewPos = (50.7, -1.3)
		self.viewZoom = 14
		self.unscaledTileSize = 512
		self.tileSize = metrics.dp(self.unscaledTileSize)
		self.map = map.Map()

		#source = osmfile.OsmFile("Simple.osm.gz")
		source = osmfilecached.OsmFileCached("IsleOfWight-Fosm-Oct2013.osm.gz")

		highways = maphighways.MapHighways()
		highways.SetSource(source)
		self.map.AddPlugin(highways)

		water = mapwater.MapWater()
		water.SetSource(source)
		self.map.AddPlugin(water)

		places = mapplaces.MapPlaces()
		places.SetSource(source)
		self.map.AddPlugin(places)

		landscape = maplandscape.MapLandscape()
		landscape.SetSource(source)
		self.map.AddPlugin(landscape)

		Clock.schedule_interval(self.LateRendering, 0.1)

		self.bind(pos=self.update_graphics_pos,
			size=self.update_graphics_size)
コード例 #3
0
ファイル: main.py プロジェクト: akdor1154/fit3140
class FIT3140Ui(BoxLayout):
	def __init__(self, maze, robotController, **kwargs):
	
		super(self.__class__,self).__init__(**kwargs)
		self.app = kivy.app.App.get_running_app()
		
		self.maze = maze
		self.robotController = robotController
		self.robot = self.robotController.robot
		
		self.mazeViewFloat = RelativeLayout()
		self.mazeView = MazeView(self.maze, self.robot, self.mazeViewFloat)
		self.mazeViewFloat.add_widget(self.mazeView)
		
		self.workspaceLayout = BoxLayout(orientation="vertical", size_hint=(1, .9))#will contain a 'begin' button and label
		self.beginButton = Button(text="Begin", size_hint=(1, .1))#run the tree
		self.beginButton.bind(on_press=self.app.runProgram)
		self.workspace = FCodeWorkspace()
		self.workspaceLayout.add_widget(self.workspace)
		self.workspaceLayout.add_widget(self.beginButton)
		
		#add all the things to the main screen
		self.add_widget(Palette(workspace=self.workspace))#add the palette
		self.add_widget(self.workspaceLayout)#add the workspace	
		self.add_widget(self.mazeViewFloat)#add the maze
コード例 #4
0
    def build(self):
##        SM = ScreenManager(transition=NoTransition())
##        SM.add_widget(ClusterDetailsScreen(name='cluster details'))
        global SM
        window=RelativeLayout()
        SM = ClusterDetailsScreen()
        window.add_widget(SM)
        picto = SM.ids['pictoPanel']
        bubble = SM.ids['bubblePanel']
        specs = SM.ids['specsPanel']

#'left_top', 'left_mid', 'left_bottom',
#'top_left', 'top_mid', 'top_right',
#'right_top', 'right_mid', 'right_bottom',
#'bottom_left', 'bottom_mid', 'bottom_right'
        
        c1=Comment("capabilities of\nthe cluster in\nlayman's terms", \
                   (10,100),(152,89),'top_mid')
        c2=Comment("adequate size +\nuniform strokes =\nreadable font", \
                   (20,390),(175,90),'bottom_left')
        c3=Comment("1 square falling into \nplace = 4 nodes\nchanging status", \
                   (150,230),(207,80),'right_bottom')
        c4=Comment("1 circle = 1 job with\ndiameter, position, color,\nand transparency\nreflecting job\ncharacteristics", \
                   (420,200),(245,120),'right_bottom')
        c5=Comment("The circles rise like\nbubbles as they\napproach completion,\nfinally floating away\nwhen they finish.", \
                   (690,360),(198,140),'bottom_left')
        c6=Comment("scrolling banner with\nhyperlinks that direct\nto the user's website", \
                   (100,10),(230,80),'right_bottom')
        c7=Comment("Bar graphs depict\ndifferences more\nclearly than pie\n charts[2].", \
                   (210,500),(170,110),'bottom_right')
        c8=Comment("Click on a circle\nto see job details.", \
                   (710,230),(180,60),'left_mid')
        c9=Comment("color-blind-\nfriendly palette", \
                   (420,450),(160,60),'right_bottom')

        comments=[c1,c2,c3,c4,c5,c6,c7,c8,c9]

        for x in comments:
            window.add_widget(x)
        
        specs.ids['details'].text = SM.importText('melete.rst')
        SM.ids['banner'].text = SM.importText('users.rst')

        Clock.schedule_once(self.scrollBanner)
        Clock.schedule_once(c1.appear,12)
        Clock.schedule_once(c2.appear,24)
        Clock.schedule_once(c3.appear,36)
        Clock.schedule_once(c4.appear,48)
        Clock.schedule_once(c5.appear,60)
        Clock.schedule_once(c6.appear,72)
        Clock.schedule_once(c7.appear,84)
        Clock.schedule_once(c8.appear,96)
        Clock.schedule_once(c9.appear,108)
        Clock.schedule_interval(self.scrollBanner, 60)
        Clock.schedule_interval(picto.addNodes, .1)
        Clock.schedule_interval(picto.moreNodes, 5)
        Clock.schedule_once(bubble.addJobs)
        Clock.schedule_interval(bubble.progress, 6.1)
        
        return window
コード例 #5
0
ファイル: carousel.py プロジェクト: KeyWeeUsr/kivy
 def add_widget(self, widget, index=0):
     slide = RelativeLayout(size=self.size, x=self.x - self.width, y=self.y)
     slide.add_widget(widget)
     super(Carousel, self).add_widget(slide, index)
     if index != 0:
         self.slides.insert(index - len(self.slides), widget)
     else:
         self.slides.append(widget)
コード例 #6
0
    def __init__(self, **kwargs):
        super(ChessboardUI, self).__init__(**kwargs)
        game = kwargs.get('game', None)

        # left numbers
        left_box = BoxLayout(orientation='vertical', size_hint_x=None, width=dp(30))
        for n in range(8, -1, -1):
            if n == 0:
                left_box.add_widget(Label())
                break
            left_box.add_widget(Label(text=str(n), color=(0,0,0,1)))

        # right numbers
        right_box = BoxLayout(orientation='vertical', size_hint_x=None, width=dp(30))
        for n in range(8, -1, -1):
            if n == 0:
                right_box.add_widget(Label(size_hint_y=None, height=dp(30)))
                break
            right_box.add_widget(GridLabelOpponent(text=str(n), color=(0,0,0,1)))


        main_box = BoxLayout(orientation='vertical')

        merge_layers = RelativeLayout()
        background_grid = ChessboardGrid()
        self.actual_board = Chessboard(game=game)
        self.actual_board.bind(move_made=self.set_moves)
        merge_layers.add_widget(background_grid)
        merge_layers.add_widget(self.actual_board)


        bottom_box = BoxLayout(size_hint_y=None, height=dp(30))
        for c in ('a','b','c','d','e','f','g','h'):
            bottom_box.add_widget(Label(text=c, color=(0,0,0,1)))

        top_box = BoxLayout(size_hint_y=None, height=dp(30))
        for c in ('','a','b','c','d','e','f','g','h',''):
            if not c:
                top_box.add_widget(Label(size_hint_x=None, width=dp(30)))
                continue
            top_box.add_widget(GridLabelOpponent(text=c))

        main_box.add_widget(merge_layers)
        main_box.add_widget(bottom_box)

        except_top = BoxLayout()

        except_top.add_widget(left_box)
        except_top.add_widget(main_box)
        except_top.add_widget(right_box)

        self.orientation = 'vertical'
        self.add_widget(top_box)
        self.add_widget(except_top)

        self.labels = [bottom_box, top_box, left_box, right_box]
        self.bind(minimize=self.min, all_moves=self.change_board_moves)
コード例 #7
0
class KivyCardPile(CardPile):

    def __init__(self, name, player):
        super(KivyCardPile,self).__init__(name, player)
        self.displayed=False
        self.lock = threading.Lock()
        
    def initDisplay(self,xpos,ypos,scale,parentlayout,orientation):
        #ignores orientation
        self.displayed=True
        self.xpos=int(xpos)
        self.ypos=int(ypos)
        self.scale=scale
        self.layout= RelativeLayout()
        parentlayout.add_widget(self.layout)
        self.updateDisplay()

    def updateDisplay(self):
        self.layout.clear_widgets()
        card=self.peek()
        offset=0
        if card.state == eCardState.good:
            offset=10
            card2=self.peekpeek()
            card2.scatter.scale=self.scale
            card2.scatter.pos=(self.xpos,self.ypos)
            self.layout.add_widget(card2.scatter)
            
        card.scatter.scale=self.scale
        card.scatter.pos=(int(self.xpos+offset),int(self.ypos-offset))
        self.layout.add_widget(card.scatter)

    def dealCard(self,newCardList,newState):
        if self.displayed:
            #Display the card underneath (the next top one)
            self.layout.clear_widgets()
            card=self.peekpeek()
            card.scatter.scale=self.scale
            card.scatter.pos=(self.xpos,self.ypos)
            self.layout.add_widget(card.scatter)
        super(KivyCardPile,self).dealCard(newCardList,newState)

    def append(self,card):
        #self.lock.acquire()
        print card
        super(KivyCardPile,self).append(card)
        offset=0
        if card.state == eCardState.good:
            offset=10
        if self.displayed:
            card.setDest(self.xpos+offset,self.ypos-offset,self.scale,self,True)

    def bringToFront(self):
        parent = self.layout.parent
        parent.remove_widget(self.layout)
        parent.add_widget(self.layout)
コード例 #8
0
ファイル: map.py プロジェクト: reneklacan/kivybomber
    def __init__(self, **kwargs):
        self.ix = None
        self.iy = None
        RelativeLayout.__init__(self, **kwargs)
        self.type = kwargs['type']
        self.ix = kwargs['ix']
        self.iy = kwargs['iy']

        self.rectangle = None
        self.bomb = None
        self.effect = None
コード例 #9
0
ファイル: main.py プロジェクト: mariahc/KivyKyra
 def buildUI(self):
     bottomBox = RelativeLayout() # 1024,188
     self.screenManager = KYRScreenManager(size=(1024,512), size_hint=(None,None))
     self.info = TextInput(text=self.infoText, multiline=True, readonly=True, size=(1014,30), size_hint=(None,None), pos=(6,152))
     btnMenu = Button(text='menu', size=(200,140), size_hint=(None,None), pos=(6,6))
     
     bottomBox.add_widget(self.info)
     bottomBox.add_widget(btnMenu)
     
     self.add_widget(self.screenManager)
     self.add_widget(bottomBox)
コード例 #10
0
ファイル: yadjc-old.py プロジェクト: jwbowler/21m359-final
    def __init__(self):
        super(MainWidget, self).__init__()

        songpath1 = 'together-we-are.wav'
        songpath2 = 'lionhearted.wav'

        self.selection = Selection()

        song1 = Song(songpath1, song1_structure, self.selection)
        song2 = Song(songpath2, song2_structure, self.selection)

        self.beatgen = BeatwiseGenerator()
        self.beatgen.add_song(song1)
        self.beatgen.add_song(song2)

        audio = Audio()
        audio.add_generator(self.beatgen)

        self.selection.beatgen = self.beatgen

        self.clock = ClassClock()
        self.conductor = Conductor(self.clock)
        self.scheduler = Scheduler(self.conductor)

        self.conductor.set_bpm(128)

        #info = Label(text = "text", pos=(0, 500), text_size=(100,100), valign='top')
        #self.add_widget(info)

        # root = ScrollView(size_hint=(None, None), size=(800, 600),
        #                   pos_hint={'center_x': .5, 'center_y': .5})
        # self.add_widget(root)

        #self.rel = AnchorLayout(size_hint=(None, None), width=9000, pos_hint={'center_x': .5, 'center_y': .5},
        #                        anchor_x='left', anchor_y='top')
        self.rel = RelativeLayout(size_hint=(None, None), width=9000, pos_hint={'center_x': .5, 'center_y': .5})
        self.add_widget(self.rel)

        # anchor = AnchorLayout(anchor_x='left', anchor_y='top')
        # self.rel.add_widget(anchor)

        layout = GridLayout(cols=1, padding=50, spacing=50, size_hint=(None, None), width=9000, row_force_default=True,
                            row_default_height=100)
        self.rel.add_widget(layout)

        for song in self.beatgen.get_songs():
            container = RelativeLayout()
            layout.add_widget(container)
            container.add_widget(song)

        self.nowline = Nowline(self.scheduler)
        self.rel.add_widget(self.nowline)

        self.beatgen.nowline = self.nowline
コード例 #11
0
class ColorPickerBox(RelativeLayout):
    def __init__(self, popupwindow, **kwargs):
        super(ColorPickerBox, self).__init__(**kwargs)

        self.popupwindow = popupwindow

        self.generator = RelativeLayout(
                                    size_hint = (None, None),
                                    width = "400dp",
                                    height = "200dp",
                                    pos = ["50dp", "100dp"]   #"50dp"
                                       )

        self.acw = AutonomousColorWheel(self)
        self.generator.add_widget(self.acw)

        self.gpi = ColoredTextInput(pos = ["230dp", "80dp"])
        self.generator.add_widget(self.gpi)

        self.add_widget(self.generator)


        self.create_btn = Button(
                                    size_hint = [None, None],
                                    size = ["100dp","30dp"],
                                    pos = ["320dp","10dp"]
                                )
        self.create_btn.bind(on_release=self.create_group)


        self.cancel_btn = Button(
                                    size_hint = [None, None],
                                    size = ["100dp","30dp"],
                                    pos = ["200dp","10dp"]
                                )
        self.cancel_btn.bind(on_release=self.cancel_creation)



        self.add_widget(self.cancel_btn)
        self.add_widget(self.create_btn)

    def create_group(self, instance):
        print("creation")
        self.popupwindow.change_group()
        self.popupwindow.dismiss()

    def cancel_creation(self, instance):
        print("cancel creation")
        self.popupwindow.dismiss()

    def color_change(self, rgba):
        self.gpi.back_color = rgba
コード例 #12
0
ファイル: template.py プロジェクト: opqopq/BoardGameMaker
 def add_widget(self, widget, index=0):
     #replacing index by z-index
     #a = RelativeLayout.add_widget(self, widget, getattr(widget,'z',0))
     #Duplicate pointer to template
     widget.template = self
     #Re order them according to z elt:
     cs = self.children[:]
     cs.append(widget)
     cs.sort(key= lambda x: getattr(x,'z',0))
     self.clear_widgets()
     for c in cs:
         RelativeLayout.add_widget(self,c)
     self.children = cs
コード例 #13
0
	def _generateMap(self):
		
		layout = RelativeLayout()
		self.mapImg=Image(source='resources/images/map.png',allow_stretch = True, keep_ratio = False)	
		self.mapPin = MapPin( parent=self.mapImg,view = self,allow_stretch = False, source='resources/images/pin.png', size=(20,34))
		self.mapImg.add_widget(self.mapPin)

		layout.add_widget(self.mapImg)

		print "Scheduling."
		# Clock.schedule_interval(self._updateMapImg, 2)
		Clock.schedule_interval(self._timeseriesGenerated, 2)

		return layout
コード例 #14
0
ファイル: main_bak.py プロジェクト: jonoco/KivyKyra
 def buildUI(self):
     bottomBox = RelativeLayout() # 1024,188
     self.screenManager = KYRScreenManager(size=(1068,450), size_hint=(None,None), pos=(25,224))
     self.info = Info(text=self.infoText, multiline=True,
                     readonly=True, size=(1064,30), size_hint=(None,None), pos=(25,167))
     btnMenu = Button(text='menu', size=(196,120), size_hint=(None,None), pos=(28,16), opacity = .5)
     self.inventory = GridLayout(orientation='vertical',cols=5,pos=(333,-562),spacing=15)
     
     bottomBox.add_widget(self.info)
     bottomBox.add_widget(btnMenu)
     self.add_widget(self.inventory)
     self.add_widget(self.screenManager)
     self.add_widget(bottomBox)
     self.buildInventory() 
コード例 #15
0
ファイル: gameover.py プロジェクト: victor-rene/ld-shooter
class GameOver(Popup):
  
  def __init__(self, root_widget, **kw):
    super(GameOver, self).__init__(**kw)
    self.root_widget = root_widget
    self.title = 'GAME OVER'
    self.layout = RelativeLayout()
    self.btn_new_game = Button(text='New Game', size_hint=(.5,.1), pos_hint={'center_x':.25, 'center_y': .05})
    self.btn_new_game.bind(on_press=self.new_game)
    self.btn_exit = Button(text='Exit', size_hint=(.5,.1), pos_hint={'center_x':.75, 'center_y': .05})
    self.btn_exit.bind(on_press=self.root_widget.close_app)
    self.lbl_score = Label(size_hint=(.5,.1), pos_hint={'center_x':.5, 'center_y': .4})
    self.lbl_high_score = Label(size_hint=(.5,.1), pos_hint={'center_x':.5, 'center_y': .7})
    self.layout.add_widget(self.lbl_score)
    self.layout.add_widget(self.lbl_high_score)
    self.layout.add_widget(self.btn_new_game)
    self.layout.add_widget(self.btn_exit)
    self.content = self.layout
    self.size_hint = (None, None)
    self.size = (400, 400)
        
  def set_score(self, score):
    high_score = load_data('data/score.txt')
    if score > high_score:
      high_score = score
      write_data('data/score.txt', score)
    self.lbl_score.text = 'Score: %s' % score
    self.lbl_high_score.text = 'High Score: %s' % high_score
  
  def new_game(self, *args):
    self.dismiss()
    self.root_widget.new_game()
コード例 #16
0
ファイル: comments.py プロジェクト: insiderr/insiderr-app
    def __init__(self, **kwargs):
        super(CommentsScreen, self).__init__(**kwargs)
        self.viewablebox = None
        if not self.scrollview:
            self.bind(scrollview=(lambda *instance: self.scrollview.bind(on_stopped=self.refresh_scrollview)))
        else:
            from kivy import platform
            if platform in ['ios', 'macosx']:
                from kivy.uix.relativelayout import RelativeLayout
                from kivy.core.window import Window
                w = RelativeLayout(size_hint=(1, None), height=0.02*Window.height)
                w.height = 0.02*Window.height
                self.scrollview.children[0].add_widget(w, index=len(self.scrollview.children[0].children))

            self.scrollview.bind(on_stopped=self.refresh_scrollview)
コード例 #17
0
ファイル: app.py プロジェクト: abuchanan/biscuits
class BiscuitsApp(App):

    def __init__(self):
        super().__init__()
        self.widget = RelativeLayout()
        self._scene = None
        self.input = Input()
        self.game = BiscuitsGame(self)

    @property
    def scene(self):
        return self._scene

    @scene.setter
    def scene(self, scene):
        if self._scene:
            self._scene.unload()
            self.widget.remove_widget(self._scene.widget)

        self._scene = scene
        self.widget.add_widget(scene.widget)

    def load_scene(self, loadpoint_ID):
        loadpoint = loadpoints[loadpoint_ID]

        if loadpoint.type == 'dead':
            self.scene = DeadScene(self)

        elif loadpoint.type == 'start':
            self.scene = StartScene(self)

        elif loadpoint.type == 'comic':
            self.scene = ComicScene(self, loadpoint)
        else:
            self.scene = self.game.load(loadpoint)

    def update(self, dt):
        self.input.update(dt)
        self.scene.update(dt)

    def build(self):
        EventLoop.ensure_window()
        self.load_scene('Loadpoint 1a')
        Clock.schedule_interval(self.update, 1.0 / 60.0)

        return self.widget
コード例 #18
0
ファイル: sprite.py プロジェクト: reneklacan/kivybomber
    def __init__(self, **kwargs):
        self.image_size = kwargs['size']
        RelativeLayout.__init__(self, size_hint=(None,None), **kwargs)

        self.grid = kwargs['grid']
        self.start_position = self.pos

        self.frozen = False
        self.alive = True
        self.animation = None
        self.safe_pos = self.pos
        self.path = []
        self.moving = False
        self.last_to_tuple = None
        self.move_duration = 0.25

        self.setup()
        self.init()
コード例 #19
0
 def initDisplay(self,xpos,ypos,scale,parentlayout,orientation):
     #ignores orientation
     self.displayed=True
     self.xpos=int(xpos)
     self.ypos=int(ypos)
     self.scale=scale
     self.layout= RelativeLayout()
     parentlayout.add_widget(self.layout)
     self.updateDisplay()
コード例 #20
0
 def initDisplay(self,xpos,ypos,scale,parentlayout,orientation):
     self.displayed=True
     self.xpos=xpos
     self.ypos=ypos
     self.scale=scale
     self.orientation=orientation
     self.layout= RelativeLayout()
     parentlayout.add_widget(self.layout)
     #self.ipos=(card.image.width*card.scatter.scale)
     self.updateDisplay()
コード例 #21
0
ファイル: buttonpad.py プロジェクト: victor-rene/kivy-gamelib
class ButtonPad(Widget):

  def __init__(self, **kw):
    super(ButtonPad, self).__init__(**kw)
    self.listeners = []
    self.layout = RelativeLayout()
    self.add_widget(self.layout)
    btn_ids = ['A', 'B', 'X', 'Y']
    btn_pos = [(.8, .5), (.5, .2), (.5, .8), (.2, .5)]
    btn_colors = [[.7,0,0,1],[.9,.7,0,1],[0,.3,.7,1],[0,.7,0,1]]
    for i in range(4):
      btn = Button(id=btn_ids[i], size_hint=(.2, .2),
        background_color=btn_colors[i],
        background_normal='img/btn-normal.png',
        background_down='img/btn-down.png',
        pos_hint={'center_x': btn_pos[i][0], 'center_y': btn_pos[i][1]})
      btn.bind(on_press=self.btn_press)
      self.layout.add_widget(btn)
    with self.canvas.before:
      Color(1, 1, 1, 1)
      self.rect = Rectangle(pos=self.pos, size=self.size, source='img/bpad.png')
    self.bind(pos=self._update_rect)
    self.bind(size=self._update_rect)
    # self.polling = kw['polling'] if 'polling' in kw else .01
    # Clock.schedule_interval(self.send_input, self.polling)
    
  def _update_rect(self, *args):
    self.rect.pos = self.pos
    self.rect.size = self.size
    self.layout.pos = self.pos
    self.layout.size = self.size
    
  def btn_press(self, btn):
    self.notify('bpad_input', btn=btn.id)
      
  def notify(self, event_name, *args, **kw):
    for listener in self.listeners:
      if event_name in listener.handlers:
        getattr(listener, event_name)(*args, **kw)
        
  # def send_input(self, dt):
    # self.notify('bpad_input', input=self.input)
コード例 #22
0
ファイル: region.py プロジェクト: abuchanan/biscuits
    def __init__(self, loader, region_config):

        self.loader = loader
        self.widget = RelativeLayout()
        self.objects = set()

        for tile in region_config.tiles:
            self.widget.add_widget(tile.image)

        for ID in region_config.object_IDs:
            self.load_object(ID)

        self._to_cleanup = []
コード例 #23
0
ファイル: app.py プロジェクト: abuchanan/biscuits
    def __init__(self, app):

        # TODO pretty sure this causes circular references that prevent
        #      garbage collection of the whole scene
        self.app = app
        self.world = World()
        self.widget = RelativeLayout()
        self.objects_layer = RelativeLayout()

        object_configs = dict(map.objects)
        object_configs['player'] = Config(type='Player',
                                          body=Config(x=0, y=0, w=1, h=1))

        scene = WorldScene(object_configs, self.world, app)
        self.scene = scene

        # TODO figure out a nice way to get rid of this
        self.tilewidth = map.tilewidth
        self.tileheight = map.tileheight

        self.region = None
        self.region_cache = {}

        player = scene.objects.load('player')

        self.player = player
        self.world.add(player)

        self.hud = HUDWidget(size_hint=(1, .05), pos_hint={'top': 1})
        # TODO move debug to app
        debug = DebugWidget(player, size_hint=(1, .05))

        self.widget.add_widget(self.objects_layer)
        self.widget.add_widget(player.widget._kivy_widget)
        self.widget.add_widget(self.hud)
        self.widget.add_widget(debug)
コード例 #24
0
ファイル: gameover.py プロジェクト: victor-rene/ld-shooter
 def __init__(self, root_widget, **kw):
   super(GameOver, self).__init__(**kw)
   self.root_widget = root_widget
   self.title = 'GAME OVER'
   self.layout = RelativeLayout()
   self.btn_new_game = Button(text='New Game', size_hint=(.5,.1), pos_hint={'center_x':.25, 'center_y': .05})
   self.btn_new_game.bind(on_press=self.new_game)
   self.btn_exit = Button(text='Exit', size_hint=(.5,.1), pos_hint={'center_x':.75, 'center_y': .05})
   self.btn_exit.bind(on_press=self.root_widget.close_app)
   self.lbl_score = Label(size_hint=(.5,.1), pos_hint={'center_x':.5, 'center_y': .4})
   self.lbl_high_score = Label(size_hint=(.5,.1), pos_hint={'center_x':.5, 'center_y': .7})
   self.layout.add_widget(self.lbl_score)
   self.layout.add_widget(self.lbl_high_score)
   self.layout.add_widget(self.btn_new_game)
   self.layout.add_widget(self.btn_exit)
   self.content = self.layout
   self.size_hint = (None, None)
   self.size = (400, 400)
コード例 #25
0
ファイル: main.py プロジェクト: FlapKap/Eyes4Drones
    def build(self):
        self.itu_lat = 55.6593807
        self.itu_lon = 12.5910774
        self.obs_dic = None        
        self.old_time = 0.0
        self.weatherbox = AnchorLayout(anchor_x = 'center', anchor_y = 'bottom')
        self.Layout = RelativeLayout()
        self.mapview = MapView(zoom=11, lat=self.itu_lat, lon=self.itu_lon)
        mapview = self.mapview
        self.Layout.add_widget(mapview)
        # add map layer
        self.jsonmap = GeoJsonMapLayer(source='5_mile_airport.json')
        self.mapview.add_layer(self.jsonmap)        



        
        self.overlay = AnchorLayout(anchor_x='right', anchor_y='top')
        lowerLeft = AnchorLayout(anchor_x='left', anchor_y='bottom')
        self.lowerLeftStack = StackLayout(orientation='lr-bt',size_hint=(0.15,0.15))
        lowerLeft.add_widget(self.lowerLeftStack)
        btnre = Button(background_normal='refocus_normal.png', background_down='refocus_down.png', size_hint = (2,1))
        btnre.bind(on_press=self.resetloc)        
        btnnf = ToggleButton(background_normal='nofly_normal.png', background_down='nofly_down.png',size_hint = (2,1))
        btnnf.bind(on_press=self.nofly)
        self.lowerLeftStack.add_widget(btnre)
        self.lowerLeftStack.add_widget(btnnf)
        
        
        btn = ToggleButton(background_normal='Settings B.png', background_down="Settings G.png")
        btn.bind(on_press= self.show_dropdown)
        self.settings = StackLayout(size_hint=(0.2,0.2))
        self.settings.add_widget(btn)
        self.overlay.add_widget(self.settings)
        self.Layout.add_widget(lowerLeft)
        self.Layout.add_widget(self.overlay)
        
        marker = MapMarker(anchor_x = 0.5, anchor_y = 0.5, lat=self.itu_lat, lon=self.itu_lon)
        self.mapview.add_marker(marker)        
         
        return self.Layout
コード例 #26
0
ファイル: buttonpad.py プロジェクト: victor-rene/kivy-gamelib
 def __init__(self, **kw):
   super(ButtonPad, self).__init__(**kw)
   self.listeners = []
   self.layout = RelativeLayout()
   self.add_widget(self.layout)
   btn_ids = ['A', 'B', 'X', 'Y']
   btn_pos = [(.8, .5), (.5, .2), (.5, .8), (.2, .5)]
   btn_colors = [[.7,0,0,1],[.9,.7,0,1],[0,.3,.7,1],[0,.7,0,1]]
   for i in range(4):
     btn = Button(id=btn_ids[i], size_hint=(.2, .2),
       background_color=btn_colors[i],
       background_normal='img/btn-normal.png',
       background_down='img/btn-down.png',
       pos_hint={'center_x': btn_pos[i][0], 'center_y': btn_pos[i][1]})
     btn.bind(on_press=self.btn_press)
     self.layout.add_widget(btn)
   with self.canvas.before:
     Color(1, 1, 1, 1)
     self.rect = Rectangle(pos=self.pos, size=self.size, source='img/bpad.png')
   self.bind(pos=self._update_rect)
   self.bind(size=self._update_rect)
コード例 #27
0
    def build(self):
        self.itu_lat = 55.6593807
        self.itu_lon = 12.5910774
        self.obs_dic = None        
        self.old_time = 0.0
        
        self.Layout = RelativeLayout(size=(900,450))
        self.mapview = MapView(zoom=17, lat=self.itu_lat, lon=self.itu_lon)
        self.Layout.add_widget(self.mapview)
        
        self.overlay = AnchorLayout(anchor_x='right', anchor_y='top')
#        btn = Button(text="test", size_hint=(.2, .2))
#        btn = Button(background_normal='Settings G.png', size=(0.2, 0.2), pos=(100,100)) 
        self.btn = Button(background_normal='Settings B.png', size_hint=(0.06, 0.1))        
        self.overlay.add_widget(self.btn)
        self.Layout.add_widget(self.overlay)        
        self.btn.bind(on_press = self.show_dropdown)
        
        marker = MapMarker(anchor_x = 0.5, anchor_y = 0.5, lat=self.itu_lat, lon=self.itu_lon)
        self.mapview.add_marker(marker)        
        return self.Layout
コード例 #28
0
    def __init__(self, popupwindow, **kwargs):
        super(ColorPickerBox, self).__init__(**kwargs)

        self.popupwindow = popupwindow

        self.generator = RelativeLayout(
                                    size_hint = (None, None),
                                    width = "400dp",
                                    height = "200dp",
                                    pos = ["50dp", "100dp"]   #"50dp"
                                       )

        self.acw = AutonomousColorWheel(self)
        self.generator.add_widget(self.acw)

        self.gpi = ColoredTextInput(pos = ["230dp", "80dp"])
        self.generator.add_widget(self.gpi)

        self.add_widget(self.generator)


        self.create_btn = Button(
                                    size_hint = [None, None],
                                    size = ["100dp","30dp"],
                                    pos = ["320dp","10dp"]
                                )
        self.create_btn.bind(on_release=self.create_group)


        self.cancel_btn = Button(
                                    size_hint = [None, None],
                                    size = ["100dp","30dp"],
                                    pos = ["200dp","10dp"]
                                )
        self.cancel_btn.bind(on_release=self.cancel_creation)



        self.add_widget(self.cancel_btn)
        self.add_widget(self.create_btn)
コード例 #29
0
ファイル: region.py プロジェクト: abuchanan/biscuits
class Region:

    def __init__(self, loader, region_config):

        self.loader = loader
        self.widget = RelativeLayout()
        self.objects = set()

        for tile in region_config.tiles:
            self.widget.add_widget(tile.image)

        for ID in region_config.object_IDs:
            self.load_object(ID)

        self._to_cleanup = []


    def update(self, dt):
        for obj in self.objects:
            obj.signals.update.send(dt)

        while self._to_cleanup:
            obj = self._to_cleanup.pop()

            self.objects.remove(obj)

            # TODO consider using weakref.finalize
            try:
                self.widget.remove_widget(obj.widget._kivy_widget)
            except AttributeError:
                pass

    def load_object(self, ID):
        obj = self.loader.load(ID)

        obj.signals.destroy.connect(self.cleanup)
        self.objects.add(obj)

        try:
            # TODO clean up this widget stuff
            self.widget.add_widget(obj.widget._kivy_widget)
        except AttributeError:
            pass

    def cleanup(self, obj):
        self._to_cleanup.append(obj)
コード例 #30
0
ファイル: visualizer.py プロジェクト: encukou/slides
    def build(self):
        self.layout = RelativeLayout()
        self.edge_widget = Widget()
        self.layout.add_widget(self.edge_widget)

        Clock.schedule_interval(lambda t: self.rescan(), 2)

        kbd = Window.request_keyboard(lambda: None, self.edge_widget, 'text')
        kbd.bind(on_key_down=self._on_keyboard_down)

        self.option_widgets = []
        # Finding objects to show
        self.add_option('a', 'all', 'All', (1, 1, 1))
        self.add_option('i', 'index', 'Idx', (1, 1/2, 1))
        self.add_option('f', 'list-refs', 'reF', (1/2, 1, 1))
        self.add_option('l', 'reflog', 'Log', (1, 1/2, 1/2), default=False)
        # Filer shown objects
        self.add_option('b', 'blobs', 'Blb', (1/2, 1/2, 1/2))
        self.add_option('t', 'trees', 'Tre', (1/2, 1, 1/2))
        self.add_option('c', 'commits', 'Com', (1/2, 1/2, 1))
        self.add_option('r', 'refs', 'Ref', (1/2, 1, 1), default=False)

        return self.layout
コード例 #31
0
ファイル: test.py プロジェクト: skelouse/DateMaster-public
class TestLayout(Screen):
    def __init__(self, **kwargs):
        super(TestLayout, self).__init__(**kwargs)
        self.app = App.get_running_app()
        self.layout = RelativeLayout()
        self.grid = GridLayout(cols=1)

        self.tutbtn = genericButton(text='Tutorial')
        self.tutbtn.bind(on_press=self.test_tutorial)
        self.grid.add_widget(self.tutbtn)

        self.screensbtn = genericButton(text='Screens')
        self.screensbtn.bind(on_press=self.test_screens)
        self.grid.add_widget(self.screensbtn)

        self.dbbtn = genericButton(text='Database')
        self.dbbtn.bind(on_press=self.test_db)
        self.grid.add_widget(self.dbbtn)

        self.layout.add_widget(self.grid)
        self.add_widget(self.layout)

        self.refresh_button = Button(text='ref',
                                     size_hint=(.1, .1),
                                     pos_hint={
                                         'center_x': .99,
                                         'center_y': .99
                                     })

    def test_screens(self, event):
        self.layout.remove_widget(self.grid)

        self.screengrid = GridLayout(cols=1)

        self.loginbtn = genericButton(text='Login')
        self.loginbtn.bind(on_press=self.login_screen)
        self.screengrid.add_widget(self.loginbtn)

        self.depbtn = genericButton(text='Dep Select')
        self.depbtn.bind(on_press=self.depselect_screen)
        self.screengrid.add_widget(self.depbtn)

        self.viewbtn = genericButton(text='item viewer')
        self.viewbtn.bind(on_press=self.itemviewer_screen)
        self.screengrid.add_widget(self.viewbtn)

        self.homebtn = genericButton(text='Home')
        self.homebtn.bind(on_press=self.home)
        self.screengrid.add_widget(self.homebtn)

        self.layout.add_widget(self.screengrid)

    ###################
    # LOGIN SCREEN
    ###################
    def login_screen(self, event):
        print('testing login screen')
        self.log_num = 0
        self.login = main.Login(name='login')
        self.refresh_button.bind(on_press=self.refresh_login)
        self.login.add_widget(self.refresh_button)
        sm.add_widget(self.login)
        sm.current = 'login'

    def refresh_login(self, event):
        print('refreshing')
        self.login.remove_widget(self.refresh_button)
        self.log_num += 1
        try:
            importlib.reload(main)
            self.login = main.Login(name='login%s' % self.log_num)
            self.login.add_widget(self.refresh_button)
            sm.add_widget(self.login)
            sm.current = 'login%s' % self.log_num
        except Exception as e:
            self.login.remove_widget(self.refresh_button)
            self.login.add_widget(self.refresh_button)
            print('compile error\n- ', e)

    ###################
    # DEP_SELECT SCREEN
    ###################
    def depselect_screen(self, event):
        print('testing dep_select screen')
        self.get_department_list_from_file()
        self.log_num = 0
        self.depselect = main.DepSelect(name='dep_select')
        self.refresh_button.bind(on_press=self.refresh_depselect)
        self.depselect.add_widget(self.refresh_button)
        sm.add_widget(self.depselect)
        sm.current = 'dep_select'

    def refresh_depselect(self, event):
        print('refreshing')
        self.depselect.remove_widget(self.refresh_button)
        self.log_num += 1
        try:
            importlib.reload(main)
            self.depselect = main.DepSelect(name='dep_select%s' % self.log_num)
            self.depselect.add_widget(self.refresh_button)
            sm.add_widget(self.depselect)
            sm.current = 'dep_select%s' % self.log_num
        except Exception as e:
            self.depselect.remove_widget(self.refresh_button)
            self.depselect.add_widget(self.refresh_button)
            print('compile error\n- ', e)

    def get_department_list_from_file(self):
        with open('Front/DateMaster/tests/test_save.txt',
                  encoding='ISO-8859-1') as f:
            app.department_list = {}
            read_data = (f.read())
            data = ast.literal_eval(read_data)
            for i in data:
                if i != 'edited_by' and i != 'timezone':
                    todo = data[i]['todo']
                    app.department_list[i] = ({
                        'name': i,
                        'todo': todo,
                        'todo_count': len(todo)
                    })

    ###################
    # ITEM_VIEWER SCREEN
    ###################
    def itemviewer_screen(self, event):
        print('testing item_viewer screen')
        self.get_department_list_from_file()
        self.depselect = main.DepSelect(name='dep_select')
        sm.add_widget(self.depselect)

        self.select_dep(main.ItemViewer)
        self.log_num = 0
        self.itemviewer = main.ItemViewer(name='item_viewer')

        self.refresh_button.bind(on_press=self.refresh_itemviewer)
        self.itemviewer.add_widget(self.refresh_button)
        sm.add_widget(self.itemviewer)
        sm.current = 'item_viewer'

    def refresh_itemviewer(self, event):
        print('refreshing')
        self.itemviewer.remove_widget(self.refresh_button)
        self.log_num += 1
        try:
            importlib.reload(main)
            self.select_dep(main.ItemViewer)
            self.itemviewer = main.ItemViewer(name='item_viewer%s' %
                                              self.log_num)
            self.itemviewer.add_widget(self.refresh_button)
            sm.add_widget(self.itemviewer)
            sm.current = 'item_viewer%s' % self.log_num
        except Exception as e:
            self.itemviewer.remove_widget(self.refresh_button)
            self.itemviewer.add_widget(self.refresh_button)
            print('compile error\n- ', e)

    def select_dep(self, ItemViewer):
        ItemViewer.todo = []
        ItemViewer.todo_num = 0
        app.selected_dep = 'Dairy'
        todo = app.department_list['Dairy']['todo']
        for i in todo.items():
            ItemViewer.todo.append(i)

    ###################
    # TEST_TUTORIAL
    ###################
    def test_tutorial(self, event):
        # self.get_department_list_from_file()
        # for i in app.department_list['Dairy']['todo'].items():
        #     print(i[1]['ftype'], i)

        app.department_list = {}

        self.tutorial = tutorial_screen.Tutorial(main.DepSelect,
                                                 main.ItemViewer,
                                                 sm,
                                                 name=('tutorial'))

        self.log_num = 0

        self.refresh_button.bind(on_press=self.refresh_tutorial)

        sm.add_widget(self.tutorial)
        sm.get_screen('tutorial').refresh_button = self.refresh_button
        sm.current = 'tutorial'

    def refresh_tutorial(self, event):
        print('refreshing')
        if self.log_num == 0:
            sm.get_screen('tutorial').clear_widgets()
        else:
            sm.get_screen('tutorial%s' % self.log_num).clear_widgets()
        self.log_num += 1
        #try:
        importlib.reload(tutorial_screen)
        self.tutorial = tutorial_screen.Tutorial(main.DepSelect,
                                                 main.ItemViewer,
                                                 sm,
                                                 name=('tutorial%s' %
                                                       self.log_num))

        sm.add_widget(self.tutorial)
        sm.get_screen('tutorial%s' %
                      self.log_num).refresh_button = self.refresh_button
        sm.current = 'tutorial%s' % self.log_num
        #except Exception as e:
        # self.tutorial.remove_widget(self.refresh_button)
        # self.tutorial.add_widget(self.refresh_button)
        # print('compile error\n- ', e)

    ###################
    # TEST_TUTORIAL
    ###################

    def test_db(self, event):
        print('testing database')

    def home(self, event):
        for i in self.layout.children:
            self.layout.remove_widget(i)
        self.layout.add_widget(self.grid)
コード例 #32
0
ファイル: bottom_up.py プロジェクト: Geetesh05/Internship
class Nn(App):
    def build(self):
        global huling, dur
        self.box = RelativeLayout()
        fig, ax = plt.subplots()
        ax.set_xlabel("PC1")
        ax.set_ylabel("PC2")
        ax.plot(file2[:, 0], file2[:, 1], "o")
        for i, k in zip(range(len(huling)), range(len(dur))):
            for simplex in huling[i]:
                ax.plot(np.array(dur[k])[simplex, 0],
                        np.array(dur[k])[simplex, 1],
                        marker='o',
                        linestyle='-',
                        markerfacecolor="blue",
                        color='red')

        self.win = fig.canvas
        # FigureCanvasKivyAgg(fig.canvas, size_hint=(1, 0.9), pos_hint={"top": 1})
        self.box.add_widget(self.win)
        self.one = NavigationToolbar2Kivy(self.win)
        self.box1 = BoxLayout(orientation="horizontal")
        self.box1.add_widget(self.one.actionbar)
        self.box2 = BoxLayout(orientation="horizontal")
        # self.box2=GridLayout()
        self.bt3 = Button(text="scores plot",
                          size_hint=(0.15, 0.06),
                          pos=(0, 0))
        self.bt4 = Button(text="pathway list",
                          size_hint=(0.15, 0.06),
                          pos=(1, 0))
        self.box2.add_widget(self.bt3)
        self.bt3.bind(on_press=self.pop1)
        self.bt4.bind(on_press=self.pop)
        self.box2.add_widget(self.bt4)
        self.box.add_widget(self.box1)
        self.box.add_widget(self.box2)
        self.pop_up1 = Popup(title="Visvualization", content=self.box)
        self.pop_up1.open()

    def pop(self, button):
        layout = GridLayout(cols=1, spacing=10, size_hint_y=None)
        layout.bind(minimum_height=layout.setter('height'))
        title = "List of pathways"
        b = []
        for i in range(len(file3)):
            b.append(
                Button(text=str(i + 1) + ". " + file3[i], size_hint_y=None))
            layout.add_widget(b[i])
            b[i].bind(on_press=partial(self.specific, i))

        # for i in range(len(file3)):
        # layout.add_widget(Button(text=str(i+1)+". "+file3[i],size_hint_y=None))
        closeButton = Button(text="Close the pop-up", size_hint_y=None)
        layout.add_widget(closeButton)
        root = ScrollView(size_hint=(1, None),
                          size=(Window.width, Window.height))
        root.add_widget(layout)
        self.pop_up = Popup(title=title, content=root, size_hint=(1, 1))
        self.pop_up.open()
        closeButton.bind(on_press=self.pop_up.dismiss)

    def pop1(self, button):
        self.boxp1 = RelativeLayout()
        fig1, ax1 = plt.subplots()
        ax1.set_xlabel("PC1")
        ax1.set_ylabel("PC2")
        for k in range(len(file4)):
            ax1.plot(file4[k][0], file4[k][1], marker="o", color="blue")
        self.win1 = fig1.canvas
        # FigureCanvasKivyAgg(ax1.gcf(), size_hint=(1, 0.9), pos_hint={"top": 1})
        self.boxp1.add_widget(self.win1)
        closeButton1 = Button(text="Close the pop-up",
                              size_hint=(0.15, 0.06),
                              pos=(0, 0))
        self.one1 = NavigationToolbar2Kivy(self.win1)
        self.boxp1.add_widget(self.one1.actionbar)
        self.boxp1.add_widget(closeButton1)
        self.pop_upp = Popup(title="Visualization", content=self.boxp1)
        self.pop_upp.open()
        closeButton1.bind(on_press=self.pop_upp.dismiss)

    def specific(self, index, unused):
        self.boxp2 = RelativeLayout()
        fig2, ax2 = plt.subplots()
        ax2.set_xlabel("PC1")
        ax2.set_ylabel("PC2")
        ax2.plot(file2[:, 0], file2[:, 1], "o")
        for j in huling[index]:
            ax2.plot(np.array(dur[index])[j, 0],
                     np.array(dur[index])[j, 1],
                     marker='o',
                     linestyle='-',
                     markerfacecolor="blue",
                     color='red')
        self.win2 = fig2.canvas
        # FigureCanvasKivyAgg(ax1.gcf(), size_hint=(1, 0.9), pos_hint={"top": 1})
        self.boxp2.add_widget(self.win2)
        closeButton2 = Button(text="Close the pop-up",
                              size_hint=(0.3, 0.1),
                              pos=(0, 0))
        self.one2 = NavigationToolbar2Kivy(self.win2)
        self.boxp2.add_widget(self.one2.actionbar)
        self.boxp2.add_widget(closeButton2)
        self.pop_up2 = Popup(title="Visualization", content=self.boxp2)
        self.pop_up2.open()
        closeButton2.bind(on_press=self.pop_up2.dismiss)
コード例 #33
0
ファイル: dragBlockCore.py プロジェクト: DiJei/Baratino
 def on_touch_move(self, touch):
     if self.selected:
         self.center = (touch.x,touch.y)
         return True
     return RelativeLayout.on_touch_move(self, touch)
コード例 #34
0
    def update(self, day, month, year):
        lunar_day, lunar_month, lunar_year = self.lunarDay(day, month, year)
        solar_day = datetime.date(year, month, day)
        dayOfMonth = solar_day.day
        dayOfWeek = self.day_of_week[solar_day.weekday()]
        month = solar_day.month
        year = solar_day.year
        event_text = self.getEvent(day, month, year)
        self.layout = RelativeLayout()
        box = BoxLayout(orientation='vertical')

        solar_layout = RelativeLayout(size_hint=(1, 3))
        solar_box = BoxLayout(spacing=2, padding=2, orientation='vertical')
        solar_background_image = Image(
            source='Image/Calendar/Background/Calendar/snow.png',
            allow_stretch=True,
            keep_ratio=False)

        monthYear_lbl = Label(
            text='[color=ffffff][b]Tháng %s Năm %s[/b][/color]' %
            (month, year),
            size_hint=(1, .3),
            font_size=20,
            valign='top',
            halign='center',
            markup=True)
        day_lbl = Label(
            text=
            '[color=000000][b][size=150]%s[/size]\n[size=35]%s[/size][/b][/color]'
            % (dayOfMonth, dayOfWeek),
            size_hint=(1, 3),
            valign='top',
            halign='center',
            markup=True)

        event_lbl = AutoLineBreakLabel(
            text='[color=%s][b][size=13]%s[/size][/b][/color]' % event_text,
            width=320,
            valign='middle',
            halign='center')
        solar_box.add_widget(Label(size_hint=(1, .5)))
        solar_box.add_widget(monthYear_lbl)
        solar_box.add_widget(day_lbl)
        solar_box.add_widget(event_lbl)

        solar_layout.add_widget(solar_background_image)
        solar_layout.add_widget(solar_box)

        lunar_canChi_layout = RelativeLayout(size_hint=(1, 1))
        lunar_canChi_box = GridLayout(spacing=2, padding=2, cols=4)

        lunar_lbl_background = 'Image/Calendar/Button/button_default.png'
        self.lunar_time_lbl = Button(
            text='[size=15][b]Giờ[/b][/size]\n[color=ff0000]%s[/color]' %
            self.get_time(),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        lunar_day_lbl = Button(
            text='[size=15][b]Ngày[/b][/size]\n[color=ff0000]%s[/color]' %
            lunar_day,
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        lunar_month_lbl = Button(
            text='[size=15][b]Tháng[/b][/size]\n[color=ff0000]%s[/color]' %
            (lunar_month),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        lunar_year_lbl = Button(
            text='[size=15][b]Năm[/b][/size]\n[color=ff0000]%s[/color]' %
            (lunar_year),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        self.canChi_time_lbl = Button(
            text='[color=ff0000]%s[/color]' % self.get_canchi_time_by_day(),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        canChi_day_lbl = Button(
            text='[color=ff0000]%s[/color]' % self.getCanChiDay(solar_day),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        canChi_month_lbl = Button(
            text='[color=ff0000]%s %s[/color]' %
            (self.getCanChiMonth(lunar_month, lunar_year)),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        canChi_year_lbl = Button(text='[color=ff0000]%s %s[/color]' %
                                 (self.getCanChiYear(lunar_year)),
                                 markup=True,
                                 background_normal=lunar_lbl_background,
                                 background_down=lunar_lbl_background,
                                 valign='middle',
                                 halign='center')

        lunar_canChi_box.add_widget(self.lunar_time_lbl)
        lunar_canChi_box.add_widget(lunar_day_lbl)
        lunar_canChi_box.add_widget(lunar_month_lbl)
        lunar_canChi_box.add_widget(lunar_year_lbl)
        lunar_canChi_box.add_widget(self.canChi_time_lbl)
        lunar_canChi_box.add_widget(canChi_day_lbl)
        lunar_canChi_box.add_widget(canChi_month_lbl)
        lunar_canChi_box.add_widget(canChi_year_lbl)
        lunar_canChi_box.add_widget(Label(size_hint=(1, .8)))

        lunar_canChi_layout.add_widget(lunar_canChi_box)

        box.add_widget(solar_layout)
        box.add_widget(lunar_canChi_layout)

        background_image = Image(
            source=
            'Image/Calendar/Background/Calendar/background_lunar_calendar.png',
            allow_stretch=True,
            keep_ratio=False)

        self.layout.add_widget(background_image)
        self.layout.add_widget(box)
        self.content = self.layout
        self.getAllCanChiDay()
コード例 #35
0
    def build(self):

        Config.set('graphics', 'width', str(resolution[0]))
        Config.set('graphics', 'height', str(resolution[1]))
        Config.set('graphics', 'borderless', 1)
        Config.set('graphics', 'fullscreen', 1)
        # creates a float layout
        root = FloatLayout(size=(resolution[0], resolution[1]), pos=(0, 0))
        # Creates a scatter widget
        scatter = Scatter()

        # Creates an image widget
        root_image = Image(source='Bottom_Screen1.jpeg',
                           size_hint_x=None,
                           width=resolution[0],
                           size_hint_y=None,
                           height=resolution[1],
                           allow_stretch=True,
                           keep_ratio=True)
        root.add_widget(root_image)

        # Creates the knob objects - creates first knob
        knob1 = MyKnob(
            size=(scale_to_res(315, 1980, 0), scale_to_res(315, 1980, 0)),
            min=0,
            max=360,
            step=1,
            show_marker=True,
            knobimg_source="knob1.png",
            marker_img="img/bline.png",
            markeroff_color=(0.3, 0.3, .3, 1),
            pattern_id=99,  #(ids 1 to 8, or 99 for no id)
            debug=False,
            obj=scatter)  # Passes the object to the knob

        # Creates second knob object
        knob2 = MyKnob(
            size=(scale_to_res(315, 1980, 0), scale_to_res(315, 1980, 0)),
            min=0,
            max=360,
            step=1,
            show_marker=True,
            knobimg_source="knob2.png",
            marker_img="img/bline.png",
            markeroff_color=(0.3, 0.3, .3, 1),
            pattern_id=99,  #(ids 1 to 8, or 99 for no id)
            debug=False,
            obj=scatter)  # Passes the object to the knob

        # Creates third knob
        knob3 = MyKnob(
            size=(scale_to_res(315, 1980, 0), scale_to_res(315, 1980, 0)),
            min=0,
            max=360,
            step=1,
            show_marker=True,
            knobimg_source="knob3.png",
            marker_img="img/bline.png",
            markeroff_color=(0.3, 0.3, .3, 1),
            pattern_id=99,  #(ids 1 to 8, or 99 for no id)
            debug=False,
            obj=scatter)  # Passes the object to the knob

        # Creates fourth knob
        knob4 = MyKnob(
            size=(scale_to_res(315, 1980, 0), scale_to_res(315, 1980, 0)),
            min=0,
            max=360,
            step=1,
            show_marker=True,
            knobimg_source="knob4.png",
            marker_img="img/bline.png",
            markeroff_color=(0.3, 0.3, .3, 1),
            pattern_id=99,  #(ids 1 to 8, or 99 for no id)
            debug=False,
            obj=scatter)  # Passes the object to the knob

        # These functions place the konbs on the screen in the right position
        widget1 = RelativeLayout(size_hint=(None, None),
                                 size=(scale_to_res(315, 1980, 0),
                                       scale_to_res(315, 1980, 0)),
                                 pos=(scale_to_res(96, 1980, 0),
                                      scale_to_res(40, 1080, 1)))  #152
        widget1.add_widget(knob1)

        widget2 = RelativeLayout(size_hint=(None, None),
                                 size=(scale_to_res(315, 1980, 0),
                                       scale_to_res(315, 1980, 0)),
                                 pos=(scale_to_res(585, 1980, 0),
                                      scale_to_res(40, 1080, 1)))  #880
        widget2.add_widget(knob2)

        widget3 = RelativeLayout(size_hint=(None, None),
                                 size=(scale_to_res(315, 1980, 0),
                                       scale_to_res(315, 1980, 0)),
                                 pos=(scale_to_res(1080, 1980, 0),
                                      scale_to_res(40, 1080, 1)))  #1610
        widget3.add_widget(knob3)

        widget4 = RelativeLayout(size_hint=(None, None),
                                 size=(scale_to_res(315, 1980, 0),
                                       scale_to_res(315, 1980, 0)),
                                 pos=(scale_to_res(1574, 1980, 0),
                                      scale_to_res(40, 1080, 1)))  #2340
        widget4.add_widget(knob4)

        # Adds knob to the root
        root.add_widget(widget1)

        root.add_widget(widget2)

        root.add_widget(widget3)

        root.add_widget(widget4)

        #done by wade
        arrows1 = Image(source='arrows.png',
                        size_hint_x=None,
                        width=425,
                        size_hint_y=None,
                        height=425,
                        pos=(scale_to_res(-10, 1980,
                                          0), scale_to_res(-65, 1080, 1)),
                        allow_stretch=True,
                        keep_ratio=True)
        #scatter1 = Scatter()
        #scatter1.add_widget(arrows1)
        root.add_widget(arrows1)
        arrows2 = Image(source='arrows.png',
                        size_hint_x=None,
                        width=425,
                        size_hint_y=None,
                        height=425,
                        pos=(scale_to_res(470, 1980,
                                          0), scale_to_res(-65, 1080, 1)),
                        allow_stretch=True,
                        keep_ratio=True)
        #scatter2 = Scatter().add_widget(arrows2)
        root.add_widget(arrows2)
        arrows3 = Image(source='arrows.png',
                        size_hint_x=None,
                        width=425,
                        size_hint_y=None,
                        height=425,
                        pos=(scale_to_res(965, 1980,
                                          0), scale_to_res(-65, 1080, 1)),
                        allow_stretch=True,
                        keep_ratio=True)
        #scatter3 = Scatter().add_widget(arrows3)
        root.add_widget(arrows3)
        arrows4 = Image(source='arrows.png',
                        size_hint_x=None,
                        width=425,
                        size_hint_y=None,
                        height=425,
                        pos=(scale_to_res(1465, 1980,
                                          0), scale_to_res(-65, 1080, 1)),
                        allow_stretch=True,
                        keep_ratio=True)
        #scatter4 = Scatter().add_widget(arrows4)
        root.add_widget(arrows4)

        #anim = Animation(center = scatter1.pos, rotation = 360)
        #anim.start(scatter1);
        return root
コード例 #36
0
ファイル: display.py プロジェクト: seanirby/mpf-mc
class DisplayWidget(Widget, RelativeLayout):

    """A widget showing a display."""

    widget_type_name = 'Display'
    animation_properties = ('x', 'y', 'pos')

    def __init__(self, mc: "MpfMc", config: dict, key: Optional[str] = None, **kwargs) -> None:
        del kwargs
        self.display = mc.displays[config['source_display']]

        super().__init__(mc=mc, config=config, key=key)

        if 'effects' in self.config and self.config['effects']:
            self.effects = EffectWidget(pos=self.pos, size_hint=(1, 1))
            self.effects.key = None
            self._add_effects(self.config['effects'])
        else:
            self.effects = RelativeLayout(pos=self.pos, size_hint=(1, 1))

        # Establish link between display and this display widget
        self.display_output = DisplayOutput(self.effects, self.display)
        self.effects.add_widget(self.display_output)
        self.add_widget(self.effects)
        self.display_output.add_display_source(self.display)

    def prepare_for_removal(self):
        """Remove display and effects."""
        super().prepare_for_removal()
        self.remove_widget(self.effects)
        self.display_output.remove_display_source(self.display)

    def __repr__(self) -> str:  # pragma: no cover
        try:
            return '<DisplayWidget size={}, pos={}, source={}>'.format(
                self.size, self.pos, self.display.name)
        except AttributeError:
            return '<DisplayWidget size={}, source=(none)>'.format(self.size)

    def on_pos(self, instance, pos):
        del instance
        self.effects.pos = pos

    def _add_effects(self, config: Optional[list]) -> None:
        """Adds any effects specified in the config for this display widget."""
        if config:
            effects_list = list()
            for effect_config in config:
                effect_config['width'] = self.width
                effect_config['height'] = self.height
                effects_list.extend(self.mc.effects_manager.get_effect(effect_config))

            self.effects.effects = effects_list

    def get_display(self):
        """List display."""
        return self.display

    @property
    def current_slide(self) -> Optional["Slide"]:
        """The current slide shown on the linked display."""
        if self.display:
            return self.display.current_slide
        else:
            return None

    @property
    def current_slide_name(self) -> Optional[str]:
        """The name of the current slide shown on the linked display."""
        if self.display:
            return self.display.current_slide_name
        else:
            return None
コード例 #37
0
class confirmExit(ModalView):
	def __init__(self,**kwargs):
		super(confirmExit,self).__init__(**kwargs)
		
		self.size_hint = (None, None)
		self.size = (290*g.scale, 290*g.scale)
		self.border = (0.2,0.4,0.2,0)
		
		self.auto_dismiss = False
		
		self.background_color = (0,0,0,0.2)
		self.background = g.IMG_CONFIRM_BG
		
		textlabel = Label(text = g.xml_root[6][5].text)
		textlabel.font_name = g.FONT_CR
		textlabel.font_size = 26*g.scale
		textlabel.color = g.COLOR_BLUE
		
		self.rl = RelativeLayout()
		self.add_widget(self.rl)
		
		self.rl.add_widget( confirmationButton('yes') )
		self.rl.add_widget( confirmationButton('no') )
		self.rl.add_widget( textlabel )
		
		# If we're in the main screen, add option to return to title
		if g.manager.current_screen.name == 'main_screen':
			self.title_btn = confSmallButton('title',self) #The btn will addd itself to parent
			show_undo = False
			if len(g.moves_history['player_1'])>0:
				show_undo = True
			if g.players == 1 and g.player == 'player_2':
				show_undo = False
			if show_undo:
				pass
			self.undo_btn = confSmallButton('undo',self) #The btn will addd itself to parent
		
		# Create volume button
		self.volume_btn = ToggleButton()
		self.volume_btn.size_hint = (None,None)
		self.volume_btn.size = (130*g.scale, 130*g.scale)
			
		self.volume_btn.border = (0,0,0,0)
		self.volume_btn.background_normal = g.IMG_CONFIRM_VOLUMEBTN_NORMAL
		self.volume_btn.background_down = g.IMG_CONFIRM_VOLUMEBTN_PRESS
		posx = self.size[0]/2 - self.volume_btn.size[0]/2
		posy = self.size[1]/2 - self.volume_btn.size[1]/2 + 235*g.scale
		self.volume_btn.pos = (posx, posy)
		self.volume_btn.bind( on_press = self.confirm_volume )
		
		if g.sound:
			self.volume_btn.state = 'normal'
		else:
			self.volume_btn.state = 'down'
			
		self.rl.add_widget(self.volume_btn)
		

	def confirm_title(self, arg1):
		self.dismiss()
		print 'COUNTING:',g.ad_count
		if g.ad_count > 5:
			g.manager.current = 'splash_screen'
		else:
			g.manager.current = 'title_screen'
		g.modal_screen = False

	def confirm_volume(self, btn):
		if self.volume_btn.state == 'normal':
			#Volume has just been turned on
			#g.sound_controller.play_music()
			g.sound = True
		elif self.volume_btn.state == 'down':
			#Volume has just been turned off
			#g.sound_controller.stop_music()
			g.sound = False
コード例 #38
0
class DateDetailPopup(Popup):
    def __init__(self, **kwargs):
        super(DateDetailPopup, self).__init__(**kwargs)
        self.title = 'CALENDAR'
        self.title_align = 'center'
        self.title_color = (1, 1, 0, 1)
        self.day = kwargs['day']
        self.month = kwargs['month']
        self.year = kwargs['year']
        self.day_of_week = [
            'Thứ Hai', 'Thứ Ba', 'Thứ Tư', 'Thứ Năm', 'Thứ Sáu', 'Thứ Bảy',
            'Chủ Nhật'
        ]

        self.can_year_list = [
            'Canh', 'Tân', 'Nhâm', 'Quý', 'Giáp', 'Ất', 'Bính', 'Đinh', 'Mậu',
            'Kỷ'
        ]
        self.chi_year_list = [
            'Thân', 'Dậu', 'Tuất', 'Hợi', 'Tý', 'Sửu', 'Dần', 'Mảo', 'Thìn',
            'Tỵ', 'Ngọ', 'Mùi'
        ]

        self.chi_month_list = [
            'Dần', 'Mảo', 'Thìn', 'Tỵ', 'Ngọ', 'Mùi', 'Thân', 'Dậu', 'Tuất',
            'Hợi', 'Tý', 'Sửu'
        ]
        self.can_month_list = {
            'Giáp Kỷ': 'Bính',
            'Bính Tân': 'Canh',
            'Đinh Nhâm': 'Nhâm',
            'Mậu Quý': 'Giáp',
            'Ất Canh': 'Mậu'
        }

        self.all_can_chi_list = [
            'Giáp Tý', 'Ất Sửu', 'Bính Dần', 'Đinh Mão', 'Mậu Thìn', 'Kỷ Tỵ',
            'Canh Ngọ', 'Tân Mùi', 'Nhâm Thân', 'Quý Dậu', 'Giáp Tuất',
            'Ất Hợi', 'Bính Tý', 'Đinh Sửu', 'Mậu Dần', 'Kỷ Mão', 'Canh Thìn',
            'Tân Tỵ', 'Nhâm Ngọ', 'Quý Mùi', 'Giáp Thân', 'Ất Dậu',
            'Bính Tuất', 'Đinh Hợi', 'Mậu Tý', 'Kỷ Sửu', 'Canh Dần', 'Tân Mão',
            'Nhâm Thìn', 'Quý Tỵ', 'Giáp Ngọ', 'Ất Mùi', 'Bính Thân',
            'Đinh Dậu', 'Mậu Tuất', 'Kỷ Hợi', 'Canh Tý', 'Tân Sửu', 'Nhâm Dần',
            'Quý Mão', 'Giáp Thìn', 'Ất Tỵ', 'Bính Ngọ', 'Đinh Mùi',
            'Mậu Thân', 'Kỷ Dậu', 'Canh Tuất', 'Tân Hợi ', 'Nhâm Tý',
            'Quý Sửu', 'Giáp Dần', 'Ất Mão', 'Bính Thìn', 'Đinh tỵ', 'Mậu Ngọ',
            'Kỷ Mùi', 'Canh thân', 'Tân Dậu', 'Nhâm Tuất', 'Quý Hợi'
        ]

        self.can_chi_first_day = [
            datetime.date(1900, 1, 31),
            self.all_can_chi_list.index('Giáp Thìn')
        ]

        self.can_first_hour = 'Giáp'  # first hour of 31/1/1900 ~ 1/1/1900 in lunar calendar

        self.can_chi_hour_list = [('Tý', 23, 0), ('Sửu', 1, 2), ('Dần', 3, 4),
                                  ('Mão', 5, 6), ('Thìn', 7, 8), ('Tị', 9, 10),
                                  ('Ngọ', 11, 12), ('Mùi', 13, 14),
                                  ('Thân', 15, 16), ('Dậu', 17, 18),
                                  ('Tuất', 19, 20), ('Hợi', 21, 22)]

        self.update(self.day, self.month, self.year)
        Clock.schedule_interval(self.update_time, 1)

    def update(self, day, month, year):
        lunar_day, lunar_month, lunar_year = self.lunarDay(day, month, year)
        solar_day = datetime.date(year, month, day)
        dayOfMonth = solar_day.day
        dayOfWeek = self.day_of_week[solar_day.weekday()]
        month = solar_day.month
        year = solar_day.year
        event_text = self.getEvent(day, month, year)
        self.layout = RelativeLayout()
        box = BoxLayout(orientation='vertical')

        solar_layout = RelativeLayout(size_hint=(1, 3))
        solar_box = BoxLayout(spacing=2, padding=2, orientation='vertical')
        solar_background_image = Image(
            source='Image/Calendar/Background/Calendar/snow.png',
            allow_stretch=True,
            keep_ratio=False)

        monthYear_lbl = Label(
            text='[color=ffffff][b]Tháng %s Năm %s[/b][/color]' %
            (month, year),
            size_hint=(1, .3),
            font_size=20,
            valign='top',
            halign='center',
            markup=True)
        day_lbl = Label(
            text=
            '[color=000000][b][size=150]%s[/size]\n[size=35]%s[/size][/b][/color]'
            % (dayOfMonth, dayOfWeek),
            size_hint=(1, 3),
            valign='top',
            halign='center',
            markup=True)

        event_lbl = AutoLineBreakLabel(
            text='[color=%s][b][size=13]%s[/size][/b][/color]' % event_text,
            width=320,
            valign='middle',
            halign='center')
        solar_box.add_widget(Label(size_hint=(1, .5)))
        solar_box.add_widget(monthYear_lbl)
        solar_box.add_widget(day_lbl)
        solar_box.add_widget(event_lbl)

        solar_layout.add_widget(solar_background_image)
        solar_layout.add_widget(solar_box)

        lunar_canChi_layout = RelativeLayout(size_hint=(1, 1))
        lunar_canChi_box = GridLayout(spacing=2, padding=2, cols=4)

        lunar_lbl_background = 'Image/Calendar/Button/button_default.png'
        self.lunar_time_lbl = Button(
            text='[size=15][b]Giờ[/b][/size]\n[color=ff0000]%s[/color]' %
            self.get_time(),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        lunar_day_lbl = Button(
            text='[size=15][b]Ngày[/b][/size]\n[color=ff0000]%s[/color]' %
            lunar_day,
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        lunar_month_lbl = Button(
            text='[size=15][b]Tháng[/b][/size]\n[color=ff0000]%s[/color]' %
            (lunar_month),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        lunar_year_lbl = Button(
            text='[size=15][b]Năm[/b][/size]\n[color=ff0000]%s[/color]' %
            (lunar_year),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        self.canChi_time_lbl = Button(
            text='[color=ff0000]%s[/color]' % self.get_canchi_time_by_day(),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        canChi_day_lbl = Button(
            text='[color=ff0000]%s[/color]' % self.getCanChiDay(solar_day),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center',
        )

        canChi_month_lbl = Button(
            text='[color=ff0000]%s %s[/color]' %
            (self.getCanChiMonth(lunar_month, lunar_year)),
            markup=True,
            background_normal=lunar_lbl_background,
            background_down=lunar_lbl_background,
            valign='middle',
            halign='center')

        canChi_year_lbl = Button(text='[color=ff0000]%s %s[/color]' %
                                 (self.getCanChiYear(lunar_year)),
                                 markup=True,
                                 background_normal=lunar_lbl_background,
                                 background_down=lunar_lbl_background,
                                 valign='middle',
                                 halign='center')

        lunar_canChi_box.add_widget(self.lunar_time_lbl)
        lunar_canChi_box.add_widget(lunar_day_lbl)
        lunar_canChi_box.add_widget(lunar_month_lbl)
        lunar_canChi_box.add_widget(lunar_year_lbl)
        lunar_canChi_box.add_widget(self.canChi_time_lbl)
        lunar_canChi_box.add_widget(canChi_day_lbl)
        lunar_canChi_box.add_widget(canChi_month_lbl)
        lunar_canChi_box.add_widget(canChi_year_lbl)
        lunar_canChi_box.add_widget(Label(size_hint=(1, .8)))

        lunar_canChi_layout.add_widget(lunar_canChi_box)

        box.add_widget(solar_layout)
        box.add_widget(lunar_canChi_layout)

        background_image = Image(
            source=
            'Image/Calendar/Background/Calendar/background_lunar_calendar.png',
            allow_stretch=True,
            keep_ratio=False)

        self.layout.add_widget(background_image)
        self.layout.add_widget(box)
        self.content = self.layout
        self.getAllCanChiDay()

    def update_time(self, *args):
        now = self.get_time()
        self.lunar_time_lbl.text = '[size=15][b]Giờ[/b][/size]\n[color=ff0000]%s[/color]' % now
        self.canChi_time_lbl.text = '[color=ff0000]%s[/color]' % self.get_canchi_time_by_day(
        )

    def get_time(self):
        ''' Get time from now '''
        now = datetime.datetime.now().time()
        return str(now)[:8]

    def get_canchi_time_by_now(self, time):
        hour = int(time[:2])

        chi = ''
        chi_hour_offset = 0  # calculate 'can' in day
        for i in range(len(self.can_chi_hour_list)):
            if hour in self.can_chi_hour_list[i][1:3]:
                chi = self.can_chi_hour_list[i][0]
                chi_hour_offset = i

        dayRange = (datetime.date(self.year, self.month, self.day) -
                    self.can_chi_first_day[0]).days
        hourRange = dayRange * 24
        hourOffset = (self.can_year_list.index(self.can_first_hour) +
                      hourRange + chi_hour_offset) % len(self.can_year_list)
        can = self.can_year_list[hourOffset]
        return can + ' ' + chi

    def get_canchi_time_by_day(self):
        chi = 'Tý'
        dayRange = (datetime.date(self.year, self.month, self.day) -
                    self.can_chi_first_day[0]).days
        hourRange = dayRange * 24
        hourOffset = (self.can_year_list.index(self.can_first_hour) +
                      hourRange) % len(self.can_year_list)
        can = self.can_year_list[hourOffset]
        return can + ' ' + chi

    def getEvent(self, day, month, year):
        '''Return event and color of event'''
        event = ''
        event_color = 'ffffff'
        lunar_day, lunar_month, lunar_year = self.lunarDay(day, month, year)

        for evt in LUNAR_EVENT:
            if (lunar_day, lunar_month) == evt:
                event = event + LUNAR_EVENT[evt] + '\n'
                event_color = '00ff00'

        for evt in SOLAR_TRADITIONAL_EVENT:
            if (day, month) == evt:
                event = event + SOLAR_TRADITIONAL_EVENT[evt] + '\n'
                event_color = '00ff00'

        for evt in SOLAR_EVENT:
            if (day, month) == evt:
                event = event + SOLAR_EVENT[evt] + '\n'
                event_color = '00ffff'

        if (lunar_day, lunar_month) in LUNAR_IMPORTANT_EVENT:
            event_color = 'ff0000'

        if (day, month) in SOLAR_IMPORTANT_EVENT:
            event_color = 'ff0000'

        return event_color, event

    def getCanChiYear(self, year):
        ''' Return Can Chi Year '''
        start = int(str(year)[:2])  # get first two number
        end = int(str(year)[-2:])  # get last two number
        can = int(str(year)[-1])
        chi = ((start % 3) * 4 + end) % 12  # Can Chi Year = Can + Chi
        return (self.can_year_list[can], self.chi_year_list[chi])

    def getCanChiMonth(self, month, year):
        ''' Return Can Chi Month '''
        canYear = self.getCanChiYear(year)[0]
        chi = self.chi_month_list[month - 1]
        canOfJanuary = ''

        # Check if Can of Year in can_month_list or not
        for i in self.can_month_list:
            if canYear in i:
                canOfJanuary = self.can_month_list[i]
                break

        # Calculate current year from January
        can = self.can_year_list[(self.can_year_list.index(canOfJanuary) +
                                  month - 1) % 10]
        return can, chi

    def getCanChiDay(self, day):
        dayRange = day - self.can_chi_first_day[0]
        can_chi_day_offset = (self.can_chi_first_day[1] + dayRange.days) % len(
            self.all_can_chi_list)
        return self.all_can_chi_list[can_chi_day_offset]

    def getAllCanChiDay(self):
        allCanChiDay = {}
        curDay = datetime.date(1900, 1, 31)  # ~1/1/1990 in Lunar Calendar
        for year in range(1901, 2056):
            allCanChiDay[curDay.year, curDay.day, curDay.month] = "Giáp Thìn"
            offset = 360
            curDay = curDay + datetime.timedelta(days=offset)

    def isLeapSolarYear(self, year):
        return (((year % 4 == 0) and (year % 100 != 0)) or year % 400 == 0)

    def isLeapLunarYear(self, year):
        ''' Check if lunar year is leap or not '''
        if (year % 19) in (0, 3, 6, 9, 11, 14, 17):
            return True
        return False

    def lunarDay(self, day, month, year):
        ''' Return Lunar Day from Solar Day '''
        lunar_date = lunardate.LunarDate.fromSolarDate(year, month, day)
        return lunar_date.day, lunar_date.month, lunar_date.year
コード例 #39
0
ファイル: Home.py プロジェクト: TheSociologist/PharmGUI
    def build(self):
        def GetRecentPill():
            name = Slot1.name
            namelength = len(Slot1.name)
            length = 20 - namelength
            for i in range(length):
                name = name + "  "

            return name.upper()

        def GetRecentPillTime(Slot, now):
            hour = Slot.hour
            minute = Slot.minute
            hoursleft = hour - now.hour
            if hoursleft == 0:
                minutesleft = minute - now.minute
                if minutesleft < 0:
                    hoursleft = 24
                    return str(hoursleft) + " Hours Left"
                else:
                    return str(minutesleft) + " Minutes Left"
            elif hoursleft < 0:
                hours = abs(24 - now.hour)
                hoursleft = hours + Slot.hour
                return str(hoursleft) + " Hours Left"
            elif hoursleft == 1:
                return str(hoursleft) + " Hour Left"
            else:
                return str(hoursleft) + " Hours Left"

        def ChooseIcon(Slot):
            if Slot.Type() == "solid":
                return SolidPillTypeIcon
            else:
                return LiquidTypeIcon

        def ChooseLabel(self, Slot):
            if Slot.Type() == 'solid':
                if Slot.number == 1:
                    return str(Slot.number) + ' Pill'
                else:
                    return str(Slot.number) + " Pills"
            else:
                if Slot.volume == 1:
                    return str(Slot.volume) + ' mL'
                else:
                    return str(Slot.volume) + " mL"

        HomeScreen = Screen(name='home')
        HomeScreen.clearcolor = Black
        HomeScreenLayout = RelativeLayout(size_hint_x=None,
                                          width=200,
                                          size_hint_y=None,
                                          height=500)

        UpNext = Label(text="Up Next",
                       color=Black,
                       font_size=35,
                       font_name=DefaultFont,
                       pos=(-25, 10))
        PillType = Image(source=ChooseIcon(Slot12),
                         size_hint_x=None,
                         width=200,
                         pos=(-50, -75))
        PillName = Label(text=GetRecentPill(),
                         color=Red,
                         font_size=40,
                         font_name=DefaultFont,
                         pos=(230, -75),
                         size_hint_x=None,
                         width=150)
        PillTime = Label(text=GetRecentPillTime(Slot12, datetime.now()),
                         color=Black,
                         font_size=35,
                         font_name=DefaultFont,
                         pos=(575, -75))
        PillNumber = Label(text=ChooseLabel(self, Slot12),
                           color=Black,
                           font_size=35,
                           font_name=DefaultFont,
                           pos=(-35, -150))

        HomeScreenLayout.add_widget(UpNext)
        HomeScreenLayout.add_widget(PillType)
        HomeScreenLayout.add_widget(PillName)
        HomeScreenLayout.add_widget(PillTime)
        HomeScreenLayout.add_widget(PillNumber)

        HomeScreen.add_widget(HomeScreenLayout)
        return HomeScreen
コード例 #40
0
class clienteHACKVISION(App):
    def Label1(self):
        global lbl1
        lbl1 = Label()
        lbl1.text = "Esperando instrucciones:"
        lbl1.pos = 200 + self.xo, 280 + self.yo
        self.widget1.add_widget(lbl1)
        print "Esperando instrucciones:"

    def Label2(self):
        widget3 = Widget()
        img2 = Image()
        img2.source = "img/text.png"
        x, y = 130, 370
        img2.pos = x + self.xo, y - 160 + self.yo
        img2.size = 300, 500
        lbl2 = Label()
        lbl2.pos = x + 90 + self.xo, y + 40 + self.yo
        lbl2.text = "            " + 'HACK-VISION DEMO\n                 Recibe GPS \n' + "          " + '      Blueetooth '
        widget3.add_widget(img2)
        widget3.add_widget(lbl2)
        self.widget1.add_widget(widget3)

    def Label3(self):
        global lbl3
        lbl3 = Label()
        lbl3.text = "Esperando instrucciones:"
        lbl3.pos = 200, 80
        self.widget1.add_widget(lbl3)
        print "Esperando instrucciones:"

    def IMAG(self):
        layout = RelativeLayout()
        widget3 = Widget()
        img2 = Image()
        img2.source = "img/text.png"
        x, y = 130, 370
        img2.pos = x + self.xo, y - 420 + self.yo
        img2.size = 300, 680

        widget3.add_widget(img2)
        self.widget1.add_widget(widget3)

    def IMAG2(self):
        layout = RelativeLayout()
        widget4 = Widget()
        img2 = Image()
        img2.source = "img/text.png"
        x, y = 140, -250
        img2.pos = x, y
        img2.size = 300, 680

        widget4.add_widget(img2)
        layout.add_widget(widget4)
        self.widget1.add_widget(layout)

    def EncenderBluetooth(self, *args):
        print "Llamado a prender"
        try:
            Dispo = "HC-05"
            lbl1.text = "Espere conectando el Bluetooth"
            ArduinoB.obtenerCorrienteEnchufe('HC-06')
            Mensaje = "Dispositivo conectado"
            print Mensaje
            lbl1.text = Mensaje
        except:
            Mensaje = "Dispositivo NO CONECTADO revise su conexion "
            print Mensaje
            ArduinoB.obtenerCorrienteEnchufe("HC-05")
            lbl1.text = Mensaje

    def ApagarBluetooth(self, *args):
        try:
            ArduinoB.Cerrar()
            Mensaje = "Conexion cerrada"
            print Mensaje
            lbl1.text = Mensaje

        except:
            Mensaje = "Revise su conexion"
            print Mensaje
            lbl1.text = Mensaje

    def EscribirBluetooth(self, Mensaje, *args):
        try:
            ArduinoB.Escribir(Mensaje)
            Mensaje1 = "Se envio el mensaje [" + Mensaje + "] correctamente."
            print Mensaje1
            Mensa = Mensaje.split("\t")
            MensajeFinal = "\n\t\t\t\tLatitud: " + Mensa[
                1] + "\n\t\t\t\tLongitud: " + Mensa[
                    2] + "\n\t\t\t\tAltitud: " + Mensa[
                        3] + "\n\t\t\t\tRapidez: " + Mensa[4]
            lbl1.text = MensajeFinal
        except:
            Mensaje1 = "Fallo el envio del mensaje [" + Mensaje + "]  revise su conexion."
            print Mensaje1
            lbl1.text = Mensaje1

    def Lectura(self, *args):
        print "esta leyendo"
        Lec1 = ArduinoB.LeerCADENA()
        lec1 = Lec1.split("\t")
        lec2 = str(lec1)
        print lec1
        lec2 = "\n\n\n\n\t\t\t\LECTURA DEL GPS  \n\t\t\t\tLatitud: " + lec1[
            1] + "\n\t\t\t\tLongitud: " + lec1[
                2] + "\n\t\t\t\tAltitud: " + lec1[
                    3] + "\n\t\t\t\tRapidez: " + lec1[4]
        lbl1.text = str(lec2)

#comienza la lectura del sensor

    def Com_Lec(self, *args):
        Hilo1 = Clock.schedule_interval(self.Lectura, 3 / 2)

    #   Clock.unschedule(self.Lectura)

# IDENTIFICADOR DE PROCESOS EN ARDUINO

    def Procesos_Arduino(self):
        try:
            global ArduinoB
            print "Llamado a la libreria"
            from ArduinoBluetooth import *

            print "paso el llamado"
            print "instanciando la clase ArduinoBluetooth"
            ArduinoB = ArduinoBluetooth()
            Mensaje = "Todos los procesos Arduino Activados "
            print Mensaje
            lbl1.text = Mensaje

        except:
            Mensaje = "Fallo al activar los procesos Arduino"
            print Mensaje
            lbl1.text = Mensaje

        try:
            print "Revizando la lectura del Bluetooth"
            self.EncenderBluetooth()
            self.Com_Lec()
            print "Lectura correcta"
        except:
            Mensaje = "Fallo La Lectura del bluetooth"
            print Mensaje
            lbl1.text = Mensaje
        pass

#LECTURAS SENSOR DE CAMPO MAGNETICO

    def lecturaas(self, *args):
        lectura = self.SensorM.Disparo()
        if (lectura == None):
            pass
        if (lectura != None):
            try:
                lecto = str(lectura)
                lec = lecto.split("\t")
                print 'aca voy pendejo ', lec
                ang = lec[1]
                Bx = lec[2]
                By = lec[3]
                Bz = lec[4]
                lec2 = "\n\n\n\n\t\t\t\LECTURA DEL SCM  \n\t\t\t\tAngulo " + str(
                    ang) + "\n\t\t\t\tBx: " + str(
                        Bx) + "\n\t\t\t\tBy:  " + str(
                            By) + "\n\t\t\t\tBz: " + str(Bz)
                lbl3.text = str(lec2)
            except:
                pass
        else:
            pass

    #identificaor de procesos Brujula
    def ProcesosBrujula(self):
        try:
            self.SensorM = Brujula()
            self.SensorM.Hardware()
            if True:
                Clock.schedule_interval(self.lecturaas, 3 / 2)
        except:
            pass


# IDENTIFICADOR DE PROCESOS EN PYTHON

    def Procesos_Kivy(self):
        Mensaje0 = "Cativado Label1"
        Mensaje1 = "Fallo al activar label 1"
        Mensaje2 = "Label2 Activado"
        Mensaje3 = "Fallo al Activar el label 2"
        Mensaje4 = "boton imagen1 activado"
        Mensaje5 = "Fallo Al activar la imagen boton1"
        Mensaje6 = "boton imagen2 activado"
        Mensaje7 = "Fallo Al activar la imagen boton2"
        Mensaje8 = "boton imagen3 activado"
        Mensaje9 = "Fallo Al activar la imagen boton3"
        Mensaje10 = "boton imagen4 activado"
        Mensaje11 = "Fallo Al activar la imagen boton4"
        try:
            self.Label1()
            self.IMAG()
            self.Label3()
            self.IMAG2()
            print Mensaje0
        except:
            print Mensaje1

        try:
            self.Label2()
            print Mensaje2
        except:
            self.Label2()
            print Mensaje3

        pass

    def PROCESOS(self):
        self.Procesos_Kivy()
        # import time
        #     time.sleep(1)
        self.Procesos_Arduino()
        #        self.Procesos_Kivy()
        self.ProcesosBrujula()

    def Dispersion2(self):
        self.dis2 = Scatter()
        self.dis2.pos = -90, -50
        #self.dis2.pos =  random.randrange(100,680), 100
        self.dis2.size_hint = None, None
        #      self.dis2.size = 86, 86
        self.dis2.do_rotation = False
        self.dis2.do_scale = False
        self.dis2.do_translation = False
        self.dis2.rotation = 0
        self.dis2.scale = 1.7

    def Camara(self, *args):
        self.Dispersion2()
        camwidget = Widget()  #Create a camera Widget
        cam = Camera()  #Get the camera
        cam.resolution = (640, 480)
        cam.size = 1000, 800
        cam.pos = (-100, -100)
        cam.play = True  #Start the camera
        camwidget.add_widget(cam)
        self.dis2.add_widget(camwidget)
        self.RelativaDispo.add_widget(self.dis2)

    def BotonCamara(self):
        Layout = RelativeLayout()
        wid2 = Widget()
        Btn5 = Button()
        Btn5.background_normal = 'img/observa.png'
        Btn5.pos = 750, 30
        Btn5.bind(on_press=self.TomarFoto)
        wid2.add_widget(Btn5)
        Layout.add_widget(wid2)
        self.RelativaDispo.add_widget(Layout)

    def TomarFoto(self, *args):
        #  Layout = RelativeLayout()
        #    wid2 = Widget()
        #   Mensaje = getoutput("pwd")
        #  LBL1 = Label()
        #   LBL1.pos = 150, 200
        #   LBL1.text = Mensaje
        #    print Mensaje
        #    wid2.add_widget(LBL1)
        # Layout.add_widget(wid2)
        #   self.DisposicionRelativa.add_widget(wid2)
        try:
            Window.screenshot(name='../../../../../mnt/sdcard/DCIM/imagen.png')
        except:
            print "No se pudo tomar  la foto"

    def build(self):
        self.xo = 0
        self.yo = -40
        self.RelativaDispo = RelativeLayout()
        self.Camara()
        self.BotonCamara()
        self.widget1 = Widget()
        self.widget2 = Widget()
        self.RelativaDispo.add_widget(self.widget1)
        self.RelativaDispo.add_widget(self.widget2)
        self.PROCESOS()
        return self.RelativaDispo
コード例 #41
0
class InfoPanel(ScrollView):
    ##
    # Class Constructor: __init__
    # ---------------------------
    # This method is called during the creation of the InfoPanel object
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (Various) **kwargs                    Arguments for construction of internal
    #                                                               ScrollView object
    ##
    def __init__(self, **kwargs):
        super(InfoPanel,
              self).__init__(size_hint=(1, 1),
                             pos_hint={
                                 "x-center": .5,
                                 "top": 1
                             },
                             size=(Window.width, Window.height - 50),
                             **kwargs)
        with self.canvas.before:
            self.rect = Image(source=BKGD_CHRC,
                              allow_stretch=True,
                              keep_ratio=False)
        self.bind(pos=manager.update_rect, size=manager.update_rect)
        self.bind(size=self.update_layout)
        self.layout = GridLayout(cols=1,
                                 size_hint_y=(None),
                                 pos_hint={
                                     "x-center": .5,
                                     "top": 1
                                 },
                                 row_default_height=30,
                                 row_force_default=False,
                                 padding=15)
        self.layout.bind(minimum_height=self.layout.setter('height'))
        self.add_widget(self.layout)
        self.attribute_labels = []
        self.info_label = Label(text="Users",
                                text_size=(self.width, 30),
                                font_size=30,
                                color=(1, 1, 1, 1))
        self.line = Image(source='images/white.jpg',
                          size_hint=(None, None),
                          allow_stretch=True,
                          pos_hint={
                              'center_y': .1,
                              'center_x': .5
                          },
                          keep_ratio=False,
                          size=(self.width - 60, 1))
        self.header_layout = RelativeLayout(size=(100, 50),
                                            size_hint=(1, None))
        self.header_layout.add_widget(self.info_label)
        self.header_layout.add_widget(self.line)
        self.layout.add_widget(self.header_layout)

    ##
    # Class Method: update_layout
    # ---------------------------
    # When called, this function sets the width of the InfoPanel
    # layout to be equal to the width of the InfoPanel itself.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (InfoPanel) instance                  The InfoPanel which tiggered the bound function
    # (list) value                          List containing InfoPanel size info
    ##
    def update_layout(self, instance, value):
        self.layout.width = self.width
        self.line.size = (self.width - 40, 1)
        self.info_label.text_size = (self.width - 40, 0)
        self.header_layout.width = self.width

    ##
    # Class Method: change_label
    # --------------------------
    # This method changes the label at the top of the info panel.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (str) mode                            Mode that the screen is on 'Users' or 'Groups'
    ##
    def change_label(self, mode):
        self.info_label.text = mode

    ##
    # Class Method: clear
    # -------------------
    # This function clears the InfoPanel of all widgets.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    ##
    def clear(self):
        self.layout.clear_widgets()
        self.layout.add_widget(self.header_layout)
        self.attribute_labels = []

    ##
    # Class Method: create_member_label
    # ---------------------------------
    # This function creates a label displaying a given group member's username
    # and priority value.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (list: [name, priority]) member       The group member
    ##
    def create_member_label(self, member):
        attr_layout = RelativeLayout(size=(100, 30), size_hint=(1, None))
        attr_layout.add_widget(
            Label(text=(member[0]),
                  color=(1, 1, 1, 1),
                  font_size=14,
                  pos_hint={
                      "center_x": .31,
                      "center_y": .5
                  }))
        attr_layout.add_widget(
            Label(text=(str(member[1])),
                  color=(1, 1, 1, 1),
                  font_size=14,
                  pos_hint={
                      "center_x": .7,
                      "center_y": .5
                  }))
        self.layout.add_widget(attr_layout)

    ##
    # Class Method: create_attr_label
    # ---------------------------------
    # This function creates an editable label for displaying and interacting
    # with a given attribute.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (Attribute) attr                      Attribute to display
    # (bool) editable                       Whether the label should be editable
    # (bool) group                          True for a group atribute, false for a user attribute
    ##
    def create_attr_label(self, attr, editable, group=False):
        attr_layout = RelativeLayout(size=(100, 30), size_hint=(1, None))
        color = (1, 1, 1, 1)
        bold = manager.menu.get_search_mode(
        ) != 'name' and manager.menu.get_search_term() != ""
        if self.color_dark(attr.name, attr.value):
            color = (1, 1, 1, .6)
            bold = False
        label = EditableLabel(text=("" + attr.name + " " + attr.operator +
                                    " " + attr.value),
                              attr_category=attr.category,
                              color=color,
                              size=(300, 30),
                              group=group,
                              bold=bold,
                              editable=editable,
                              size_hint=(None, None),
                              pos_hint={
                                  "center_x": .5,
                                  "center_y": .5
                              },
                              font_size=14)
        label.name = attr.name
        label.val = attr.value
        attr_layout.add_widget(label)
        self.attribute_labels.append(label)
        self.layout.add_widget(attr_layout)

    ##
    # Class Method: recolor_labels
    # ----------------------------
    # This function goes through all the labels displayed on the info panel and
    # recolors them between normal, dark, and bolded text depending on what type
    # of search is being made.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    ##
    def recolor_labels(self):
        for label in self.attribute_labels:
            if not label.name or not label.val:
                if label.current_attr:
                    label.name = label.current_attr.name
                    label.val = label.current_attr.value
            bold = manager.menu.get_search_mode(
            ) != 'name' and manager.menu.get_search_term() != ""
            if self.color_dark(label.name, label.val):
                label.bold = False
                label.color = (1, 1, 1, .6)
            else:
                label.bold = bold
                label.color = (1, 1, 1, 1)

    ##
    # Class Method: color_dark
    # ------------------------
    # This function, given an attribute's name and value, determines whether or not
    # the attribute's label should be colored dark.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (str) name                            The attribute name
    # (str) value                           The attribute value
    #
    # (bool) return                         True if label should be colored dark, False if not
    ##
    def color_dark(self, name, val):
        if name == None or val == None:
            return True
        return (manager.menu.get_search_mode() == 'attr name' \
           and manager.menu.get_search_term().lower() not in name.lower()) \
           or (manager.menu.get_search_mode() == 'attr val' \
           and manager.menu.get_search_term().lower() not in val.lower())

    ##
    # Class Method: display_user_info
    # -------------------------------
    # This function, given a username in the database, displays all of a user's
    # attributes, coloring in bold the attributes that match the search term if
    # the search bar filter is in attribute mode.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (str) user                            Username whose info is to be displayed
    ##
    def display_user_info(self, user):
        self.clear()
        editable = manager.ADMIN
        manager.CURRENT_USER = user
        manager.menu.show_searched_users()

        self.layout.add_widget(
            Label(text=(user), color=(1, 1, 1, 1), font_size=25))
        for attr in database.get_user_attrs(user):
            if "password" in attr.name.lower():
                color = (1, 1, 1, 1)
                bold = manager.menu.get_search_mode(
                ) != 'name' and manager.menu.get_search_term() != ""
                if self.color_dark(attr.name, attr.value):
                    color = (1, 1, 1, .7)
                    bold = False

                attr_layout = RelativeLayout(size=(100, 30),
                                             size_hint=(1, None))
                label = Label(text=("" + attr.name + " " + attr.operator +
                                    " " + attr.value),
                              color=color,
                              size=(300, 30),
                              bold=bold,
                              size_hint=(None, None),
                              pos_hint={
                                  "center_x": .5,
                                  "center_y": .2
                              },
                              font_size=14)
                label.name = attr.name
                label.val = attr.value
                attr_layout.add_widget(label)
                self.attribute_labels.append(label)
                self.layout.add_widget(attr_layout)
            else:
                self.create_attr_label(attr, editable)

    ##
    # Class Method: display_group_info
    # -------------------------------
    # This function, given a groupname in the database, displays all of a group's
    # users and attributes, coloring in bold the attributes that match the search
    # term if the search bar filter is in attribute mode.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (str) group                           Groupname whose info is to be displayed
    ##
    def display_group_info(self, group):
        manager.CURRENT_GROUP = group
        editable = manager.ADMIN
        manager.menu.show_searched_groups()
        self.clear()
        self.layout.add_widget(
            Label(text=(group), color=(1, 1, 1, 1), font_size=25))
        self.layout.add_widget(
            Label(text=("Group Members:"), color=(1, 1, 1, .6), font_size=18))
        group_members = database.get_group_members(group)
        self.layout.add_widget(
            Label(text=("Username:                       Priority: "),
                  color=(1, 1, 1, .6),
                  font_size=15,
                  pos_hint={"center_x": .5}))
        num_other_members = 0
        for member in group_members:
            if member[0] == manager.LOGGED_IN or manager.ADMIN:
                self.create_member_label(member)
            else:
                num_other_members += 1
        if not manager.ADMIN:
            message = "+" + str(num_other_members) + " additional group member"
            if num_other_members != 1:
                message += 's'
            self.layout.add_widget(
                Label(text=message,
                      color=(1, 1, 1, .6),
                      font_size=14,
                      pos_hint={"center_x": .5}))

        attr_layout = RelativeLayout(size=(100, 30), size_hint=(1, None))
        self.layout.add_widget(attr_layout)
        self.layout.add_widget(
            Label(text=("Group Attributes:"),
                  color=(1, 1, 1, .6),
                  font_size=18))
        for attr in database.get_group_attrs(group):
            self.create_attr_label(attr, editable, True)

    ##
    # Class Method: add_new_label
    # ---------------------------
    # This function adds a new editable label to the info panel and sets it to
    # edit mode. This is so the logged-in user can add a new attribute to the
    # currently displayed group or user.
    #
    # @params
    # (InfoPanel) self                      This instance of InfoPanel
    # (bool) group                          True if group is currently displayed, false if user
    ##
    def add_new_label(self, group=False):
        for child in self.layout.children:
            if type(child) == EditableLabel:
                if child.text == '':
                    self.layout.remove_widget(child)
                else:
                    pass

        if manager.CURRENT_USER != None or manager.CURRENT_GROUP != None:

            attr_layout = RelativeLayout(size=(100, 30), size_hint=(1, None))

            edit_label = EditableLabel(text=(''),
                                       pos_hint={
                                           "center_x": .5,
                                           "center_y": .5
                                       },
                                       size_hint=(None, None),
                                       size=(300, 30),
                                       group=group,
                                       color=(1, 1, 1, 1),
                                       font_size=14)
            edit_label.name = None
            edit_label.val = None
            self.attribute_labels.append(edit_label)
            attr_layout.add_widget(edit_label)
            self.layout.add_widget(attr_layout)
            edit_label.toggle_edit(edit_label)