当前位置: 首页>>代码示例>>Python>>正文


Python Dialog.present方法代码示例

本文整理汇总了Python中dialogs.Dialog.present方法的典型用法代码示例。如果您正苦于以下问题:Python Dialog.present方法的具体用法?Python Dialog.present怎么用?Python Dialog.present使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dialogs.Dialog的用法示例。


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

示例1: present

# 需要导入模块: from dialogs import Dialog [as 别名]
# 或者: from dialogs.Dialog import present [as 别名]
    def present(self, client, pos):
        client = client or self.root
        self.topleft = client.local_to_global(pos)
        focus = self.handler or get_focus()
        font = self.font
        h = font.get_linesize()
        items = self._items
        margin = self.margin
        if self.scrolling:
            height = h * self.scroll_items + h
        else:
            height = h * len(items) + h
        w1 = w2 = 0
        for item in items:
            item.enabled = self.command_is_enabled(item, focus)
            w1 = max(w1, font.size(item.text)[0])
            w2 = max(w2, font.size(item.keyname)[0])
        width = w1 + 2 * margin
        self._key_margin = width
        if w2 > 0:
            width += w2 + margin
        if self.scrolling:
            width += self.scroll_button_size
        self.size = (width, height)
        self._hilited = None

        self.rect.clamp_ip(self.root.rect)

        return Dialog.present(self, centered=False)
开发者ID:BossosaurusRex,项目名称:MCEdit-Unified,代码行数:31,代码来源:menu.py

示例2: present

# 需要导入模块: from dialogs import Dialog [as 别名]
# 或者: from dialogs.Dialog import present [as 别名]
	def present(self, client, pos):
		client = client or get_root()
		self.topleft = client.local_to_global(pos)
		focus = get_focus()
		font = self.font
		h = font.get_linesize()
		items = self._items
		margin = self.margin
		height = h * len(items) + h
		w1 = w2 = 0
		for item in items:
			item.enabled = self.command_is_enabled(item, focus)
			w1 = max(w1, font.size(item.text)[0])
			w2 = max(w2, font.size(item.keyname)[0])
		width = w1 + 2 * margin
		self._key_margin = width
		if w2 > 0:
			width += w2 + margin
		self.size = (width, height)
		self._hilited = None
		return Dialog.present(self, centered = False)
开发者ID:AnnanFay,项目名称:pyge-solitaire,代码行数:23,代码来源:menu.py

示例3: RootWidget

# 需要导入模块: from dialogs import Dialog [as 别名]
# 或者: from dialogs.Dialog import present [as 别名]
class RootWidget(Widget):
    #  surface   Pygame display surface
    #  is_gl     True if OpenGL surface

    redraw_every_frame = False
    bonus_draw_time = False
    _is_gl_container = True

    def __init__(self, surface):
        global root_widget
        Widget.__init__(self, surface.get_rect())
        self.surface = surface
        root_widget = self
        widget.root_widget = self
        self.is_gl = surface.get_flags() & OPENGL != 0
        self.idle_handlers = []
        self.editor = None
        self.selectTool = None
        self.movementMath = [-1, 1, 1, -1, 1, -1]
        self.movementNum = [0, 0, 2, 2, 1, 1]
        self.cameraMath = [-1., 1., -1., 1.]
        self.cameraNum = [0, 0, 1, 1]
        self.notMove = False
        self.nudge = None
        self.testTime = None
        self.testTimeBack = 0.4
        self.nudgeDirection = None
        self.sessionStolen = False
        self.sprint = False
        self.filesToChange = []

    def get_modifiers(self):
        """Returns the 'modifiers' global object."""
        return modifiers

    def get_nudge_block(self):
        return self.selectTool.panel.nudgeBlocksButton

    def take_screenshot(self):
        try:
            os.mkdir(os.path.join(directories.getCacheDir(), "screenshots"))
        except OSError:
            pass
        screenshot_name = os.path.join(directories.getCacheDir(), "screenshots", time.strftime("%Y-%m-%d (%I-%M-%S-%p)") + ".png")
        pygame.image.save(pygame.display.get_surface(), screenshot_name)
        self.diag = Dialog()
        lbl = Label(_("Screenshot taken and saved as '%s'") % screenshot_name, doNotTranslate=True)
        folderBtn = Button("Open Folder", action=self.open_screenshots_folder)
        btn = Button("Ok", action=self.screenshot_notify)
        buttonsRow = Row((btn, folderBtn))
        col = Column((lbl, buttonsRow))
        self.diag.add(col)
        self.diag.shrink_wrap()
        self.diag.present()

    def open_screenshots_folder(self):
        from mcplatform import platform_open
        platform_open(os.path.join(directories.getCacheDir(), "screenshots"))
        self.screenshot_notify()

    def screenshot_notify(self):
        self.diag.dismiss()

    @staticmethod
    def set_timer(ms):
        pygame.time.set_timer(USEREVENT, ms)

    def run(self):
        self.run_modal(None)

    captured_widget = None

    def capture_mouse(self, widget):
        # put the mouse in "virtual mode" and pass mouse moved events to the
        # specified widget
        if widget:
            pygame.mouse.set_visible(False)
            pygame.event.set_grab(True)
            self.captured_widget = widget
        else:
            pygame.mouse.set_visible(True)
            pygame.event.set_grab(False)
            self.captured_widget = None

    frames = 0
    hover_widget = None

    def fix_sticky_ctrl(self):
        self.ctrlClicked = -1

    def run_modal(self, modal_widget):
        if self.editor is None:
            self.editor = self.mcedit.editor
            self.selectTool = self.editor.toolbar.tools[0]
        old_captured_widget = None

        if self.captured_widget:
            old_captured_widget = self.captured_widget
            self.capture_mouse(None)

#.........这里部分代码省略.........
开发者ID:Khroki,项目名称:MCEdit-Unified,代码行数:103,代码来源:root.py

示例4: RootWidget

# 需要导入模块: from dialogs import Dialog [as 别名]
# 或者: from dialogs.Dialog import present [as 别名]
class RootWidget(Widget):
    #  surface   Pygame display surface
    #  is_gl     True if OpenGL surface

    redraw_every_frame = False
    bonus_draw_time = False
    _is_gl_container = True

    def __init__(self, surface):
        global root_widget
        Widget.__init__(self, surface.get_rect())
        self.surface = surface
        root_widget = self
        widget.root_widget = self
        self.is_gl = surface.get_flags() & OPENGL != 0
        self.idle_handlers = []
        self.editor = None
        self.selectTool = None
        self.movementMath = [-1, 1, 1, -1, 1, -1]
        self.movementNum = [0, 0, 2, 2, 1, 1]
        self.cameraMath = [-1., 1., -1., 1.]
        self.cameraNum = [0, 0, 1, 1]
        self.notMove = False
        self.nudge = None
        self.testTime = None
        self.testTimeBack = 0.4
        self.nudgeDirection = None
        self.sessionStolen = False
        self.sprint = False
        self.filesToChange = []

    def get_nudge_block(self):
        return self.selectTool.panel.nudgeBlocksButton

    def take_screenshot(self):
        try:
            os.mkdir(os.path.join(directories.getCacheDir(), "screenshots"))
        except OSError:
            pass
        screenshot_name = os.path.join(directories.getCacheDir(), "screenshots", time.strftime("%Y-%m-%d (%I-%M-%S-%p)")+".png")
        pygame.image.save(pygame.display.get_surface(), screenshot_name)
        self.diag = Dialog()
        lbl = Label(_("Screenshot taken and saved as '%s'")%screenshot_name, doNotTranslate=True)
        folderBtn = Button("Open Folder", action=self.open_screenshots_folder)
        btn = Button("Ok", action=self.screenshot_notify)
        buttonsRow = Row((btn,folderBtn))
        col = Column((lbl,buttonsRow))
        self.diag.add(col)
        self.diag.shrink_wrap()
        self.diag.present()

    def open_screenshots_folder(self):
        from mcplatform import platform_open
        platform_open(os.path.join(directories.getCacheDir(), "screenshots"))
        self.screenshot_notify()

    def screenshot_notify(self):
        self.diag.dismiss()

    @staticmethod
    def set_timer(ms):
        pygame.time.set_timer(USEREVENT, ms)

    def run(self):
        self.run_modal(None)

    captured_widget = None

    def capture_mouse(self, widget):
        #put the mouse in "virtual mode" and pass mouse moved events to the
        #specified widget
        if widget:
            pygame.mouse.set_visible(False)
            pygame.event.set_grab(True)
            self.captured_widget = widget
        else:
            pygame.mouse.set_visible(True)
            pygame.event.set_grab(False)
            self.captured_widget = None

    frames = 0
    hover_widget = None

    def fix_sticky_ctrl(self):
        self.ctrlClicked = -1

    def run_modal(self, modal_widget):
        if self.editor is None:
            self.editor = self.mcedit.editor
            self.selectTool = self.editor.toolbar.tools[0]
        old_captured_widget = None

        if self.captured_widget:
            old_captured_widget = self.captured_widget
            self.capture_mouse(None)

        global last_mouse_event, last_mouse_event_handler
        global top_widget, clicked_widget
        is_modal = modal_widget is not None
        modal_widget = modal_widget or self
#.........这里部分代码省略.........
开发者ID:germanalen,项目名称:MCEdit-Unified,代码行数:103,代码来源:root.py


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