Whats a miniframe and why would I use it

A mini-frame is just like a regular frame with two primary exceptions: it has a smaller title area, and it doesn't display in the window task bar under MS Windows or GTK. Figure 8.8 displays an example of a smaller title area.

The code for creating the mini-frame is almost identical to creating a regular frame, the only difference is that the parent class is now wx.MiniFrame. Listing 8.9 displays the code.

Listing 8.9 Creating a mini-frame import wx class MiniFrame(wx.MiniFrame):

wx.MiniFrame._init_(self, None, -1, size=(3 00, 100)) panel = wx.Panel(self, -1, size=(300,

Figure 8.8 A mini-frame in action

Figure 8.8 A mini-frame in action

button = wx.Button(panel, -1, "Close Me", pos=(15, 15)) self.Bind(wx.EVT_BUTTON, self.OnCloseMe, button) self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)

def OnCloseMe(self, event): self.Close(True)

def OnCloseWindow(self, event): self.Destroy()

app = wx.PySimpleApp()



The constructor for wx.MiniFrame is identical to the constructor for wx.Frame, however the mini-frame supports additional style flags, listed in table 8.8.

Table 8.8 Style flags for wx.MiniFrame




Under MS Windows or Motif, draws the frame with a thick border.


Replaces wx.caption to display a smaller horizontal caption.


Replaces wx.caption to display a smaller vertical caption.

Typically, mini-frames are used in toolbox windows (i.e., Photoshop), where they are always available and they don't clutter up the task bar. The smaller caption makes them more space efficient, and visually separates them from normal frames.

Was this article helpful?

0 0

Post a comment