signature stringlengths 8 3.44k | body stringlengths 0 1.41M | docstring stringlengths 1 122k | id stringlengths 5 17 |
|---|---|---|---|
def hide(self): | self.widget.hide()<EOL> | Call hide on the toplevel widget | f5917:c0:m7 |
def show_and_run(self): | self.show()<EOL>gtk.main()<EOL> | Show the main widget and run the gtk loop | f5917:c0:m8 |
def hide_and_quit(self): | self.hide()<EOL>gtk.main_quit()<EOL> | Hide the widget and quit the main loop | f5917:c0:m9 |
def get_builder_toplevel(self, builder): | toplevel = builder.get_object(self.toplevel_name)<EOL>if toplevel is None:<EOL><INDENT>toplevel = get_first_builder_window(builder).child<EOL><DEDENT>if toplevel is not None:<EOL><INDENT>toplevel.get_parent().remove(toplevel)<EOL><DEDENT>return toplevel<EOL> | Get the toplevel widget from a gtk.Builder file.
The slave view implementation first searches for the widget named as
self.toplevel_name (which defaults to "main". If this is missing, the
first toplevel widget is discovered in the Builder file, and it's
immediate child is used as the to... | f5917:c1:m0 |
def show_and_run(self): | self.display_widget = gtk.Window()<EOL>self.display_widget.add(self.widget)<EOL>self.display_widget.show()<EOL>BaseDelegate.show_and_run(self)<EOL> | Show the main widget in a window and run the gtk loop | f5917:c1:m2 |
def get_builder_toplevel(self, builder): | toplevel = builder.get_object(self.toplevel_name)<EOL>if not gobject.type_is_a(toplevel, gtk.Window):<EOL><INDENT>toplevel = None<EOL><DEDENT>if toplevel is None:<EOL><INDENT>toplevel = get_first_builder_window(builder)<EOL><DEDENT>return toplevel<EOL> | Get the toplevel widget from a gtk.Builder file.
The main view implementation first searches for the widget named as
self.toplevel_name (which defaults to "main". If this is missing, or not
a gtk.Window, the first toplevel window found in the gtk.Builder is
used. | f5917:c2:m0 |
def get_keywords(): | <EOL>git_refnames = "<STR_LIT>"<EOL>git_full = "<STR_LIT>"<EOL>git_date = "<STR_LIT>"<EOL>keywords = {"<STR_LIT>": git_refnames, "<STR_LIT>": git_full, "<STR_LIT:date>": git_date}<EOL>return keywords<EOL> | Get the keywords needed to look up the version information. | f5919:m0 |
def get_config(): | <EOL>cfg = VersioneerConfig()<EOL>cfg.VCS = "<STR_LIT>"<EOL>cfg.style = "<STR_LIT>"<EOL>cfg.tag_prefix = "<STR_LIT:v>"<EOL>cfg.parentdir_prefix = "<STR_LIT>"<EOL>cfg.versionfile_source = "<STR_LIT>"<EOL>cfg.verbose = False<EOL>return cfg<EOL> | Create, populate and return the VersioneerConfig() object. | f5919:m1 |
def register_vcs_handler(vcs, method): | def decorate(f):<EOL><INDENT>"""<STR_LIT>"""<EOL>if vcs not in HANDLERS:<EOL><INDENT>HANDLERS[vcs] = {}<EOL><DEDENT>HANDLERS[vcs][method] = f<EOL>return f<EOL><DEDENT>return decorate<EOL> | Decorator to mark a method as the handler for a particular VCS. | f5919:m2 |
def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,<EOL>env=None): | assert isinstance(commands, list)<EOL>p = None<EOL>for c in commands:<EOL><INDENT>try:<EOL><INDENT>dispcmd = str([c] + args)<EOL>p = subprocess.Popen([c] + args, cwd=cwd, env=env,<EOL>stdout=subprocess.PIPE,<EOL>stderr=(subprocess.PIPE if hide_stderr<EOL>else None))<EOL>break<EOL><DEDENT>except EnvironmentError:<EOL><I... | Call the given command(s). | f5919:m3 |
def versions_from_parentdir(parentdir_prefix, root, verbose): | rootdirs = []<EOL>for i in range(<NUM_LIT:3>):<EOL><INDENT>dirname = os.path.basename(root)<EOL>if dirname.startswith(parentdir_prefix):<EOL><INDENT>return {"<STR_LIT:version>": dirname[len(parentdir_prefix):],<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT>": False, "<STR_LIT:error>": None, "<STR_LIT:date>": None}<EOL><DEDENT>e... | Try to determine the version from the parent directory name.
Source tarballs conventionally unpack into a directory that includes both
the project name and a version string. We will also support searching up
two directory levels for an appropriately named parent directory | f5919:m4 |
@register_vcs_handler("<STR_LIT>", "<STR_LIT>")<EOL>def git_get_keywords(versionfile_abs): | <EOL>keywords = {}<EOL>try:<EOL><INDENT>f = open(versionfile_abs, "<STR_LIT:r>")<EOL>for line in f.readlines():<EOL><INDENT>if line.strip().startswith("<STR_LIT>"):<EOL><INDENT>mo = re.search(r'<STR_LIT>', line)<EOL>if mo:<EOL><INDENT>keywords["<STR_LIT>"] = mo.group(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>if line.strip().sta... | Extract version information from the given file. | f5919:m5 |
@register_vcs_handler("<STR_LIT>", "<STR_LIT>")<EOL>def git_versions_from_keywords(keywords, tag_prefix, verbose): | if not keywords:<EOL><INDENT>raise NotThisMethod("<STR_LIT>")<EOL><DEDENT>date = keywords.get("<STR_LIT:date>")<EOL>if date is not None:<EOL><INDENT>date = date.strip().replace("<STR_LIT:U+0020>", "<STR_LIT:T>", <NUM_LIT:1>).replace("<STR_LIT:U+0020>", "<STR_LIT>", <NUM_LIT:1>)<EOL><DEDENT>refnames = keywords["<STR_LIT... | Get version information from git keywords. | f5919:m6 |
@register_vcs_handler("<STR_LIT>", "<STR_LIT>")<EOL>def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command): | GITS = ["<STR_LIT>"]<EOL>if sys.platform == "<STR_LIT:win32>":<EOL><INDENT>GITS = ["<STR_LIT>", "<STR_LIT>"]<EOL><DEDENT>out, rc = run_command(GITS, ["<STR_LIT>", "<STR_LIT>"], cwd=root,<EOL>hide_stderr=True)<EOL>if rc != <NUM_LIT:0>:<EOL><INDENT>if verbose:<EOL><INDENT>print("<STR_LIT>" % root)<EOL><DEDENT>raise NotTh... | Get version from 'git describe' in the root of the source tree.
This only gets called if the git-archive 'subst' keywords were *not*
expanded, and _version.py hasn't already been rewritten with a short
version string, meaning we're inside a checked out source tree. | f5919:m7 |
def plus_or_dot(pieces): | if "<STR_LIT:+>" in pieces.get("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>return "<STR_LIT:.>"<EOL><DEDENT>return "<STR_LIT:+>"<EOL> | Return a + if we don't already have one, else return a . | f5919:m8 |
def render_pep440(pieces): | if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"] or pieces["<STR_LIT>"]:<EOL><INDENT>rendered += plus_or_dot(pieces)<EOL>rendered += "<STR_LIT>" % (pieces["<STR_LIT>"], pieces["<STR_LIT>"])<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT><DEDENT><... | Build up version string, with post-release "local version identifier".
Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
Exceptions:
1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty] | f5919:m9 |
def render_pep440_pre(pieces): | if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>" % pieces["<STR_LIT>"]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>rendered = "<STR_LIT>" % pieces["<STR_LIT>"]<EOL><DEDENT>return rendered<EOL> | TAG[.post.devDISTANCE] -- No -dirty.
Exceptions:
1: no tags. 0.post.devDISTANCE | f5919:m10 |
def render_pep440_post(pieces): | if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"] or pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>" % pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT>rendered += plus_or_dot(pieces)<EOL>rendered += "<STR_LIT>" % pieces... | TAG[.postDISTANCE[.dev0]+gHEX] .
The ".dev0" means dirty. Note that .dev0 sorts backwards
(a dirty tree will appear "older" than the corresponding clean one),
but you shouldn't be releasing software with -dirty anyways.
Exceptions:
1: no tags. 0.postDISTANCE[.dev0] | f5919:m11 |
def render_pep440_old(pieces): | if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"] or pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>" % pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>rendered = "<STR_LIT>" % pieces["<... | TAG[.postDISTANCE[.dev0]] .
The ".dev0" means dirty.
Eexceptions:
1: no tags. 0.postDISTANCE[.dev0] | f5919:m12 |
def render_git_describe(pieces): | if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>" % (pieces["<STR_LIT>"], pieces["<STR_LIT>"])<EOL><DEDENT><DEDENT>else:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL><DEDENT>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL... | TAG[-DISTANCE-gHEX][-dirty].
Like 'git describe --tags --dirty --always'.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix) | f5919:m13 |
def render_git_describe_long(pieces): | if pieces["<STR_LIT>"]:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL>rendered += "<STR_LIT>" % (pieces["<STR_LIT>"], pieces["<STR_LIT>"])<EOL><DEDENT>else:<EOL><INDENT>rendered = pieces["<STR_LIT>"]<EOL><DEDENT>if pieces["<STR_LIT>"]:<EOL><INDENT>rendered += "<STR_LIT>"<EOL><DEDENT>return rendered<EOL> | TAG-DISTANCE-gHEX[-dirty].
Like 'git describe --tags --dirty --always -long'.
The distance/hash is unconditional.
Exceptions:
1: no tags. HEX[-dirty] (note: no 'g' prefix) | f5919:m14 |
def render(pieces, style): | if pieces["<STR_LIT:error>"]:<EOL><INDENT>return {"<STR_LIT:version>": "<STR_LIT>",<EOL>"<STR_LIT>": pieces.get("<STR_LIT>"),<EOL>"<STR_LIT>": None,<EOL>"<STR_LIT:error>": pieces["<STR_LIT:error>"],<EOL>"<STR_LIT:date>": None}<EOL><DEDENT>if not style or style == "<STR_LIT:default>":<EOL><INDENT>style = "<STR_LIT>" <E... | Render the given version pieces into the requested style. | f5919:m15 |
def get_versions(): | <EOL>cfg = get_config()<EOL>verbose = cfg.verbose<EOL>try:<EOL><INDENT>return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,<EOL>verbose)<EOL><DEDENT>except NotThisMethod:<EOL><INDENT>pass<EOL><DEDENT>try:<EOL><INDENT>root = os.path.realpath(__file__)<EOL>for i in cfg.versionfile_source.split('<STR_LIT:/>')... | Get version information or return default if unable to do so. | f5919:m16 |
def initial_setup(): | warnings.warn('<STR_LIT>', DeprecationWarning)<EOL>gdk.threads_init()<EOL>gobject.threads_init()<EOL> | * set up gdk threading
* enter it
* set up glib mainloop threading
.. versionchanged:: 0.18
Do not execute ``gdk.threads_enter()``.
``gdk.threads_enter()/gdk.threads_leave()`` should only be used to wrap
GTK code blocks.
See `What are the general tips for using threads with PyGTK?
<http://faq.pyg... | f5920:m0 |
def gcall(func, *args, **kwargs): | def idle():<EOL><INDENT>with gdk.lock:<EOL><INDENT>return bool(func(*args, **kwargs))<EOL><DEDENT><DEDENT>return gobject.idle_add(idle)<EOL> | Calls a function, with the given arguments inside Gtk's main loop.
Example::
gcall(lbl.set_text, "foo")
If this call would be made in a thread there could be problems, using
it inside Gtk's main loop makes it thread safe. | f5920:m1 |
def invoke_in_mainloop(func, *args, **kwargs): | results = queue.Queue()<EOL>@gcall<EOL>def run():<EOL><INDENT>try:<EOL><INDENT>data = func(*args, **kwargs)<EOL>results.put(data)<EOL>results.put(None)<EOL><DEDENT>except BaseException: <EOL><INDENT>results.put(None)<EOL>results.put(sys.exc_info())<EOL>raise<EOL><DEDENT><DEDENT>data = results.get()<EOL>exception = res... | Invoke a function in the mainloop, pass the data back. | f5920:m2 |
def gtk_threadsafe(func): | <EOL>gtk.gdk.threads_init()<EOL>wraps_func = func.func if isinstance(func, functools.partial) else func<EOL>@functools.wraps(wraps_func)<EOL>def _gtk_threadsafe(*args):<EOL><INDENT>def _no_return_func(*args):<EOL><INDENT>func(*args)<EOL><DEDENT>gobject.idle_add(_no_return_func, *args)<EOL><DEDENT>return _gtk_threadsafe... | Decorator to make wrapped function threadsafe by forcing it to execute
within the GTK main thread.
.. versionadded:: 0.18
.. versionchanged:: 0.22
Add support for keyword arguments in callbacks by supporting functions
wrapped by `functools.partial()`. Also, ignore callback return value
to prevent callbac... | f5920:m3 |
def start(self, *args, **kwargs): | args = (self.counter,) + args<EOL>thread = threading.Thread(<EOL>target=self._work_callback,<EOL>args=args, kwargs=kwargs<EOL>)<EOL>_thread.setDaemon(self.daemon)<EOL>_thread.start()<EOL> | Start the task.
This is:
* not threadsave
* assumed to be called in the gtk mainloop | f5920:c0:m1 |
def parse_args(args=None): | if args is None:<EOL><INDENT>args = sys.argv<EOL><DEDENT>parser = ArgumentParser(description='<STR_LIT>'<EOL>'<STR_LIT>')<EOL>log_levels = ('<STR_LIT>', '<STR_LIT:error>', '<STR_LIT>', '<STR_LIT:info>', '<STR_LIT>', '<STR_LIT>')<EOL>parser.add_argument('<STR_LIT>', '<STR_LIT>', type=str, choices=log_levels,<EOL>default... | Parses arguments, returns (options, args). | f5921:m0 |
def __init__(self, form_class, title=None, short_desc=None, long_desc=None,<EOL>parent=None): | self.title = title<EOL>self.short_desc = short_desc<EOL>self.long_desc = long_desc<EOL>self.parent = parent<EOL>self.form_class = form_class<EOL> | Parameters
----------
title : str, optional
The short description
short_desc : str, optional
The short description
long_desc : str, optional
The long description
parent : gtk.Window, optional
The parent window to make this dialog transient to | f5923:c0:m0 |
def create_ui(self): | builder = gtk.Builder()<EOL>glade_str = pkgutil.get_data(__name__,<EOL>'<STR_LIT>')<EOL>builder.add_from_string(glade_str)<EOL>self.window = builder.get_object('<STR_LIT>')<EOL>self.vbox_form = builder.get_object('<STR_LIT>')<EOL>if self.title:<EOL><INDENT>self.window.set_title(self.title)<EOL><DEDENT>if self.short_des... | .. versionchanged:: 0.21.2
Load the builder configuration file using :func:`pkgutil.getdata`,
which supports loading from `.zip` archives (e.g., in an app
packaged with Py2Exe). | f5923:c0:m1 |
def simple(type, short, long=None,<EOL>parent=None, buttons=gtk.BUTTONS_OK, default=None, **kw): | if buttons == gtk.BUTTONS_OK:<EOL><INDENT>default = gtk.RESPONSE_OK<EOL><DEDENT>return _message_dialog(type, short, long, parent=parent, buttons=buttons,<EOL>default=default, **kw)<EOL> | A simple dialog
:param type: The type of dialog
:param short: The short description
:param long: The long description
:param parent: The parent Window to make this dialog transient to
:param buttons: A buttons enum
:param default: A default response | f5924:m2 |
def open_filechooser(title, parent=None, patterns=None,<EOL>folder=None, filter=None, multiple=False,<EOL>_before_run=None, action=None): | assert not (patterns and filter)<EOL>if multiple:<EOL><INDENT>if action is not None and action != gtk.FILE_CHOOSER_ACTION_OPEN:<EOL><INDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>action = gtk.FILE_CHOOSER_ACTION_OPEN<EOL><DEDENT>else:<EOL><INDENT>assert action is not None<EOL><DEDENT>filechooser = gt... | An open dialog.
:param parent: window or None
:param patterns: file match patterns
:param folder: initial folder
:param filter: file filter
Use of filter and patterns at the same time is invalid. | f5924:m3 |
def save(title='<STR_LIT>', parent=None, current_name='<STR_LIT>', folder=None,<EOL>_before_run=None, _before_overwrite=None): | filechooser = gtk.FileChooserDialog(title, parent,<EOL>gtk.FILE_CHOOSER_ACTION_SAVE,<EOL>(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,<EOL>gtk.STOCK_SAVE, gtk.RESPONSE_OK))<EOL>if current_name:<EOL><INDENT>filechooser.set_current_name(current_name)<EOL><DEDENT>filechooser.set_default_response(gtk.RESPONSE_OK)<EOL>if folder:<... | Displays a save dialog. | f5924:m5 |
def animation_dialog(images, delay_s=<NUM_LIT:1.>, loop=True, **kwargs): | def _as_pixbuf(image):<EOL><INDENT>if isinstance(image, types.StringTypes):<EOL><INDENT>return gtk.gdk.pixbuf_new_from_file(image)<EOL><DEDENT>else:<EOL><INDENT>return image<EOL><DEDENT><DEDENT>pixbufs = map(_as_pixbuf, images)<EOL>gtk.gdk.threads_init()<EOL>dialog = gtk.MessageDialog(**kwargs)<EOL>image = gtk.Image()<... | .. versionadded:: v0.19
Parameters
----------
images : list
Filepaths to images or :class:`gtk.Pixbuf` instances.
delay_s : float, optional
Number of seconds to display each frame.
Default: ``1.0``.
loop : bool, optional
If ``True``, restart animation after last image has been displayed.
Default:... | f5924:m7 |
def create_model(self): | raise NotImplementedError<EOL> | Create the TreeModel instance.
This abstract method must be implemented for subclasses. The concrete
model should be created and returned.
:rtype: gtk.TreeModel | f5925:c0:m1 |
def __len__(self): | return len(self.model)<EOL> | Number of items in this list | f5925:c0:m2 |
def __contains__(self, item): | return id(item) in self._id_to_iter<EOL> | Identity based check of membership
:param item: The item to check membership for | f5925:c0:m3 |
def __iter__(self): | for row in self.model:<EOL><INDENT>yield row[<NUM_LIT:0>]<EOL><DEDENT> | Iterable | f5925:c0:m4 |
def _get_selected_item(self): | selection = self.get_selection()<EOL>if selection.get_mode() != gtk.SELECTION_SINGLE:<EOL><INDENT>raise AttributeError('<STR_LIT>')<EOL><DEDENT>model, selected = selection.get_selected()<EOL>if selected is not None:<EOL><INDENT>return self._object_at_sort_iter(selected)<EOL><DEDENT> | The currently selected item | f5925:c0:m9 |
def _get_selected_items(self): | selection = self.get_selection()<EOL>if selection.get_mode() != gtk.SELECTION_MULTIPLE:<EOL><INDENT>raise AttributeError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>model, selected_paths = selection.get_selected_rows()<EOL>result = []<EOL>for path in selected_paths:<EOL><INDENT>result.append(model[path][<NUM_LIT:0>])<EOL>... | List of currently selected items | f5925:c0:m11 |
def _get_selected_ids(self): | selection = self.get_selection()<EOL>if selection.get_mode() != gtk.SELECTION_MULTIPLE:<EOL><INDENT>raise AttributeError('<STR_LIT>')<EOL><DEDENT>model, selected_paths = selection.get_selected_rows()<EOL>if selected_paths:<EOL><INDENT>return zip(*selected_paths)[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>return ()<EOL>... | List of currently selected ids | f5925:c0:m15 |
def clear(self): | self.model.clear()<EOL>self._id_to_iter.clear()<EOL> | Clear all the items in the list | f5925:c0:m17 |
def update(self, item): | self.model.set(self._iter_for(item), <NUM_LIT:0>, item)<EOL> | Manually update an item's display in the list
:param item: The item to be updated. | f5925:c0:m18 |
def move_item_down(self, item): | next_iter = self._next_iter_for(item)<EOL>if next_iter is not None:<EOL><INDENT>self.model.swap(self._iter_for(item), next_iter)<EOL><DEDENT> | Move an item down in the list.
Essentially swap it with the item below it.
:param item: The item to be moved. | f5925:c0:m19 |
def move_item_up(self, item): | prev_iter = self._prev_iter_for(item)<EOL>if prev_iter is not None:<EOL><INDENT>self.model.swap(prev_iter, self._iter_for(item))<EOL><DEDENT> | Move an item up in the list.
Essentially swap it with the item above it.
:param item: The item to be moved. | f5925:c0:m20 |
def item_after(self, item): | next_iter = self._next_iter_for(item)<EOL>if next_iter is not None:<EOL><INDENT>return self._object_at_iter(next_iter)<EOL><DEDENT> | The item after an item | f5925:c0:m21 |
def item_before(self, item): | prev_iter = self._prev_iter_for(item)<EOL>if prev_iter is not None:<EOL><INDENT>return self._object_at_iter(prev_iter)<EOL><DEDENT> | The item before an item
:param item: The item to get the previous item relative to | f5925:c0:m22 |
def set_visible_func(self, visible_func): | self.model_filter.set_visible_func(<EOL>self._internal_visible_func,<EOL>visible_func,<EOL>)<EOL>self._visible_func = visible_func<EOL>self.model_filter.refilter()<EOL> | Set the function to decide visibility of an item
:param visible_func: A callable that returns a boolean result to
decide if an item should be visible, for
example::
def is_visible(item):
... | f5925:c0:m23 |
def item_visible(self, item): | return self._visible_func(item)<EOL> | Return whether an item is visible
:param item: The item to test visibility
:rtype: bool | f5925:c0:m24 |
def sort_by(self, attr_or_key, direction='<STR_LIT>'): | <EOL>if direction in ('<STR_LIT:+>', '<STR_LIT>', gtk.SORT_ASCENDING):<EOL><INDENT>direction = gtk.SORT_ASCENDING<EOL><DEDENT>elif direction in ('<STR_LIT:->', '<STR_LIT>', gtk.SORT_DESCENDING):<EOL><INDENT>direction = gtk.SORT_DESCENDING<EOL><DEDENT>else:<EOL><INDENT>raise AttributeError('<STR_LIT>')<EOL><DEDENT>if ca... | Sort the view by an attribute or key
:param attr_or_key: The attribute or key to sort by
:param direction: Either `asc` or `desc` indicating the direction of
sorting | f5925:c0:m25 |
def remove(self, item): | if item not in self:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>item_id = int(self._view_path_for(item))<EOL>giter = self._iter_for(item)<EOL>del self[giter]<EOL>self.emit('<STR_LIT>', item, item_id)<EOL> | Remove an item from the list
:param item: The item to remove from the list.
:raises ValueError: If the item is not present in the list. | f5925:c1:m0 |
def insert(self, position, item, select=False): | if item in self:<EOL><INDENT>raise ValueError("<STR_LIT>" % item)<EOL><DEDENT>modeliter = self.model.insert(position, (item,))<EOL>self._id_to_iter[id(item)] = modeliter<EOL>if select:<EOL><INDENT>self.selected_item = item<EOL><DEDENT>self.emit('<STR_LIT>', item, position)<EOL> | Insert an item at the specified position in the list.
:param position: The position to insert the item at
:param item: The item to be added
:param select: Whether the item should be selected after adding | f5925:c1:m2 |
def append(self, item, select=False): | if item in self:<EOL><INDENT>raise ValueError("<STR_LIT>" % item)<EOL><DEDENT>modeliter = self.model.append((item,))<EOL>self._id_to_iter[id(item)] = modeliter<EOL>if select:<EOL><INDENT>self.selected_item = item<EOL><DEDENT>self.emit('<STR_LIT>', item)<EOL> | Add an item to the end of the list.
:param item: The item to be added
:param select: Whether the item should be selected after adding | f5925:c1:m3 |
def extend(self, iter): | for item in iter:<EOL><INDENT>self.append(item)<EOL><DEDENT> | Add a sequence of items to the end of the list
:param iter: The iterable of items to add. | f5925:c1:m4 |
def append(self, item, parent=None, select=False): | if item in self:<EOL><INDENT>raise ValueError("<STR_LIT>" % item)<EOL><DEDENT>if parent is not None:<EOL><INDENT>giter = self._iter_for(parent)<EOL><DEDENT>else:<EOL><INDENT>giter = None<EOL><DEDENT>modeliter = self.model.append(giter, (item,))<EOL>self._id_to_iter[id(item)] = modeliter<EOL>if select:<EOL><INDENT>self.... | Add an item to the end of the list.
:param item: The item to be added
:param parent: The parent item to add this as a child of, or None for
a top-level node
:param select: Whether the item should be selected after adding | f5925:c5:m2 |
def extend(self, iter, parent=None): | for item in iter:<EOL><INDENT>self.append(item, parent)<EOL><DEDENT> | Add a sequence of items to the end of the list
:param iter: The iterable of items to add.
:param parent: The node to add the items as a child of, or None for
top-level nodes. | f5925:c5:m3 |
def expand_item(self, item, open_all=True): | self.expand_row(self._view_path_for(item), open_all)<EOL> | Display a node as expanded
:param item: The item to show expanded
:param open_all: Whether all child nodes should be recursively
expanded. | f5925:c5:m4 |
def collapse_item(self, item): | self.collapse_row(self._path_for(item))<EOL> | Display a node as collapsed
:param item: The item to show collapsed | f5925:c5:m5 |
def item_expanded(self, item): | return self.row_expanded(self._path_for(item))<EOL> | Return whether an item is expanded or collapsed
:param item: The item that is queried for expanded state | f5925:c5:m6 |
def insert(self, parent, position, item, select=False): | if item in self:<EOL><INDENT>raise ValueError("<STR_LIT>" % item)<EOL><DEDENT>modeliter = self.model.insert(parent, position, (item,))<EOL>self._id_to_iter[id(item)] = modeliter<EOL>if select:<EOL><INDENT>self.selected_item = item<EOL><DEDENT>item_path = self._view_path_for(item)<EOL>self.emit('<STR_LIT>', item, item_p... | Insert an item at the specified position in the list.
:param position: The position to insert the item at
:param item: The item to be added
:param select: Whether the item should be selected after adding | f5925:c5:m19 |
def remove(self, item): | if item not in self:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>item_path = self._view_path_for(item)<EOL>giter = self._iter_for(item)<EOL>del self[giter]<EOL>self.emit('<STR_LIT>', item, item_path)<EOL> | Remove an item from the list
:param item: The item to remove from the list.
:raises ValueError: If the item is not present in the list. | f5925:c5:m25 |
def __iter__(self): | if self:<EOL><INDENT>for item in self._iter_siblings(self[<NUM_LIT:0>]):<EOL><INDENT>yield item<EOL><DEDENT><DEDENT> | Iterable | f5925:c5:m34 |
def uuid4(): | <EOL>try:<EOL><INDENT>import os<EOL>return UUID(bytes=os.urandom(<NUM_LIT:16>), version=<NUM_LIT:4>)<EOL><DEDENT>except Exception:<EOL><INDENT>import random<EOL>bytes = [chr(random.randrange(<NUM_LIT>)) for i in range(<NUM_LIT:16>)]<EOL>return UUID(bytes=bytes, version=<NUM_LIT:4>)<EOL><DEDENT> | Generate a random UUID. | f5926:m0 |
def uuid5(namespace, name): | from hashlib import sha1<EOL>hash = sha1(namespace.bytes + name).digest()<EOL>return UUID(bytes=hash[:<NUM_LIT:16>], version=<NUM_LIT:5>)<EOL> | Generate a UUID from the SHA-1 hash of a namespace UUID and a name. | f5926:m1 |
def __init__(self, hex=None, bytes=None, bytes_le=None, fields=None,<EOL>int=None, version=None): | if [hex, bytes, bytes_le, fields, int].count(None) != <NUM_LIT:4>:<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>if hex is not None:<EOL><INDENT>hex = hex.replace('<STR_LIT>', '<STR_LIT>').replace('<STR_LIT>', '<STR_LIT>')<EOL>hex = hex.strip('<STR_LIT:{}>').replace('<STR_LIT:->', '<STR_LIT>')<EOL>if len(hex) !=... | r"""Create a UUID from either a string of 32 hexadecimal digits,
a string of 16 bytes as the 'bytes' argument, a string of 16 bytes
in little-endian order as the 'bytes_le' argument, a tuple of six
integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version,
8-bit clock_seq_hi_var... | f5926:c0:m0 |
def create_treecolumn(self, objectlist): | col = gtk.TreeViewColumn(self.title)<EOL>col.set_data('<STR_LIT>', objectlist)<EOL>col.set_data('<STR_LIT>', self)<EOL>col.props.visible = self.visible<EOL>if self.expand is not None:<EOL><INDENT>col.props.expand = self.expand<EOL><DEDENT>if self.resizable is not None:<EOL><INDENT>col.props.resizable = self.resizable<E... | Create a gtk.TreeViewColumn for the configuration. | f5927:c3:m1 |
def search_by(self, objectlist): | objectlist.set_search_equal_func(self._search_equal_func)<EOL> | Search by this column on an ObjectList
:param objectlist: An ObjectList or ObjectTree | f5927:c3:m3 |
def render_tooltip(self, tooltip, obj): | if self.tooltip_attr:<EOL><INDENT>val = getattr(obj, self.tooltip_attr)<EOL><DEDENT>elif self.tooltip_value:<EOL><INDENT>val = self.tooltip_value<EOL><DEDENT>else:<EOL><INDENT>return False<EOL><DEDENT>setter = getattr(tooltip, TOOLTIP_SETTERS.get(self.tooltip_type))<EOL>if self.tooltip_type in TOOLTIP_SIZED_TYPES:<EOL>... | Render the tooltip for this column for an object | f5927:c3:m4 |
def get_py_dtype(np_dtype): | if np_dtype.type == np.object_:<EOL><INDENT>return object<EOL><DEDENT>elif hasattr(np_dtype.type(<NUM_LIT:0>), '<STR_LIT>'):<EOL><INDENT>return type(np_dtype.type(<NUM_LIT:0>).item())<EOL><DEDENT>else:<EOL><INDENT>return type(np_dtype.type(<NUM_LIT:0>))<EOL><DEDENT> | Args:
np_dtype (numpy.dtype)
Returns:
(type) : Python data type that corresponds to the specified numpy
dtype. | f5928:m0 |
def get_py_dtypes(data_frame): | df_py_dtypes = data_frame.dtypes.map(get_py_dtype).to_frame('<STR_LIT>').copy()<EOL>df_py_dtypes.loc[df_py_dtypes.dtype == object, '<STR_LIT>'] =(df_py_dtypes.loc[df_py_dtypes.dtype == object].index<EOL>.map(lambda c: str if data_frame[c]<EOL>.map(lambda v: isinstance(v, str)).all() else object))<EOL>df_py_dtypes.inser... | Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame`.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
(pandas.DataFrame) : Data frame indexed by the column names from
`data_frame`, with the columns `'i'` and `'dtype'` indic... | f5928:m1 |
def get_list_store(data_frame): | df_py_dtypes = get_py_dtypes(data_frame)<EOL>list_store = gtk.ListStore(*df_py_dtypes.dtype)<EOL>for i, row_i in data_frame.iterrows():<EOL><INDENT>list_store.append(row_i.tolist())<EOL><DEDENT>return df_py_dtypes, list_store<EOL> | Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame` and a `gtk.ListStore` matching the contents of the
data frame.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
(tuple) : The first element is a data frame as returned by
... | f5928:m2 |
def add_columns(tree_view, df_py_dtypes, list_store): | tree_view.set_model(list_store)<EOL>for column_i, (i, dtype_i) in df_py_dtypes[['<STR_LIT:i>', '<STR_LIT>']].iterrows():<EOL><INDENT>tree_column_i = gtk.TreeViewColumn(column_i)<EOL>tree_column_i.set_name(column_i)<EOL>if dtype_i in (int, long):<EOL><INDENT>property_name = '<STR_LIT:text>'<EOL>cell_renderer_i = gtk.Cel... | Add columns to a `gtk.TreeView` for the types listed in `df_py_dtypes`.
Args:
tree_view (gtk.TreeView) : Tree view to append columns to.
df_py_dtypes (pandas.DataFrame) : Data frame containing type
information for one or more columns in `list_store`.
list_store (gtk.ListStore) : Model data.
Retur... | f5928:m3 |
def set_column_format(tree_column, model_column_index, format_str,<EOL>cell_renderer=None): | def set_property(column, cell_renderer, list_store, iter, store_i):<EOL><INDENT>value = list_store[iter][store_i]<EOL>cell_renderer.set_property('<STR_LIT:text>', format_str.format(value=value))<EOL><DEDENT>if cell_renderer is None:<EOL><INDENT>cells = tree_column.get_cells()<EOL><DEDENT>else:<EOL><INDENT>cells = [cell... | Set the text of a cell according to a [format][1] string.
[1]: https://docs.python.org/2/library/string.html#formatstrings
Args:
tree_column (gtk.TreeViewColumn) : Tree view to append columns to.
model_column_index (int) : Index in list store model corresponding to
tree view column.
format_str (s... | f5928:m4 |
def set_column_si_format(tree_column, model_column_index, cell_renderer=None,<EOL>digits=<NUM_LIT:2>): | def set_property(column, cell_renderer, list_store, iter, store_i):<EOL><INDENT>cell_renderer.set_property('<STR_LIT:text>', si_format(list_store[iter][store_i],<EOL>digits))<EOL><DEDENT>if cell_renderer is None:<EOL><INDENT>cells = tree_column.get_cells()<EOL><DEDENT>else:<EOL><INDENT>cells = [cell_renderer]<EOL><DEDE... | Set the text of a numeric cell according to [SI prefixes][1]
For example, `1000 -> '1.00k'`.
[1]: https://en.wikipedia.org/wiki/Metric_prefix#List_of_SI_prefixes
Args:
tree_column (gtk.TreeViewColumn) : Tree view to append columns to.
model_column_index (int) : Index in list store model corresponding to
... | f5928:m5 |
def on_edited_dataframe_sync(cell_renderer, iter, new_value, column,<EOL>df_py_dtypes, list_store, df_data): | <EOL>column_name = column.get_name()<EOL>i, dtype = df_py_dtypes.ix[column_name]<EOL>if dtype == float:<EOL><INDENT>value = si_parse(new_value)<EOL><DEDENT>elif dtype == bool:<EOL><INDENT>value = not list_store[iter][i]<EOL><DEDENT>if value == list_store[iter][i]:<EOL><INDENT>return False<EOL><DEDENT>list_store[iter][i... | Handle the `'edited'` signal from a `gtk.CellRenderer` to:
* Update the corresponding entry in the list store.
* Update the corresponding entry in the provided data frame instance.
The callback can be connected to the cell renderer as follows:
cell_renderer.connect('edited', on_edited_dataframe_sync, column,
... | f5928:m6 |
def _update_row_fields(self, form_name, row_id, attrs): | if form_name not in self._forms or row_id >= len(self):<EOL><INDENT>return<EOL><DEDENT>combined_row = self[row_id]<EOL>form_row = combined_row.get_row_fields(form_name)<EOL>for attr, value in attrs.items():<EOL><INDENT>setattr(form_row, attr, value)<EOL><DEDENT>self.update(combined_row)<EOL> | -get row values for (form_name, row_id)
-set affected objectlist item attributes based on row values | f5929:c1:m8 |
def __init__(self, patterns=None): | gtk.HBox.__init__(self, spacing=<NUM_LIT:3>)<EOL>self.set_border_width(<NUM_LIT:6>)<EOL>self.set_size_request(<NUM_LIT>, -<NUM_LIT:1>)<EOL>self.filepath_entry = gtk.Entry()<EOL>self.filepath_entry.set_editable(False)<EOL>self.browse_button = gtk.Button(label='<STR_LIT>')<EOL>self.browse_button.connect('<STR_LIT>', self... | Args
----
patterns (list) : List of tuples, where each tuple contains two
items: 1) label to show in file filter drop-down, and 2) list
of glob file patterns to match. | f5931:c2:m0 |
def _attr_sort_func(model, iter1, iter2, attribute): | attr1 = getattr(model[iter1][<NUM_LIT:0>], attribute, None)<EOL>attr2 = getattr(model[iter2][<NUM_LIT:0>], attribute, None)<EOL>return cmp(attr1, attr2)<EOL> | Internal helper | f5932:m0 |
def set_empty(self): | self.buffer.props.text = '<STR_LIT>'<EOL> | Display a bank text view | f5932:c3:m3 |
def set_empty_text(self): | self.buffer.insert_with_tags_by_name(<EOL>self.buffer.get_start_iter(),<EOL>self.empty_text, '<STR_LIT>')<EOL> | Display the empty text | f5932:c3:m4 |
def on_new(self, button): | buttons = (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,<EOL>gtk.STOCK_OPEN, gtk.RESPONSE_OK)<EOL>dialog = gtk.FileChooserDialog("<STR_LIT>", self.parent,<EOL>gtk.FILE_CHOOSER_ACTION_OPEN, buttons)<EOL>add_filters(dialog, [{'<STR_LIT:name>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>'}])<EOL>if self.template_dir is not None:<EO... | Copy selected notebook template to notebook directory.
## Notes ##
- An exception is raised if the parent of the selected file is the
notebook directory.
- If notebook with same name already exists in notebook directory,
offer is made to overwrite (the new copy of the file is renamed with
a count if overwr... | f5934:c0:m6 |
def combobox_set_model_from_list(cb, items): | cb.clear()<EOL>model = gtk.ListStore(str)<EOL>for i in items:<EOL><INDENT>model.append([i])<EOL><DEDENT>cb.set_model(model)<EOL>if type(cb) == gtk.ComboBoxEntry:<EOL><INDENT>cb.set_text_column(<NUM_LIT:0>)<EOL><DEDENT>elif type(cb) == gtk.ComboBox:<EOL><INDENT>cell = gtk.CellRendererText()<EOL>cb.pack_start(cell, True)... | Setup a ComboBox or ComboBoxEntry based on a list of strings. | f5936:m0 |
def get_run_command_dialog(command, shell=False, title='<STR_LIT>', data_callback=None,<EOL>parent=None, **kwargs): | dialog = gtk.Dialog(title=title or None, parent=parent)<EOL>dialog.set_size_request(<NUM_LIT>, -<NUM_LIT:1>)<EOL>for key, value in kwargs.items():<EOL><INDENT>setattr(dialog.props, key, value)<EOL><DEDENT>dialog.add_buttons(gtk.STOCK_OK, gtk.RESPONSE_OK)<EOL>dialog.set_default_response(gtk.RESPONSE_OK)<EOL>content_area... | Launch command in a subprocess and create a dialog window to monitor the
output of the process.
Parameters
----------
command : list or str
Subprocess command to execute.
shell : bool, optional
If :data:`shell` is ``False``, :data:`command` **must** be a
:class:`list`.
If :data:`shell` is ``True``, :d... | f5938:m0 |
def find_closest(df_points, point): | return df_points.iloc[((df_points - point) ** <NUM_LIT:2>).sum(axis=<NUM_LIT:1>).values<EOL>.argmin()]<EOL> | Parameters
----------
df_points : pandas.DataFrame
Table with at least ``x`` and ``y`` columns.
point : pandas.Series
Series with at least ``x`` and ``y`` keys.
Returns
-------
pandas.Series
Row of :data:`df_points` table with point closest to specified
:data:`point`.
.. versionchanged:: 0.21
Dis... | f5940:m0 |
def parse_args(args=None): | import sys<EOL>from argparse import ArgumentParser<EOL>from path_helpers import path<EOL>if args is None:<EOL><INDENT>args = sys.argv<EOL><DEDENT>parser = ArgumentParser(description='<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>parser.add_argument('<STR_LIT>', type=path, default=None)<EOL>parser.add_argument('<STR_L... | Parses arguments, returns (options, args). | f5941:m0 |
def create_ui(self): | super(GtkShapesCanvasView, self).create_ui()<EOL>self.widget.set_events(gtk.gdk.BUTTON_PRESS |<EOL>gtk.gdk.BUTTON_RELEASE |<EOL>gtk.gdk.BUTTON_MOTION_MASK |<EOL>gtk.gdk.BUTTON_PRESS_MASK |<EOL>gtk.gdk.BUTTON_RELEASE_MASK |<EOL>gtk.gdk.POINTER_MOTION_HINT_MASK)<EOL>self._dirty_check_timeout_id = gtk.timeout_add(<NUM_LIT... | .. versionchanged:: 0.20
Debounce window expose and resize handlers to improve
responsiveness.
.. versionchanged:: X.X.X
Call debounced `_on_expose_event` handler on _leading_ edge to make
UI update more responsive when, e.g., changing window focus.
Decrease debounce time to 250 ms. | f5941:c0:m2 |
def check_dirty(self): | if self._dirty_size is None:<EOL><INDENT>if self._dirty_render:<EOL><INDENT>self.render()<EOL>self._dirty_render = False<EOL><DEDENT>if self._dirty_draw:<EOL><INDENT>self.draw()<EOL>self._dirty_draw = False<EOL><DEDENT>return True<EOL><DEDENT>width, height = self._dirty_size<EOL>self._dirty_size = None<EOL>self.reset_c... | .. versionchanged:: 0.20
Do not log size change. | f5941:c0:m6 |
def on_widget__configure_event(self, widget, event): | if event.x < <NUM_LIT:0> and event.y < <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>self.resize(event.width, event.height)<EOL> | Called when size of drawing area changes. | f5941:c0:m7 |
def _resize(self, width, height): | self._dirty_size = width, height<EOL>self.reset_canvas(width, height)<EOL>self.draw()<EOL>self._dirty_draw = True<EOL> | .. versionadded:: 0.20
Clear canvas, draw frame off screen, and mark dirty.
..notes::
This method is debounced to improve responsiveness. | f5941:c0:m8 |
def _on_expose_event(self, widget, event): | logger.info('<STR_LIT>')<EOL>self.draw()<EOL>self._dirty_draw = True<EOL> | .. versionchanged:: 0.20
Renamed from ``on_widget__expose_event`` to allow wrapping for
debouncing to improve responsiveness.
Called when drawing area is first displayed and, for example, when part
of drawing area is uncovered after being covered up by another window.
Clear canvas, draw frame off screen, and ... | f5941:c0:m9 |
def render_label(self, cairo_context, shape_id, text=None, label_scale=<NUM_LIT>): | text = shape_id if text is None else text<EOL>shape = self.canvas.df_bounding_shapes.ix[shape_id]<EOL>shape_center = self.canvas.df_shape_centers.ix[shape_id]<EOL>font_size, text_shape =aspect_fit_font_size(text, shape * label_scale,<EOL>cairo_context=cairo_context)<EOL>cairo_context.set_font_size(font_size)<EOL>cairo_... | Draw label on specified shape.
Parameters
----------
cairo_context : cairo.Context
Cairo context to draw text width. Can be preconfigured, for
example, to set font style, etc.
shape_id : str
Shape identifier.
text : str, optional
Label text. If not specified, shape identifier is used.
label_scale : f... | f5941:c0:m12 |
def set_surfaces(self, df_surfaces): | for column in self.treeview_layers.get_columns():<EOL><INDENT>self.treeview_layers.remove_column(column)<EOL><DEDENT>self.df_surfaces = pd.DataFrame(df_surfaces.index.values,<EOL>columns=[df_surfaces.index.name or<EOL>'<STR_LIT:index>'],<EOL>index=df_surfaces.index)<EOL>if '<STR_LIT>' in df_surfaces:<EOL><INDENT>self.d... | Reset the contents of the tree view to show one row per surface, with
a column containing the alpha multiplier for the corresponding surface
(in the range [0, 1]), indexed by surface name.
For example:
| index | alpha |
|--------|--------|
| layer1 | 1.00 |
| layer2 | 0.65 |
| ... | ... ... | f5942:c0:m6 |
def set_scale_alpha_from_selection(self): | <EOL>selection = self.treeview_layers.get_selection()<EOL>list_store, selected_iter = selection.get_selected()<EOL>if selected_iter is None:<EOL><INDENT>self.adjustment_alpha.set_value(<NUM_LIT:100>)<EOL>self.scale_alpha.set_sensitive(False)<EOL>return<EOL><DEDENT>else:<EOL><INDENT>surface_name, alpha = list_store[sele... | Set scale marker to alpha for selected layer. | f5942:c0:m9 |
def set_alpha_for_selection(self, alpha): | <EOL>selection = self.treeview_layers.get_selection()<EOL>list_store, selected_iter = selection.get_selected()<EOL>if selected_iter is None:<EOL><INDENT>return<EOL><DEDENT>else:<EOL><INDENT>surface_name, original_alpha = list_store[selected_iter]<EOL>self.set_alpha(surface_name, alpha)<EOL>self.set_scale_alpha_from_sel... | Set alpha for selected layer. | f5942:c0:m10 |
def gsignal(name, *args, **kwargs): | frame = sys._getframe(<NUM_LIT:1>)<EOL>try:<EOL><INDENT>locals = frame.f_locals<EOL><DEDENT>finally:<EOL><INDENT>del frame<EOL><DEDENT>dict = locals.setdefault('<STR_LIT>', {})<EOL>if args and args[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>dict[name] = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>retval = kwargs.get('<STR_... | Add a GObject signal to the current object.
It current supports the following types:
- str, int, float, long, object, enum
:param name: name of the signal
:param args: types for signal parameters,
if the first one is a string 'override', the signal will be
overridden and must there... | f5943:m0 |
def gproperty(name, ptype, default=None, nick='<STR_LIT>', blurb='<STR_LIT>',<EOL>flags=gobject.PARAM_READWRITE, **kwargs): | <EOL>if default is None:<EOL><INDENT>default = _DEFAULT_VALUES.get(ptype)<EOL><DEDENT>elif not isinstance(default, ptype):<EOL><INDENT>raise TypeError("<STR_LIT>" % (<EOL>ptype, default))<EOL><DEDENT>if not isinstance(nick, str):<EOL><INDENT>raise TypeError('<STR_LIT>' % (<EOL>name, nick))<EOL><DEDENT>nick = nick or na... | Add a GObject property to the current object.
:param name: name of property
:param ptype: type of property
:param default: default value
:param nick: short description
:param blurb: long description
:param flags: parameter flags, a combination of:
- PARAM_READABLE
- P... | f5943:m2 |
def refresh_gui(delay=<NUM_LIT>, wait=<NUM_LIT>): | time.sleep(delay)<EOL>while gtk.events_pending():<EOL><INDENT>gtk.main_iteration_do(block=False)<EOL>time.sleep(wait)<EOL><DEDENT> | Use up all the events waiting to be run
:param delay: Time to wait before using events
:param wait: Time to wait between iterations of events
This function will block until all pending events are emitted. This is
useful in testing to ensure signals and other asynchronous functionality
is required ... | f5943:m3 |
def run_in_window(target, on_destroy=gtk.main_quit): | w = _get_in_window(target)<EOL>if on_destroy:<EOL><INDENT>w.connect('<STR_LIT>', on_destroy)<EOL><DEDENT>w.resize(<NUM_LIT>, <NUM_LIT>)<EOL>w.move(<NUM_LIT:100>, <NUM_LIT:100>)<EOL>w.show_all()<EOL>gtk.main()<EOL> | Run a widget, or a delegate in a Window | f5943:m5 |
def dict_to_form(dict): | from flatland import Boolean, Form, String, Integer, Float<EOL>def is_float(v):<EOL><INDENT>try:<EOL><INDENT>return (float(str(v)), True)[<NUM_LIT:1>]<EOL><DEDENT>except (ValueError, TypeError):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>def is_int(v):<EOL><INDENT>try:<EOL><INDENT>return (int(str(v)), True)[<NUM_LIT:... | Generate a flatland form based on a pandas Series. | f5943:m7 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.