本文整理汇总了Python中kivy.uix.relativelayout.RelativeLayout类的典型用法代码示例。如果您正苦于以下问题:Python RelativeLayout类的具体用法?Python RelativeLayout怎么用?Python RelativeLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RelativeLayout类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
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: FIT3140Ui
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
示例3: build
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
示例4: __init__
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)
示例5: add_widget
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: __init__
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: KivyCardPile
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: __init__
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
示例9: buildUI
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: __init__
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
示例11: ColorPickerBox
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: add_widget
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: buildUI
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()
示例14: GameOver
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()
示例15: _generateMap
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