當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。