This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from tkinter import ttk | |
""" | |
The demo shows how to position a topside window relative to a button widget from multiple directions. The purpose | |
is to show that one could theoretically create a custom menu from a toplevel that could be positioned correctly | |
aligned to the parent widget with and without a titlebar. | |
The problem with positioning a topside relative to another widget is due to the fact that, normally, window | |
decorations are added to the window. This adds additional horizontal a vertical space that is not accounted for in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cursor: | |
"""The cursor shown when the mouse is over the widget.""" | |
ARROW='arrow' | |
BASED_ARROW_DOWN='based_arrow_down' | |
BASED_ARROW_UP='based_arrow_up' | |
BOAT='boat' | |
BOGOSITY='bogosity' | |
BOTTOM_LEFT_CORNER='bottom_left_corner' | |
BOTTOM_RIGHT_CORNER='bottom_right_corner' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
def shipping_status(tracking_num): | |
"""Request shipment status via tracking number. | |
Args: | |
tracking_num (int): The FedEx tracking number assigned to the shipment. | |
""" | |
url = "https://www.fedex.com/trackingCal/track" | |
headers = { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from tkinter import ttk | |
from PIL import Image, ImageDraw, ImageTk | |
def sizegrip_style(background, foreground): | |
"""Create style configuration for ttk sizegrip | |
Args: | |
background (str): The color used for the background. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from PIL import Image, ImageTk, ImageDraw | |
from tkinter import StringVar, IntVar | |
from tkinter import ttk | |
from tkinter.ttk import Frame | |
class NeedleMeter(Frame): | |
def __init__(self, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pathlib | |
from PIL import ImageGrab | |
class Screenshot: | |
def __init__(self, parent, filename): | |
self.parent = parent | |
self.parent.bind("<Insert>", self.get_bounding_box) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from tkinter import ttk | |
def submit(source, dest): | |
"""Collect data from source text and insert into destination text""" | |
text = source.get('1.0', 'end') | |
dest.insert('end', text) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter as tk | |
from tkinter import ttk | |
from PIL import Image, ImageTk, ImageDraw | |
class Gauge(ttk.Label): | |
def __init__(self, parent, **kwargs): | |
self.arc = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client as client | |
outlook = client.Dispatch('Outlook.Application') | |
namespace = outlook.GetNameSpace('MAPI') | |
inbox = namespace.GetDefaultFolder(6) | |
# search for messages meeting a specific criteria | |
target_messages = [item for item in inbox.Items if 'product' in item.Subject] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Author: Israel Dryer | |
Modified: 2021-04-16 | |
Here's a simple example of creating a new theme with a single custom widget - a modern looking radiobutton. | |
In this example, I used a dictionary of settings. However, you can just as well do it with the Style.map, | |
Style.layout, and Style.configure methods. But, if you're going to build an entire theme, then using a settings | |
dictionary is more scalable, and could technically be stored in an offline json file as well. | |
""" | |
from PIL import ImageDraw, Image, ImageTk |
NewerOlder