output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = TimePicker(self.get_context(), None, d.style or '@attr/timePickerStyle')
Write a Python 3 function for creating the underlying widget.
As a python code expert, you are capable of creating scripts from specifications.
Initialize the underlying widget.
How would you explain what the following Python 3 function does def init_widget(self): super(AndroidTimePicker, self).init_widget() d = self.declaration w = self.widget self.set_hour(d.hour) self.set_minute(d.minute) self.set_hour_mode(d.hour_mode) w.setOnTimeCha...
As a Python code analyst, you investigate and solve complex coding mysteries
A reimplemented destructor. This destructor will clear the reference to the toolkit widget and set its parent to None.
Make a summary of the following Python 3 code def destroy(self): widget = self.widget if widget is not None: parent = self.parent_widget() if parent is not None: parent.removeView(widget) del self.widget super(AndroidToolkitObject, self).destro...
You are a Python code generator, capable of creating scripts from specifications.
Create the underlying widget.
Can you generate the documentation for the following Python 3 function def create_widget(self): d = self.declaration self.widget = ToggleButton(self.get_context(), None, d.style or "@attr/buttonStyleToggle")
As a Python code analyst, you investigate and solve complex coding mysteries
def init_widget(self): """ Bind the on property to the checked state """ super(UiKitSwitch, self).init_widget() d = self.declaration if d.checked: self.set_checked(d.checked) #: Watch the on property for change #: So apparently UISwitch is not KVO compliant....
Can you implement a function in Python 3 that initializes the UIKitSwitch widget.
You are a Python code generator, capable of creating scripts from specifications.
Called when the check button is changed.
Can you generate the documentation for the following Python 3 function def on_checked_changed(self, on): #: Since iOS decides to call this like 100 times for each defer it d = self.declaration with self.widget.setOn.suppressed(): d.checked = on
As a python code expert, you are capable of creating scripts from specifications.
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Chronometer(self.get_context(), None, d.style)
Write a Python 3 function for creating the underlying widget.
You are a Python code generator, capable of creating scripts from specifications.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidChronometer, self).init_widget() w = self.widget w.setOnChronometerTickListener(w.getId()) w.onChronometerTick.connect(self.on_chronometer_tick)
How would you code a function in Python 3 to initialize the underlying widget.
As a Python code translator, you convert algorithms and pseudocode into Python.
Update the code object of a function
Explain what the following Python 3 code does def update_function(old, new): for name in func_attrs: try: setattr(old, name, getattr(new, name)) except (AttributeError, TypeError): pass
You are a Python code architect, reviewing and designing scalable and efficient code
def update_property(old, new): """Replace get/set/del functions of a property""" update_generic(old.fdel, new.fdel) update_generic(old.fget, new.fget) update_generic(old.fset, new.fset)
Can you implement a function in Python 3 that replaces get set and delete functions of a property
You are a Python code architect, reviewing and designing scalable and efficient code
Enhanced version of the builtin reload function.
Given the following Python 3 function, write the documentation def superreload(module, reload=reload, old_objects={}): # collect old objects in the module for name, obj in list(module.__dict__.items()): if not hasattr(obj, '__module__') or obj.__module__ != module.__name__: continue ...
As a python code expert, you are capable of creating scripts from specifications.
Mark the named module as skipped
Make a summary of the following Python 3 code def mark_module_skipped(self, module_name): try: del self.modules[module_name] except KeyError: pass self.skip_modules[module_name] = True
As a Python code translator, you convert algorithms and pseudocode into Python.
def mark_module_reloadable(self, module_name): """Reload the named module in the future (if it is imported)""" try: del self.skip_modules[module_name] except KeyError: pass self.modules[module_name] = True
Write a Python 3 script to mark a named module as reloadable.
You are a Python code architect, reviewing and designing scalable and efficient code
Import a module and mark it reloadable.
Can you generate a brief explanation for the following Python 3 code def aimport_module(self, module_name): self.mark_module_reloadable(module_name) import_module(module_name) top_name = module_name.split('.')[0] top_module = sys.modules[top_name] return top_module, top_name
You are a Python code analyst, evaluating scripts for potential improvements.
Check whether some modules need to be reloaded.
Given the following Python 3 function, write the documentation def check(self, check_all=False, do_reload=True): if not self.enabled and not check_all: return if check_all or self.check_all: modules = list(sys.modules.keys()) else: modules = list(self.module...
As a Python code translator, you convert algorithms and pseudocode into Python.
def aimport(self, parameter_s='', stream=None): """%aimport => Import modules for automatic reloading. %aimport List modules to automatically import and not to import. %aimport foo Import module 'foo' and mark it to be autoreloaded for %autoreload 1 %aimport foo, bar ...
Create a Python 3 function for importing modules for automatic reloading.
As a python code expert, you are capable of creating scripts from specifications.
def post_execute(self): """Cache the modification times of any modules imported in this execution """ newly_loaded_modules = set(sys.modules) - self.loaded_modules for modname in newly_loaded_modules: _, pymtime = self._reloader.filename_and_mtime(sys.modules[modname]) ...
Write a Python 3 script for caching the modification times of any modules imported in this execution
As a Python code analyst, you investigate and solve complex coding mysteries
Create the underlying widget.
Make a summary of the following Python 3 code def create_widget(self): d = self.declaration self.widget = EditText(self.get_context(), None, d.style or "@attr/editTextStyle")
You are a Python code architect, reviewing and designing scalable and efficient code
Create the underlying widget.
Given the following Python 3 function, write the documentation def create_widget(self): d = self.declaration style = d.style if d.style else ( '@attr/borderlessButtonStyle' if d.flat else '@attr/buttonStyle') self.widget = Button(self.get_context(), None, style)
You are a Python code analyst, evaluating scripts for potential improvements.
Create the underlying widget.
How would you explain what the following Python 3 function does def create_widget(self): d = self.declaration self.widget = FloatingActionButton(self.get_context(), None, d.style)
As a Python code analyst, you investigate and solve complex coding mysteries
Create the underlying widget.
Explain what the following Python 3 code does def create_widget(self): d = self.declaration self.widget = Picker(self.get_context(), None, d.style or '@attr/numberPickerStyle')
You are a Python code generator, capable of creating scripts from specifications.
Initialize the AndroidPicker widget.
Explain what the following Python 3 code does def init_widget(self): super(AndroidPicker, self).init_widget() d = self.declaration w = self.widget if d.items: self.set_items(d.items) else: if d.max_value: self.set_max_value(d.max_value) ...
As a Python code composer, you craft elegant and concise scripts.
def on_value_change(self, picker, old, new): """ Set the checked property based on the checked state of all the children """ d = self.declaration with self.widget.setValue.suppressed(): d.value = new
Can you write a function in Python 3 where it sets the checked property based on the checked state of all the children and the new value.
As a Python code translator, you convert algorithms and pseudocode into Python.
def create_widget(self): """ Create the underlying label widget. """ d = self.declaration mode = 1 if d.mode == 'dropdown' else 0 self.widget = Spinner(self.get_context(), mode) # Create the adapter simple_spinner_item = 0x01090008 self.adapter = ArrayAdapter(se...
Write a Python 3 function that can create the underlying label widget.
You are a Python code architect, reviewing and designing scalable and efficient code
def init_widget(self): """ Initialize the underlying widget. """ w = self.widget # Selection listener w.setAdapter(self.adapter) w.setOnItemSelectedListener(w.getId()) w.onItemSelected.connect(self.on_item_selected) w.onNothingSelected.connect(self.on_not...
Can you create a Python 3 function that initializes the underlying widget.
You are a Python code architect, reviewing and designing scalable and efficient code
Generate the view cache
How would you explain what the following Python 3 function does def set_items(self, items): self.adapter.clear() self.adapter.addAll(items)
As a Python code composer, you craft elegant and concise scripts.
Load the objc library using ctypes.
Can you generate a brief explanation for the following Python 3 code def _default_objc(self): objc = ctypes.cdll.LoadLibrary(find_library('objc')) objc.objc_getClass.restype = ctypes.c_void_p objc.sel_registerName.restype = ctypes.c_void_p objc.objc_msgSend.restype = ctypes.c_void_p ...
As a python code expert, you are capable of creating scripts from specifications.
Get an instance of the ENBridge class using ctypes.
Here you have a function in Python 3, explain what it does def _default_bridge(self): objc = self.objc ENBridge = objc.objc_getClass('ENBridge') return objc.objc_msgSend(ENBridge, objc.sel_registerName('instance'))
As a Python code composer, you craft elegant and concise scripts.
def processEvents(self, data): """ Sends msgpack data to the ENBridge instance by calling the processEvents method via ctypes. """ objc = self.objc bridge = self.bridge #: This must come after the above as it changes the arguments! objc.objc_msgSend.argtypes = [ctypes...
How would you implement a function in Python 3 that sends msgpack data to the ENBridge instance holding the data.
As a Python code translator, you convert algorithms and pseudocode into Python.
Returns the current thread s IOLoop.
Can you generate a brief explanation for the following Python 3 code def current(instance=True): current = getattr(IOLoop._current, "instance", None) if current is None and instance: current = None #if asyncio is not None: # from tornado.platform.asyncio import Asy...
You are a Python code generator, capable of creating scripts from specifications.
def log_stack(self, signal, frame): """Signal handler to log the stack trace of the current thread. For use with `set_blocking_signal_threshold`. """ gen_log.warning('IOLoop blocked for %f seconds in\n%s', self._blocking_signal_threshold, ...
How would you code a function in Python 3 to signal handler to log the stack trace of the current thread.
As a python code expert, you are capable of creating scripts from specifications.
def run_sync(self, func, timeout=None): """Starts the `IOLoop`, runs the given function, and stops the loop. The function must return either a yieldable object or ``None``. If the function returns a yieldable object, the `IOLoop` will run until the yieldable is resolved (and `ru...
Can you write a function in Python 3 where it starts the IOLoop runs the given function and stops the loop.
As a Python code translator, you convert algorithms and pseudocode into Python.
Adds a timeout to the current time for the specified time.
Can you tell what is the following Python 3 function doing def add_timeout(self, deadline, callback, *args, **kwargs): if isinstance(deadline, numbers.Real): return self.call_at(deadline, callback, *args, **kwargs) elif isinstance(deadline, datetime.timedelta): return self.call_a...
As a Python code analyst, you investigate and solve complex coding mysteries
def call_later(self, delay, callback, *args, **kwargs): """Runs the ``callback`` after ``delay`` seconds have passed. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note that unlike the `asyncio` method of the same name, the returned object does not have a `...
Write a Python 3 script for running the callback at the given delay seconds. Returns an opaque handle that can be passed to remove_timeout.
You are a Python code analyst, evaluating scripts for potential improvements.
def call_at(self, when, callback, *args, **kwargs): """Runs the ``callback`` at the absolute time designated by ``when``. ``when`` must be a number using the same reference point as `IOLoop.time`. Returns an opaque handle that may be passed to `remove_timeout` to cancel. Note ...
Create a Python 3 function for running the callback at the absolute time designated by when. Returns an opaque handle that can be used to cancel the call.
As a Python code composer, you craft elegant and concise scripts.
def spawn_callback(self, callback, *args, **kwargs): """Calls the given callback on the next IOLoop iteration. Unlike all other callback-related methods on IOLoop, ``spawn_callback`` does not associate the callback with its caller's ``stack_context``, so it is suitable for fire-and-forg...
Can you create a Python 3 function that spawns a callback on the next IOLoop iteration.
You are a Python code analyst, evaluating scripts for potential improvements.
Schedules a callback on the IOLoop when the given . Future is finished.
Here you have a function in Python 3, explain what it does def add_future(self, future, callback): assert is_future(future) callback = stack_context.wrap(callback) future.add_done_callback( lambda future: self.add_callback(callback, future))
As a Python code translator, you convert algorithms and pseudocode into Python.
def _run_callback(self, callback): """Runs a callback with error handling. For use in subclasses. """ try: ret = callback() if ret is not None: from . import gen # Functions that return Futures typically swallow all ...
Create a Python 3 function for running a callback with error handling.
You are a Python code generator, capable of creating scripts from specifications.
Utility method to close an fd.
Can you generate a brief explanation for the following Python 3 code def close_fd(self, fd): try: try: fd.close() except AttributeError: os.close(fd) except OSError: pass
You are a Python code analyst, evaluating scripts for potential improvements.
def init_widget(self): """ Initialize the state of the toolkit widget. This method is called during the top-down pass, just after the 'create_widget()' method is called. This method should init the state of the widget. The child widgets will not yet be created. Note: This does ...
Create a Python 3 function for initializing the state of the toolkit widget.
You are a Python code generator, capable of creating scripts from specifications.
def create_widget(self): """ Create the underlying widget. A toast is not a subclass of view, hence we don't set name as widget or children will try to use it as their parent (which crashes). """ d = self.declaration Snackbar.make(self.parent_widget(), d.text, ...
Implement a function in Python 3 to create the underlying widget.
As a Python code translator, you convert algorithms and pseudocode into Python.
Initialize the Android Snackbar widget.
Can you generate a brief explanation for the following Python 3 code def init_widget(self): if not self.widget: return super(AndroidSnackbar, self).init_widget() d = self.declaration #: Bind events self.widget.onClick.connect(self.on_click) #: Use the custo...
As a Python code composer, you craft elegant and concise scripts.
Using Snackbar. make returns async so we have to initialize it later.
Explain what the following Python 3 code does def on_widget_created(self, ref): d = self.declaration self.widget = Snackbar(__id__=ref) self.init_widget()
You are a Python code generator, capable of creating scripts from specifications.
def set_duration(self, duration): """ Android for whatever stupid reason doesn't let you set the time it only allows 1-long or 0-short. So we have to repeatedly call show until the duration expires, hence this method does nothing see `set_show`. """ if duration ...
How would you code a function in Python 3 to set the duration of the current time .
As a Python code translator, you convert algorithms and pseudocode into Python.
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = SeekBar(self.get_context(), None, d.style or '@attr/seekBarStyle')
Write a Python 3 script for creating the underlying widget.
As a Python code translator, you convert algorithms and pseudocode into Python.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidSeekBar, self).init_widget() w = self.widget #: Setup listener w.setOnSeekBarChangeListener(w.getId()) w.onProgressChanged.connect(self.on_progress_changed)
Can you implement a function in Python 3 that initializes the underlying widget.
You are a Python code generator, capable of creating scripts from specifications.
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = TextView(self.get_context(), None, d.style or '@attr/textViewStyle')
Create a Python 3 function to create the underlying widget.
As a Python code analyst, you investigate and solve complex coding mysteries
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidTextView, self).init_widget() d = self.declaration w = self.widget if d.input_type: self.set_input_type(d.input_type) w.addTextChangedListener(w.getId()) w.o...
Implement a function in Python 3 to initialize the underlying widget.
As a Python code composer, you craft elegant and concise scripts.
def set_text(self, text): """ Set the text in the widget. """ d = self.declaration if d.input_type == 'html': text = Spanned(__id__=Html.fromHtml(text)) self.widget.setTextKeepState(text)
How would you implement a function in Python 3 that sets the text in the widget.
As a Python code composer, you craft elegant and concise scripts.
def create_widget(self): """ Create the underlying widget. A dialog is not a subclass of view, hence we don't set name as widget or children will try to use it as their parent. """ d = self.declaration self.dialog = BottomSheetDialog(self.get_context(), d.style)
How would you implement a function in Python 3 that creates the underlying widget.
As a Python code analyst, you investigate and solve complex coding mysteries
def encode(obj): """ Encode an object for proper decoding by Java or ObjC """ if hasattr(obj, '__id__'): return msgpack.ExtType(ExtType.REF, msgpack.packb(obj.__id__)) return obj
Create a Python 3 function for encoding an object for proper decoding by Java or ObjC
As a Python code composer, you craft elegant and concise scripts.
Dereference the pointer and return the handler method.
Can you tell what is the following Python 3 function doing def get_handler(ptr, method): obj = CACHE.get(ptr, None) if obj is None: raise BridgeReferenceError( "Reference id={} never existed or has already been destroyed" .format(ptr)) elif not hasattr(obj, method): r...
As a Python code composer, you craft elegant and concise scripts.
Suppress calls within this context to avoid feedback loops
Given the following Python 3 function, write the documentation def suppressed(self, obj): obj.__suppressed__[self.name] = True yield obj.__suppressed__[self.name] = False
You are a Python code analyst, evaluating scripts for potential improvements.
def init_widget(self): """ Initialize the state of the toolkit widget. This method is called during the top-down pass, just after the 'create_widget()' method is called. This method should init the state of the widget. The child widgets will not yet be created. """ supe...
Implement a function in Python 3 to initialize the state of the toolkit widget.
As a Python code translator, you convert algorithms and pseudocode into Python.
def is_wifi_enabled(cls): """ Check if wifi is currently enabled. Returns -------- result: future A future that resolves with the value. """ app = AndroidApplication.instance() f = app.create_future() def on_permission_result(r...
Implement a function in Python 3 to check if wifi is currently enabled. Returns a future that resolves with the value.
As a Python code composer, you craft elegant and concise scripts.
def set_wifi_enabled(cls, state=True): """ Set the wifi enabled state. Returns -------- result: future A future that resolves with whether the operation succeeded. """ app = AndroidApplication.instance() f = app.create_future() ...
Write a Python 3 script to set the wifi enabled state.
As a Python code translator, you convert algorithms and pseudocode into Python.
Get the list of wifi networks currently available.
Can you tell what is the following Python 3 function doing def get_networks(cls): app = AndroidApplication.instance() activity = app.widget f = app.create_future() def on_permission_result(result): if not result: f.set_result(None) return ...
You are a Python code generator, capable of creating scripts from specifications.
def disconnect(cls): """ Disconnect from the current network (if connected). Returns -------- result: future A future that resolves to true if the disconnect was successful. Will be set to None if the change network pe...
Write a Python 3 function for disconnecting from the current network.
You are a Python code analyst, evaluating scripts for potential improvements.
def connect(cls, ssid, key=None, **kwargs): """ Connect to the given ssid using the key (if given). Returns -------- result: future A future that resolves with the result of the connect """ app = AndroidApplication.instance() f = app....
How would you code a function in Python 3 to connect to the given ssid using the given key.
You are a Python code analyst, evaluating scripts for potential improvements.
def get_connection_info(cls): """ Get info about current wifi connection (if any). Returns info such as the IP address, BSSID, link speed, signal, etc.. Returns -------- result: future A future that resolves with a dict of the connection info ...
Implement a function in Python 3 to get info about current wifi connection.
As a python code expert, you are capable of creating scripts from specifications.
def request_permission(cls, permissions): """ Requests permission and returns an future result that returns a boolean indicating if all the given permission were granted or denied. """ app = AndroidApplication.instance() f = app.create_future() def on_result(p...
How would you code a function in Python 3 to request permission and returns an future result that returns a boolean indicating if all the given permissions were granted or denied.
As a Python code translator, you convert algorithms and pseudocode into Python.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidActionMenuView, self).init_widget() d = self.declaration w = self.widget #: Kinda hackish, but when we get the menu back, load it w.getMenu().then(self.on_menu) w.setOnMenuItem...
How would you implement a function in Python 3 that initializes the underlying widget.
As a Python code composer, you craft elegant and concise scripts.
An observer which sends the state change to the proxy.
Can you generate the documentation for the following Python 3 function def _update_proxy(self, change): if change['type'] == 'event': self.proxy.set_refreshed(True) else: super(SwipeRefreshLayout, self)._update_proxy(change)
You are a Python code architect, reviewing and designing scalable and efficient code
Decorator to make a function that returns via callback return a Formula
Make a summary of the following Python 3 code def return_future(f): replacer = ArgReplacer(f, 'callback') @functools.wraps(f) def wrapper(*args, **kwargs): future = TracebackFuture() callback, args, kwargs = replacer.replace( lambda value=_NO_RESULT: future.set_result(value), ...
As a python code expert, you are capable of creating scripts from specifications.
def chain_future(a, b): """Chain two futures together so that when one completes, so does the other. The result (success or failure) of ``a`` will be copied to ``b``, unless ``b`` has already been completed or cancelled by the time ``a`` finishes. """ def copy(future): assert future is a ...
Can you create a Python 3 function that chains two futures together so that when one completes then does the other.
As a python code expert, you are capable of creating scripts from specifications.
If the operation succeeded return its result. If it failed return its exception.
Can you generate a brief explanation for the following Python 3 code def result(self, timeout=None): self._clear_tb_log() if self._result is not None: return self._result if self._exc_info is not None: try: raise_exc_info(self._exc_info) finall...
As a python code expert, you are capable of creating scripts from specifications.
Returns the Exception object if the operation raised an exception otherwise returns None.
Can you generate the documentation for the following Python 3 function def exception(self, timeout=None): self._clear_tb_log() if self._exc_info is not None: return self._exc_info[1] else: self._check_done() return None
You are a Python code generator, capable of creating scripts from specifications.
Attaches the given callback to the Future.
Can you tell what is the following Python 3 function doing def add_done_callback(self, fn): if self._done: fn(self) else: self._callbacks.append(fn)
As a Python code composer, you craft elegant and concise scripts.
Sets the exception of a Future.
Here you have a function in Python 3, explain what it does def set_exception(self, exception): self.set_exc_info( (exception.__class__, exception, getattr(exception, '__traceback__', None)))
You are a Python code generator, capable of creating scripts from specifications.
def set_exc_info(self, exc_info): """Sets the exception information of a ``Future.`` Preserves tracebacks on Python 2. .. versionadded:: 4.0 """ self._exc_info = exc_info self._log_traceback = True if not _GC_CYCLE_FINALIZERS: self._tb_logger = _Trac...
Implement a function in Python 3 to set the exception information of a Future.
As a Python code composer, you craft elegant and concise scripts.
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = CoordinatorLayout(self.get_context(), None, d.style)
Can you write a function in Python 3 where it creates the underlying widget.
You are a Python code generator, capable of creating scripts from specifications.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidCompoundButton, self).init_widget() w = self.widget w.setOnCheckedChangeListener(w.getId()) w.onCheckedChanged.connect(self.on_checked)
Implement a function in Python 3 to initialize the underlying widget.
As a python code expert, you are capable of creating scripts from specifications.
Create the underlying widget.
Given the following Python 3 function, write the documentation def create_widget(self): d = self.declaration self.widget = RelativeLayout(self.get_context(), None, d.style)
You are a Python code generator, capable of creating scripts from specifications.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidRelativeLayout, self).init_widget() d = self.declaration if d.gravity: self.set_gravity(d.gravity) if d.horizontal_gravity: self.set_horizontal_gravity(d.horizontal_grav...
Write a Python 3 script to initialize the underlying widget.
You are a Python code architect, reviewing and designing scalable and efficient code
Initialize the underlying widget.
Can you generate the documentation for the following Python 3 function def init_widget(self): super(AndroidTextureView, self).__init__(self) w = self.widget w.setSurfaceTextureListener(w.getId()) w.onSurfaceTextureAvailable.connect(self.on_surface_texture_available) w.onSurfaceTe...
You are a Python code architect, reviewing and designing scalable and efficient code
Initialize the layout of the AndroidTextureView.
Given the following Python 3 function, write the documentation def init_layout(self): super(AndroidTextureView, self).init_layout() # Force layout using the default params if not self.layout_params: self.set_layout({})
As a Python code analyst, you investigate and solve complex coding mysteries
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = DrawerLayout(self.get_context(), None, d.style)
Can you write a function in Python 3 where it creates the underlying widget.
As a python code expert, you are capable of creating scripts from specifications.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidDrawerLayout, self).init_widget() d = self.declaration if d.title: self.set_title(d.title) if d.drawer_elevation: self.set_drawer_elevation(d.drawer_elevation) i...
How would you implement a function in Python 3 that initializes the underlying widget.
As a python code expert, you are capable of creating scripts from specifications.
Initialize the layout of the toolkit widget.
Make a summary of the following Python 3 code def init_layout(self): layout = self.layout #: Add the layout as a subview self.widget.addSubview(layout) #: Add all child widgets to the layout for child_widget in self.child_widgets(): layout.addArrangedSubview(child_wi...
You are a Python code generator, capable of creating scripts from specifications.
def child_added(self, child): """ Handle the child added event from the declaration. This handler will unparent the child toolkit widget. Subclasses which need more control should reimplement this method. """ super(UiKitView, self).child_added(child) layout = self.layo...
Write a Python 3 function for handling the child added event from the declaration.
As a Python code composer, you craft elegant and concise scripts.
Handle the child removed event from the declaration.
Can you generate a brief explanation for the following Python 3 code def child_removed(self, child): layout = self.layout if child.widget is not None: layout.removeArrangedSubview(child.widget) layout.removeSubview(child.widget)
As a python code expert, you are capable of creating scripts from specifications.
def pack_args(self, obj, *args, **kwargs): """ Arguments must be packed according to the kwargs passed and the signature defined. """ signature = self.__signature__ #: No arguments expected if not signature: return (self.name, []) #: Build args, firs...
Implement a function in Python 3 to pack the arguments passed to the method into a list of strings.
As a python code expert, you are capable of creating scripts from specifications.
Create the underlying widget.
Can you generate the documentation for the following Python 3 function def create_widget(self): d = self.declaration self.widget = RatingBar(self.get_context(), None, d.style or '@attr/ratingBarStyle')
You are a Python code generator, capable of creating scripts from specifications.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidRatingBar, self).init_widget() d = self.declaration self.set_rating(d.rating) w = self.widget w.setOnRatingBarChangeListener(w.getId()) w.onRatingChanged.connect(self.on_rating_...
Write a Python 3 function for initializing the underlying widget.
As a Python code translator, you convert algorithms and pseudocode into Python.
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = LinearLayout(self.get_context(), None, d.style)
How would you implement a function in Python 3 that creates the underlying widget.
As a Python code composer, you craft elegant and concise scripts.
Create the underlying widget.
Here you have a function in Python 3, explain what it does def create_widget(self): d = self.declaration self.widget = FrameLayout(self.get_context(), None, d.style)
As a Python code translator, you convert algorithms and pseudocode into Python.
def create_widget(self): """ Create the underlying widget. """ context = self.get_context() d = self.declaration style = d.style or '@attr/autoCompleteTextViewStyle' self.widget = AutoCompleteTextView(context, None, style) self.adapter = ArrayAdapter(context, '@l...
How would you code a function in Python 3 to create the underlying widget.
As a Python code composer, you craft elegant and concise scripts.
def init_widget(self): """ Initialize the underlying widget. """ super(AndroidAutoCompleteTextView, self).init_widget() self.widget.setAdapter(self.adapter)
Write a Python 3 function that can initialize the underlying widget.
You are a Python code architect, reviewing and designing scalable and efficient code
def create_widget(self): """ Create the underlying widget. """ d = self.declaration self.widget = Icon(self.get_context(), None, d.style)
Write a Python 3 script for creating the underlying widget.
As a Python code analyst, you investigate and solve complex coding mysteries
def _remove_deactivated(contexts): """Remove deactivated handlers from the chain""" # Clean ctx handlers stack_contexts = tuple([h for h in contexts[0] if h.active]) # Find new head head = contexts[1] while head is not None and not head.active: head = head.old_contexts[1] # Process...
Write a Python 3 function for removing deactivated handlers from the chain
As a Python code translator, you convert algorithms and pseudocode into Python.
Wraps a function that will restore the current stack head when executed.
Can you generate the documentation for the following Python 3 function def wrap(fn): # Check if function is already wrapped if fn is None or hasattr(fn, '_wrapped'): return fn # Capture current stack head # TODO: Any other better way to store contexts and update them in wrapped function? ca...
As a Python code translator, you convert algorithms and pseudocode into Python.
Starts listening to events for this sensor.
Here you have a function in Python 3, explain what it does def start(self, callback, rate=SENSOR_DELAY_NORMAL): if not self.manager: raise RuntimeError( "Cannot start a sensor without a SensorManager!") self.onSensorChanged.connect(callback) return self.manager.regist...
You are a Python code architect, reviewing and designing scalable and efficient code
Initialize the underlying widget.
Can you generate the documentation for the following Python 3 function def init_widget(self): super(AndroidListView, self).init_widget() d = self.declaration self.set_arrangement(d.arrangement)
As a Python code composer, you craft elegant and concise scripts.
Return a generator of all items that are declared in this list view.
Explain what the following Python 3 code does def get_declared_items(self): for k, v in super(AndroidListView, self).get_declared_items(): if k == 'layout': yield k, v break
As a Python code composer, you craft elegant and concise scripts.
def init_layout(self): """ Initialize the underlying widget. """ super(AndroidListView, self).init_layout() d = self.declaration w = self.widget # Prepare adapter adapter = self.adapter = BridgedRecyclerAdapter(w) # I'm sure this will make someone upset...
Write a Python 3 function for initializing the underlying list view.
As a Python code translator, you convert algorithms and pseudocode into Python.
Recycle the item at the given index
Here you have a function in Python 3, explain what it does def on_recycle_view(self, index, position): item = self.list_items[index] self.item_mapping[position] = item item.recycle_view(position)
As a Python code composer, you craft elegant and concise scripts.
def refresh_views(self, change=None): """ Set the views that the adapter will cycle through. """ adapter = self.adapter # Set initial ListItem state item_mapping = self.item_mapping for i, item in enumerate(self.list_items): item_mapping[i] = item item.re...
Write a Python 3 script to refresh the views that the adapter will cycle through.
As a python code expert, you are capable of creating scripts from specifications.
Observe items changed and update the adapter appropriately.
Here you have a function in Python 3, explain what it does def _on_items_changed(self, change): if change['type'] != 'container': return op = change['operation'] if op == 'append': i = len(change['value'])-1 self.adapter.notifyItemInserted(i) elif op =...
As a Python code translator, you convert algorithms and pseudocode into Python.
def recycle_view(self, position): """ Tell the view to render the item at the given position """ d = self.declaration if position < len(d.parent.items): d.index = position d.item = d.parent.items[position] else: d.index = -1 d.item = None
Can you implement a function in Python 3 that tells the view to render the item at the given position
You are a Python code architect, reviewing and designing scalable and efficient code
Provides the errno attribute from an exception object.
Make a summary of the following Python 3 code def errno_from_exception(e): # type: (BaseException) -> Optional[int] """Provides the errno from an Exception object. There are cases that the errno attribute was not set so we pull the errno out of the args but if someone instantiates an Exception with...
You are a Python code generator, capable of creating scripts from specifications.