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


Python Dialog.shrink_wrap方法代码示例

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


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

示例1: RootWidget

# 需要导入模块: from dialogs import Dialog [as 别名]
# 或者: from dialogs.Dialog import shrink_wrap [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

示例2: RootWidget

# 需要导入模块: from dialogs import Dialog [as 别名]
# 或者: from dialogs.Dialog import shrink_wrap [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.shrink_wrap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。