Esempio n. 1
0
    def addSessionsToGrid(self, grid, begin_row, begin_col):
        """ Add session.id to each row of the grid

            Arguments:
            grid -- wx.grid.Grid    The grid to add session IDs to
            begin_row -- int        The row to begin adding values to
            begin_col -- int        The column to begin adding values to
            
        """
        if None == self.sessions:
            self.sessions = self.calibratorDB.getSessions()

        grid.ClearGrid()

        # Add rows to the grid if necessary
        numSessions = len(self.sessions)
        rowsNeeded = numSessions - grid.NumberRows
        if rowsNeeded > 0:
            grid.AppendRows(rowsNeeded)

        myRow = begin_row
        for session in self.sessions:
            grid.SetCellValue(myRow, begin_col, str(session.id))
            myRow += 1
        grid.AutoSizeColumns()
        grid.AutoSizeRows()
Esempio n. 2
0
    def setSessionDetail(self, grid, session, begin_row, begin_col):
        """ Sets session detail in GUI
        
            Arguments:
            grid -- wx.grid.Grid    The grid to add session details t
            session -- model_runner_db.CalibrationSession
            begin_row -- int        The row to begin adding values to
            begin_col -- int        The column to begin adding values to
        """
        #self.sessionDetail.Clear()
        #self.sessionDetail.WriteText("id: %s\nobs_filename: %s" %
        #                             (session.id, session.obs_filename))

        grid.ClearGrid()
        
        grid.SetCellValue(begin_row, begin_col, str(session.starttime))
        if session.endtime:
            grid.SetCellValue(begin_row+1, begin_col, str(session.endtime))
        grid.SetCellValue(begin_row+2, begin_col, session.user)
        grid.SetCellValue(begin_row+3, begin_col, session.project)
        grid.SetCellValue(begin_row+4, begin_col, str(session.iterations))
        grid.SetCellValue(begin_row+5, begin_col, str(session.processes))
        grid.SetCellValue(begin_row+6, begin_col, session.status)
        if session.obs_filename:
            grid.SetCellValue(begin_row+7, begin_col, session.obs_filename)
        if session.notes:
            grid.SetCellValue(begin_row+8, begin_col, session.notes)
        grid.AutoSizeColumns()
        grid.AutoSizeRows()
Esempio n. 3
0
    def OnSearch(self, event):
        # Scan libraries looking for parts that match search string.
        progress = wx.ProgressDialog("Searching Part Libraries",
                                     "Loading parts from libraries.")
        self.lib_parts = set()
        search_text = self.search_text.GetLineText(0)
        for lib_part in search_libraries(search_text):
            if lib_part[0] == "LIB":
                lib_name, lib_idx, num_libs = lib_part[1:4]
                progress.SetRange(num_libs)
                progress.Update(lib_idx,
                                "Reading library {}...".format(lib_name))
            elif lib_part[0] == "PART":
                self.lib_parts.add(LibPart(*lib_part[1:]))

        # Sort parts by libraries and part names.
        self.lib_parts = sorted(
            list(self.lib_parts),
            key=lambda x: "/".join([x.lib_name, x.part_name]),
        )

        # place libraries and parts into a table.
        grid = self.found_parts

        # Clear any existing grid cells and add/sub rows to hold search results.
        grid.Resize(len(self.lib_parts))

        # Places libs and part names into table.
        for row, lib_part in enumerate(self.lib_parts):
            grid.SetCellValue(row, 0, lib_part.lib_name)
            grid.SetCellValue(row, 1, lib_part.part_name)

        # Size the columns for their new contents.
        grid.AutoSizeColumns()
def setGridProperties(variableObj):
    for grid in variableObj.gridList:
        grid.SetCellBackgroundColour(0,0,variableObj.constantObj.COLOR_LABEL)   #SETTING COLOR FOR CELL (0,0)
        grid.SetSize((variableObj.maximizedFrameSize[0])-100,variableObj.maximizedFrameSize[1] - 150)   #setting the (width, height) in pixels of the grid
        grid.SetColMinimalAcceptableWidth(70)                                  #setting minimum length of a column possible(in pixel)
        grid.SetDefaultCellAlignment(ALIGN_CENTRE,ALIGN_CENTRE)                #values will be centered aligned
        grid.AutoSizeColumns()                                                 #column will be set to the size of longest element in the column
Esempio n. 5
0
    def __init__(self, parent, arr, title):
        wxFrame.__init__(self, parent, -1, title)
        global grid
        grid = HugeTableGrid(self, arr)

        grid.EnableDragRowSize(0)
        grid.SetDefaultCellAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
        grid.SetFont(wx.SWISS_FONT)
        grid.AutoSizeColumns()
Esempio n. 6
0
    def OnSelectCell(self, event):
        # When a row of the lib/part table is selected, display the data for that part.

        def natural_sort_key(s, _nsre=re.compile("([0-9]+)")):
            return [
                int(text) if text.isdigit() else text.lower()
                for text in _nsre.split(s)
            ]

        # Get any selected rows in the lib/part table plus wherever the cell cursor is.
        selection = self.found_parts.GetSelectedRows()
        selection.append(self.found_parts.GetGridCursorRow())

        # Only process the part in the first selected row and ignore the rest.
        for row in selection:
            # Fully instantiate the selected part.
            part = self.lib_parts[row].part
            part.parse()  # Instantiate pins.

            # Show the part description.
            self.part_desc.Remove(0, self.part_desc.GetLastPosition())
            desc = part.description
            # if part.aliases:
            #     desc += "\nAliases: " + ", ".join(list(part.aliases))
            if part.keywords:
                desc += "\nKeywords: " + part.keywords
            self.part_desc.WriteText(desc)

            # Display the link to the part datasheet.
            self.datasheet_link.SetURL(part.datasheet)

            # Place pin data into a table.
            grid = self.pin_info

            # Clear any existing pin data and add/sub rows to hold results.
            grid.Resize(len(part))

            # Sort pins by pin number.
            pins = sorted(part,
                          key=lambda p: natural_sort_key(p.get_pin_info()[0]))

            # Place pin data into the table.
            for row, pin in enumerate(pins):
                num, names, func = pin.get_pin_info()
                grid.SetCellValue(row, 0, num)
                grid.SetCellValue(row, 1, names)
                grid.SetCellValue(row, 2, func)

            # Size the columns for their new contents.
            grid.AutoSizeColumns()

            # Return after processing only one part.
            return
Esempio n. 7
0
    def _init_gui(self, result):
        table = DataTable(result)

        grid = wx.grid.Grid(self, -1)
        grid.SetTable(table, takeOwnership=True)
        grid.AutoSizeColumns()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 1, wx.EXPAND)
        self.SetSizer(sizer)
        #self.SetTitle(result[5:8] + " Timetable")

        self.Bind(wx.EVT_CLOSE, self.exit)
Esempio n. 8
0
def changeGrid(grid,
               data,
               colnames,
               rownames,
               oddcol="#f0f0f0",
               evencol="white"):
    if len(data) > 0:
        model = MinimalGridTableModel(len(data), len(data[0]), data, colnames,
                                      rownames, oddcol, evencol)
        grid.SetTable(model, True)
        grid.Refresh()
        grid.AutoSizeRows()
        grid.AutoSizeColumns()
        return grid
Esempio n. 9
0
    def _init_gui(self):
        df = pd.DataFrame(np.random.random((20, 5)))
        table = DataTable(df)

        grid = wx.grid.Grid(self, -1)
        grid.SetTable(table, takeOwnership=True)
        grid.AutoSizeColumns()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 1, wx.EXPAND)
        self.SetSizer(sizer)
        sizer.SetSizeHints(self)

        self.Bind(wx.EVT_CLOSE, self.exit)
Esempio n. 10
0
    def _init_gui(self):
        df = pd.DataFrame(np.random.random((10, 5)))
        # 色を塗りたいところ
        x = [[1, 1], [3, 3], [5, 5]]
        table = DataTable(df, x)

        grid = wx.grid.Grid(self, -1)
        grid.SetTable(table, takeOwnership=True)
        grid.AutoSizeColumns()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 1, wx.EXPAND)
        self.SetSizer(sizer)

        self.Bind(wx.EVT_CLOSE, self.exit)
Esempio n. 11
0
    def __init__(self):
        wx.Dialog.__init__(self, None, -1, u'模板管理器', size=(500, 200))

        #这里利用grid(其实用listCtrl就足够了,但是不会用--imageList的部分??)
        colLabels = [u'模板名', u'基本信息']
        grid = wx.grid.Grid(self, -1, size=(500, 115))
        grid.CreateGrid(len(data.column1), 2)
        grid.EnableEditing(False)  #设置为不可编辑的状态

        #设置表头
        grid.SetColLabelValue(0, colLabels[0])
        grid.SetColLabelValue(1, colLabels[1])

        #设置表内容
        '''
        i = 0
        while i < len(data.column1):
            grid.SetCellValue(i,0,data.column1[i])
            grid.SetCellValue(i,1,data.column2[i])
            ++i
        grid.AutoSizeColumns(setAsMin=True)
        '''
        grid.SetCellValue(0, 0, data.column1[0])
        grid.SetCellValue(0, 1, data.column2[0])
        grid.SetCellValue(1, 0, data.column1[1])
        grid.SetCellValue(1, 1, data.column2[1])
        grid.AutoSizeColumns(setAsMin=True)
        grid.SetCellValue(2, 0, data.column1[2])
        grid.SetCellValue(2, 1, data.column2[2])
        grid.SetCellValue(3, 0, data.column1[3])
        grid.SetCellValue(3, 1, data.column2[3])

        #所有按钮
        #NameButton = wx.Button(self,wx.ID_OK,u'更名',pos=(100,125))
        NameButton = wx.Button(self, -1, u'更名', pos=(50, 125))
        self.Bind(wx.EVT_BUTTON, self.OnName, NameButton)

        DeleteButton = wx.Button(self, -1, u'删除', pos=(150, 125))
        self.Bind(wx.EVT_BUTTON, self.OnDelete, DeleteButton)

        AddButton = wx.Button(self, -1, u'新增', pos=(250, 125))
        self.Bind(wx.EVT_BUTTON, self.OnAdd, AddButton)

        #这两个暂时没什么作用,也没绑定事件
        CancelButton = wx.Button(self, wx.ID_CANCEL, u'取消', pos=(350, 125))
Esempio n. 12
0
    def timer(self):
        df = pd.read_csv(
            "/Users/raedzorkot/Desktop/pythontestodes/Workbook2.csv")
        table = DataTable(df)

        grid = wx.grid.Grid(self, -1)
        grid.SetTable(table, takeOwnership=True)
        grid.AutoSizeColumns()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(grid, 1, wx.EXPAND)
        self.SetSizer(sizer)

        self.Bind(wx.EVT_CLOSE, self.exit)
        self.Layout()
        self.Show()

        wx.CallLater(5000, self.timer)
Esempio n. 13
0
 def update_grid(self):
     """Update the grid after the table data has changed"""
     need_column_layout = False
     grid = self.grid
     v = self.v
     if len(v.column_names) < grid.GetNumberCols():
         tm = wx.grid.GridTableMessage(
             grid.Table,
             wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED,
             0,
             grid.GetNumberCols() - len(v.column_names),
         )
         grid.ProcessTableMessage(tm)
         need_column_layout = True
     elif grid.GetNumberCols() < len(v.column_names):
         tm = wx.grid.GridTableMessage(
             grid.Table,
             wx.grid.GRIDTABLE_NOTIFY_COLS_INSERTED,
             0,
             len(v.column_names) - grid.GetNumberCols(),
         )
         grid.ProcessTableMessage(tm)
         need_column_layout = True
     if len(v.data) < grid.GetNumberRows():
         tm = wx.grid.GridTableMessage(
             grid.Table,
             wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED,
             0,
             grid.GetNumberRows() - len(v.data),
         )
         grid.ProcessTableMessage(tm)
     elif grid.GetNumberRows() < len(v.data):
         tm = wx.grid.GridTableMessage(
             grid.Table,
             wx.grid.GRIDTABLE_NOTIFY_ROWS_INSERTED,
             0,
             len(v.data) - grid.GetNumberRows(),
         )
         grid.ProcessTableMessage(tm)
     if need_column_layout:
         grid.AutoSizeColumns()
Esempio n. 14
0
    def addRunDetailsToGrid(self, grid, run, begin_row, begin_col):
        """ Sets run detail in GUI

            Arguments:
            grid -- wx.grid.Grid    The grid to add run details to
            run -- model_runner_db.CalibrationRun
            begin_row -- int        The row to begin adding values to
            begin_col -- int        The column to begin adding values to 
        """
        grid.ClearGrid()

        grid.SetCellValue(begin_row, begin_col, run.worldfile)
        grid.SetCellValue(begin_row+1, begin_col, run.output_path)
        grid.SetCellValue(begin_row+2, begin_col, run.cmd_raw)
        if run.param_s1:
            grid.SetCellValue(begin_row+3, begin_col, "%.4f" % run.param_s1)
        if run.param_s2:
            grid.SetCellValue(begin_row+4, begin_col, "%.4f" % run.param_s2)
        if run.param_s3:
            grid.SetCellValue(begin_row+5, begin_col, "%.4f" % run.param_s3)
        if run.param_sv1:
            grid.SetCellValue(begin_row+6, begin_col, "%.4f" % run.param_sv1)
        if run.param_sv2:
            grid.SetCellValue(begin_row+7, begin_col, "%.4f" % run.param_sv2)
        if run.param_gw1:
            grid.SetCellValue(begin_row+8, begin_col, "%.4f" % run.param_gw1)
        if run.param_gw2:
            grid.SetCellValue(begin_row+9, begin_col, "%.4f" % run.param_gw2)
        if run.param_vgsen1:
            grid.SetCellValue(begin_row+10, begin_col, 
                              "%.4f" % run.param_vgsen1)
        if run.param_vgsen2:
            grid.SetCellValue(begin_row+11, begin_col, 
                              "%.4f" % run.param_vgsen2)
        if run.param_vgsen3:
            grid.SetCellValue(begin_row+12, begin_col, 
                              "%.4f" % run.param_vgsen3)
        grid.AutoSizeColumns()
        grid.AutoSizeRows()
Esempio n. 15
0
    def __init__(self, parent, id, TableTitle, digests):
        wx.Frame.__init__(self, parent, id, title=TableTitle, size=(640, 480))

        #add icon
        self.SetIcon(parent.get_icon())

        colHeaders = [
            'Protein Header', 'Sequence', 'Range', 'Missed Cleavage',
            '1+ Mass', '2+ Mass', '3+ Mass'
        ]
        rowCount = len(digests)

        pane = wx.Panel(self, -1, style=wx.TAB_TRAVERSAL | wx.CLIP_CHILDREN)

        #mass table
        grid = wx.grid.Grid(pane, -1)
        grid.CreateGrid(rowCount, len(colHeaders))

        #Set Column Headers
        for i, col in enumerate(colHeaders):
            grid.SetColLabelValue(i, col)

        #Print Data
        for i, peptide in enumerate(digests):
            for j, v in enumerate(peptide):
                if j != 2:
                    grid.SetCellValue(i, j, str(v))
                else:
                    grid.SetCellValue(i, j, '%d...%d' % v)

        grid.AutoSizeColumns(False)

        box = wx.BoxSizer()
        box.Add(grid, 1, wx.EXPAND | wx.ALL, 5)
        pane.SetSizerAndFit(box)

        w, h = self.GetSize()
        self.SetSize((grid.GetSize()[0] + 36, h))
        self.SetMinSize((w / 2, h / 2))
Esempio n. 16
0
  def __init__(self, parent,lbl,hid):
    wx.Frame.__init__(self, parent, title='HDFGridView: '+lbl,size=wx.Size(750, 650))
    imgDir=ut.Path.GetImage()
    icon = wx.Icon(os.path.join(imgDir,'h5pyViewer.ico'), wx.BITMAP_TYPE_ICO)
    self.SetIcon(icon)

    pan = wx.Panel(self, -1)

    t=type(hid)
    if t==h5py.h5d.DatasetID:
      data=h5py.Dataset(hid)
    elif t==np.ndarray:
      data=hid
    else:
      raise(TypeError('unhandled type'))
    grid = Grid(pan, data)

    tbl=grid.GetTable()

    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(grid, 1, wx.EXPAND)
    wxAxCtrlLst=[]
    l=len(data.shape)
    if l==1:
      if type(hid.get_type())==h5py.h5t.TypeCompoundID:
        tbl = Table1DCompound(data)
      else:
        tbl = Table1DArray(data)
    else:
      idxXY=(l-2,l-1)
      #idxXY=(l-1,l-2)
      for idx,l in enumerate(data.shape):
        if idx in idxXY:
          continue
        wxAxCtrl=ut.SliderGroup(pan, label='Axis:%d'%idx,range=(0,l-1))
        wxAxCtrl.idx=idx
        wxAxCtrlLst.append(wxAxCtrl)
        sizer.Add(wxAxCtrl.sizer, 0, wx.EXPAND | wx.ALIGN_CENTER | wx.ALL, border=5)
        wxAxCtrl.SetCallback(Grid.OnSetView,wxAxCtrl)

      sl=ut.GetSlice(idxXY,data.shape,wxAxCtrlLst)

      if type(hid.get_type())==h5py.h5t.TypeCompoundID:
        tbl = Table2DArray(data)
      else:
        tbl = Table2DArray(data)
      tbl.idxXY=idxXY
      if idxXY[0]<idxXY[1]:
        tbl.view = tbl.data[sl]
      else:
        tbl.view = tbl.data[sl].T
    self.wxAxCtrlLst=wxAxCtrlLst
    #print type(tbl)

    grid.SetTable (tbl, True)
    #AutoSize must be called after SetTable, but takes lot of time on big tables!
    if tbl.GetNumberCols()*tbl.GetNumberRows()<50*50:
      grid.AutoSizeColumns(True);grid.AutoSizeRows(True)
    #grid.SetDefaultColSize(200, True)       
    self.grid=grid

    pan.SetSizer(sizer)
    pan.Layout()
    self.Centre()
    self.BuildMenu()
    grid.Bind(wx.grid.EVT_GRID_CMD_COL_SIZE, self.OnColSize)
Esempio n. 17
0
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(1100, 600))
        wx.Log.SetActiveTarget(wx.LogStderr())
        self.CenterOnScreen()
        self.CreateStatusBar()
        #		self.SetStatusText("This is the statusbar")

        #Initialising the MenuBar
        menuBar = wx.MenuBar()
        menu1 = wx.Menu()
        #		menu1.Append(101,"Paste\tCtrl+V")
        #		menu1.Append(102,"Copy\tCtrl+C")
        menu1.AppendSeparator()
        menu1.Append(103, "Quit\tCtrl+Q")
        self.Bind(wx.EVT_MENU, self.MenuClose, id=103)
        menuBar.Append(menu1, "File")
        self.SetMenuBar(menuBar)

        #Initialising the Graphical User Interface (GUI)
        Tabs = wx.Notebook(self, style=wx.BK_BOTTOM)

        panelA = wx.Window(Tabs, wx.ID_ANY)
        Tabs.AddPage(panelA, "Overview")
        browser = wx.html2.WebView.New(panelA)
        browser.LoadURL("file://" + globals.filepath + "/overview_frame.html")

        panelB = wx.Window(panelA, wx.ID_ANY)
        browser2 = wx.html2.WebView.New(panelB)
        browser2.LoadURL("file://" + globals.filepath + "/html/" +
                         "overview2.html")

        panelC = wx.Window(panelB, wx.ID_ANY)

        panelD = wx.Window(panelC, wx.ID_ANY)  #For all investment indicators
        panelE = wx.Window(panelC,
                           wx.ID_ANY)  #For 'Liqudity' and 'Total' indicators
        total = 0.0
        total_inv = 0.0
        panel_scrolled = wx.lib.scrolledpanel.ScrolledPanel(
            panelD,
            -1,
            style=wx.TAB_TRAVERSAL | wx.SUNKEN_BORDER,
            name="panel1")
        fgs1 = wx.FlexGridSizer(cols=2, vgap=2, hgap=0)
        fgs1.SetMinSize(230, 10)

        #Summary Label
        st_summary = wx.StaticText(panel_scrolled, wx.ID_ANY,
                                   "Summary of assets: ")
        st_summary_placeholder = wx.StaticText(panel_scrolled, wx.ID_ANY, "")
        fgs1.Add(st_summary, flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
        fgs1.Add(st_summary_placeholder,
                 flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)

        for i in globals.config.sections():
            fullname = str(globals.config[i]["fullname"])
            j = globals.config.sections().index(i)
            if str(globals.config[i]["type"]) == "deka":
                clr = ""
                if globals.wealth_amount[j][-1] - globals.invested[j] > 0:
                    clr = "#00cc00"
                else:
                    clr = "red"
                st_fullname = wx.StaticText(panel_scrolled, wx.ID_ANY,
                                            fullname + " : ")
                st_placeholder = wx.StaticText(panel_scrolled, wx.ID_ANY, "")
                st_amount = wx.StaticText(panel_scrolled, wx.ID_ANY, "")
                st_amount.SetLabelMarkup(
                    "<b><span color='" + str(globals.config[i]["color"]) +
                    "'>" + "  {:.2f}".format(globals.wealth_amount[j][-1]) +
                    " </span></b>")
                try:
                    st_amount_percentage = wx.StaticText(
                        panel_scrolled, wx.ID_ANY, "")
                    st_amount_percentage.SetLabelMarkup(
                        "<span color='" + str(clr) + "'>" +
                        ("+" if globals.wealth_amount[j][-1] -
                         globals.invested[j] > 0 else "") + "{:.2f}".format(
                             round(
                                 globals.wealth_amount[j][-1] -
                                 globals.invested[j], 2)) + " (" +
                        "{:.2f}".format(
                            round((
                                (globals.wealth_amount[j][-1] -
                                 globals.invested[j]) / globals.invested[j]) *
                                  100, 2)) + " %) </span>")
                except ZeroDivisionError:
                    st_amount_percentage = wx.StaticText(
                        panel_scrolled, wx.ID_ANY, "")
                    st_amount_percentage.SetLabelMarkup(
                        "<span color='" + str(clr) + "'>" +
                        ("+" if globals.wealth_amount[j][-1] -
                         globals.invested[j] > 0 else "") + "{:.2f}".format(
                             round(
                                 globals.wealth_amount[j][-1] -
                                 globals.invested[j], 2)) + " </span>")
                total_inv += globals.invested[j]
                total += globals.wealth_amount[j][-1]
                fgs1.Add(st_fullname,
                         flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
                fgs1.Add(st_amount,
                         flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL)
                fgs1.Add(st_placeholder, flag=wx.ALIGN_LEFT | wx.ALIGN_TOP)
                fgs1.Add(st_amount_percentage,
                         flag=wx.ALIGN_LEFT | wx.ALIGN_TOP)
                fgs1.Add((0, 2))
                fgs1.Add((0, 2))
            if str(globals.config[i]["type"]) == "liq":
                st_fullname = wx.StaticText(panelE, wx.ID_ANY,
                                            fullname + " : ", (10, 0))
                st_amount = wx.StaticText(
                    panelE, wx.ID_ANY,
                    "  {:.2f} ".format(globals.liquidity[0]), (217, 0))

        #Total Labels
        st_total_fullname = wx.StaticText(panelE, wx.ID_ANY,
                                          "Total (w/o Liquidity): ", (10, 20))
        st_total_amount = wx.StaticText(panelE, wx.ID_ANY, "", (217, 20))
        st_total_amount.SetLabelMarkup("<b><span>" + "  {:.2f}".format(total) +
                                       " </span></b>")
        st_toal_amount_percentage = wx.StaticText(panelE, wx.ID_ANY, "",
                                                  (217, 40))
        st_toal_amount_percentage.SetLabelMarkup(
            "<span color='" +
            ("red" if (total - total_inv) < 0 else "#00cc00") + "'>" +
            ("+" if (total - total_inv) > 0 else "") +
            "{:.2f}".format(round(total - total_inv, 2)) + " (" +
            "{:.2f}".format(round((total - total_inv) * 100 / total_inv, 2)) +
            " %) </span>")
        panel_scrolled.SetSizer(fgs1)
        panel_scrolled.SetAutoLayout(1)
        panel_scrolled.SetupScrolling()

        hbox = wx.BoxSizer(wx.HORIZONTAL)
        hbox.Add(panel_scrolled, 1, wx.FIXED_MINSIZE | wx.EXPAND)
        panelD.SetSizer(hbox)

        bsizerDE = wx.BoxSizer(wx.VERTICAL)
        bsizerDE.Add(panelD, 3, wx.FIXED_MINSIZE | wx.EXPAND)
        bsizerDE.Add(panelE, 1, wx.EXPAND)
        panelC.SetSizer(bsizerDE)

        bsizer1 = wx.BoxSizer(wx.VERTICAL)
        bsizer1.Add(browser2, 1, wx.EXPAND)
        bsizer1.Add(panelC, 1, wx.EXPAND)
        panelB.SetSizer(bsizer1)

        bsizer2 = wx.BoxSizer(wx.HORIZONTAL)
        bsizer2.Add(browser, 2, wx.EXPAND)
        bsizer2.Add(panelB, 1, wx.EXPAND)
        panelA.SetSizer(bsizer2)

        self.choiceboxes = []  #300+
        self.browsers = []
        self.checkboxes = []
        self.checkboxes_ids = []  #400+
        self.checkboxes_auto_ids = []  #500+
        self.DatePicker_ids = []  #600+
        self.DatePickers = []
        self.SpinCtrls = []  #700+
        self.Notebooks = []  #800+

        self.choices = ["Fond Evolution", "Investment Evolution"]

        j = 0
        for i in globals.config.sections():
            panelA = wx.Window(Tabs, wx.ID_ANY)
            name = str(globals.config[str(i)]["name"])
            Tabs.AddPage(panelA, name)

            browser = wx.html2.WebView.New(panelA)
            browser.LoadURL("file://" + globals.filepath + "/html/" + name +
                            "/" + name + ".html")
            self.browsers.append(browser)

            panelB = wx.Window(panelA, wx.ID_ANY)

            panelC = wx.Window(panelB, wx.ID_ANY)

            t1 = wx.StaticText(panelC, wx.ID_ANY, "Settings")
            choicebox = wx.Choice(panelC,
                                  300 + len(self.choiceboxes),
                                  choices=self.choices)
            self.choiceboxes.append(choicebox)
            self.Bind(wx.EVT_CHOICE, self.OnChose, choicebox)

            cb = wx.CheckBox(panelC, 400 + len(self.checkboxes_ids),
                             "Show since establishment")
            self.checkboxes_ids.append(cb.GetId())
            cb.SetValue(False)
            self.checkboxes.append(cb)
            self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBox, cb)

            if str(globals.config[i]["type"]) == "deka":
                clr = ""
                if globals.wealth_amount[j][-1] - globals.invested[j] > 0:
                    clr = "#00cc00"
                else:
                    clr = "red"
                wx.StaticText(panelC, wx.ID_ANY, "Invested Amount: ", (10, 90))
                wx.StaticText(panelC, wx.ID_ANY,
                              "{:.2f}".format(globals.invested[j]), (250, 90))
                wx.StaticText(
                    panelC, wx.ID_ANY,
                    "Value of the Invested Amount\n(w reinvested dividends): ",
                    (10, 110))
                wx.StaticText(panelC, wx.ID_ANY,
                              "{:.2f}".format(globals.wealth_amount[j][-1]),
                              (250, 115))
                wx.StaticText(panelC, wx.ID_ANY, "Current Holding: ",
                              (10, 145))
                wx.StaticText(panelC, wx.ID_ANY,
                              str(round(globals.current_holding[j], 3)) + " ",
                              (250, 145))
                wx.StaticText(panelC, wx.ID_ANY, "", (10, 165)).SetLabelMarkup(
                    "<span color='blue'>Reinvested dividends: </span>")
                wx.StaticText(panelC, wx.ID_ANY,
                              "{:.2f}".format(globals.dividends_invested[j]),
                              (250, 165))
                wx.StaticText(panelC, wx.ID_ANY, "", (10, 185)).SetLabelMarkup(
                    "<span color='red'>Transferred dividends: </span>")
                wx.StaticText(
                    panelC, wx.ID_ANY,
                    str("{:.2f}".format(globals.dividends_transferred[j])),
                    (250, 185))
                wx.StaticText(panelC, wx.ID_ANY, "Total gain/loss:", (10, 205))
                wx.StaticText(panelC, wx.ID_ANY, "", (
                    250 - 5,
                    205)).SetLabelMarkup("<span color='" + str(clr) + "'>" +
                                         ("+" if globals.wealth_amount[j][-1] -
                                          globals.invested[j] > 0 else "") +
                                         "{:.2f}".format(
                                             round(
                                                 globals.wealth_amount[j][-1] -
                                                 globals.invested[j], 2)) +
                                         " </span>")
                try:
                    wx.StaticText(
                        panelC, wx.ID_ANY, "", (250 - 5, 225)).SetLabelMarkup(
                            "<span color='" + str(clr) + "'>" +
                            ("+" if globals.wealth_amount[j][-1] -
                             globals.invested[j] > 0 else "") +
                            "{:.2f}".format(
                                round(((globals.wealth_amount[j][-1] -
                                        globals.invested[j]) /
                                       globals.invested[j]) * 100, 2)) +
                            " % </span>")
                except ZeroDivisionError:
                    wx.StaticText(
                        panelC, wx.ID_ANY, "", (250 - 5, 225)).SetLabelMarkup(
                            "<span color='" + str(clr) + "'>" +
                            ("+" if globals.wealth_amount[j][-1] -
                             globals.invested[j] > 0 else "") +
                            "{:.2f}".format(
                                round(
                                    globals.wealth_amount[j][-1] -
                                    globals.invested[j], 2)) + " </span>")
                cb_aut = wx.CheckBox(panelC,
                                     500 + len(self.checkboxes_auto_ids),
                                     "Monthly Automatisation from:", (10, 255))
                self.checkboxes_auto_ids.append(cb_aut.GetId())
                self.Bind(wx.EVT_CHECKBOX, self.EvtCheckBoxAut, cb_aut)
                dpc = wx.adv.DatePickerCtrl(panelC,
                                            600 + len(self.DatePicker_ids),
                                            wx.DateTime.Today(), (10, 275))
                if len(globals.wealth_dates[0]) > 1:
                    minimumdate = wx.DateTime(
                        int(str(globals.wealth_dates[j][0])[-2:]),
                        int(str(globals.wealth_dates[j][0])[5:7]) - 1,
                        int(str(globals.wealth_dates[j][0])[:4]))
                    maximumdate = wx.DateTime(
                        int(str(globals.wealth_dates[j][-1])[-2:]),
                        int(str(globals.wealth_dates[j][-1])[5:7]) - 1,
                        int(str(globals.wealth_dates[j][-1])[:4]))
                    dpc.SetRange(minimumdate, maximumdate)
                date = globals.config[i]["aut"]
                if date == "":
                    dpc.Disable()
                    dpc.SetValue(wx.DateTime.Today())
                    cb_aut.SetValue(False)
                else:
                    cb_aut.SetValue(True)
                    dpc.SetValue(
                        wx.DateTime(int(date[:2]),
                                    int(date[3:5]) - 1, int(date[-4:])))
                self.Bind(wx.adv.EVT_DATE_CHANGED, self.OnDateChanged, dpc)
                self.DatePicker_ids.append(dpc.GetId())
                self.DatePickers.append(dpc)
                SpinCtrlDouble_amount = wx.SpinCtrlDouble(panelC,
                                                          value='25.00',
                                                          min=25,
                                                          max=1000,
                                                          pos=(200, 280),
                                                          id=700 +
                                                          len(self.SpinCtrls),
                                                          inc=0.01)
                if date == "": SpinCtrlDouble_amount.Enable(False)
                if globals.config[i]["aut_amount"] != "":
                    SpinCtrlDouble_amount.SetValue(
                        str(
                            globals.ConvertToFloat(
                                globals.config[i]["aut_amount"])))
                self.SpinCtrls.append(SpinCtrlDouble_amount)
                self.Bind(wx.EVT_SPINCTRL, self.OnSpinCtrl,
                          SpinCtrlDouble_amount)
                self.Bind(wx.EVT_TEXT, self.OnSpinCtrl, SpinCtrlDouble_amount)
            if str(globals.config[i]["type"]) == "liq":
                wx.StaticText(panelC, wx.ID_ANY, "Available Liqudity",
                              (10, 185))
                wx.StaticText(panelC, wx.ID_ANY,
                              "{:.2f}".format(globals.liquidity[0]),
                              (250, 185))

            panelD = wx.Window(panelB, wx.ID_ANY)
            smallTabs = wx.Notebook(panelD,
                                    style=wx.BK_TOP,
                                    id=800 + len(self.Notebooks))
            self.Notebooks.append(smallTabs)
            self.Bind(wx.EVT_NOTEBOOK_PAGE_CHANGED,
                      self.EvtNotebookPageChanged, smallTabs)
            panelE = wx.Window(smallTabs, wx.ID_ANY)
            smallTabs.AddPage(panelE, "History")
            grid = wx.grid.Grid(panelE)
            grid.SetRowLabelSize(0)
            grid.SetMargins(0, 0)
            grid.AutoSizeColumns(False)
            name = str(globals.config[str(i)]["name"])
            if str(globals.config[i]["type"]) == "deka":
                date_b, amount_b, date_d, amount_d = globals.parseInvestementData(
                    i, name)
                grid.CreateGrid(
                    max(len(date_b), len(amount_b), len(date_d),
                        len(amount_d)), 4)
                for k in range(len(date_d)):
                    grid.SetCellValue(k, 2, date_d[k])
                    grid.SetCellValue(k, 3, amount_d[k])
                    grid.SetCellBackgroundColour(k, 2,
                                                 wx.Colour(0, 0, 255, 80))
                    grid.SetCellBackgroundColour(k, 3,
                                                 wx.Colour(0, 0, 255, 80))
                date_d_t, amount_d_t = globals.parseTransferedDividendData(
                    name)
                for k in range(len(date_d_t)):
                    index = len(date_d) + k
                    grid.SetCellValue(index, 2, date_d_t[k])
                    grid.SetCellValue(index, 3, amount_d_t[k])
                    grid.SetCellBackgroundColour(index, 2,
                                                 wx.Colour(255, 0, 0, 80))
                    grid.SetCellBackgroundColour(index, 3,
                                                 wx.Colour(255, 0, 0, 80))
                grid.SetColLabelValue(2, "Date \nDividend")
                grid.SetColLabelValue(3, "Amount")
                grid.SetColSize(2, 80)
                grid.SetColSize(3, 70)
                grid.SetColLabelValue(0, "Date \nBuy")
            if str(globals.config[i]["type"]) == "liq":
                date_b, amount_b = globals.parseLiqudityData(name)
                grid.CreateGrid(len(date_b), 2)
                cb.Enable(False)
                choicebox.Enable(False)
                grid.SetColLabelValue(0, "Date")
            for k in range(len(date_b)):
                grid.SetCellValue(k, 0, date_b[k])
                grid.SetCellValue(k, 1, amount_b[k])
            grid.SetColLabelValue(1, "Amount")
            grid.SetColSize(0, 80)
            grid.SetColSize(1, 70)
            grid.SetRowLabelSize(20)
            grid.EnableEditing(False)
            grid.DisableDragGridSize()

            boxsizerE = wx.BoxSizer(wx.VERTICAL)
            boxsizerE.Add(grid, 0, wx.EXPAND)
            panelE.SetSizer(boxsizerE)

            if str(globals.config[i]["type"]) == "deka":
                panelF = wx.Window(smallTabs, wx.ID_ANY)
                smallTabs.AddPage(panelF, "ScopeAnalyis")
                s = globals.scopeAnalysisData[globals.config.sections().index(
                    i)]
                panelFa = wx.Window(panelF, wx.ID_ANY)
                wx.StaticText(panelFa, wx.ID_ANY, "Scope Rating ", (10, 5))
                wx.StaticText(
                    panelFa, wx.ID_ANY, "{} ({})".format(
                        s.rating,
                        str(s.score) + "/100" if s.score > 0 else "--/--"),
                    (250, 5))
                wx.lib.agw.hyperlink.HyperLinkCtrl(panelFa,
                                                   wx.ID_ANY,
                                                   "Detailed Report",
                                                   URL=s.url,
                                                   pos=(225, 25))

                boxsizerFa = wx.BoxSizer(wx.VERTICAL)
                panelFa.SetSizer(boxsizerFa)

                #panelFb = wx.Window(panelF,wx.ID_ANY)
                #browser3 = wx.html2.WebView.New(panelFb,pos=(0,10))
                #browser3.LoadURL("file://"+globals.filepath+"/html/"+name+"/"+name+"_Scope.html")
                #browser3.LoadURL("file://"+globals.filepath+"/html/"+"overview1.html")

                #boxsizerFb = wx.BoxSizer(wx.VERTICAL)
                #boxsizerFb.Add(browser3,1,wx.EXPAND)
                #panelFb.SetSizer(boxsizerFb)

                boxsizerF = wx.BoxSizer(wx.VERTICAL)
                boxsizerF.Add(panelFa, 1, wx.EXPAND)
                #boxsizerF.Add(panelFb, 2, wx.EXPAND|wx.ALIGN_BOTTOM)
                panelF.SetSizer(boxsizerF)

            boxsizerD = wx.BoxSizer(wx.VERTICAL)
            boxsizerD.Add(smallTabs, 1, wx.EXPAND)
            panelD.SetSizer(boxsizerD)

            boxsizerC = wx.BoxSizer(wx.VERTICAL)
            boxsizerC.Add(t1, 0, wx.ALIGN_TOP | wx.LEFT, 10)
            boxsizerC.Add(choicebox, 0, wx.TOP | wx.LEFT, 10)
            boxsizerC.Add(cb, 0, wx.TOP | wx.LEFT, 10)
            panelC.SetSizer(boxsizerC)

            bsizerB = wx.BoxSizer(wx.VERTICAL)
            bsizerB.Add(panelC, 6, wx.EXPAND)
            bsizerB.Add(panelD, 4, wx.EXPAND | wx.FIXED_MINSIZE)
            panelB.SetSizer(bsizerB)

            bsizer1 = wx.BoxSizer(wx.HORIZONTAL)
            bsizer1.Add(browser, 2, wx.EXPAND)
            bsizer1.Add(panelB, 1, wx.EXPAND)
            panelA.SetSizer(bsizer1)
            j += 1

        self.Show(True)
Esempio n. 18
0
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title)
        colors = [
            ['wx.SYS_COLOUR_SCROLLBAR', 'The scrollbar grey area.'],
            ['wx.SYS_COLOUR_DESKTOP', 'The desktop colour.'],
            ['wx.SYS_COLOUR_ACTIVECAPTION', 'Active window caption colour.'],
            [
                'wx.SYS_COLOUR_INACTIVECAPTION',
                'Inactive window caption colour.'
            ], ['wx.SYS_COLOUR_MENU', 'Menu background colour.'],
            ['wx.SYS_COLOUR_WINDOW', 'Window background colour.'],
            ['wx.SYS_COLOUR_WINDOWFRAME', 'Window frame colour.'],
            [
                'wx.SYS_COLOUR_MENUTEXT',
                'Colour of the text used in the menus.'
            ],
            [
                'wx.SYS_COLOUR_WINDOWTEXT',
                'Colour of the text used in generic windows.'
            ],
            [
                'wx.SYS_COLOUR_CAPTIONTEXT',
                'Colour of the text used in captions, size boxes and scrollbar arrow boxes.'
            ], ['wx.SYS_COLOUR_ACTIVEBORDER', 'Active window border colour.'],
            ['wx.SYS_COLOUR_INACTIVEBORDER', 'Inactive window border colour.'],
            [
                'wx.SYS_COLOUR_APPWORKSPACE',
                'Background colour for MDI applications.'
            ],
            [
                'wx.SYS_COLOUR_HIGHLIGHT',
                'Colour of item(s) selected in a control.'
            ],
            [
                'wx.SYS_COLOUR_HIGHLIGHTTEXT',
                'Colour of the text of item(s) selected in a control.'
            ],
            ['wx.SYS_COLOUR_BTNFACE', 'Face shading colour on push buttons.'],
            [
                'wx.SYS_COLOUR_BTNSHADOW',
                'Edge shading colour on push buttons.'
            ], ['wx.SYS_COLOUR_GRAYTEXT', 'Colour of greyed (disabled) text.'],
            ['wx.SYS_COLOUR_BTNTEXT', 'Colour of the text on push buttons.'],
            [
                'wx.SYS_COLOUR_INACTIVECAPTIONTEXT',
                'Colour of the text in active captions.'
            ], ['wx.SYS_COLOUR_BTNHIGHLIGHT', 'Highlight colour for buttons.'],
            [
                'wx.SYS_COLOUR_3DDKSHADOW',
                'Dark shadow colour for three-dimensional display elements.'
            ],
            [
                'wx.SYS_COLOUR_3DLIGHT',
                'Light colour for three-dimensional display elements.'
            ], ['wx.SYS_COLOUR_INFOTEXT', 'Text colour for tooltip controls.'],
            [
                'wx.SYS_COLOUR_INFOBK',
                'Background colour for tooltip controls.'
            ],
            [
                'wx.SYS_COLOUR_LISTBOX',
                'Background colour for list-like controls.'
            ],
            [
                'wx.SYS_COLOUR_HOTLIGHT',
                'Colour for a hyperlink or hot-tracked item.'
            ],
            [
                'wx.SYS_COLOUR_GRADIENTACTIVECAPTION',
                'Right side colour in the color gradient of an active window\'s title bar.'
            ],
            [
                'wx.SYS_COLOUR_GRADIENTINACTIVECAPTION',
                'Right side colour in the color gradient of an inactive window\'s title bar.'
            ],
            [
                'wx.SYS_COLOUR_MENUHILIGHT',
                'The colour used to highlight menu items when the menu appears as a flat menu.'
            ],
            [
                'wx.SYS_COLOUR_MENUBAR',
                'The background colour for the menu bar when menus appear as flat menus.'
            ],
            [
                'wx.SYS_COLOUR_LISTBOXTEXT',
                'Text colour for list-like controls.'
            ],
            [
                'wx.SYS_COLOUR_LISTBOXHIGHLIGHTTEXT',
                'Text colour for the unfocused selection of list-like controls.'
            ],
            ['wx.SYS_COLOUR_BACKGROUND', 'Synonym for SYS_COLOUR_DESKTOP .'],
            ['wx.SYS_COLOUR_3DFACE', 'Synonym for SYS_COLOUR_BTNFACE .'],
            ['wx.SYS_COLOUR_3DSHADOW', 'Synonym for SYS_COLOUR_BTNSHADOW .'],
            [
                'wx.SYS_COLOUR_BTNHILIGHT',
                'Synonym for SYS_COLOUR_BTNHIGHLIGHT .'
            ],
            [
                'wx.SYS_COLOUR_3DHIGHLIGHT',
                'Synonym for SYS_COLOUR_BTNHIGHLIGHT .'
            ],
            [
                'wx.SYS_COLOUR_3DHILIGHT',
                'Synonym for SYS_COLOUR_BTNHIGHLIGHT .'
            ], ['wx.SYS_COLOUR_FRAMEBK', 'Synonym for SYS_COLOUR_BTNFACE .']
        ]

        grid = wx.grid.Grid(self)
        grid.CreateGrid(len(colors), 4)

        for row in range(len(colors)):
            name, desc = colors[row]
            color = wx.SystemSettings.GetColour(eval(name))
            grid.SetCellValue(row, 0, str(color))
            grid.SetCellBackgroundColour(row, 1, color)
            grid.SetCellValue(row, 2, name)
            grid.SetCellValue(row, 3, desc)

        grid.AutoSizeColumns()

        # Top level
        top_sizer = wx.BoxSizer(wx.VERTICAL)
        top_sizer.Add(grid, 1, wx.EXPAND | wx.ALL, 5)
        self.SetSizerAndFit(top_sizer)
        self.Fit()
        self.Show(True)
Esempio n. 19
0
    def __init__(self, parent, title):
        wx.Frame.__init__(self, parent, title=title, size=(400, 300))
        #self.control = wx.TextCtrl(self, style=wx.TE_MULTILINE)
        self.statusbar = self.CreateStatusBar(
        )  # A Statusbar in the bottom of the window

        # Setting up the menu.
        filemenu = wx.Menu()
        # wx.ID_ABOUT and wx.ID_EXIT are standard IDs provided by wxWidgets.
        filemenu.Append(wx.ID_ABOUT, "&About",
                        " Information about this program")
        filemenu.AppendSeparator()
        filemenu.Append(wx.ID_EXIT, "E&xit", " Terminate the program")

        # Creating the menubar.
        menuBar = wx.MenuBar()
        menuBar.Append(filemenu,
                       "&File")  # Adding the "filemenu" to the MenuBar
        self.SetMenuBar(menuBar)  # Adding the MenuBar to the Frame content.
        panel = wx.Panel(self)

        # Create a wxGrid object
        self.grid = grid = wx.grid.Grid()
        # Then we call CreateGrid to set the dimensions of the grid
        # (100 rows and 10 columns in this example)
        grid.Create(panel)
        grid.CreateGrid(1, 10)
        grid.SetDefaultColSize(50, True)
        grid.SetDefaultRowSize(20, True)

        grid.HideRowLabels()
        grid.EnableGridLines(False)

        grid.AppendRows(grid.GetNumberCols())
        for i in range(1, grid.GetNumberCols()):
            grid.SetColLabelValue(i, "")
        grid.SetColLabelValue(0, "Filename")
        grid.SetColLabelValue(1, "Page")
        grid.SetColLabelValue(2, "New name")
        grid.AutoSizeColumns()

        # Let's lay out the space.  We fill the panel with a vertical sizer so things in it are stcked vertically.
        # Inside that we have a top sizer for small controls and a secon sizer below it for the grid.
        gbs = wx.GridBagSizer(4, 2)

        # The top gridbag row gets buttons
        self.buttonLoad = wx.Button(panel, id=wx.ID_ANY, label="Load")
        gbs.Add(self.buttonLoad, (0, 0))
        self.buttonLoad.Bind(wx.EVT_BUTTON, self.OnLoadButtonClicked)
        self.buttonGenerate = wx.Button(panel, id=wx.ID_ANY, label="Rename")
        gbs.Add(self.buttonGenerate, (0, 1))

        # Now put a pair of buttons with labels above them in the middle two gridbag rows
        gbs.Add(wx.StaticText(panel, label=" Fanzine name"), (1, 0))
        self.fanzineNameTextbox = wx.TextCtrl(panel, id=wx.ID_ANY)
        gbs.Add(self.fanzineNameTextbox, (2, 0))
        self.fanzineNameTextbox.Bind(wx.EVT_TEXT,
                                     self.OnFanzinenameOrIssueTextboxChanged)

        gbs.Add(wx.StaticText(panel, label=" Issue number"), (1, 1))
        self.fanzineIssuenumber = wx.TextCtrl(panel, id=wx.ID_ANY)
        gbs.Add(self.fanzineIssuenumber, (2, 1))
        self.fanzineIssuenumber.Bind(wx.EVT_TEXT,
                                     self.OnFanzinenameOrIssueTextboxChanged)

        # And the grid itself goes in the bottom gridbag row, spanning both columns
        gbs.Add(grid, (3, 0), span=(2, 2))

        panel.SetSizerAndFit(gbs)

        self.Show(True)