本文整理汇总了Python中pyglet_gui.manager.Manager.set_position方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.set_position方法的具体用法?Python Manager.set_position怎么用?Python Manager.set_position使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyglet_gui.manager.Manager
的用法示例。
在下文中一共展示了Manager.set_position方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EventLogController
# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import set_position [as 别名]
class EventLogController(pygsty.controllers.BaseController):
def __init__(self):
super().__init__()
self.hud_batch = pyglet.graphics.Batch()
self.doc = Document(self.last_message, width=800, height=100, is_fixed_size=True)
self.frame = Frame(self.doc)
self.manager = Manager(self.frame, window=pygsty.engine(), batch=self.hud_batch, theme=config.ui_theme)
self.manager.set_position(0, 0)
self._latest_event = None
self._log = self.last_message
def draw_hud(self):
self.hud_batch.draw()
@property
def last_message(self):
last_event = models.event_log.last_event()
if last_event:
return last_event.formatted_message()
else:
return ""
def update(self, dt):
if not models.event_log.last_event() is self._latest_event:
self._log = self.last_message + self._log
self.doc.set_text(self._log)
self._latest_event = models.event_log.last_event()
示例2: __init__
# 需要导入模块: from pyglet_gui.manager import Manager [as 别名]
# 或者: from pyglet_gui.manager.Manager import set_position [as 别名]
class HUD:
def __init__(self, window):
with open('etc/gui/theme.json') as theme_file:
theme_dict = json.loads(theme_file.read())
self.theme = Theme(
theme_dict,
resources_path=os.path.join(os.getcwd(), 'etc/gui/images')
)
self.window = window
self.clear_action_gui()
self.clear_status_gui()
def handle_click(self, button_state, action):
print(action)
if button_state is not False:
self.selected_action = action
return True
def handle_building_click(self, button_state, button, selected_object, action):
if button_state is not False:
self.selected_action = action
selected_object.add_action(action) #this should probably get moved to the event_handler
return True
def clear_action_gui(self):
self.selected_action = None
self.action_gui_batch = None
self.action_gui_manager = None
def clear_status_gui(self):
self.status_box = None
self.status_gui_batch = None
self.status_gui_manager = None
def build_building_gui(self, selected_building):
building = selected_building
produce_content = [Label(text='Produce')]
for resource in building.producable_resources:
produce_button = GroupButton(
group_id='action-gui-buttons',
label=resource.name,
on_press=lambda x: self.handle_building_click(x, produce_button, building, Produce(building, resource, selected_building.container.remaining_capacity(resource))),
)
produce_content.append(produce_button)
produce_container = HorizontalContainer(produce_content)
action_container = VerticalContainer([
produce_container,
])
self.action_gui_batch = pyglet.graphics.Batch()
self.action_gui_manager = Manager(
action_container,
window=self.window,
theme=self.theme,
batch=self.action_gui_batch,
)
self.action_gui_manager.set_position(
#it's on the right as a hack to fix the Manager bug
self.window.width - action_container.width - 30,
self.window.height - action_container.height - 10,
)
self.action_gui_manager.is_movable = False
def build_unit_gui(self, selected_object):
harvest_content = [Label(text='Harvest')]
#for resource in selected_object.harvestable_resources:
# harvest_button = GroupButton(
# group_id='action-gui-buttons',
# label=resource.name,
# on_press=lambda x: self.handle_click(x, Harvest(resource, selected_object.container.remaining_capacity(resource))),
# )
# harvest_content.append(harvest_button)
harvest_wood_button = GroupButton(
group_id='action-gui-buttons',
label=Wood.name,
on_press=lambda x: self.handle_click(x, Harvest(Wood, selected_object.container.remaining_capacity(Wood))),
)
harvest_content.append(harvest_wood_button)
harvest_container = HorizontalContainer(harvest_content)
building_content = [Label(text='Construct')]
#for building_factory in selected_object.building_factories.values():
# building_button = GroupButton(
# group_id='action-gui-buttons',
# label=building_factory.product.name,
# on_press=lambda x:
# self.handle_click(x, Construct(building_factory.product)),
# )
# building_content.append(building_button)
building_cabbage_farm_button = GroupButton(
group_id='action-gui-buttons',
label=CabbageFarm.name,
on_press=lambda x:
self.handle_click(x, Construct(CabbageFarm)),
)
building_content.append(building_cabbage_farm_button)
building_iron_mine_button = GroupButton(
group_id='action-gui-buttons',
label=IronMine.name,
#.........这里部分代码省略.........