Python kivy.core.window.Window.width() Examples
The following are 30
code examples of kivy.core.window.Window.width().
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: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
def denoise_preview(self, width, height, pos_x, pos_y): left = pos_x right = pos_x + width lower = pos_y + width upper = pos_y original_image = self.original_image preview = original_image.crop(box=(left, upper, right, lower)) if preview.mode != 'RGB': preview = preview.convert('RGB') preview_cv = cv2.cvtColor(numpy.array(preview), cv2.COLOR_RGB2BGR) preview_cv = cv2.fastNlMeansDenoisingColored(preview_cv, None, self.luminance_denoise, self.color_denoise, self.search_window, self.block_size) preview_cv = cv2.cvtColor(preview_cv, cv2.COLOR_BGR2RGB) preview = Image.fromarray(preview_cv) preview_bytes = BytesIO() preview.save(preview_bytes, 'jpeg') preview_bytes.seek(0) return preview_bytes
Example #2
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
def left_panel_width(self): """Returns the saved width for the left panel. Returns: Width of the panel in pixels. """ minpanelsize = (self.button_scale / 2) leftpanel = float(self.config.get('Settings', 'leftpanel')) leftpanelsize = (leftpanel * Window.width) maxwidth = Window.width * 0.4 if leftpanelsize > minpanelsize and leftpanelsize < maxwidth: panelwidth = leftpanelsize elif leftpanelsize >= maxwidth: panelwidth = maxwidth else: panelwidth = minpanelsize panelwidth = int(panelwidth) return panelwidth
Example #3
Source File: gcodeCanvas.py From GroundControl with GNU General Public License v3.0 | 6 votes |
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 #4
Source File: gcodeCanvas.py From GroundControl with GNU General Public License v3.0 | 6 votes |
def callBackMechanism(self, callback) : ''' Call the loadNextLine function periodically in a non-blocking way to update the gcode. ''' with self.scatterObject.canvas: self.line = Line(points = (), width = 1, group = 'gcode') #Draw numberOfTimesToCall lines on the canvas numberOfTimesToCall = 500 for _ in range(numberOfTimesToCall): self.loadNextLine() #Repeat until end of file if self.lineNumber < min(len(self.data.gcode),self.maxNumberOfLinesToRead): Clock.schedule_once(self.callBackMechanism)
Example #5
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
def on_transform_with_touch(self, touch): """Modified to not allow widgets to be moved out of the visible area.""" width = self.bbox[1][0] height = self.bbox[1][1] scale = self.scale local_bottom = self.bbox[0][1] local_left = self.bbox[0][0] local_top = local_bottom+height local_right = local_left+width local_xmax = width/scale local_xmin = 0 local_ymax = height/scale local_ymin = 0 if local_right < local_xmax: self.transform[12] = local_xmin - (width - local_xmax) if local_left > local_xmin: self.transform[12] = local_xmin if local_top < local_ymax: self.transform[13] = local_ymin - (height - local_ymax) if local_bottom > local_ymin: self.transform[13] = local_ymin
Example #6
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
def convert_distance_to_scroll(self, dx, dy): box = self.children[0] wheight = box.default_size[1] + box.spacing if not self._viewport: return 0, 0 vp = self._viewport vp_height = len(self.data) * wheight if vp.width > self.width: sw = vp.width - self.width sx = dx / float(sw) else: sx = 0 if vp_height > self.height: sh = vp_height - self.height sy = dy / float(sh) else: sy = 1 return sx, sy #Buttons
Example #7
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
def on_hidden(self, *_): app = App.get_running_app() if self.animating: self.animating.cancel(self) if self.hidden: if app.animations: self.animating = anim = Animation(width=0, opacity=0, duration=app.animation_length) anim.bind(on_complete=self.done_animating) anim.start(self) else: self.opacity = 0 self.width = 0 else: if app.animations: self.animating = anim = Animation(width=self.display_width, opacity=1, duration=app.animation_length) anim.bind(on_complete=self.done_animating) anim.start(self) else: self.opacity = 1 self.width = self.display_width
Example #8
Source File: main.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 6 votes |
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 #9
Source File: alerteditor.py From RaceCapture_App with GNU General Public License v3.0 | 6 votes |
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 #10
Source File: gauge.py From RaceCapture_App with GNU General Public License v3.0 | 6 votes |
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 #11
Source File: hidinput.py From Tickeys-linux with MIT License | 5 votes |
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: settings.py From Tickeys-linux with MIT License | 5 votes |
def _create_popup(self, instance): # create the popup content = BoxLayout(orientation='vertical', spacing='5dp') popup_width = min(0.95 * Window.width, dp(500)) self.popup = popup = Popup( content=content, title=self.title, size_hint=(None, None), size=(popup_width, '400dp')) popup.height = len(self.options) * dp(55) + dp(150) # add all the options content.add_widget(Widget(size_hint_y=None, height=1)) uid = str(self.uid) for option in self.options: state = 'down' if option == self.value else 'normal' btn = ToggleButton(text=option, state=state, group=uid) btn.bind(on_release=self._set_option) content.add_widget(btn) # finally, add a cancel button to return on the previous panel content.add_widget(SettingSpacer()) btn = Button(text='Cancel', size_hint_y=None, height=dp(50)) btn.bind(on_release=popup.dismiss) content.add_widget(btn) # and open the popup ! popup.open()
Example #13
Source File: settings.py From Tickeys-linux with MIT License | 5 votes |
def _create_popup(self, instance): # create popup layout content = BoxLayout(orientation='vertical', spacing='5dp') popup_width = min(0.95 * Window.width, dp(500)) self.popup = popup = Popup( title=self.title, content=content, size_hint=(None, None), size=(popup_width, '250dp')) # create the textinput used for numeric input self.textinput = textinput = TextInput( text=self.value, font_size='24sp', multiline=False, size_hint_y=None, height='42sp') textinput.bind(on_text_validate=self._validate) self.textinput = textinput # construct the content, widget are used as a spacer content.add_widget(Widget()) content.add_widget(textinput) content.add_widget(Widget()) content.add_widget(SettingSpacer()) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') btn = Button(text='Ok') btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') btn.bind(on_release=self._dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # all done, open the popup ! popup.open()
Example #14
Source File: dashboardview.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def _adjust_width(self): min_width = PopupAlertView.MIN_POPUP_WIDTH for screen in self._current_screens.itervalues(): min_width = max(min_width, len(screen.popup_alertaction.message) * PopupAlertView.MSG_CHAR_WIDTH) self.width = min(min_width, Window.width)
Example #15
Source File: settings.py From Tickeys-linux with MIT License | 5 votes |
def _create_popup(self, instance): # create the popup content = BoxLayout(orientation='vertical', spacing='5dp') popup_width = min(0.95 * Window.width, dp(500)) self.popup = popup = Popup( content=content, title=self.title, size_hint=(None, None), size=(popup_width, '400dp')) popup.height = len(self.options) * dp(55) + dp(150) # add all the options content.add_widget(Widget(size_hint_y=None, height=1)) uid = str(self.uid) for option in self.options: state = 'down' if option == self.value else 'normal' btn = ToggleButton(text=option, state=state, group=uid) btn.bind(on_release=self._set_option) content.add_widget(btn) # finally, add a cancel button to return on the previous panel content.add_widget(SettingSpacer()) btn = Button(text='Cancel', size_hint_y=None, height=dp(50)) btn.bind(on_release=popup.dismiss) content.add_widget(btn) # and open the popup ! popup.open()
Example #16
Source File: settings.py From Tickeys-linux with MIT License | 5 votes |
def _create_popup(self, instance): # create popup layout content = BoxLayout(orientation='vertical', spacing=5) popup_width = min(0.95 * Window.width, dp(500)) self.popup = popup = Popup( title=self.title, content=content, size_hint=(None, 0.9), width=popup_width) # create the filechooser self.textinput = textinput = FileChooserListView( path=self.value, size_hint=(1, 1), dirselect=True) textinput.bind(on_path=self._validate) self.textinput = textinput # construct the content content.add_widget(textinput) content.add_widget(SettingSpacer()) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') btn = Button(text='Ok') btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') btn.bind(on_release=self._dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # all done, open the popup ! popup.open()
Example #17
Source File: settings.py From Tickeys-linux with MIT License | 5 votes |
def _create_popup(self, instance): # create popup layout content = BoxLayout(orientation='vertical', spacing='5dp') popup_width = min(0.95 * Window.width, dp(500)) self.popup = popup = Popup( title=self.title, content=content, size_hint=(None, None), size=(popup_width, '250dp')) # create the textinput used for numeric input self.textinput = textinput = TextInput( text=self.value, font_size='24sp', multiline=False, size_hint_y=None, height='42sp') textinput.bind(on_text_validate=self._validate) self.textinput = textinput # construct the content, widget are used as a spacer content.add_widget(Widget()) content.add_widget(textinput) content.add_widget(Widget()) content.add_widget(SettingSpacer()) # 2 buttons are created for accept or cancel the current value btnlayout = BoxLayout(size_hint_y=None, height='50dp', spacing='5dp') btn = Button(text='Ok') btn.bind(on_release=self._validate) btnlayout.add_widget(btn) btn = Button(text='Cancel') btn.bind(on_release=self._dismiss) btnlayout.add_widget(btn) content.add_widget(btnlayout) # all done, open the popup ! popup.open()
Example #18
Source File: hidinput.py From Tickeys-linux with MIT License | 5 votes |
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 #19
Source File: core.py From pypercard with MIT License | 5 votes |
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 #20
Source File: utils.py From RaceCapture_App with GNU General Public License v3.0 | 5 votes |
def pct_w(pct): return Window.width * pct
Example #21
Source File: telenium_client.py From telenium with MIT License | 5 votes |
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 #22
Source File: slidingpanel.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def toggle(self): Animation.stop_all(self, 'x') Animation.stop_all(self.shadow, 'color') if self._open: if self.side == 'left': target_x = -1 * self.width else: target_x = Window.width sh_anim = Animation(duration=self.anim_length_open, t=self.animation_t_open, color=[0, 0, 0, 0]) sh_anim.start(self.shadow) self._get_main_animation(duration=self.anim_length_close, t=self.animation_t_close, x=target_x, is_closing=True).start(self) self._open = False else: if self.side == 'left': target_x = 0 else: target_x = Window.width - self.width Animation(duration=self.anim_length_open, t=self.animation_t_open, color=[0, 0, 0, 0.5]).start(self.shadow) self._get_main_animation(duration=self.anim_length_open, t=self.animation_t_open, x=target_x, is_closing=False).start(self) self._open = True
Example #23
Source File: snackbar.py From Blogs-Posts-Tutorials with MIT License | 5 votes |
def begin(self): if self.button_text == '': self.remove_widget(self.ids['_button']) else: self.ids['_spacer'].width = dp(16) if \ DEVICE_TYPE == "mobile" else dp(40) self.padding_right = dp(16) Window.add_widget(self) anim = Animation(y=0, duration=.3, t='out_quad') anim.start(self) Clock.schedule_once(lambda dt: self.die(), self.duration)
Example #24
Source File: telenium_client.py From telenium with MIT License | 5 votes |
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 #25
Source File: telenium_client.py From telenium with MIT License | 5 votes |
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 #26
Source File: snackbar.py From KivyMD with MIT License | 5 votes |
def begin(self): if self.button_text == '': self.remove_widget(self.ids['_button']) else: self.ids['_spacer'].width = dp(16) if \ DEVICE_TYPE == "mobile" else dp(40) self.padding_right = dp(16) Window.add_widget(self) anim = Animation(y=0, duration=.3, t='out_quad') anim.start(self) Clock.schedule_once(lambda dt: self.die(), self.duration)
Example #27
Source File: generalelements.py From Snu-Photo-Manager with GNU Lesser General Public License v3.0 | 5 votes |
def set_crop(self, posx, posy, width, height): """Sets the crop values based on the cropper widget.""" texture_size = self.get_texture_size() texture_top_edge = texture_size[0] texture_right_edge = texture_size[1] texture_bottom_edge = texture_size[2] texture_left_edge = texture_size[3] left_crop = posx - texture_left_edge bottom_crop = posy - texture_bottom_edge right_crop = texture_right_edge - width - posx top_crop = texture_top_edge - height - posy texture_width = (texture_right_edge - texture_left_edge) divisor = self.original_width / texture_width if left_crop < 0: self.crop_left = 0 else: self.crop_left = left_crop * divisor if right_crop < 0: self.crop_right = 0 else: self.crop_right = right_crop * divisor if top_crop < 0: self.crop_top = 0 else: self.crop_top = top_crop * divisor if bottom_crop < 0: self.crop_bottom = 0 else: self.crop_bottom = bottom_crop * divisor #self.update_preview(recrop=False) self.update_crop_controls()
Example #28
Source File: __init__.py From kivystudio with MIT License | 5 votes |
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 #29
Source File: simulationCanvas.py From GroundControl with GNU General Public License v3.0 | 5 votes |
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 #30
Source File: gcodeCanvas.py From GroundControl with GNU General Public License v3.0 | 5 votes |
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)