Esempio n. 1
0
class StatusbarWidget(wx.StatusBar):
    def __init__(self, parent):
        super(StatusbarWidget, self).__init__(parent, style=wx.SB_FLAT)
        self.SetFieldsCount(3)
        self.SetStatusWidths([-6, -1, -1])
        self.size_changed = False

        self._label_info = GenStaticText(self, -1, '')
        self._label_coord = GenStaticText(self, -1, '')
        self._label_simulation = GenStaticText(self, -1, '')

        self.Bind(wx.EVT_SIZE, self.on_size)
        self.Bind(wx.EVT_IDLE, self.on_idle)

    def set_log_text(self, msg, mode=psi.LOG_INFO):
        self._label_info.SetLabel(msg)

        font = self._label_info.GetFont()

        if mode == psi.LOG_ERROR:
            self._label_info.SetForegroundColour((193, 43, 1))
            font.SetWeight(wx.BOLD)

        else:
            self._label_info.SetForegroundColour((0, 0, 0))
            font.SetWeight(wx.NORMAL)

        self._label_info.SetFont(font)

    def set_coord_text(self, msg):
        self._label_coord.SetLabel(msg)

    def set_simulation_text(self, msg):
        self._label_simulation.SetLabel(msg)
        # self.SetStatusText(msg, 1)

    def on_size(self, event):
        self.reposition()
        self.size_changed = True

    def on_idle(self, event):
        if self.size_changed:
            self.reposition()

    def reposition(self):
        rect = self.GetFieldRect(0)
        self._label_info.SetPosition((rect.x + 3, rect.y + 4))
        self._label_info.SetSize((rect.width - 4, rect.height - 4))

        rect = self.GetFieldRect(1)
        self._label_coord.SetPosition((rect.x + 3, rect.y + 4))
        self._label_coord.SetSize((rect.width - 4, rect.height - 4))

        rect = self.GetFieldRect(2)
        self._label_simulation.SetPosition((rect.x + 3, rect.y + 4))
        self._label_simulation.SetSize((rect.width - 4, rect.height - 4))

        self.size_changed = False

    def SetStatusText(self, *args, **kwargs):
        'ignoring'
        pass
Esempio n. 2
0
def LaunchDialog(localsettings, splashimagepath=False):

    dialog = wx.Dialog(None, -1, "Evette")
    dialog.Bind(wx.EVT_CLOSE, ExitApp)

    iconFile = "icons/evette.ico"
    icon1 = wx.Icon(iconFile, wx.BITMAP_TYPE_ICO)
    dialog.SetIcon(icon1)

    dialogsizer = wx.BoxSizer(wx.VERTICAL)

    panel = wx.Panel(dialog)

    topsizer = wx.BoxSizer(wx.VERTICAL)

    bgsizer = wx.BoxSizer(wx.VERTICAL)

    if splashimagepath == False:

        imagebitmap = wx.Bitmap(miscmethods.GetImagePath())

    else:

        imagebitmap = wx.Bitmap("icons/images/" + splashimagepath)

    randomimage = wx.StaticBitmap(panel, -1, imagebitmap)
    framesize = imagebitmap.GetSize()
    bgsizer.Add(randomimage, 0, wx.ALIGN_CENTER)

    spacer = GenStaticText(panel, -1, "")
    topsizer.Add(spacer, 1, wx.EXPAND)

    horizontalsizer = wx.BoxSizer(wx.HORIZONTAL)

    infosizer = wx.BoxSizer(wx.VERTICAL)

    infosizer.Add(GenStaticText(panel, 1, ""), 1, wx.EXPAND)

    versionnolabel = GenStaticText(panel, -1,
                                   GetLabel("versionlabel", localsettings))
    font = versionnolabel.GetFont()
    font.SetPointSize(font.GetPointSize() - 2)
    versionnolabel.SetFont(font)
    infosizer.Add(versionnolabel, 0, wx.ALIGN_CENTER)

    versionnoentry = GenStaticText(panel, -1,
                                   str(dbupdates.GetCurrentVersion()))
    font = versionnoentry.GetFont()
    font.SetPointSize(font.GetPointSize() + 8)
    font.SetWeight(wx.FONTWEIGHT_BOLD)
    versionnoentry.SetFont(font)
    versionnoentry.SetForegroundColour("blue")
    infosizer.Add(versionnoentry, 0, wx.ALIGN_CENTER)

    infosizer.Add(GenStaticText(panel, 1, ""), 1, wx.EXPAND)

    horizontalsizer.Add(infosizer, 1, wx.ALIGN_BOTTOM)

    horizontalsizer.Add(GenStaticText(panel, -1, ""), 1, wx.EXPAND)

    entrysizer = wx.BoxSizer(wx.VERTICAL)

    userlabel = GenStaticText(panel, -1,
                              GetLabel("usernamelabel", localsettings) + ":")
    font = userlabel.GetFont()
    font.SetPointSize(font.GetPointSize() - 2)
    userlabel.SetFont(font)
    entrysizer.Add(userlabel, 0, wx.ALIGN_LEFT)

    userentry = wx.TextCtrl(panel,
                            -1,
                            localsettings.lastuser,
                            size=(150, -1),
                            style=wx.TE_PROCESS_ENTER)
    userentry.description = "username"
    userentry.Bind(wx.EVT_CHAR, ButtonPressed)
    userentry.SetToolTipString(
        GetLabel("tabbetweenentriestooltip", localsettings))
    userentry.SetFocus()
    entrysizer.Add(userentry, 0, wx.EXPAND)

    passwordlabel = GenStaticText(
        panel, -1,
        GetLabel("passwordlabel", localsettings) + ":")
    passwordlabel.SetFont(font)
    entrysizer.Add(passwordlabel, 0, wx.ALIGN_LEFT)

    passwordentry = wx.TextCtrl(panel,
                                -1,
                                "",
                                style=wx.TE_PASSWORD | wx.TE_PROCESS_ENTER)
    passwordentry.description = "password"
    passwordentry.SetFocus()
    passwordentry.Bind(wx.EVT_CHAR, ButtonPressed)
    entrysizer.Add(passwordentry, 0, wx.EXPAND)

    horizontalsizer.Add(entrysizer, 0, wx.ALIGN_BOTTOM)

    topsizer.Add(horizontalsizer, 1, wx.EXPAND)

    panel.SetSizer(topsizer)

    panel.userentry = userentry
    panel.passwordentry = passwordentry
    panel.localsettings = localsettings

    dialogsizer.Add(panel, 1, wx.EXPAND)

    dialog.SetSizer(dialogsizer)

    dialog.panel = panel

    dialog.SetSize(framesize)
    dialog.CenterOnScreen()

    dialog.ShowModal()