ModulePanel

A ModulePage is a container widget that holds a variable number of ModulePanels. A ModulePanel is a customized collapsible wxPanel for displaying a list of labeled wxWidgets. While these two are mainly used for showing pyFSRS modules and their properties, the widgets can be used very general.

Example usage:

import wx
from ModulePanel import *

# create wxPython app
app = wx.App()
frame = wx.Frame(None, title="pyFSRS - Test module panel")
frame.SetBackgroundColour(wx.Colour(255, 255, 255))

# create a new ModulePage
page = ModulePage(frame, -1)

# create ModulePanels and add them to ModulePage
pane1 = ModulePanel(page, -1, label="Module 1")
pane1.Add("some", "text")
pane1.Add("Left", wx.TextCtrl(pane1.GetPane(), -1, "Hallo Welt"))
page.AddPanel(pane1)

pane2 = ModulePanel(page, -1, color=wx.Colour(0, 0, 255), label="Module 2")
pane2.Add("some", "text")
pane2.Add("Left", wx.TextCtrl(pane2.GetPane(), -1, "Hallo Welt"))
page.AddPanel(pane2)

# this demonstrates how widgets can be added after creating the panel
page.GetPanel(page.AddPanel(ModulePanel(page, -1, label="Module 3"))).Add("A", "Line")
page.GetPanel(page.AddPanel(ModulePanel(page, -1, label="Module 4"))).Add("B", "Line")
page.GetPanel(page.AddPanel(ModulePanel(page, -1, label="Module 5"))).Add("C", "Line")
page.GetPanel(page.AddPanel(ModulePanel(page, -1, label="Module 6"))).Add("D", "Line")

# show the fram and run the app
frame.Show()
app.MainLoop()
class core.ModulePanel.ModulePage(*args, **kwargs)[source]

Container widget holding a number of ModulePanels. Only one panel may be expanded at a time.

AddPanel(panel)[source]

Add a ModulePanel.

Params ModulePanel panel:
 Panel which to add to the ModulePage.
Returns:Id of added panel.
GetNumPanels()[source]

Returns number of panels on this page.

GetPanel(id)[source]

Returns the ModulePanel with given id.

Parameters:id (int) – Id or index of panel to return.
Returns:Instance of ModulePanel.
onPanelHide(event)[source]

Event handler to manage the exclusive expansion of a single panel at a time by closing all other panels.

class core.ModulePanel.ModulePanel(*args, **kwargs)[source]

A collapsible wxPanel that is used to display FSRSModules and their properties. This panel arranges child widgets row by row with a label printed in the left column and the actual widget displayed in the right column.

Accepts wxPanel’s standard parameters. Especially

  • color: wxColour that defines the color of the panel’s frame. This value indirectly defines also the color of the title font. If it is a light color, the title is black, otherwise it is white.
  • bgcolor: wxColour that defines the background color of the panel’s interior.
  • label: Title of the panel that appears on the top.
  • font: wxFont for the panel’s title and its children.
Add(label, wnd)[source]

Add a widget to the panel.

Parameters:
  • label (str) – Text / label to be displayed in the left column.
  • wnd (mixed) – Either wxWidget to be added in the right column or a string to be added as simple static text.
GetPanel()[source]

Returns the main panel, which serves as parent to the child widgets.

Hide(hide=True)[source]

(Un-) Hide the panel’s content and (expand) shrink it to show its (full content) title bar when hide is (False) True. Call this function only after the main frame has been initialized. Emits a PanelHideEvent to notify other panels of its action.

expanded = None

Expanded or not.

mouseInBtn()[source]

Returns True if mouse hovers above the panel’s title bar, which is used to collapse or uncollapse the panel.

onEraseBackground(event)[source]

This event is used to paint the panel’s frame in the background.

onLMouseDown(event)[source]

Mouse left-click event handler that controls collapsing or uncollapsing the panel.”

onMouseMove(event)[source]

Mouse move event handler that controls cursor appearance.

onResize(event)[source]

Handle a resize by repainting the panel.