_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q21700 | Apps.get_cdn_auth_token | train | def get_cdn_auth_token(self, app_id, hostname):
"""Get CDN authentication token
:param app_id: app id
:type app_id: :class:`int`
:param hostname: cdn hostname
:type hostname: :class:`str`
:return: `CMsgClientGetCDNAuthTokenResponse <https://github.com/ValvePython/steam/b... | python | {
"resource": ""
} |
q21701 | Apps.get_product_access_tokens | train | def get_product_access_tokens(self, app_ids=[], package_ids=[]):
"""Get access tokens
:param app_ids: list of app ids
:type app_ids: :class:`list`
:param package_ids: list of package ids
:type package_ids: :class:`list`
:return: dict with ``apps`` and ``packages`` contai... | python | {
"resource": ""
} |
q21702 | a2s_players | train | def a2s_players(server_addr, timeout=2, challenge=0):
"""Get list of players and their info
:param server_addr: (ip, port) for the server
:type server_addr: tuple
:param timeout: (optional) timeout in seconds
:type timeout: float
:param challenge: (optional) challenge number
:type challe... | python | {
"resource": ""
} |
q21703 | a2s_rules | train | def a2s_rules(server_addr, timeout=2, challenge=0):
"""Get rules from server
:param server_addr: (ip, port) for the server
:type server_addr: tuple
:param timeout: (optional) timeout in seconds
:type timeout: float
:param challenge: (optional) challenge number
:type challenge: int
:r... | python | {
"resource": ""
} |
q21704 | a2s_ping | train | def a2s_ping(server_addr, timeout=2):
"""Ping a server
.. warning::
This method for pinging is considered deprecated and may not work on certian servers.
Use :func:`.a2s_info` instead.
:param server_addr: (ip, port) for the server
:type server_addr: tuple
:param timeout: (optional... | python | {
"resource": ""
} |
q21705 | get_cmsg | train | def get_cmsg(emsg):
"""Get protobuf for a given EMsg
:param emsg: EMsg
:type emsg: :class:`steam.enums.emsg.EMsg`, :class:`int`
:return: protobuf message
"""
if not isinstance(emsg, EMsg):
emsg = EMsg(emsg)
if emsg in cmsg_lookup_predefined:
return cmsg_lookup_predefined[em... | python | {
"resource": ""
} |
q21706 | Web.get_web_session_cookies | train | def get_web_session_cookies(self):
"""Get web authentication cookies via WebAPI's ``AuthenticateUser``
.. note::
The cookies are valid only while :class:`.SteamClient` instance is logged on.
:return: dict with authentication cookies
:rtype: :class:`dict`, :class:`None`
... | python | {
"resource": ""
} |
q21707 | User.change_status | train | def change_status(self, **kwargs):
"""
Set name, persona state, flags
.. note::
Changing persona state will also change :attr:`persona_state`
:param persona_state: persona state (Online/Offlane/Away/etc)
:type persona_state: :class:`.EPersonaState`
:param pl... | python | {
"resource": ""
} |
q21708 | User.request_persona_state | train | def request_persona_state(self, steam_ids, state_flags=863):
"""Request persona state data
:param steam_ids: list of steam ids
:type steam_ids: :class:`list`
:param state_flags: client state flags
:type state_flags: :class:`.EClientPersonaStateFlag`
"""
m = Msg... | python | {
"resource": ""
} |
q21709 | User.games_played | train | def games_played(self, app_ids):
"""
Set the apps being played by the user
:param app_ids: a list of application ids
:type app_ids: :class:`list`
These app ids will be recorded in :attr:`current_games_played`.
"""
if not isinstance(app_ids, list):
ra... | python | {
"resource": ""
} |
q21710 | GlobalID.new | train | def new(sequence_count, start_time, process_id, box_id):
"""Make new GlobalID
:param sequence_count: sequence count
:type sequence_count: :class:`int`
:param start_time: start date time of server (must be after 2005-01-01)
:type start_time: :class:`str`, :class:`datetime`
... | python | {
"resource": ""
} |
q21711 | Service.get_shared_people | train | def get_shared_people(self):
"""Retrieves all people that share their location with this account"""
people = []
output = self._get_data()
self._logger.debug(output)
shared_entries = output[0] or []
for info in shared_entries:
try:
people.append... | python | {
"resource": ""
} |
q21712 | Service.get_authenticated_person | train | def get_authenticated_person(self):
"""Retrieves the person associated with this account"""
try:
output = self._get_data()
self._logger.debug(output)
person = Person([
self.email,
output[9][1],
None,
None... | python | {
"resource": ""
} |
q21713 | Service.get_person_by_nickname | train | def get_person_by_nickname(self, nickname):
"""Retrieves a person by nickname"""
return next((person for person in self.get_all_people()
if person.nickname.lower() == nickname.lower()), None) | python | {
"resource": ""
} |
q21714 | Service.get_person_by_full_name | train | def get_person_by_full_name(self, name):
"""Retrieves a person by full name"""
return next((person for person in self.get_all_people()
if person.full_name.lower() == name.lower()), None) | python | {
"resource": ""
} |
q21715 | Service.get_coordinates_by_nickname | train | def get_coordinates_by_nickname(self, nickname):
"""Retrieves a person's coordinates by nickname"""
person = self.get_person_by_nickname(nickname)
if not person:
return '', ''
return person.latitude, person.longitude | python | {
"resource": ""
} |
q21716 | Service.get_coordinates_by_full_name | train | def get_coordinates_by_full_name(self, name):
"""Retrieves a person's coordinates by full name"""
person = self.get_person_by_full_name(name)
if not person:
return '', ''
return person.latitude, person.longitude | python | {
"resource": ""
} |
q21717 | Person.datetime | train | def datetime(self):
"""A datetime representation of the location retrieval"""
return datetime.fromtimestamp(int(self.timestamp) / 1000, tz=pytz.utc) | python | {
"resource": ""
} |
q21718 | xnormpath | train | def xnormpath(path):
""" Cross-platform version of os.path.normpath """
# replace escapes and Windows slashes
normalized = posixpath.normpath(path).replace(b'\\', b'/')
# fold the result
return posixpath.normpath(normalized) | python | {
"resource": ""
} |
q21719 | xstrip | train | def xstrip(filename):
""" Make relative path out of absolute by stripping
prefixes used on Linux, OS X and Windows.
This function is critical for security.
"""
while xisabs(filename):
# strip windows drive with all slashes
if re.match(b'\\w:[\\\\/]', filename):
filename = re.sub(b'^\\w+... | python | {
"resource": ""
} |
q21720 | pathstrip | train | def pathstrip(path, n):
""" Strip n leading components from the given path """
pathlist = [path]
while os.path.dirname(pathlist[0]) != b'':
pathlist[0:1] = os.path.split(pathlist[0])
return b'/'.join(pathlist[n:]) | python | {
"resource": ""
} |
q21721 | PatchSet._detect_type | train | def _detect_type(self, p):
""" detect and return type for the specified Patch object
analyzes header and filenames info
NOTE: must be run before filenames are normalized
"""
# check for SVN
# - header starts with Index:
# - next line is ===... delimiter
# - filename is follo... | python | {
"resource": ""
} |
q21722 | PatchSet.findfile | train | def findfile(self, old, new):
""" return name of file to be patched or None """
if exists(old):
return old
elif exists(new):
return new
else:
# [w] Google Code generates broken patches with its online editor
debug("broken patch from Google Code, stripping prefixes..")
if ol... | python | {
"resource": ""
} |
q21723 | PatchSet.revert | train | def revert(self, strip=0, root=None):
""" apply patch in reverse order """
reverted = copy.deepcopy(self)
reverted._reverse()
return reverted.apply(strip, root) | python | {
"resource": ""
} |
q21724 | PatchSet.can_patch | train | def can_patch(self, filename):
""" Check if specified filename can be patched. Returns None if file can
not be found among source filenames. False if patch can not be applied
clearly. True otherwise.
:returns: True, False or None
"""
filename = abspath(filename)
for p in self.items:
i... | python | {
"resource": ""
} |
q21725 | PatchSet.patch_stream | train | def patch_stream(self, instream, hunks):
""" Generator that yields stream patched with hunks iterable
Converts lineends in hunk lines to the best suitable format
autodetected from input
"""
# todo: At the moment substituted lineends may not be the same
# at the start and at the e... | python | {
"resource": ""
} |
q21726 | cd | train | def cd(new_directory, clean_up=lambda: True): # pylint: disable=invalid-name
"""Changes into a given directory and cleans up after it is done
Args:
new_directory: The directory to change to
clean_up: A method to clean up the working directory once done
"""
previous_directory = os.getc... | python | {
"resource": ""
} |
q21727 | tempdir | train | def tempdir():
"""Creates a temporary directory"""
directory_path = tempfile.mkdtemp()
def clean_up(): # pylint: disable=missing-docstring
shutil.rmtree(directory_path, onerror=on_error)
with cd(directory_path, clean_up):
yield directory_path | python | {
"resource": ""
} |
q21728 | ScrolledListbox._grid_widgets | train | def _grid_widgets(self):
"""Puts the two whole widgets in the correct position depending on compound."""
scrollbar_column = 0 if self.__compound is tk.LEFT else 2
self.listbox.grid(row=0, column=1, sticky="nswe")
self.scrollbar.grid(row=0, column=scrollbar_column, sticky="ns") | python | {
"resource": ""
} |
q21729 | ItemsCanvas.left_press | train | def left_press(self, event):
"""
Callback for the press of the left mouse button.
Selects a new item and sets its highlightcolor.
:param event: Tkinter event
"""
self.current_coords = self.canvas.canvasx(event.x), self.canvas.canvasy(event.y)
self.set_cu... | python | {
"resource": ""
} |
q21730 | ItemsCanvas.left_release | train | def left_release(self, event):
"""
Callback for the release of the left button.
:param event: Tkinter event
"""
self.config(cursor="")
if len(self.canvas.find_withtag("current")) != 0 and self.current is not None:
self.canvas.itemconfigure(tk.CURRENT, fill=se... | python | {
"resource": ""
} |
q21731 | ItemsCanvas.left_motion | train | def left_motion(self, event):
"""
Callback for the B1-Motion event, or the dragging of an item.
Moves the item to the desired location, but limits its movement to a
place on the actual Canvas. The item cannot be moved outside of the Canvas.
:param event: Tkinter event
"... | python | {
"resource": ""
} |
q21732 | ItemsCanvas.del_item | train | def del_item(self):
"""Delete the current item on the Canvas."""
item = self.current
rectangle = self.items[item]
self.canvas.delete(item, rectangle)
if callable(self._callback_del):
self._callback_del(item, rectangle) | python | {
"resource": ""
} |
q21733 | DebugWindow.save | train | def save(self):
"""Save widget content."""
file_name = fd.asksaveasfilename()
if file_name is "" or file_name is None:
return
with open(file_name, "w") as f:
f.write(self.text.get("1.0", tk.END)) | python | {
"resource": ""
} |
q21734 | LimitVar.get | train | def get(self):
"""
Convert the content to int between the limits of the variable.
If the content is not an integer between the limits, the value is
corrected and the corrected result is returned.
"""
val = tk.StringVar.get(self)
try:
val = int(val)
... | python | {
"resource": ""
} |
q21735 | askcolor | train | def askcolor(color="red", parent=None, title=_("Color Chooser"), alpha=False):
"""
Open a ColorPicker dialog and return the chosen color.
:return: the selected color in RGB(A) and hexadecimal #RRGGBB(AA) formats.
(None, None) is returned if the color selection is cancelled.
:param color: ... | python | {
"resource": ""
} |
q21736 | ColorPicker._unfocus | train | def _unfocus(self, event):
"""Unfocus palette items when click on bar or square."""
w = self.focus_get()
if w != self and 'spinbox' not in str(w) and 'entry' not in str(w):
self.focus_set() | python | {
"resource": ""
} |
q21737 | ColorPicker._update_preview | train | def _update_preview(self):
"""Update color preview."""
color = self.hexa.get()
if self.alpha_channel:
prev = overlay(self._transparent_bg, hexa_to_rgb(color))
self._im_color = ImageTk.PhotoImage(prev, master=self)
self.color_preview.configure(image=self._im_co... | python | {
"resource": ""
} |
q21738 | ColorPicker._change_sel_color | train | def _change_sel_color(self, event):
"""Respond to motion of the color selection cross."""
(r, g, b), (h, s, v), color = self.square.get()
self.red.set(r)
self.green.set(g)
self.blue.set(b)
self.saturation.set(s)
self.value.set(v)
self.hexa.delete(0, "end")... | python | {
"resource": ""
} |
q21739 | ColorPicker._change_color | train | def _change_color(self, event):
"""Respond to motion of the hsv cursor."""
h = self.bar.get()
self.square.set_hue(h)
(r, g, b), (h, s, v), sel_color = self.square.get()
self.red.set(r)
self.green.set(g)
self.blue.set(b)
self.hue.set(h)
self.saturat... | python | {
"resource": ""
} |
q21740 | ColorPicker._update_color_hexa | train | def _update_color_hexa(self, event=None):
"""Update display after a change in the HEX entry."""
color = self.hexa.get().upper()
self.hexa.delete(0, 'end')
self.hexa.insert(0, color)
if re.match(r"^#[0-9A-F]{6}$", color):
r, g, b = hexa_to_rgb(color)
self.r... | python | {
"resource": ""
} |
q21741 | ColorPicker._update_alpha | train | def _update_alpha(self, event=None):
"""Update display after a change in the alpha spinbox."""
a = self.alpha.get()
hexa = self.hexa.get()
hexa = hexa[:7] + ("%2.2x" % a).upper()
self.hexa.delete(0, 'end')
self.hexa.insert(0, hexa)
self.alphabar.set(a)
sel... | python | {
"resource": ""
} |
q21742 | ColorPicker._update_color_hsv | train | def _update_color_hsv(self, event=None):
"""Update display after a change in the HSV spinboxes."""
if event is None or event.widget.old_value != event.widget.get():
h = self.hue.get()
s = self.saturation.get()
v = self.value.get()
sel_color = hsv_to_rgb(h,... | python | {
"resource": ""
} |
q21743 | ColorPicker._update_color_rgb | train | def _update_color_rgb(self, event=None):
"""Update display after a change in the RGB spinboxes."""
if event is None or event.widget.old_value != event.widget.get():
r = self.red.get()
g = self.green.get()
b = self.blue.get()
h, s, v = rgb_to_hsv(r, g, b)
... | python | {
"resource": ""
} |
q21744 | ColorPicker.ok | train | def ok(self):
"""Validate color selection and destroy dialog."""
rgb, hsv, hexa = self.square.get()
if self.alpha_channel:
hexa = self.hexa.get()
rgb += (self.alpha.get(),)
self.color = rgb, hsv, hexa
self.destroy() | python | {
"resource": ""
} |
q21745 | AlphaBar._draw_gradient | train | def _draw_gradient(self, alpha, color):
"""Draw the gradient and put the cursor on alpha."""
self.delete("gradient")
self.delete("cursor")
del self.gradient
width = self.winfo_width()
height = self.winfo_height()
bg = create_checkered_image(width, height)
... | python | {
"resource": ""
} |
q21746 | AlphaBar.set | train | def set(self, alpha):
"""
Set cursor position on the color corresponding to the alpha value.
:param alpha: new alpha value (between 0 and 255)
:type alpha: int
"""
if alpha > 255:
alpha = 255
elif alpha < 0:
alpha = 0
x = alpha / 2... | python | {
"resource": ""
} |
q21747 | AlphaBar.set_color | train | def set_color(self, color):
"""
Change gradient color and change cursor position if an alpha value is supplied.
:param color: new gradient color in RGB(A) format
:type color: tuple[int]
"""
if len(color) == 3:
alpha = self.get()
else:
alph... | python | {
"resource": ""
} |
q21748 | FontChooser._grid_widgets | train | def _grid_widgets(self):
"""Puts all the child widgets in the correct position."""
self._font_family_header.grid(row=0, column=1, sticky="nswe", padx=5, pady=5)
self._font_label.grid(row=1, column=1, sticky="nswe", padx=5, pady=(0, 5))
self._font_family_list.grid(row=2, rowspan=3, column... | python | {
"resource": ""
} |
q21749 | FontChooser._on_change | train | def _on_change(self):
"""Callback if any of the values are changed."""
font = self.__generate_font_tuple()
self._example_label.configure(font=font) | python | {
"resource": ""
} |
q21750 | GradientBar._draw_gradient | train | def _draw_gradient(self, hue):
"""Draw the gradient and put the cursor on hue."""
self.delete("gradient")
self.delete("cursor")
del self.gradient
width = self.winfo_width()
height = self.winfo_height()
self.gradient = tk.PhotoImage(master=self, width=width, heigh... | python | {
"resource": ""
} |
q21751 | GradientBar._on_click | train | def _on_click(self, event):
"""Move selection cursor on click."""
x = event.x
self.coords('cursor', x, 0, x, self.winfo_height())
self._variable.set(round2((360. * x) / self.winfo_width())) | python | {
"resource": ""
} |
q21752 | GradientBar._on_move | train | def _on_move(self, event):
"""Make selection cursor follow the cursor."""
w = self.winfo_width()
x = min(max(event.x, 0), w)
self.coords('cursor', x, 0, x, self.winfo_height())
self._variable.set(round2((360. * x) / w)) | python | {
"resource": ""
} |
q21753 | FontSelectFrame._grid_widgets | train | def _grid_widgets(self):
"""
Puts all the widgets in the correct place.
"""
self._family_dropdown.grid(row=0, column=0, sticky="nswe")
self._size_dropdown.grid(row=0, column=1, sticky="nswe")
self._properties_frame.grid(row=0, column=2, sticky="nswe") | python | {
"resource": ""
} |
q21754 | FontSelectFrame._on_change | train | def _on_change(self):
"""Call callback if any property is changed."""
if callable(self.__callback):
self.__callback((self._family, self._size, self._bold, self._italic, self._underline, self._overstrike)) | python | {
"resource": ""
} |
q21755 | LinkLabel._on_enter | train | def _on_enter(self, *args):
"""Set the text color to the hover color."""
self.config(foreground=self._hover_color, cursor=self._cursor) | python | {
"resource": ""
} |
q21756 | LinkLabel._on_leave | train | def _on_leave(self, *args):
"""Set the text color to either the normal color when not clicked or the clicked color when clicked."""
if self.__clicked:
self.config(foreground=self._clicked_color)
else:
self.config(foreground=self._normal_color)
self.config(cursor="... | python | {
"resource": ""
} |
q21757 | LinkLabel.open_link | train | def open_link(self, *args):
"""Open the link in the web browser."""
if "disabled" not in self.state():
webbrowser.open(self._link)
self.__clicked = True
self._on_leave() | python | {
"resource": ""
} |
q21758 | LinkLabel.keys | train | def keys(self):
"""Return a list of all resource names of this widget."""
keys = ttk.Label.keys(self)
keys.extend(["link", "normal_color", "hover_color", "clicked_color"])
return keys | python | {
"resource": ""
} |
q21759 | Table._move_dragged_row | train | def _move_dragged_row(self, item):
"""Insert dragged row at item's position."""
self.move(self._dragged_row, '', self.index(item))
self.see(self._dragged_row)
bbox = self.bbox(self._dragged_row)
self._dragged_row_y = bbox[1]
self._dragged_row_height = bbox[3]
self... | python | {
"resource": ""
} |
q21760 | Table._start_drag_col | train | def _start_drag_col(self, event):
"""Start dragging a column"""
# identify dragged column
col = self.identify_column(event.x)
self._dragged_col = ttk.Treeview.column(self, col, 'id')
# get column width
self._dragged_col_width = w = ttk.Treeview.column(self, col, 'width')
... | python | {
"resource": ""
} |
q21761 | Table._start_drag_row | train | def _start_drag_row(self, event):
"""Start dragging a row"""
self._dragged_row = self.identify_row(event.y) # identify dragged row
bbox = self.bbox(self._dragged_row)
self._dy = bbox[1] - event.y # distance between cursor and row upper border
self._dragged_row_y = bbox[1] # y ... | python | {
"resource": ""
} |
q21762 | Table._on_release | train | def _on_release(self, event):
"""Stop dragging."""
if self._drag_cols or self._drag_rows:
self._visual_drag.place_forget()
self._dragged_col = None
self._dragged_row = None | python | {
"resource": ""
} |
q21763 | Table._on_motion | train | def _on_motion(self, event):
"""Drag around label if visible."""
if not self._visual_drag.winfo_ismapped():
return
if self._drag_cols and self._dragged_col is not None:
self._drag_col(event)
elif self._drag_rows and self._dragged_row is not None:
self... | python | {
"resource": ""
} |
q21764 | Table._drag_col | train | def _drag_col(self, event):
"""Continue dragging a column"""
x = self._dx + event.x # get dragged column new left x coordinate
self._visual_drag.place_configure(x=x) # update column preview position
# if one border of the dragged column is beyon the middle of the
# neighboring ... | python | {
"resource": ""
} |
q21765 | Table._drag_row | train | def _drag_row(self, event):
"""Continue dragging a row"""
y = self._dy + event.y # get dragged row new upper y coordinate
self._visual_drag.place_configure(y=y) # update row preview position
if y > self._dragged_row_y:
# moving downward
item = self.identify_row... | python | {
"resource": ""
} |
q21766 | Table._sort_column | train | def _sort_column(self, column, reverse):
"""Sort a column by its values"""
if tk.DISABLED in self.state():
return
# get list of (value, item) tuple where value is the value in column for the item
l = [(self.set(child, column), child) for child in self.get_children('')]
... | python | {
"resource": ""
} |
q21767 | Table.column | train | def column(self, column, option=None, **kw):
"""
Query or modify the options for the specified column.
If `kw` is not given, returns a dict of the column option values. If
`option` is specified then the value for that option is returned.
Otherwise, sets the options to the corres... | python | {
"resource": ""
} |
q21768 | Table._config_options | train | def _config_options(self):
"""Apply options set in attributes to Treeview"""
self._config_sortable(self._sortable)
self._config_drag_cols(self._drag_cols) | python | {
"resource": ""
} |
q21769 | Table._config_sortable | train | def _config_sortable(self, sortable):
"""Configure a new sortable state"""
for col in self["columns"]:
command = (lambda c=col: self._sort_column(c, True)) if sortable else ""
self.heading(col, command=command)
self._sortable = sortable | python | {
"resource": ""
} |
q21770 | Table._config_drag_cols | train | def _config_drag_cols(self, drag_cols):
"""Configure a new drag_cols state"""
self._drag_cols = drag_cols
# remove/display drag icon
if self._drag_cols:
self._im_drag.paste(self._im_draggable)
else:
self._im_drag.paste(self._im_not_draggable)
self.... | python | {
"resource": ""
} |
q21771 | Table.delete | train | def delete(self, *items):
"""
Delete all specified items and all their descendants. The root item may not be deleted.
:param items: list of item identifiers
:type items: sequence[str]
"""
self._visual_drag.delete(*items)
ttk.Treeview.delete(self, *items) | python | {
"resource": ""
} |
q21772 | Table.detach | train | def detach(self, *items):
"""
Unlinks all of the specified items from the tree.
The items and all of their descendants are still present, and may be
reinserted at another point in the tree, but will not be displayed.
The root item may not be detached.
:param items: list... | python | {
"resource": ""
} |
q21773 | Table.heading | train | def heading(self, column, option=None, **kw):
"""
Query or modify the heading options for the specified column.
If `kw` is not given, returns a dict of the heading option values. If
`option` is specified then the value for that option is returned.
Otherwise, sets the options to ... | python | {
"resource": ""
} |
q21774 | Table.item | train | def item(self, item, option=None, **kw):
"""
Query or modify the options for the specified item.
If no options are given, a dict with options/values for the item is returned.
If option is specified then the value for that option is returned.
Otherwise, sets the options to the co... | python | {
"resource": ""
} |
q21775 | Table.set | train | def set(self, item, column=None, value=None):
"""
Query or set the value of given item.
With one argument, return a dictionary of column/value pairs for the
specified item. With two arguments, return the current value of the
specified column. With three arguments, set the value ... | python | {
"resource": ""
} |
q21776 | ScaleEntry._on_scale | train | def _on_scale(self, event):
"""
Callback for the Scale widget, inserts an int value into the Entry.
:param event: Tkinter event
"""
self._entry.delete(0, tk.END)
self._entry.insert(0, str(self._variable.get())) | python | {
"resource": ""
} |
q21777 | ScaleEntry.config_scale | train | def config_scale(self, cnf={}, **kwargs):
"""Configure resources of the Scale widget."""
self._scale.config(cnf, **kwargs)
# Update self._variable limits in case the ones of the scale have changed
self._variable.configure(high=self._scale['to'],
low=self.... | python | {
"resource": ""
} |
q21778 | Balloon._grid_widgets | train | def _grid_widgets(self):
"""Place the widgets in the Toplevel."""
self._canvas.grid(sticky="nswe")
self.header_label.grid(row=1, column=1, sticky="nswe", pady=5, padx=5)
self.text_label.grid(row=3, column=1, sticky="nswe", pady=6, padx=5) | python | {
"resource": ""
} |
q21779 | Balloon.show | train | def show(self):
"""
Create the Toplevel widget and its child widgets to show in the spot of the cursor.
This is the callback for the delayed :obj:`<Enter>` event (see :meth:`~Balloon._on_enter`).
"""
self._toplevel = tk.Toplevel(self.master)
self._canvas = tk.Canvas(sel... | python | {
"resource": ""
} |
q21780 | FontPropertiesFrame._on_click | train | def _on_click(self):
"""Handles clicks and calls callback."""
if callable(self.__callback):
self.__callback((self.bold, self.italic, self.underline, self.overstrike)) | python | {
"resource": ""
} |
q21781 | rgb_to_hsv | train | def rgb_to_hsv(r, g, b):
"""Convert RGB color to HSV."""
h, s, v = colorsys.rgb_to_hsv(r / 255., g / 255., b / 255.)
return round2(h * 360), round2(s * 100), round2(v * 100) | python | {
"resource": ""
} |
q21782 | hexa_to_rgb | train | def hexa_to_rgb(color):
"""Convert hexadecimal color to RGB."""
r = int(color[1:3], 16)
g = int(color[3:5], 16)
b = int(color[5:7], 16)
if len(color) == 7:
return r, g, b
elif len(color) == 9:
return r, g, b, int(color[7:9], 16)
else:
raise ValueError("Invalid hexadec... | python | {
"resource": ""
} |
q21783 | col2hue | train | def col2hue(r, g, b):
"""Return hue value corresponding to given RGB color."""
return round2(180 / pi * atan2(sqrt(3) * (g - b), 2 * r - g - b) + 360) % 360 | python | {
"resource": ""
} |
q21784 | create_checkered_image | train | def create_checkered_image(width, height, c1=(154, 154, 154, 255),
c2=(100, 100, 100, 255), s=6):
"""
Return a checkered image of size width x height.
Arguments:
* width: image width
* height: image height
* c1: first color (RGBA)
* c2: second colo... | python | {
"resource": ""
} |
q21785 | TimeLine.grid_widgets | train | def grid_widgets(self):
"""
Configure all widgets using the grid geometry manager
Automatically called by the :meth:`__init__` method.
Does not have to be called by the user except in extraordinary
cases.
"""
# Categories
for index, label in enumerate(sel... | python | {
"resource": ""
} |
q21786 | TimeLine.draw_timeline | train | def draw_timeline(self):
"""Draw the contents of the whole TimeLine Canvas"""
# Configure the canvas
self.clear_timeline()
self.create_scroll_region()
self._timeline.config(width=self.pixel_width)
self._canvas_scroll.config(width=self._width, height=self._height)
... | python | {
"resource": ""
} |
q21787 | TimeLine.draw_time_marker | train | def draw_time_marker(self):
"""Draw the time marker on the TimeLine Canvas"""
self._time_marker_image = self._canvas_ticks.create_image((2, 16), image=self._time_marker)
self._time_marker_line = self._timeline.create_line(
(2, 0, 2, self._timeline.winfo_height()), fill="#016dc9", wid... | python | {
"resource": ""
} |
q21788 | TimeLine.draw_categories | train | def draw_categories(self):
"""Draw the category labels on the Canvas"""
for label in self._category_labels.values():
label.destroy()
self._category_labels.clear()
canvas_width = 0
for category in (sorted(self._categories.keys() if isinstance(self._categories, dict) el... | python | {
"resource": ""
} |
q21789 | TimeLine.create_scroll_region | train | def create_scroll_region(self):
"""Setup the scroll region on the Canvas"""
canvas_width = 0
canvas_height = 0
for label in self._category_labels.values():
width = label.winfo_reqwidth()
canvas_height += label.winfo_reqheight()
canvas_width = width if ... | python | {
"resource": ""
} |
q21790 | TimeLine.clear_timeline | train | def clear_timeline(self):
"""
Clear the contents of the TimeLine Canvas
Does not modify the actual markers dictionary and thus after
redrawing all markers are visible again.
"""
self._timeline.delete(tk.ALL)
self._canvas_ticks.delete(tk.ALL) | python | {
"resource": ""
} |
q21791 | TimeLine.draw_ticks | train | def draw_ticks(self):
"""Draw the time tick markers on the TimeLine Canvas"""
self._canvas_ticks.create_line((0, 10, self.pixel_width, 10), fill="black")
self._ticks = list(TimeLine.range(self._start, self._finish, self._tick_resolution / self._zoom_factor))
for tick in self._ticks:
... | python | {
"resource": ""
} |
q21792 | TimeLine.draw_separators | train | def draw_separators(self):
"""Draw the lines separating the categories on the Canvas"""
total = 1
self._timeline.create_line((0, 1, self.pixel_width, 1))
for index, (category, label) in enumerate(self._category_labels.items()):
height = label.winfo_reqheight()
sel... | python | {
"resource": ""
} |
q21793 | TimeLine.draw_markers | train | def draw_markers(self):
"""Draw all created markers on the TimeLine Canvas"""
self._canvas_markers.clear()
for marker in self._markers.values():
self.create_marker(marker["category"], marker["start"], marker["finish"], marker) | python | {
"resource": ""
} |
q21794 | TimeLine.__configure_timeline | train | def __configure_timeline(self, *args):
"""Function from ScrolledFrame, adapted for the _timeline"""
# Resize the canvas scrollregion to fit the entire frame
(size_x, size_y) = (self._timeline.winfo_reqwidth(), self._timeline.winfo_reqheight())
self._canvas_scroll.config(scrollregion="0 0... | python | {
"resource": ""
} |
q21795 | TimeLine.create_marker | train | def create_marker(self, category, start, finish, marker=None, **kwargs):
"""
Create a new marker in the TimeLine with the specified options
:param category: Category identifier, key as given in categories
dictionary upon initialization
:type category: Any
:param star... | python | {
"resource": ""
} |
q21796 | TimeLine._draw_text | train | def _draw_text(self, coords, text, foreground, font):
"""Draw the text and shorten it if required"""
if text is None:
return None
x1_r, _, x2_r, _ = coords
while True:
text_id = self._timeline.create_text(
(0, 0), text=text,
fill=fo... | python | {
"resource": ""
} |
q21797 | TimeLine.update_marker | train | def update_marker(self, iid, **kwargs):
"""
Change the options for a certain marker and redraw the marker
:param iid: identifier of the marker to change
:type iid: str
:param kwargs: Dictionary of options to update
:type kwargs: dict
:raises: ValueError
"... | python | {
"resource": ""
} |
q21798 | TimeLine.delete_marker | train | def delete_marker(self, iid):
"""
Delete a marker from the TimeLine
:param iid: marker identifier
:type iid: str
"""
if iid == tk.ALL:
for iid in self.markers.keys():
self.delete_marker(iid)
return
options = self._markers[i... | python | {
"resource": ""
} |
q21799 | TimeLine.zoom_in | train | def zoom_in(self):
"""Increase zoom factor and redraw TimeLine"""
index = self._zoom_factors.index(self._zoom_factor)
if index + 1 == len(self._zoom_factors):
# Already zoomed in all the way
return
self._zoom_factor = self._zoom_factors[index + 1]
if self.... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.