Exemplo n.º 1
0
    def __init__(self, parent, preferences):
        wx.Panel.__init__(self, parent, -1, style=wx.RAISED_BORDER)
        self.SetBackgroundColour( preferences.GetValue('M_BGD_COLOUR') )
        self._prefs = preferences
        self.tips = Tips()

        menu   = self._create_menu()
        self.text = self._create_content()
        button = self._create_button()

        sizer = wx.BoxSizer( wx.VERTICAL )
        sizer.Add( menu, proportion=0, flag=wx.EXPAND, border=0 )
        sizer.Add( self.text, proportion=2, flag=wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, border=10 )
        sizer.Add( button, proportion=0, flag=wx.ALIGN_CENTER, border=0 )
        self.SetSizerAndFit( sizer )

        self.Bind(wx.EVT_BUTTON, self.OnClose)
Exemplo n.º 2
0
class MainTooltips( wx.Panel ):
    """
    @author:       Brigitte Bigi
    @organization: Laboratoire Parole et Langage, Aix-en-Provence, France
    @contact:      [email protected]
    @license:      GPL, v3
    @copyright:    Copyright (C) 2011-2016  Brigitte Bigi
    @summary:      Main tooltips panel.

    """
    def __init__(self, parent, preferences):
        wx.Panel.__init__(self, parent, -1, style=wx.RAISED_BORDER)
        self.SetBackgroundColour( preferences.GetValue('M_BGD_COLOUR') )
        self._prefs = preferences
        self.tips = Tips()

        menu   = self._create_menu()
        self.text = self._create_content()
        button = self._create_button()

        sizer = wx.BoxSizer( wx.VERTICAL )
        sizer.Add( menu, proportion=0, flag=wx.EXPAND, border=0 )
        sizer.Add( self.text, proportion=2, flag=wx.EXPAND|wx.ALIGN_CENTER|wx.ALL, border=10 )
        sizer.Add( button, proportion=0, flag=wx.ALIGN_CENTER, border=0 )
        self.SetSizerAndFit( sizer )

        self.Bind(wx.EVT_BUTTON, self.OnClose)

    # -----------------------------------------------------------------------

    def _create_menu(self):
        return MainActionsMenuPanel(self, self._prefs, icon=MENU_CLOSE_ICON)

    def _create_content(self):
        txt = wx.TextCtrl(self, wx.ID_ANY, value=self.tips.get(), style=wx.TE_READONLY|wx.TE_MULTILINE|wx.NO_BORDER)
        font = self._prefs.GetValue('M_FONT')
        txt.SetFont(font)
        txt.SetForegroundColour( self._prefs.GetValue('M_FG_COLOUR') )
        txt.SetBackgroundColour( self._prefs.GetValue('M_BGD_COLOUR') )
        txt.SetMinSize((300,48))
        return txt

    def _create_button(self):
        btncreator = ButtonCreator(self._prefs)
        btn = btncreator.CreateButton(self, FORWARD_ICON, " Next tip", "Show a random tip", wx.NewId())
        btn.SetBackgroundColour( self._prefs.GetValue('M_BG_COLOUR') )
        btn.Bind(wx.EVT_BUTTON, self.OnNext)
        return btn

    # -----------------------------------------------------------------------

    def OnClose(self, event):
        self.Hide()
        evt = wx.CommandEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, ID_ACTIONS)
        evt.SetEventObject(self)
        wx.PostEvent(self.GetParent(), evt)

    # -----------------------------------------------------------------------

    def OnNext(self, event):
        self.text.SetValue( self.tips.get() )
        self.Refresh()