本文整理汇总了Python中kivy.core.window.Window.bind方法的典型用法代码示例。如果您正苦于以下问题:Python Window.bind方法的具体用法?Python Window.bind怎么用?Python Window.bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.core.window.Window
的用法示例。
在下文中一共展示了Window.bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def __init__(self, **kwargs):
super(ResizeCursor, self).__init__(**kwargs)
self.size_hint = (None, None)
self.pos_hint = (None, None)
self.source = ''
self.rect = Rectangle(pos=(-9998,-9998), size=(1, 1))
self.size = (dp(22), dp(22))
self.pos = [-9998, -9998]
# Makes an instruction group with a rectangle and
# loads an image inside it
# Binds its properties to mouse positional changes and events triggered
instr = InstructionGroup()
instr.add(self.rect)
self.canvas.after.add(instr)
self.bind(pos=lambda obj, val: setattr(self.rect, 'pos', val))
self.bind(source=lambda obj, val: setattr(self.rect, 'source', val))
self.bind(hidden=lambda obj, val: self.on_mouse_move(Window.mouse_pos))
Window.bind(mouse_pos=lambda obj, val: self.on_mouse_move(val))
示例2: add_widget
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def add_widget(self, widget, tab_type=''):
if len(self.children) > 1:
if tab_type =='code' or tab_type =='new_file' or tab_type=='unsupported':
tab = TabToggleButton(text=os.path.split(widget.filename)[1],
filename=widget.filename)
widget.tab = tab
widget.tab_type = tab_type
self.code_manager.add_widget(widget, widget.filename, tab_type=tab_type)
elif tab_type=='welcome':
self.code_manager.add_widget(widget, 'kivystudiowelcome', tab_type=tab_type)
tab = TabToggleButton(text='Welcome',filename='kivystudiowelcome')
tab.bind(state=self.change_screen)
self.tab_manager.add_widget(tab)
Clock.schedule_once(lambda dt: setattr(tab, 'state', 'down'))
else:
super(CodePlace, self).add_widget(widget)
示例3: initialize
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def initialize(self):
self.targetIndicator.color = self.data.targetInicatorColor
self.positionIndicator.color = self.data.posIndicatorColor
self.drawWorkspace()
if self.data.config.getboolean('Ground Control Settings', 'centerCanvasOnResize'):
Window.bind(on_resize = self.centerCanvas)
self.data.bind(gcode = self.updateGcode)
self.data.bind(backgroundRedraw = self.reloadGcode)
self.data.bind(gcodeShift = self.reloadGcode) #No need to reload if the origin is changed, just clear and redraw
self.data.bind(gcodeFile = self.centerCanvasAndReloadGcode)
global_variables._keyboard = Window.request_keyboard(self._keyboard_closed, self)
global_variables._keyboard.bind(on_key_down=self._on_keyboard_down)
self.centerCanvasAndReloadGcode()
示例4: __init__
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def __init__(self, **kwargs):
self._win = None
if 'container' not in kwargs:
c = self.container = Builder.load_string(_grid_kv)
else:
c = None
kwargs.setdefault('do_scroll_x', False)
if 'size_hint' not in kwargs:
kwargs.setdefault('size_hint_x', None)
kwargs.setdefault('size_hint_y', None)
super(DropDown, self).__init__(**kwargs)
if c is not None:
super(DropDown, self).add_widget(c)
self.on_container(self, c)
Window.bind(on_key_down=self.on_key_down)
self.bind(size=self._reposition)
示例5: open
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def open(self, widget):
'''Open the dropdown list and attach it to a specific widget.
Depending on the position of the widget within the window and
the height of the dropdown, the dropdown might be above or below
that widget.
'''
# ensure we are not already attached
if self.attach_to is not None:
self.dismiss()
# we will attach ourself to the main window, so ensure the
# widget we are looking for have a window
self._win = widget.get_parent_window()
if self._win is None:
raise DropDownException(
'Cannot open a dropdown list on a hidden widget')
self.attach_to = widget
widget.bind(pos=self._reposition, size=self._reposition)
self._reposition()
# attach ourself to the main window
self._win.add_widget(self)
示例6: __init__
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def __init__(self, **kwargs):
super(CustomPopup, self).__init__(**kwargs)
border_color = kwargs.get("border_color", tm.c_popup_background)
label = self.children[0].children[-1]
label.shorten = True
label.shorten_from = "right"
label.markup = True
with self.canvas.after:
Color(*border_color)
self.line = Line(width=0.6,
rectangle=[self.x, self.y, self.width, self.height])
self.bind(pos=self.update_rect,
size=self.update_rect)
示例7: build
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def build(self):
self.handlingKey = False
self.manager = ScanRoot()
# Set up GPIO pin for foot pedal
os.system("gpio export 21 up")
wiringpi.wiringPiSetupSys()
#wiringpi.pinMode(21, 0)
#wiringpi.pullUpDnControl(21, 2)
self.lastPedal = 0
Clock.schedule_interval(self.update, 0.5)
Clock.schedule_interval(self.checkPedal, 0.05)
Window.bind(on_key_down=self.on_key_down)
Window.bind(on_key_up=self.on_key_up)
return self.manager
示例8: show_dialog
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def show_dialog(self, title, message, qrdata=None, cb=None):
if qrdata:
dialog_height = 300
content = QRCodeWidget(data=qrdata,
size=(dp(150), dp(150)),
size_hint=(None, None))
else:
dialog_height = 200
content = MDLabel(font_style='Body1',
theme_text_color='Secondary',
text=message,
size_hint_y=None,
valign='top')
content.bind(texture_size=content.setter('size'))
self.dialog = MDDialog(title=title,
content=content,
size_hint=(.8, None),
height=dp(dialog_height),
auto_dismiss=False)
self.dialog.add_action_button(
"Dismiss", action=cb if cb else lambda *x: self.dialog.dismiss())
self.dialog.open()
示例9: build_config_view
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def build_config_view(self):
config_view = ConfigView(name='config',
rcpConfig=self.rc_config,
rc_api=self._rc_api,
databus=self._databus,
settings=self.settings,
base_dir=self.base_dir,
track_manager=self.track_manager,
preset_manager=self.preset_manager,
status_pump=self._status_pump)
config_view.bind(on_read_config=self.on_read_config)
config_view.bind(on_write_config=self.on_write_config)
config_view.bind(on_show_main_view=lambda instance, view: self.switchMainView(view))
self.config_listeners.append(config_view)
self.tracks_listeners.append(config_view)
return config_view
示例10: on_preferences
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def on_preferences(self, *args):
"""
Display the dashboard preferences view
"""
settings_view = DashboardPreferences(self._settings, self._dashboard_factory)
def popup_dismissed(*args):
self._notify_preference_listeners()
screens = settings_view.get_selected_screens()
screens = self._filter_dashboard_screens(screens)
self._settings.userPrefs.set_dashboard_screens(screens)
self._update_screens(screens)
popup = ModalView(size_hint=DashboardView._POPUP_SIZE_HINT)
popup.add_widget(settings_view)
popup.bind(on_dismiss=popup_dismissed)
popup.open()
示例11: __init__
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def __init__(self, settings, dashboard_factory, **kwargs):
super(DashboardScreenPreferences, self).__init__(**kwargs)
self._settings = settings
current_screens = self._settings.userPrefs.get_dashboard_screens()
screen_keys = dashboard_factory.available_dashboards
for key in screen_keys:
[name, image] = dashboard_factory.get_dashboard_preview_image_path(key)
checkbox = CheckBox()
checkbox.active = True if key in current_screens else False
checkbox.bind(active=lambda i, v, k=key:self._screen_selected(k, v))
screen_item = DashboardScreenItem()
screen_item.add_widget(checkbox)
screen_item.add_widget(FieldLabel(text=name))
screen_item.add_widget(Image(source=image))
self.ids.grid.add_widget(screen_item)
self._current_screens = current_screens
示例12: show_customize_dialog
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def show_customize_dialog(self):
"""
Display the customization dialog for this widget
"""
current_track_id = None if self.track == None else self.track.track_id
params = CustomizeParams(settings=self.settings, datastore=self.datastore, track_manager=self.track_manager)
values = CustomizeValues(heatmap_channel=self.heatmap_channel, track_id=current_track_id)
content = OptionsView(values)
content.add_options_screen(CustomizeHeatmapView(name='heat', params=params, values=values), HeatmapButton())
content.add_options_screen(CustomizeTrackView(name='track', params=params, values=values), TrackmapButton())
popup = Popup(title="Customize Track Map", content=content, size_hint=(0.7, 0.7))
content.bind(on_customized=self._customized)
content.bind(on_close=lambda *args:popup.dismiss())
popup.open()
示例13: __init__
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def __init__(self, datastore, databus, settings, track_manager, session_recorder, **kwargs):
super(AnalysisView, self).__init__(**kwargs)
self._datastore = datastore
self.register_event_type('on_tracks_updated')
self._databus = databus
self._settings = settings
self._track_manager = track_manager
self._session_recorder = session_recorder
self.ids.sessions_view.bind(on_lap_selection=self.lap_selection)
self.ids.sessions_view.bind(on_session_updated=self.session_updated)
self.ids.sessions_view.bind(on_sessions_loaded=self.sessions_loaded)
self.ids.channelvalues.color_sequence = self._color_sequence
self.ids.mainchart.color_sequence = self._color_sequence
self.stream_connecting = False
Window.bind(mouse_pos=self.on_mouse_pos)
Window.bind(on_motion=self.on_motion)
self._layout_complete = False
示例14: _init_toolbar
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def _init_toolbar(self):
'''A Toolbar is created with an ActionBar widget in which buttons are
added with a specific behavior given by a callback. The buttons
properties are given by matplotlib.
'''
basedir = os.path.join(rcParams['datapath'], 'images')
actionview = ActionView()
actionprevious = ActionPrevious(title="Navigation", with_previous=False)
actionoverflow = ActionOverflow()
actionview.add_widget(actionprevious)
actionview.add_widget(actionoverflow)
actionview.use_separator = True
self.actionbar.add_widget(actionview)
id_group = uuid.uuid4()
for text, tooltip_text, image_file, callback in self.toolitems:
if text is None:
actionview.add_widget(ActionSeparator())
continue
fname = os.path.join(basedir, image_file + '.png')
if text in ['Pan', 'Zoom']:
action_button = ActionToggleButton(text=text, icon=fname,
group=id_group)
else:
action_button = ActionButton(text=text, icon=fname)
action_button.bind(on_press=getattr(self, callback))
actionview.add_widget(action_button)
示例15: __init__
# 需要导入模块: from kivy.core.window import Window [as 别名]
# 或者: from kivy.core.window.Window import bind [as 别名]
def __init__(self, figure, **kwargs):
Window.bind(mouse_pos=self._on_mouse_pos)
self.bind(size=self._on_size_changed)
self.bind(pos=self._on_pos_changed)
self.entered_figure = True
self.figure = figure
super(FigureCanvasKivy, self).__init__(figure=self.figure, **kwargs)