本文整理汇总了Python中kivy.core.window.Window.width方法的典型用法代码示例。如果您正苦于以下问题:Python Window.width方法的具体用法?Python Window.width怎么用?Python Window.width使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.core.window.Window
的用法示例。
在下文中一共展示了Window.width方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: drawWorkspace
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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)
示例2: callBackMechanism
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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)
示例3: on_transform_with_touch
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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
示例4: convert_distance_to_scroll
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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
示例5: on_hidden
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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
示例6: denoise_preview
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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
示例7: left_panel_width
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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
示例8: rescale_interface
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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)
示例9: showChannelConfigDialog
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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()
示例10: _add_new_action
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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)
示例11: begin
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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)
示例12: set_auto_mouse_position
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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
示例13: moveToCenter
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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))
示例14: centerCanvas
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
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)
示例15: done_animating
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import width [as 别名]
def done_animating(self, *_):
self.animating = None
if self.width == 0:
self.opacity = 0
else:
self.opacity = 1