• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python manager.Manager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyglet_gui.manager.Manager的典型用法代码示例。如果您正苦于以下问题:Python Manager类的具体用法?Python Manager怎么用?Python Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Manager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: UIResourceList

class UIResourceList(object):
    def __init__(self, window, batch):
        self.window = window
        self.batch = batch
        self._resource_menu = None

    def render(self):
        self.remove()

        content = Frame(
            Scrollable(
                VerticalContainer(
                    [
                        SectionHeader("Resources"),
                        UIResourceSection("Primary Resources", "primary", is_open=True),
                        UIResourceSection("Processed Material", "processed_material", is_open=False),
                        UIResourceSection("Raw Material", "raw_material", is_open=False),
                        OneTimeButton("Close", self.remove),
                    ],
                    align=HALIGN_LEFT,
                ),
                height=400,
            )
        )

        self._resource_menu = Manager(
            content, window=self.window, batch=self.batch, anchor=ANCHOR_TOP_LEFT, theme=resource_menu_theme
        )

    def remove(self, *args):
        if self._resource_menu:
            self._resource_menu.delete()
开发者ID:JStation,项目名称:omphalos,代码行数:32,代码来源:__init__.py


示例2: EventLogController

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()
开发者ID:tredfern,项目名称:terralien,代码行数:27,代码来源:event_log_controller.py


示例3: __init__

    def __init__(self, window, controls, bodies):
        self.window = window
        self.controls = controls
        self.bodies = bodies

        self.fps_counter = FPSCounter(window, self.fps_update)

        # Setup HUD elements
        self.label_fps = Label("", bold=True, font_name="Arial", font_size=12, color=(127, 127, 127, 127))
        self.label_time = Label("", bold=True, font_name="Arial", font_size=18, color=(127, 127, 127, 127))
        self.label_help = BetterLabel(load_string('help.txt'), bold=False, font_name="Arial", font_size=18, color=(170, 170, 170, 255), multiline=True, lblwidth=600)
        self.label_planet_info = BetterLabel("", bold=False, font_name="Arial", font_size=12, color=(170, 170, 170, 255), multiline=True, lblwidth=400, lblalign='right')
        self.managers = [
            Manager(self.label_fps, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT),
            Manager(self.label_time, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_LEFT)
        ]
        self.label_help_manager = Manager(self.label_help, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT, offset=(0, -17))
        self.label_planet_info_manager = Manager(self.label_planet_info, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_RIGHT, offset=(-180, 36))

        body_buttons = []
        for body in self.bodies:
            body_buttons.append(BodyButton(self, body).button)

        self.managers_when_not_locked = [
            Manager(VerticalContainer(body_buttons, align=HALIGN_RIGHT), window=window, theme=ThemeFromPath("theme/bodybutton"), is_movable=False, anchor=ANCHOR_TOP_RIGHT)
        ]
开发者ID:JamesLinus,项目名称:solarsystem,代码行数:26,代码来源:gui.py


示例4: VerticalHUD

class VerticalHUD():
    def __init__(self, window, batch, space, level, height, width):
        self.space = space
        self.level = level
        status_text = pyglet.text.decode_attributed('''
Time: 0 sec \n
Points: 0 points \n
FPS: 00.00 FPS
''')
        self.status_doc = Document(status_text, height=height, width=width)
        status_frame = Frame(self.status_doc)
        inv_text = pyglet.text.decode_html("<h4>Inventory</h4>")
        inventory_header = Document(inv_text, width=width)
        self.inventory_container = VerticalContainer([])

        container = VerticalContainer([inventory_header, self.inventory_container])
        self.inventory_frame = Frame(container)
        container = VerticalContainer([status_frame, self.inventory_frame])
        self.manager = Manager(container, window=window, batch=batch,
                group=RenderingOrder.hud, anchor=ANCHOR_TOP_RIGHT, theme=theme,
                is_movable=False)
        self.window = window
        self.window.push_handlers(on_draw=self.on_draw)
        self.tick = 0
        # Currently disabled
        #self.init_effects(space, level)

    def init_effects(self, space, level):
        pos = (self.inventory_frame.x,
               self.inventory_frame.y + self.inventory_frame.height / 2 - 50)
        self.inventory_effect = Effects.Inventory(space, pos, "Inventory",
                self.inventory_frame.width, self.inventory_frame.height + 100,
                ["H2O(l)", "CH4(g)", "NaCl(s)"], gui_container = self.inventory_container)

    def get_effects(self):
        return []
        #currently disabled
        #return [self.inventory_effect]

    def on_draw(self):
        self.tick += 1
        if self.tick > 30:
            return
        self.tick = 0
        self.update_status()

    def update_status(self):
        level_time = self.window.level.get_time()
        points = self.window.level.get_points()
        status_text = '''
Time: %d sec
Points: %d points
FPS: %.2f FPS
''' % (level_time, points, pyglet.clock.get_fps())
        self.status_doc.set_text(status_text)

    def delete(self):
        self.window.remove_handlers(on_draw = self.on_draw)
        self.manager.delete()
开发者ID:Norberg,项目名称:molecule,代码行数:59,代码来源:HUD.py


示例5: GUI

class GUI:
    """
    Controls the GUI (HUD) of this application
    """

    def __init__(self, window, controls, bodies):
        self.window = window
        self.controls = controls
        self.bodies = bodies

        self.fps_counter = FPSCounter(window, self.fps_update)

        # Setup HUD elements
        self.label_fps = Label("", bold=True, font_name="Arial", font_size=12, color=(127, 127, 127, 127))
        self.label_time = Label("", bold=True, font_name="Arial", font_size=18, color=(127, 127, 127, 127))
        self.label_help = BetterLabel(load_string('help.txt'), bold=False, font_name="Arial", font_size=18, color=(170, 170, 170, 255), multiline=True, lblwidth=600)
        self.label_planet_info = BetterLabel("", bold=False, font_name="Arial", font_size=12, color=(170, 170, 170, 255), multiline=True, lblwidth=400, lblalign='right')
        self.managers = [
            Manager(self.label_fps, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT),
            Manager(self.label_time, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_LEFT)
        ]
        self.label_help_manager = Manager(self.label_help, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_TOP_LEFT, offset=(0, -17))
        self.label_planet_info_manager = Manager(self.label_planet_info, window=window, theme=empty_theme, is_movable=False, anchor=ANCHOR_BOTTOM_RIGHT, offset=(-180, 36))

        body_buttons = []
        for body in self.bodies:
            body_buttons.append(BodyButton(self, body).button)

        self.managers_when_not_locked = [
            Manager(VerticalContainer(body_buttons, align=HALIGN_RIGHT), window=window, theme=ThemeFromPath("theme/bodybutton"), is_movable=False, anchor=ANCHOR_TOP_RIGHT)
        ]

    def fps_update(self, fps):
        self.label_fps.set_text(str(fps) + "fps")

    def update_time(self, timestep, solarsystem_time):
        self.label_time.set_text("1 second = " + str(floor(timestep / 60 / 60)) + "hours. Current Date: " + str(J2000 + datetime.timedelta(seconds=solarsystem_time)))

    def draw(self):
        if self.controls.draw_help_label:
            self.label_help_manager.draw()

        if self.controls.selected_body:
            body = self.controls.selected_body
            text = ""
            text += "Name: " + body.name + "\n"
            text += "Position: " + str(round(body.xyz.x, 2)) + " " + str(round(body.xyz.y, 2)) + " " + str(round(body.xyz.z, 2)) + "\n"
            text += "Rotation Period: " + str(round(body.sidereal_rotation_period / 60 / 60 / 24, 2)) + "days\n"
            self.label_planet_info.set_text(text)
            self.label_planet_info_manager.draw()

        for manager in self.managers:
            manager.draw()

        if not self.controls.mouse_locked:
            for manager in self.managers_when_not_locked:
                manager.draw()
开发者ID:JamesLinus,项目名称:solarsystem,代码行数:57,代码来源:gui.py


示例6: __init__

    def __init__(self, text="", window=None, batch=None, group=None,
                 theme=None, on_escape=None, have_focus=False):
        def on_ok(_):
            if on_escape is not None:
                on_escape(self)
            self.delete()

        button = FocusButton("Ok", on_press=on_ok)
        Manager.__init__(self, content=Frame(VerticalContainer(
                         [Label(text), button])),
                         window=window, batch=batch, group=group,
                         theme=theme, is_movable=True)
        Manager.set_next_focus(self, 1)
开发者ID:JStation,项目名称:omphalos,代码行数:13,代码来源:gui.py


示例7: TestContainer

class TestContainer(TestPygletGUI):
    """
    This test case tests basic functionality of
    a container. We use an empty widgets for this.
    """

    def setUp(self):
        super().setUp()

        self.container = Container([Viewer(width=50, height=50),
                                    Viewer(width=50, height=50)])

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)

    def test_set_manager(self):
        """
        Tests that the manager is set for every children.
        """
        # manager size is correct
        for item in self.container.content:
            self.assertTrue(item.has_manager())

    def test_deletion(self):
        self.manager.delete()

        # confirm that widget is also deleted
        for item in self.container.content:
            self.assertFalse(item.has_manager())

    def test_add(self):
        """
        Tests that we can add a new item.
        """
        item = Viewer(width=50, height=50)
        self.container.add(item)

        self.assertEqual(item.has_manager(), True)

    def test_remove(self):
        """
        Tests that we can remove a new item.
        """
        item = self.container.content[0]
        self.container.remove(item)

        self.assertEqual(item.has_manager(), False)

    def tearDown(self):
        self.manager.delete()
        super().tearDown()
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:50,代码来源:test_container.py


示例8: test_new_manager_without_window

    def test_new_manager_without_window(self):
        other_manager = Manager(Viewer(width=50, height=50), batch=self.batch, theme=self.theme)

        # confirm that a new manager without window starts
        # with no size
        self.assertTrue(other_manager.width, 0)

        # change the manager's window
        other_manager.window = self.window

        # confirm it has a size.
        self.assertEqual(self.manager.width, 50)

        # confirm it is in the correct position
        self.assertEqual(self.manager.x, self.window.width / 2 - self.manager.width / 2)
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:15,代码来源:test_dialog.py


示例9: GenericButtonTest

class GenericButtonTest(object):
    def setUp(self):
        self.manager = Manager(self.button, window=self.window, batch=self.batch, theme=self.theme)

    def test_creation(self):
        self.assertNotEqual(self.button.width, 0)
        self.assertNotEqual(self.button.height, 0)
        self.assertEqual(self.button.is_loaded, True)

    def test_press(self):
        self.button.on_mouse_press(0, 0, None, None)
        self.assertEqual(self.button.is_pressed, True)

    def test_delete(self):
        self.manager.delete()
        self.assertEqual(self.button.is_loaded, False)
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:16,代码来源:test_button.py


示例10: build_building_gui

	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
开发者ID:zudijyr,项目名称:Building-Sim-Game,代码行数:28,代码来源:hud.py


示例11: setUp

    def setUp(self):
        super(TestVerticalContainer, self).setUp()

        self.container = VerticalContainer([Viewer(width=50, height=50),
                                         Viewer(width=50, height=50)])

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:7,代码来源:test_vertical_container.py


示例12: setUp

    def setUp(self):
        super().setUp()

        self.container = GridContainer([[Viewer(width=50, height=50), Viewer(width=50, height=50)],
                                     [Viewer(width=50, height=50), Viewer(width=50, height=50)]])

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)
开发者ID:Norberg,项目名称:pyglet-gui,代码行数:7,代码来源:test_grid_container.py


示例13: __init__

 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
开发者ID:tredfern,项目名称:terralien,代码行数:9,代码来源:event_log_controller.py


示例14: TestButton

class TestButton(TestPygletGUI):

    def setUp(self):
        TestPygletGUI.setUp(self)
        self.button = Button(label="test")
        self.manager = Manager(self.button, window=self.window, batch=self.batch, theme=self.theme)

    def test_creation(self):
        self.assertNotEqual(self.button.width, 0)
        self.assertNotEqual(self.button.height, 0)
        self.assertEqual(self.button.is_loaded, True)

    def test_press(self):
        self.button.on_mouse_press(0, 0, None, None)
        self.assertEqual(self.button.is_pressed, True)

    def test_delete(self):
        self.manager.delete()

        self.assertEqual(self.button.is_loaded, False)
开发者ID:eggfu,项目名称:pyglet-gui,代码行数:20,代码来源:test_button.py


示例15: TestSpacer

class TestSpacer(TestPygletGUI):
    """
    Tests that the spacer is working correctly
    inside containers.
    """
    def setUp(self):
        TestPygletGUI.setUp(self)

        self.widgets = []
        for i in range(2):
            self.widgets.append(Viewer(width=100, height=50))
        for i in range(2):
            self.widgets.append(Viewer(width=20, height=50))

        self.container = VerticalContainer([HorizontalContainer([self.widgets[0],
                                                           self.widgets[1]], padding=0),
                                         HorizontalContainer([Spacer(),
                                                           self.widgets[2],
                                                           Spacer(),
                                                           self.widgets[3],
                                                           Spacer()], padding=0)], padding=0)

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)

    def test_initial(self):
        self.assertEqual(self.container.width, 200)

        # space left for the spacers occupy:
        width_left = 200 - 40

        # expected spacer size
        spacer_size = int(width_left/3.)

        # Spacers should occupy same space
        self.assertEqual(self.widgets[2].x, self.container.x + spacer_size)
        self.assertEqual(self.widgets[3].x, self.widgets[2].x + self.widgets[2].width + spacer_size)

    def tearDown(self):
        self.manager.delete()
        super(TestSpacer, self).tearDown()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:40,代码来源:test_spacer.py


示例16: TestSlider

class TestSlider(TestPygletGUI):

    def setUp(self):
        TestPygletGUI.setUp(self)
        self.slider = HorizontalSlider(min_value=0, max_value=10)
        self.manager = Manager(self.slider, window=self.window, batch=self.batch, theme=self.theme)

    def test_set_value(self):
        self.slider.set_knob_pos(0.5)
        self.assertEqual(self.slider.value, 5)

    def test_mouse_slide(self):

        # push the slider to the minimum
        self.slider.on_mouse_press(0, 0, None, None)
        self.assertEqual(self.slider.value, 0)

        # push the slider to the maximum
        self.slider.on_mouse_press(10000, 0, None, None)
        self.assertEqual(self.slider.value, 10)

    def tearDown(self):
        self.manager.delete()
        super(TestSlider, self).tearDown()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:24,代码来源:test_slider.py


示例17: TestInput

class TestInput(TestPygletGUI):

    def setUp(self):
        TestPygletGUI.setUp(self)
        self.input = TextInput(text="test")
        self.manager = Manager(self.input, window=self.window, batch=self.batch, theme=self.theme)

    def test_focus(self):
        self.input.on_gain_focus()

        self.assertEqual(self.input.is_focus(), True)

        self.input.on_lose_focus()
        self.assertEqual(self.input.is_focus(), False)

    def test_input(self):
        self.assertEqual(self.input.get_text(), "test")
        self.input.on_gain_focus()
        self.input.on_text("text")
        self.assertEqual(self.input.get_text(), "text")  # it starts with all text selected, so 'test' is erased.
        self.input.on_text(" text")
        self.assertEqual(self.input.get_text(), "text text")

    def test_motion(self):
        self.input.on_gain_focus()

        self.input.on_text_motion(pyglet.window.key.MOTION_RIGHT)
        # 'test|' where | is the carret.
        self.assertEqual(self.input.get_text(), "test")

        self.input.on_text_motion(pyglet.window.key.MOTION_BACKSPACE)
        # 'tes|'
        self.assertEqual(self.input.get_text(), "tes")

        self.input.on_text_motion(pyglet.window.key.MOTION_LEFT)
        # 't|es'
        self.input.on_text_motion(pyglet.window.key.MOTION_LEFT)

        self.input.on_text_motion(pyglet.window.key.MOTION_DELETE)
        # 't|s'
        self.assertEqual(self.input.get_text(), "ts")

    def test_delete(self):
        self.manager.delete()

    def test_delete_without_focus(self):
        self.input.on_gain_focus()
        self.input.on_lose_focus()
        self.manager.delete()

    def test_delete_with_focus(self):
        self.input.on_gain_focus()
        self.manager.delete()
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:53,代码来源:test_text_input.py


示例18: setUp

    def setUp(self):
        TestPygletGUI.setUp(self)

        self.widgets = []
        for i in range(2):
            self.widgets.append(Viewer(width=100, height=50))
        for i in range(2):
            self.widgets.append(Viewer(width=20, height=50))

        self.container = VerticalContainer([HorizontalContainer([self.widgets[0],
                                                           self.widgets[1]], padding=0),
                                         HorizontalContainer([Spacer(),
                                                           self.widgets[2],
                                                           Spacer(),
                                                           self.widgets[3],
                                                           Spacer()], padding=0)], padding=0)

        self.manager = Manager(self.container, window=self.window, batch=self.batch, theme=self.theme)
开发者ID:baccenfutter,项目名称:pyglet-gui,代码行数:18,代码来源:test_spacer.py


示例19: build_status_gui

	def build_status_gui(self):
		self.status_box = Document(
			pyglet.text.document.UnformattedDocument(),
			width=self.window.width*0.9,
			height=self.window.height/4,
			is_fixed_size=True,
			)
		status_frame = Frame(self.status_box)
		self.status_gui_batch = pyglet.graphics.Batch()
		self.status_gui_manager = Manager(
			status_frame,
			window=self.window,
			theme=self.theme,
			batch=self.status_gui_batch,
			)
		self.status_gui_manager.set_position(
			(self.window.width - status_frame.width)/2,
			10,
			)
		self.status_gui_manager.is_movable = False
开发者ID:zudijyr,项目名称:Building-Sim-Game,代码行数:20,代码来源:hud.py


示例20: __init__

 def __init__(self, window, batch, space, level, height, width):
     self.space = space
     self.level = level
     self.height = height
     self.width = width
     progress_text = "Progress: ..."
     self.progress_doc = Document(progress_text, width = width/2)
     objective_doc = Document(level.objective, width = width/2)
     left_frame = Frame(VerticalContainer([objective_doc, None,
         self.progress_doc]), is_expandable = True)
     self.left_container = VerticalContainer([left_frame])
     victory_formula = level.victory_condition[0]
     info_frame = self.create_info_frame(victory_formula)
     self.info_container = VerticalContainer([info_frame])
     container = HorizontalContainer([self.left_container, self.info_container])
     self.manager = Manager(container, window=window, batch=batch,
             group=RenderingOrder.hud, anchor=ANCHOR_BOTTOM_LEFT,
             theme=theme, is_movable=False)
     self.window = window
     self.window.push_handlers(on_draw=self.on_draw)
     self.tick = 0
     self.init_effects(space, level)
开发者ID:Norberg,项目名称:molecule,代码行数:22,代码来源:HUD.py



注:本文中的pyglet_gui.manager.Manager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.cygl_rgba函数代码示例发布时间:2022-05-25
下一篇:
Python core.Viewer类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap