Ejemplo n.º 1
0
def plugin_app(parent):
    "Called once to get the plugin widget. Return a ``tk.Frame``."

    padx, pady = 10, 5  # formatting
    sticky = tk.EW + tk.N  # full width, stuck to the top
    anchor = tk.NW

    frame = this.frame = tk.Frame(parent)
    frame.columnconfigure(0, weight=1)

    table = tk.Frame(frame)
    table.columnconfigure(1, weight=1)
    table.grid(sticky=sticky)

    HyperlinkLabel(
        table,
        text='Helper:',
        url='https://hot.forthemug.com/',
        anchor=anchor,
    ).grid(row=0, column=0, sticky=sticky)
    this.status = ttk.Label(table, anchor=anchor, text="For the Mug!")
    this.status.grid(row=0, column=1, sticky=sticky)

    widgets.StyleCaptureLabel(table, anchor=anchor, text="News:").grid(row=1, column=0, sticky=sticky)
    news.HuttonNews(table).grid(row=1, column=1, sticky=sticky)

    this.plugin_rows = {}
    this.plugin_frames = {}
    row = 1 # because the table is first

    # Add the plugins' widgets
    for plugin in this.plugins:
        try:
            plugin_frame = plugin.plugin_app(frame)
        except:
            PANIC("{}.plugin_app".format(plugin))
            continue

        if plugin_frame:
            this.plugin_rows[plugin] = row
            this.plugin_frames[plugin] = plugin_frame
            row = row + 1

    # Add the front cover
    this.front_cover_row = row
    this.front_cover = widgets.FrontCover(frame)
    _show_front_cover(True)

    # Arrange for the front cover to be shown for at least a few seconds
    this.front_cover_until = time.time() + FRONT_COVER_DELAY
    frame.after(1000 * FRONT_COVER_DELAY, _refresh)
    frame.after_idle(_refresh)

    # Add the toolbar
    toolbar.HuttonToolbar(frame).grid(row=row + 1, pady=pady, sticky=sticky)

    return frame
Ejemplo n.º 2
0
def plugin_app(parent):
    "Called once to get the plugin widget. Return a ``tk.Frame``."

    padx, pady = 10, 5  # formatting
    sticky = tk.EW + tk.N  # full width, stuck to the top
    anchor = tk.NW

    # we declare a whitelist object so we can run a timer to fetch the event whitelist from Canonn
    # This is so that we can find out what events to transmit There is no UI associated
    Canonn = whiteList(parent)
    Canonn.fetchData()

    frame = this.frame = tk.Frame(parent)
    frame.columnconfigure(0, weight=1)

    table = tk.Frame(frame)
    table.columnconfigure(1, weight=1)
    table.grid(sticky=sticky)

    HyperlinkLabel(
        table,
        text='Helper:',
        url='https://hot.forthemug.com/',
        anchor=anchor,
    ).grid(row=0, column=0, sticky=sticky)
    this.status = widgets.SelfWrappingLabel(table,
                                            anchor=anchor,
                                            text="For the Mug!",
                                            wraplength=50)
    this.status.grid(row=0, column=1, sticky=sticky)

    widgets.StyleCaptureLabel(table, anchor=anchor,
                              text="News:").grid(row=1,
                                                 column=0,
                                                 sticky=sticky)
    news.HuttonNews(table).grid(row=1, column=1, sticky=sticky)

    this.plugin_rows = {}
    this.plugin_frames = {}
    row = 1  # because the table is first

    # Add the plugins' widgets
    for plugin in this.plugins:
        try:
            plugin_frame = plugin.plugin_app(frame)
        except:
            PANIC("{}.plugin_app".format(plugin))
            continue

        if plugin_frame:
            this.plugin_rows[plugin] = row
            this.plugin_frames[plugin] = plugin_frame
            row = row + 1

    # Add the front cover
    this.front_cover_row = row
    this.front_cover = widgets.FrontCover(frame)
    _show_front_cover(False)

    # Arrange for the front cover to be shown for at least a few seconds
    this.front_cover_until = time.time() + FRONT_COVER_DELAY
    frame.after(1000 * FRONT_COVER_DELAY, _refresh)
    frame.after_idle(_refresh)
    # Uncomment the next line to thrash the status line shortly after startup:
    # frame.after(5000, _thrash, EVENT_STATUS_FORMATS.values())

    return frame