Python kivy.core.window.Window.height() Examples

The following are 21 code examples of kivy.core.window.Window.height(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module kivy.core.window.Window , or try the search function .
Example #1
Source File: alerteditor.py    From RaceCapture_App with GNU General Public License v3.0 6 votes vote down vote up
def _add_new_action(self, *args):
        def popup_dismissed(instance, result):
            if result:
                selected = instance.content.selected_item
                if selected is not None:
                    alertaction = selected.key
                    self.alertrule.alert_actions.append(alertaction)
                    self.dispatch('on_edit_action', alertaction)
                    self.refresh_view()
            popup.dismiss()

        alertaction_prototypes = get_alertaction_default_collection(exclude_filter=self.alertrule.alert_actions)

        items = [ItemSelectionRef(title=alertaction.title, image_source=alertaction.PREVIEW_IMAGE, key=alertaction) for alertaction in alertaction_prototypes]

        if len(items) == 0:
            toast('No more actions available')
        else:
            view = ItemSelectorView(item_references=items)
            popup = editor_popup('Select Action', view,
                                 popup_dismissed,
                                 size_hint=(None, None),
                                 size=(min(Window.width, dp(700)), min(Window.height,dp(400))),
                                 auto_dismiss_time=10) 
Example #2
Source File: gcodeCanvas.py    From GroundControl with GNU General Public License v3.0 6 votes vote down vote up
def drawWorkspace(self, *args):

        self.scatterObject.canvas.remove_group('workspace')
 
        with self.scatterObject.canvas:
            Color(.47, .47, .47)

            #create the bounding box
            height = float(self.data.config.get('Maslow Settings', 'bedHeight'))
            width  = float(self.data.config.get('Maslow Settings', 'bedWidth'))
            Line(points = ( -width/2 , -height/2 ,  width/2 , -height/2), group='workspace')
            Line(points = ( -width/2 ,  height/2 ,  width/2 ,  height/2), group='workspace')
            Line(points = ( -width/2 , -height/2 , -width/2 ,  height/2), group='workspace')
            Line(points = (  width/2 , -height/2 ,  width/2 ,  height/2), group='workspace')
            
            #create the axis lines
            Line(points = (-width/2,0,width/2,0), dash_offset = 5, group='workspace')
            Line(points = (0, -height/2,0,height/2), dash_offset = 5, group='workspace')
    
            texture = self.data.backgroundTexture
            if texture is not None:
                Rectangle(texture=texture, pos=(-width/2, -height/2), 
                          size=(width, height),
                          tex_coords=self.data.backgroundManualReg) 
Example #3
Source File: gauge.py    From RaceCapture_App with GNU General Public License v3.0 6 votes vote down vote up
def showChannelConfigDialog(self):

        def popup_dismissed(instance):
            self.settings.userPrefs.set_alertrules(self.channel, alertrules)
            self.dashboard_state.clear_channel_states(self.channel)

        alertrules = self.settings.userPrefs.get_alertrules(self.channel)

        content = AlertRulesView(alertrules, channel=self.channel)
        content.min_value = self.min
        content.max_value = self.max
        content.precision = self.precision

        popup = Popup(title='Customize {}'.format(self.channel),
                      content=content,
                      size=(min(Window.width, dp(700)), min(Window.height, dp(400))),
                      size_hint=(None, None))
        popup.bind(on_dismiss=popup_dismissed)
        content.bind(title=lambda i, t: setattr(popup, 'title', t))
        popup.open() 
Example #4
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 6 votes vote down vote up
def rescale_interface(self, *_, force=False):
        if self.last_width == 0:
            first_change = True
        else:
            first_change = False
        if Window.width != self.last_width or force:
            self.popup_x = int(Window.width * .75)
            self.last_width = Window.width
            if first_change:
                Clock.schedule_once(lambda x: self.rescale_interface(force=True))
                return
            if desktop:
                button_multiplier = 1
            else:
                button_multiplier = 2
            self.button_scale = int((Window.height / interface_multiplier) * int(self.config.get("Settings", "buttonsize")) / 100) * button_multiplier
            self.padding = self.button_scale / 4
            self.text_scale = int((self.button_scale / 3) * int(self.config.get("Settings", "textsize")) / 100)
            if self.standalone:
                Clock.schedule_once(lambda x: self.show_album())
            else:
                Clock.schedule_once(self.show_database) 
Example #5
Source File: viewer.py    From kivy-smoothie-host with GNU General Public License v3.0 5 votes vote down vote up
def start_cursor(self, x, y):
        tx, ty = self.transform_to_wpos(x, y)
        label = CoreLabel(text="{:1.2f},{:1.2f}".format(tx, ty))
        label.refresh()
        texture = label.texture
        px, py = (x, y)
        with self.ids.surface.canvas.after:
            Color(0, 0, 1, mode='rgb', group='cursor_group')
            self.crossx = [
                Rectangle(pos=(px, 0), size=(1, self.height), group='cursor_group'),
                Rectangle(pos=(0, py), size=(self.width, 1), group='cursor_group'),
                Line(circle=(px, py, 20), group='cursor_group'),
                Rectangle(texture=texture, pos=(px - texture.size[0] / 2, py - 40), size=texture.size, group='cursor_group')
            ] 
Example #6
Source File: telenium_client.py    From telenium with MIT License 5 votes vote down vote up
def rpc_drag(selector, target, duration):
    from kivy.base import EventLoop
    w1 = selectFirst(selector)
    w2 = selectFirst(target)
    duration = float(duration)
    if w1 and w2:
        from kivy.core.window import Window
        cx1, cy1 = w1.to_window(w1.center_x, w1.center_y)
        sx1 = cx1 / float(Window.width)
        sy1 = cy1 / float(Window.height)

        me = TeleniumMotionEvent("telenium",
                                 id=next(nextid),
                                 args=[sx1, sy1])

        telenium_input.events.append(("begin", me))
        if not duration:
            telenium_input.events.append(("end", me))

        else:
            d = 0
            while d < duration:
                t = time()
                EventLoop.idle()
                dt = time() - t
                # need to compute that ever frame, it could have moved
                cx2, cy2 = w2.to_window(w2.center_x, w2.center_y)
                sx2 = cx2 / float(Window.width)
                sy2 = cy2 / float(Window.height)

                dsx = dt * (sx2 - me.sx) / (duration - d)
                dsy = dt * (sy2 - me.sy) / (duration - d)

                me.sx += dsx
                me.sy += dsy

                telenium_input.events.append(("update", me))
                d += dt

        telenium_input.events.append(("end", me))
        return True 
Example #7
Source File: telenium_client.py    From telenium with MIT License 5 votes vote down vote up
def rpc_click_on(selector):
    w = selectFirst(selector)
    if w:
        from kivy.core.window import Window
        cx, cy = w.to_window(w.center_x, w.center_y)
        sx = cx / float(Window.width)
        sy = cy / float(Window.height)
        me = TeleniumMotionEvent("telenium",
                                 id=next(nextid),
                                 args=[sx, sy])
        telenium_input.events.append(("begin", me))
        telenium_input.events.append(("end", me))
        return True 
Example #8
Source File: telenium_client.py    From telenium with MIT License 5 votes vote down vote up
def rpc_select(selector, with_bounds=False):
    if not with_bounds:
        return list(map(path_to, selectAll(selector)))

    results = []
    for widget in selectAll(selector):
        left, bottom = widget.to_window(widget.x, widget.y)
        right, top = widget.to_window(widget.x + widget.width, widget.y + widget.height)
        bounds = (left, bottom, right, top)
        path = path_to(widget)
        results.append((path, bounds))
    return results 
Example #9
Source File: utils.py    From RaceCapture_App with GNU General Public License v3.0 5 votes vote down vote up
def pct_h(pct):
    return Window.height * pct 
Example #10
Source File: core.py    From pypercard with MIT License 5 votes vote down vote up
def _draw_text(self):
        """
        Encompasses the drawing of a single textual block onto the card.
        """
        self.text_label = Label(
            text=self.text, font_size=self.font_size, markup=True
        )
        self.text_label.color = list(self.text_color)
        self.text_label.padding = 10, 10
        self.text_label.text_size = (Window.width, Window.height)
        self.text_label.valign = "middle"
        self.text_label.halign = "center"
        self.layout.add_widget(self.text_label) 
Example #11
Source File: hidinput.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def depack(self, args):
        self.is_touch = True
        self.sx = args['x']
        self.sy = args['y']
        self.profile = ['pos']
        if 'size_w' in args and 'size_h' in args:
            self.shape = ShapeRect()
            self.shape.width = args['size_w']
            self.shape.height = args['size_h']
            self.profile.append('shape')
        if 'pressure' in args:
            self.pressure = args['pressure']
            self.profile.append('pressure')
        super(HIDMotionEvent, self).depack(args) 
Example #12
Source File: hidinput.py    From Tickeys-linux with MIT License 5 votes vote down vote up
def depack(self, args):
        self.is_touch = True
        self.sx = args['x']
        self.sy = args['y']
        self.profile = ['pos']
        if 'size_w' in args and 'size_h' in args:
            self.shape = ShapeRect()
            self.shape.width = args['size_w']
            self.shape.height = args['size_h']
            self.profile.append('shape')
        if 'pressure' in args:
            self.pressure = args['pressure']
            self.profile.append('pressure')
        super(HIDMotionEvent, self).depack(args) 
Example #13
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def drag_treeview(self, drag_object, mode, position, offset=list([0, 0])):
        """Updates the drag-n-drop widget for a treeview folder.
        Arguments:
            drag_object: The widget that is being dragged.
            mode: String, what is being done with the drag: 'start', 'end' or 'move'.
            position: The position (x, y) the drag widget should be at in window coordinates.
            offset: Needs to be provided if mode is 'start',
                    offset where the drag began, to make the image be placed in the correct location.
        """

        if mode == 'end':
            self.main_layout.remove_widget(self.drag_treenode)
            self.screen_manager.current_screen.drop_widget(drag_object.fullpath, position, dropped_type=drag_object.droptype, aspect=1)

        elif mode == 'start':
            self.drag_treenode.offset = offset
            self.main_layout.remove_widget(self.drag_treenode)
            self.drag_treenode.text = drag_object.folder_name
            if drag_object.subtext:
                self.drag_treenode.height = int(self.button_scale * 1.5)
                self.drag_treenode.subtext = drag_object.subtext
                self.drag_treenode.ids['subtext'].height = int(self.button_scale * 0.5)
            else:
                self.drag_treenode.subtext = ''
                self.drag_treenode.ids['subtext'].height = 0
                self.drag_treenode.height = int(self.button_scale * 1)
            self.drag_treenode.width = drag_object.width
            self.drag_treenode.pos = (position[0]-offset[0], position[1]-offset[1])
            self.main_layout.add_widget(self.drag_treenode)

        else:
            self.drag_treenode.pos = (position[0]-self.drag_treenode.offset[0], position[1]-self.drag_treenode.offset[1]) 
Example #14
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 5 votes vote down vote up
def popup_bubble(self, text_input, pos):
        self.close_bubble()
        text_input.unfocus_on_touch = False
        self.bubble = InputMenu(owner=text_input)
        window = self.root_window
        window.add_widget(self.bubble)
        posx = pos[0]
        posy = pos[1]
        #check position to ensure its not off screen
        if posx + self.bubble.width > window.width:
            posx = window.width - self.bubble.width
        if posy + self.bubble.height > window.height:
            posy = window.height - self.bubble.height
        self.bubble.pos = [posx, posy] 
Example #15
Source File: kivmob.py    From KivMob with MIT License 5 votes vote down vote up
def determine_banner_height(self):
        """ Utility function for determining the height (dp) of the banner ad.

            :return height: Height of banner ad in dp.
        """
        height = 32
        upper_bound = kivy.metrics.dp(720)
        if Window.height > upper_bound:
            height = 90
        elif (
            Window.height > kivy.metrics.dp(400)
            and Window.height <= upper_bound
        ):
            height = 50
        return height 
Example #16
Source File: gcodeCanvas.py    From GroundControl with GNU General Public License v3.0 5 votes vote down vote up
def centerCanvas(self, *args):
        '''
        
        Return the canvas to the center of the screen.
        
        '''
        mat = Matrix().translate(Window.width/2, Window.height/2, 0)
        self.scatterInstance.transform = mat
        
        anchor = (0,0)
        scale = self.data.config.get('Ground Control Settings', 'viewScale')
        mat = Matrix().scale(dp(scale), dp(scale), 1)

        self.scatterInstance.apply_transform(mat, anchor) 
Example #17
Source File: simulationCanvas.py    From GroundControl with GNU General Public License v3.0 5 votes vote down vote up
def moveToCenter(self, *args):
        
        
        #This moves the simulation onto the screen, I would love if it were centered
        #but for now it doesn't adapt to screen size (Window.width, Window.height)
        
        moveVertical = self.bedHeight/1.4
        moveHorizontal = self.bedWidth/1.4
        
        mat = Matrix().translate(moveHorizontal, moveVertical, 0)
        self.scatterInstance.apply_transform(mat)
        
        #scale it down to fit on the screen
        self.scatterInstance.apply_transform(Matrix().scale(.3, .3, 1)) 
Example #18
Source File: __init__.py    From kivystudio with MIT License 5 votes vote down vote up
def set_auto_mouse_position(widget):
    ''' functions trys to position widget
    automaticaly on the mouse pos'''

    if Window.mouse_pos[0]+widget.width > Window.width:
        widget.x = Window.mouse_pos[0]

    else:
        widget.x = Window.mouse_pos[0]
    
    if (Window.mouse_pos[1]+widget.height > Window.height):
        widget.top = Window.mouse_pos[1]-16
    else:
        widget.top = Window.mouse_pos[1]-16 
Example #19
Source File: viewer.py    From kivy-smoothie-host with GNU General Public License v3.0 5 votes vote down vote up
def _loaded(self):
        Logger.debug("GcodeViewerScreen: in _loaded. ok: {}".format(self._loaded_ok))
        self.remove_widget(self.li)
        self.li = None
        self.ids.surface.canvas.add(self.canv)
        self.valid = self._loaded_ok
        if self._loaded_ok:
            # not sure why we need to do this
            self.ids.surface.top = Window.height
            if self.app.is_connected:
                self.app.bind(wpos=self.update_tool) 
Example #20
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 4 votes vote down vote up
def drag(self, drag_object, mode, position, image=None, offset=list([0, 0]), fullpath='', photos=0):
        """Updates the drag-n-drop widget for a standard photo.
        Arguments:
            drag_object: The widget that is being dragged.
            mode: String, what is being done with the drag: 'start', 'end' or 'move'.
            position: The position (x, y) the drag widget should be at in window coordinates.
            image: Needs to be provided if mode is 'start', the image the drag widget should have.
            offset: Needs to be provided if mode is 'start',
                    offset where the drag began, to make the image be placed in the correct location.
            fullpath: Needs to be provided if the mode is 'start',
                      String, the database-relative path of the image being dragged.
            photos: Number of dragged photos
        """

        if mode == 'end':
            self.main_layout.remove_widget(self.drag_image)
            self.screen_manager.current_screen.drop_widget(self.drag_image.fullpath, position, dropped_type='file', aspect=self.drag_image.ids['image'].image_ratio)

        elif mode == 'start':
            orientation = drag_object.photo_orientation
            if orientation == 3 or orientation == 4:
                angle = 180
            elif orientation == 5 or orientation == 6:
                angle = 270
            elif orientation == 7 or orientation == 8:
                angle = 90
            else:
                angle = 0
            if photos > 1:
                self.drag_image.total_drags = str(photos) + ' Photos'
            else:
                self.drag_image.total_drags = ''
            self.drag_image.width = drag_object.children[0].width
            self.drag_image.height = drag_object.height
            self.drag_image.angle = angle
            self.drag_image.offset = offset
            self.main_layout.remove_widget(self.drag_image)
            self.drag_image.pos = (position[0]-offset[0], position[1]-offset[1])
            self.drag_image.ids['image'].texture = image.texture
            self.drag_image.fullpath = fullpath
            self.main_layout.add_widget(self.drag_image)

        else:  #mode == 'move'
            self.drag_image.pos = (position[0]-self.drag_image.offset[0], position[1]-self.drag_image.offset[1]) 
Example #21
Source File: main.py    From Snu-Photo-Manager with GNU Lesser General Public License v3.0 4 votes vote down vote up
def load_encoding_presets(self):
        """Loads the video encoding presets from the 'encoding_presets.ini' file."""

        try:
            configfile = ConfigParser(interpolation=None)
            configfile.read(kivy.resources.resource_find('data/encoding_presets.ini'))
            preset_names = configfile.sections()
            for preset_name in preset_names:
                if preset_name == 'Automatic':
                    preset = {'name': 'Automatic',
                              'file_format': 'auto',
                              'video_codec': '',
                              'audio_codec': '',
                              'resize': False,
                              'width': '',
                              'height': '',
                              'video_bitrate': '',
                              'audio_bitrate': '',
                              'encoding_speed': '',
                              'deinterlace': False,
                              'command_line': ''}
                    self.encoding_presets.append(preset)
                try:
                    preset = {'name': preset_name,
                              'file_format': configfile.get(preset_name, 'file_format'),
                              'video_codec': configfile.get(preset_name, 'video_codec'),
                              'audio_codec': configfile.get(preset_name, 'audio_codec'),
                              'resize': to_bool(configfile.get(preset_name, 'resize')),
                              'width': configfile.get(preset_name, 'width'),
                              'height': configfile.get(preset_name, 'height'),
                              'video_bitrate': configfile.get(preset_name, 'video_bitrate'),
                              'audio_bitrate': configfile.get(preset_name, 'audio_bitrate'),
                              'encoding_speed': configfile.get(preset_name, 'encoding_speed'),
                              'deinterlace': to_bool(configfile.get(preset_name, 'deinterlace')),
                              'command_line': configfile.get(preset_name, 'command_line')}
                    self.encoding_presets.append(preset)
                except:
                    pass
        except:
            self.encoding_presets = [{'name': 'Automatic', 'file_format': 'auto', 'video_codec': '', 'audio_codec': '', 'resize': False, 'width': '', 'height': '', 'video_bitrate': '', 'audio_bitrate': '', 'encoding_speed': '', 'deinterlace': False, 'command_line': ''}]
        try:
            self.selected_encoder_preset = self.config.get("Presets", "selected_preset")
        except:
            self.selected_encoder_preset = self.encoding_presets[0]['name']