Beispiel #1
0
 def RecordStart(self):
     self.GetUser()
     insert_sql = '''
         insert into data(user_id,app_version) values (?,?)
     '''
     data = [(self.user_id,sysutilslib.GetAppVersion()),]
     self.data_id = self.save(insert_sql,data)
Beispiel #2
0
 def CheckAppUpdate(self, ignore_error=False):
     api_addr = '%s/member/get_update' % (UserDataDb.HOST_SERVER_ADDR)
     config = wx.ConfigBase_Get()
     langId = GeneralOption.GetLangId(config.Read("Language", ""))
     lang = wx.Locale.GetLanguageInfo(langId).CanonicalName
     app_version = sysutilslib.GetAppVersion()
     data = UserDataDb.get_db().RequestData(api_addr,
                                            arg={
                                                'app_version': app_version,
                                                'lang': lang
                                            })
     if data is None:
         if not ignore_error:
             wx.MessageBox(_("could not connect to version server"),
                           style=wx.OK | wx.ICON_ERROR)
         return
     #no update
     if data['code'] == 0:
         if not ignore_error:
             wx.MessageBox(data['message'])
     #have update
     elif data['code'] == 1:
         ret = wx.MessageBox(data['message'], _("Update Available"),
                             wx.YES_NO | wx.ICON_QUESTION)
         if ret == wx.YES:
             new_version = data['new_version']
             download_url = '%s/member/download_app' % (
                 UserDataDb.HOST_SERVER_ADDR)
             payload = dict(new_version=new_version,
                            lang=lang,
                            os_name=sys.platform)
             user_id = UserDataDb.get_db().GetUserId()
             if user_id:
                 payload.update({'member_id': user_id})
             req = requests.get(download_url, params=payload, stream=True)
             #print req.headers,"------------"
             #print req.url
             if 'Content-Length' not in req.headers:
                 data = req.json()
                 if data['code'] != 0:
                     wx.MessageBox(data['message'],
                                   style=wx.OK | wx.ICON_ERROR)
             else:
                 file_length = req.headers['Content-Length']
                 content_disposition = req.headers['Content-Disposition']
                 file_name = content_disposition[content_disposition.
                                                 find(";") + 1:].replace(
                                                     "filename=",
                                                     "").replace("\"", "")
                 file_downloader = FileDownloader(file_length, file_name,
                                                  req, self.Install)
                 file_downloader.StartDownload()
     #other error
     else:
         if not ignore_error:
             wx.MessageBox(data['message'], style=wx.OK | wx.ICON_ERROR)
Beispiel #3
0
    def __init__(self, parent):
        """
        Initializes the about dialog.
        """
        wx.Dialog.__init__(self,
                           parent,
                           -1,
                           _("About ") + wx.GetApp().GetAppName(),
                           style=wx.DEFAULT_DIALOG_STYLE)

        nb = wx.Notebook(self, -1)

        aboutPage = wx.Panel(nb, -1)
        sizer = wx.BoxSizer(wx.VERTICAL)

        if not ACTIVEGRID_BASE_IDE:
            splash_bmp = getSplashBitmap()
        else:
            splash_bmp = getIDESplashBitmap()
        version = sysutilslib.GetAppVersion()
        image = wx.StaticBitmap(
            aboutPage, -1, splash_bmp, (0, 0),
            (splash_bmp.GetWidth(), splash_bmp.GetHeight()))
        sizer.Add(image, 0, wx.ALIGN_CENTER | wx.ALL, 0)
        sizer.Add(
            wx.StaticText(
                aboutPage, -1,
                wx.GetApp().GetAppName() +
                _("\n%s\n\nCopyright (c) 2014-2018 Genetalks Incorporated and Contributors.  All rights reserved."
                  ) % version), 0, wx.ALIGN_LEFT | wx.ALL, 10)
        sizer.Add(wx.StaticText(aboutPage, -1, _("http://www.novalide.com")),
                  0, wx.ALIGN_LEFT | wx.LEFT | wx.BOTTOM, 10)
        aboutPage.SetSizer(sizer)
        nb.AddPage(aboutPage, _("Copyright"))

        licensePage = wx.Panel(nb, -1)
        grid = wx.grid.Grid(licensePage, -1)
        grid.CreateGrid(len(licenseData), 2)

        dc = wx.ClientDC(grid)
        dc.SetFont(grid.GetLabelFont())
        grid.SetColLabelValue(0, _("License"))
        grid.SetColLabelValue(1, _("URL"))
        w, h1 = dc.GetTextExtent(_("License"))
        w, h2 = dc.GetTextExtent(_("URL"))
        maxHeight = max(h1, h2)
        grid.SetColLabelSize(maxHeight + 6)  # add a 6 pixel margin

        maxW = 0
        for row, data in enumerate(licenseData):
            package = data[0]
            license = data[1]
            url = data[2]
            if package:
                grid.SetRowLabelValue(row, package)
                w, h = dc.GetTextExtent(package)
                if w > maxW:
                    maxW = w
            if license:
                grid.SetCellValue(row, 0, license)
            if url:
                grid.SetCellValue(row, 1, url)

        grid.EnableEditing(False)
        grid.EnableDragGridSize(False)
        grid.EnableDragColSize(False)
        grid.EnableDragRowSize(False)
        grid.SetRowLabelAlignment(wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
        grid.SetLabelBackgroundColour(wx.WHITE)
        grid.AutoSizeColumn(0)
        grid.AutoSizeColumn(1)
        grid.SetRowLabelSize(maxW + 10)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 1, wx.EXPAND | wx.ALL, 10)
        licensePage.SetSizer(sizer)
        nb.AddPage(licensePage, _("Licenses"))

        creditsPage = wx.Panel(nb, -1)
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(
            wx.StaticText(
                creditsPage, -1,
                _("NovalIDE Developer:\n\nNAME:wukan\nMAIL:[email protected]\nQQ:273655394\nWX:w89730387"
                  )), 0, wx.ALIGN_LEFT | wx.ALL, 10)
        creditsPage.SetSizer(sizer)
        nb.AddPage(creditsPage, _("Credits"))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(nb, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        btn = wx.Button(self, wx.ID_OK)
        sizer.Add(btn, 0, wx.ALIGN_CENTRE | wx.ALL, 5)

        self.SetSizer(sizer)
        self.Layout()
        self.Fit()
        grid.ForceRefresh()  # wxBug: Get rid of unnecessary scrollbars