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


Python EventLoop.ensure_window方法代码示例

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


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

示例1: populate_fbo

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def populate_fbo(self, fbo):
        if not self.has_gui:
            return
        EventLoop.ensure_window()
        if self._update_fbo < 2:
            for obj in self.objs:
                if self.texture_size[0] == -1:
                    self.fbo_widget.size = canvas3d.PICKING_BUFFER_SIZE
                    #self.fbo_widget.size = (512, 512)
                else:
                    self.fbo_widget.size = self.texture_size
                    #self.fbo_widget.size = (512, 512)

                if self.texture_size[0] == -1:
                    self.fbo_widget.fbo.size = canvas3d.PICKING_BUFFER_SIZE
                    #self.fbo_widget.fbo.size  = (512, 512)
                else:
                    self.fbo_widget.fbo.size = self.texture_size
                    #self.fbo_widget.fbo.size = (512, 512)
                obj.texture = self.fbo_widget.fbo.texture
                with self.fbo_widget.fbo:
                    ClearColor(1, 1, 1, 1)
        self.flip_coords = False 
开发者ID:kpiorno,项目名称:kivy3dgui,代码行数:25,代码来源:node.py

示例2: test_tabState

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def test_tabState(self):
        from kivystudio.components.codeplace import CodePlace, get_tab_from_group

        code_place = CodePlace()
        filename1 = 'test_codeplace.py'
        filename2 = 'test_codeplace1.py'
        code_place.add_code_tab(filename=filename1)
        code_place.add_code_tab(filename=filename2)
        self.render(code_place)

        # ensure widow safely
        EventLoop.ensure_window()

        tab1 = get_tab_from_group(filename1)
        tab2 = get_tab_from_group(filename2)

        self.assertEqual(tab1.state, 'normal')
        self.assertEqual(tab2.state, 'down') 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:20,代码来源:test_codeplace.py

示例3: dpi

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def dpi(self):
        '''Return the DPI of the screen. Depending on the platform, the DPI can
        be taken from the Window provider (Desktop mainly) or from a
        platform-specific module (like android/ios).
        '''
        custom_dpi = environ.get('KIVY_DPI')
        if custom_dpi:
            return float(custom_dpi)

        if platform == 'android':
            import android
            return android.get_dpi()
        elif platform == 'ios':
            import ios
            return ios.get_dpi()

        # for all other platforms..
        from kivy.base import EventLoop
        EventLoop.ensure_window()
        return EventLoop.window.dpi 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:22,代码来源:metrics.py

示例4: density

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def density(self):
        '''Return the density of the screen. This value is 1 by default
        on desktops but varies on android depending on the screen.
        '''
        custom_density = environ.get('KIVY_METRICS_DENSITY')
        if custom_density:
            return float(custom_density)

        if platform == 'android':
            import jnius
            Hardware = jnius.autoclass('org.renpy.android.Hardware')
            return Hardware.metrics.scaledDensity
        elif platform == 'ios':
            # 0.75 is for mapping the same density as android tablet
            import ios
            return ios.get_scale() * 0.75
        elif platform == 'macosx':
            from kivy.base import EventLoop
            EventLoop.ensure_window()
            return  EventLoop.window.dpi / 96.

        return 1.0 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:24,代码来源:metrics.py

示例5: build

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def build(self):
        EventLoop.ensure_window()
        layout = FloatLayout()
        if self.figure:
            self.figure.size_hint_y = 0.9
            layout.add_widget(self.figure)
        if self.toolbar:
            self.toolbar.size_hint_y = 0.1
            layout.add_widget(self.toolbar)
        return layout 
开发者ID:kivy-garden,项目名称:garden.matplotlib,代码行数:12,代码来源:backend_kivyagg.py

示例6: __init__

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def __init__(self, **kwargs):
        from kivy.base import EventLoop
        EventLoop.ensure_window()
        self._invalid_scale = True
        self._tiles = []
        self._tiles_bg = []
        self._tilemap = {}
        self._layers = []
        self._default_marker_layer = None
        self._need_redraw_all = False
        self._transform_lock = False
        self.trigger_update(True)
        self.canvas = Canvas()
        self._scatter = MapViewScatter()
        self.add_widget(self._scatter)
        with self._scatter.canvas:
            self.canvas_map = Canvas()
            self.canvas_layers = Canvas()
        with self.canvas:
            self.canvas_layers_out = Canvas()
        self._scale_target_anim = False
        self._scale_target = 1.
        self._touch_count = 0
        self.map_source.cache_dir = self.cache_dir
        Clock.schedule_interval(self._animate_color, 1 / 60.)
        self.lat = kwargs.get("lat", self.lat)
        self.lon = kwargs.get("lon", self.lon)
        super(MapView, self).__init__(**kwargs) 
开发者ID:pythonindia,项目名称:PyCon-Mobile-App,代码行数:30,代码来源:view.py

示例7: setUp

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def setUp(self):
        from kivystudio.parser import emulate_file
        from kivystudio.components.emulator_area import emulator_area
        EventLoop.ensure_window()
        self.emulate_file = emulate_file
        self.emulator_area = emulator_area 
开发者ID:mahart-studio,项目名称:kivystudio,代码行数:8,代码来源:test_emulator.py

示例8: build

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def build(self):
        EventLoop.ensure_window()
        return GlslDemo() 
开发者ID:mvasilkov,项目名称:kb,代码行数:5,代码来源:color.py

示例9: build

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def build(self):
        EventLoop.ensure_window()
        return Starfield() 
开发者ID:mvasilkov,项目名称:kb,代码行数:5,代码来源:main.py

示例10: build

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def build(self):
        EventLoop.ensure_window()
        if EventLoop.window.__class__.__name__.endswith('Pygame'):
            try:
                from pygame import mouse

                a, b = pygame_compile_cursor()
                mouse.set_cursor((24, 24), (9, 9), a, b)
            except:
                pass

        self.canvas_widget = CanvasWidget()
        self.canvas_widget.set_color(
            get_color_from_hex('#2980b9'))
        return self.canvas_widget 
开发者ID:mvasilkov,项目名称:kb,代码行数:17,代码来源:main.py

示例11: __init__

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def __init__(self, **kwargs):
        # Make sure opengl context exists
        EventLoop.ensure_window()

        self.canvas = RenderContext(use_parent_projection=True,
                                    use_parent_modelview=True)

        with self.canvas:
            self.fbo = Fbo(size=self.size)

        with self.fbo.before:
            PushMatrix()
        with self.fbo:
            ClearColor(0, 0, 0, 0)
            ClearBuffers()
            self._background_color = Color(*self.background_color)
            self.fbo_rectangle = Rectangle(size=self.size)
        with self.fbo.after:
            PopMatrix()

        super(EffectWidget, self).__init__(**kwargs)

        Clock.schedule_interval(self._update_glsl, 0)

        self.bind(size=self.refresh_fbo_setup,
                  effects=self.refresh_fbo_setup,
                  background_color=self._refresh_background_color)

        self.refresh_fbo_setup()
        self._refresh_background_color()  # In case thi was changed in kwargs 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:32,代码来源:effectwidget.py

示例12: __init__

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def __init__(self, **kwargs):
        # Before doing anything, ensure the windows exist.
        EventLoop.ensure_window()

        # Assign the default context of the widget creation.
        if not hasattr(self, '_context'):
            self._context = get_current_context()

        super(Widget, self).__init__(**kwargs)

        # Create the default canvas if it does not exist.
        if self.canvas is None:
            self.canvas = Canvas(opacity=self.opacity)

        # Apply all the styles.
        if '__no_builder' not in kwargs:
            #current_root = Builder.idmap.get('root')
            #Builder.idmap['root'] = self
            Builder.apply(self)
            #if current_root is not None:
            #    Builder.idmap['root'] = current_root
            #else:
            #    Builder.idmap.pop('root')

        # Bind all the events.
        for argument in kwargs:
            if argument[:3] == 'on_':
                self.bind(**{argument: kwargs[argument]}) 
开发者ID:BillBillBillBill,项目名称:Tickeys-linux,代码行数:30,代码来源:widget.py

示例13: build

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def build(self):
        EventLoop.ensure_window()
        EventLoop.window.title = self.title = 'Rockivy | Kivy App Contest 2014'

        if EventLoop.window.__class__.__name__.endswith('Pygame'):
            try:
                # because pygame hates nice cursors
                pygame_set_cursor()
            except:
                pass

        game = Game()
        self.on_start = game.on_start
        return init_ui(game) 
开发者ID:mvasilkov,项目名称:kivy-2014,代码行数:16,代码来源:main.py

示例14: __init__

# 需要导入模块: from kivy.base import EventLoop [as 别名]
# 或者: from kivy.base.EventLoop import ensure_window [as 别名]
def __init__(self, **kwargs):
        # Make sure opengl context exists
        EventLoop.ensure_window()
        self.mask_effect = kwargs.get("mask_effect", None)
        self.motion_effect = kwargs.get("motion_effect", None)
        self.fbo_canvas = kwargs.get("motion_effect", None)

        self.canvas = RenderContext(use_parent_projection=True,
                                    use_parent_modelview=True,
                                    with_depthbuffer=True)

        self.size = C_SIZE
        with self.canvas:
            #self._viewport = Rectangle(size=(800,600), pos=self.pos)
            self.fbo = Fbo(size=C_SIZE, with_depthbuffer=True,  compute_normal_mat=True,
                           clear_color=(0.3, 0.3, 0.7, 1))

        with self.fbo.before:
            #Rectangle(size=(800, 600))
            PushMatrix()
            self.fbo_translation = Translate(-self.x, -self.y, 0)
            BindTexture(texture=self.fbo_canvas.texture, index=1)
            BindTexture(texture=self.mask_effect.texture, index=4)
            BindTexture(texture=self.motion_effect.texture, index=5)

        with self.fbo:
            Color(0, 0, 0)
            BindTexture(texture=self.fbo_canvas.texture, index=1)
            BindTexture(texture=self.mask_effect.texture, index=4)
            BindTexture(texture=self.motion_effect.texture, index=5)
            self.fbo_rectangle = Rectangle(size=C_SIZE)
            self._instructions = InstructionGroup()

        with self.fbo.after:
            PopMatrix()
            self.cbs = Callback(self.reset_gl_context)


        super(EffectWidget, self).__init__(**kwargs)
        self.size = C_SIZE

        Clock.schedule_interval(self.update_glsl, 0)

        self._instructions.add(Callback(self.setup_gl_context))

        self.refresh_fbo_setup()
        Clock.schedule_interval(self.update_fbos, 0) 
开发者ID:kpiorno,项目名称:kivy3dgui,代码行数:49,代码来源:effectwidget.py


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