本文整理汇总了Python中kivy.uix.anchorlayout.AnchorLayout.remove_widget方法的典型用法代码示例。如果您正苦于以下问题:Python AnchorLayout.remove_widget方法的具体用法?Python AnchorLayout.remove_widget怎么用?Python AnchorLayout.remove_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.anchorlayout.AnchorLayout
的用法示例。
在下文中一共展示了AnchorLayout.remove_widget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CelticKnotwork
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import remove_widget [as 别名]
class CelticKnotwork(App):
'''Main tabbed interface, each tab contains its own instance of CelticKnotwork2'''
def build(self):
##Instance Variables
self.showDots = True
self.showGrid = True
self.showBreaklines = True
self.showSkeleton = True
self.showKnot = True
self.knotX = 4
self.knotY = 4
self.knotWidth = 8
self.knotWidthView = 8
self.gridUnits = 50
self.gridUnitsView = 50
self.offsetX = 150
self.offsetY = 50
self.totTabs = 1
self.tabNo = 1
##Main Layout
self.layout_main = AnchorLayout(anchor_x = "left", anchor_y="top")
self.layout_tabs= FloatLayout(size=(Window.width, Window.height), size_hint=(0.1, 0.08))
##Top Tab Bar - allowing multiple knots
self.tp = TabbedPanel()
self.tp.default_tab_text = "Knot 1"
self.layout_main.add_widget(self.tp)
self.addTab = TabbedPanelHeader(text='+')
self.addTab.bind(on_release = self.onPressAddTab)
self.addTab = Button(text='+', pos =(Window.width*.9,Window.height*.92))
self.addTab.bind(on_press = self.onPressAddTab)
self.tp.default_tab_content = CelticKnotwork2().build() #get tab content from CelticKnotwork2
self.layout_tabs.add_widget(self.addTab)
self.layout_main.add_widget(self.layout_tabs)
Window.bind(on_resize=self.on_resize)
return self.layout_main
def onPressAddTab(self, instance):
'''Add a tab when "+" button pressed'''
self.totTabs += 1
self.tabNo = self.totTabs
self.th = TabbedPanelHeader(text='Knot '+str(self.totTabs))
self.th.content = CelticKnotwork2().build()
self.tp.add_widget(self.th)
self.tp.switch_to(self.th)
def on_resize(self, window, height, somethingesle):
'''Handles window resize'''
self.layout_main.remove_widget(self.layout_tabs)
self.layout_tabs= FloatLayout(size=(Window.width, Window.height), size_hint=(0.1, 0.05))
self.addTab = Button(text='+', pos =(Window.width*.9,Window.height*.95))
self.addTab.bind(on_press = self.onPressAddTab)
self.layout_tabs.add_widget(self.addTab)
self.layout_main.add_widget(self.layout_tabs)
示例2: BoardDisplay
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import remove_widget [as 别名]
class BoardDisplay(FloatLayout):
"""Show the 4x2 Gameboard.
Methods:
update -- refresh the full display
highlight -- highlight every card on the board
place_card -- place and display the card on the board
remove_card -- remove card from the display and return it
validate -- remove and return a list of invalid cards
pop -- remove card at the given index and return it
play_dealer -- play all dealer cards with timing
apply_specials -- apply all specials with timing and highlights
score_round -- score each match with timing and highlights
"""
board = ObjectProperty()
def __init__(self, **kwargs):
"""Set up the CardDisplays."""
FloatLayout.__init__(self, **kwargs)
self.main = BoxLayout(orientation="vertical", pos_hint={'x':0, 'y':0})
self.slots = []
for i in range(len(self.board)): # for card in board iterates all sides
layout = BoxLayout()
side_slots = []
for card in self.board[i]:
display = CardDisplay(card=card)
side_slots.append(display)
layout.add_widget(display)
self.slots.append(side_slots)
self.main.add_widget(layout)
self.add_widget(self.main)
# Prep the next round prompt widget for later
self._next_round_prompt = BoxLayout(size_hint=(1, .125))
self._next_round_prompt.add_widget(Button(text="Replay",
on_release=self.rescore_prompted))
self._next_round_prompt.add_widget(Widget()) # spacer
self._next_round_prompt.add_widget(Button(text="Continue",
on_release=self.next_round_prompted))
# Prep for powerup overlays
self.powerup_anchor = AnchorLayout(anchor_x='right', anchor_y='top',
size_hint=(1, 1),
pos_hint={'x':0, 'y':0})
self.add_widget(self.powerup_anchor)
def show_next_click_powerup(self, powerup):
"""Display a large overlay of the powerup to select."""
try: self.remove_widget(self.powerup_overlay_single)
except: pass
if powerup is None:
self.highlight(BLANK)
else:
self.highlight(DARKEN)
self.powerup_overlay_single = PowerupIcon(powerup=powerup,
color=(1, 1, 1, .3),
size_hint=(.6, .6),
pos_hint={'x':.2, 'y':.2})
self.add_widget(self.powerup_overlay_single)
def show_active_powerups(self, powerups):
"""Display a series of active powerup icons."""
try: self.powerup_anchor.remove_widget(self.powerup_overlay_tray)
except: pass
if not powerups:
return
self.powerup_overlay_tray = tray = StackLayout(size_hint_y=0.1)
for powerup in powerups:
tray.add_widget(PowerupIcon(powerup=powerup,
color=(1, 1, 1, .5),
size_hint=(None, 1)))
tray.width = tray.height * len(powerups)
from kivy.graphics import Color, Rectangle
with tray.canvas.before:
Color((1, 0, 0, 1))
Rectangle(size=tray.size, pos=tray.pos)
self.powerup_anchor.add_widget(self.powerup_overlay_tray)
def prompt_for_next_round(self):
"""Prompt the user to continue, or replay the scoring sequence."""
try: self.main.add_widget(self._next_round_prompt)
except: pass
def next_round_prompted(self, *args):
"""Continue to the next round on the user's command."""
self.main.remove_widget(self._next_round_prompt)
return App.get_running_app().root.next_round()
def rescore_prompted(self, *args):
"""Replay the scoring animation on the user's command."""
self.main.remove_widget(self._next_round_prompt)
App.get_running_app().root.replay_scoring()
def update(self):
"""Update the visual display."""
for i in range(len(self.board)):
for j, card in enumerate(self.board[i]):
#.........这里部分代码省略.........
示例3: Main
# 需要导入模块: from kivy.uix.anchorlayout import AnchorLayout [as 别名]
# 或者: from kivy.uix.anchorlayout.AnchorLayout import remove_widget [as 别名]
class Main(App):
height = 720
width = (height/16) * 9
Window.size = (width,height)
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
def resetloc(self,instance):
self.mapview.center_on(self.itu_lat,self.itu_lon)
def nofly(self,instance):
if instance.state == 'down':
self.mapview.remove_layer(self.jsonmap)
else:
self.mapview.add_layer(self.jsonmap)
def show_dropdown(self,instance):
if instance.state == 'down':
size = (1,0.5)
btn1 = ToggleButton(text='Weather', size_hint = size)
btn2 = Button(text='Level',size_hint = size)
btn3 = Button(text='Nearby\nusers', size_hint = size)
btn1.bind(on_press = self.show_weather_data)
self.settings.add_widget(btn1)
self.settings.add_widget(btn2)
self.settings.add_widget(btn3)
else:
for child in self.settings.children[:]:
if child.text != "":
self.settings.remove_widget(child)
def show_weather_data(self,instance):
weatherbox = self.weatherbox
if instance.state == 'down':
layout = BoxLayout(orientation='vertical', size_hint = (0.2,0.1) )
clat = self.mapview.lat
clon = self.mapview.lon
ctime = time.time()
if(self.obs_dic == None or ctime > (self.old_time + 0.5)):
self.old_time = ctime
self.obs_dic = api.loc_weather(clat,clon)
weList = self.obs_dic['weather']
we = weList[0]
wi = self.obs_dic['wind']
l1 = Label(text = 'Current weather: ' + we['main'], color = (0.,0.,0.,1))
main = self.obs_dic['main']
k = main['temp']
#Conversion from imperial to metric
temp = k-273.15
l2 = Label(text = 'temp: ' + str(temp) + ' ' + u'\u00B0' + 'C', color = (0.,0.,0.,1))
hu = main['humidity']
l3 = Label(text = 'humidity: ' + str(hu) + '%', color = (0.,0.,0.,1))
pre = main['pressure']
l4 = Label(text = 'pressure' + str(pre) + ' hPa', color = (0.,0.,0.,1))
#.........这里部分代码省略.........