Exemplo n.º 1
0
 def __init__(self):
     wx.Frame.__init__(self,
                       None,
                       title="Grid demo",
                       pos=wx.DefaultPosition,
                       size=wx.DefaultSize,
                       style=wx.DEFAULT_FRAME_STYLE)
     sizer = wx.BoxSizer()
     self.SetSizer(sizer)
     bmp_rabbit, bmp_carrot = [
         wx.BitmapFromImage(wx.ImageFromStream(StringIO.StringIO(x)))
         for x in (IMG_RABBIT, IMG_CARROT)
     ]
     d = {"rabbit": bmp_rabbit, "carrot": bmp_carrot}
     grid = wx.grid.Grid(self)
     sizer.Add(grid, 1, wx.EXPAND)
     grid.CreateGrid(4, 5)
     grid.SetGridLineColour(wx.BLACK)
     self.grid = grid
     for i in range(4):
         hook_grid_button_column(grid, i, d)
         for j in range(4):
             grid.SetCellValue(
                 i, j, (((i + j) % 2 == 0 and "rabbit:") or "carrot:") +
                 BU_NORMAL)
         grid.SetCellValue(i, 4, "Row %d" % (i + 1))
         grid.SetReadOnly(i, 4)
     grid.SetColLabelSize(0)
     grid.SetRowLabelSize(0)
     self.Bind(EVT_GRID_BUTTON, self.on_grid_button, grid)
     self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.on_left_click,
               grid)
    def grid_setup(self):
        """Perform the initial setup and layout of the grid."""
        # @type grid wx.grid.Grid
        grid = self.panel.gridExp
        #General settings
        #grid.SetSelectionMode(wx.grid.Grid.wxGridSelectRows)
        #Label width/height
        grid.SetColLabelSize(40)
        grid.SetRowLabelSize(40)

        #Find that the grid should be
        num_angles = len(model.instrument.inst.angles)
        num_cols = 4 + num_angles
        if grid.GetNumberCols() > num_cols:
            grid.DeleteCols(0, grid.GetNumberCols() - num_cols)
        if grid.GetNumberCols() < num_cols:
            grid.AppendCols(num_cols - grid.GetNumberCols())

        #The column headers
        grid.SetColLabelValue(0, "Use?")
        grid.SetColSize(0, 50)
        #Column # of the criterion
        self.criterion_col = num_angles + 1
        grid.SetColLabelValue(self.criterion_col, "Stopping\nCriterion")
        grid.SetColSize(self.criterion_col, 180)
        grid.SetColLabelValue(self.criterion_col + 1, "Criterion\nValue")
        grid.SetColSize(self.criterion_col + 1, 100)
        grid.SetColLabelValue(self.criterion_col + 2, "Comment")
        grid.SetColSize(self.criterion_col + 2, 120)
        for (i, anginfo) in enumerate(model.instrument.inst.angles):
            grid.SetColLabelValue(
                i + 1, anginfo.name + "\n(" + anginfo.friendly_units + ")")
            grid.SetColSize(i + 1, 100)
Exemplo n.º 3
0
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='Statistics')

        wtl = CsvTimeLogger()
        statistics = wtl.get_statistics()
        panel = wx.Panel(self)
        top_sizer = wx.BoxSizer(wx.VERTICAL)

        grid = wx.grid.Grid(self, -1)
        grid.CreateGrid(len(statistics), 2)  # + 1 due to summary row at end
        grid.SetColLabelValue(0, "Day")
        grid.SetColLabelValue(1, "Worked")
        grid.SetRowLabelSize(0)

        for i, (k, v) in enumerate(statistics.items()):
            grid.SetCellValue(i, 1, format_timedelta(v))
            grid.SetCellAlignment(i, 1, wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
            if isinstance(k, dt.date):
                grid.SetCellValue(i, 0, k.strftime('%a %Y-%m-%d'))
                grid.SetCellAlignment(i, 0, wx.ALIGN_RIGHT, wx.ALIGN_CENTER)

                rel_extra_time = v.total_seconds() / dt.timedelta(hours=4).seconds
                grid.SetCellBackgroundColour(i, 1, get_color_red_white_blue(rel_extra_time))
            else:
                grid.SetCellValue(i, 0, k)

        grid.AutoSize()
        top_sizer.Add(grid, 0, wx.CENTER)
        panel.SetSizer(top_sizer)
        top_sizer.Fit(self)
        self.Show()
Exemplo n.º 4
0
    def ResetView(self):
        """Trim/extend the control's rows and update all values"""
        grid=self.getGrid()
        grid.BeginBatch()
        for current, new, delmsg, addmsg in [
             (self.currentRows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
             (self.currentCols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED),
              ]:
              if new < current:
                  msg = wx.grid.GridTableMessage(self, delmsg, new, current-new)
                  #for i in range(current-new): 
                  grid.ProcessTableMessage(msg)
                  self.currentRows=new
              elif new > current:
                  msg = wx.grid.GridTableMessage(self, addmsg,  new-current)
                  grid.ProcessTableMessage(msg)
                  self.currentRows=new
        self.UpdateValues()
        if len(self._obj)==0: 
            ml=8
        else:
            ml=max([len(x[0]) for x in self._obj])
            grid.SetRowLabelSize(ml*10) #10 is an ad-hoc number
        grid.EndBatch()

       # print 'current row', self.currentRows
  
        # The scroll bars aren't resized (at least on windows)
        # Jiggling the size of the window rescales the scrollbars
        w, h = grid.GetSize()       
        grid.SetSize((w+1, h))
        grid.SetSize((w, h))

        grid.ForceRefresh()
Exemplo n.º 5
0
def setup_grid(grid, title):
    """
    This function only works with type wx.grid.Grid
    The it will create a grid that is like the one found in LinkCtrl/View.
    :param grid:
    :return:
    """

    grid.CreateGrid(6, 2)
    grid.EnableEditing(False)
    grid.EnableGridLines(True)
    grid.SetGridLineColour(wx.Colour(0, 0, 0))
    grid.EnableDragGridSize(False)

    # Columns
    grid.EnableDragColMove(False)
    grid.EnableDragColSize(True)
    grid.SetColLabelSize(0)
    grid.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)
    grid.SetColSize(0, 110)

    # Rows
    grid.EnableDragRowSize(True)
    grid.SetRowLabelSize(0)
    grid.SetRowLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)

    # Defaults
    grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255))  # white
    grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)

    # Set Cell Values
    grid.SetCellValue(0, 0, " %s" % title)
    grid.SetCellValue(1, 0, " Variable Name")
    grid.SetCellValue(2, 0, " Geometry Type")
    grid.SetCellValue(3, 0, " Geometry Count")
    grid.SetCellValue(4, 0, " Coordinate System")
    grid.SetCellValue(5, 0, " Spatial Extent")

    # set the default background color
    grid.SetDefaultCellBackgroundColour('WHITE')

    # change color and size of header
    grid.SetCellSize(0, 0, 1, 2)  # span cols 0 and 1
    grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195))  # Grey

    # set the table column size
    grid.SetColSize(0, 133)
    grid.SetColSize(1, 155)

    # change color of properties
    for i in range(1, grid.GetNumberRows()):
        grid.SetCellBackgroundColour(i, 0, wx.Colour(250, 250,
                                                     250))  # light Grey

    grid.SetGridLineColour(wx.Colour(195, 195, 195))
Exemplo n.º 6
0
    def draw_table(self, i, x, y):
        results = self.type_result[i]
        # size = self.ssize[i]
        size_of_par = self.size_of_par[i]

        grid = self.tables[i]
        grid.SetMaxSize(wx.Size(320, 360))
        grid.SetMinSize(wx.Size(320, 360))
        names = self.names[i]

        grid.CreateGrid(28, 13)
        grid.EnableEditing(True)
        grid.EnableGridLines(True)
        grid.EnableDragGridSize(False)
        grid.SetMargins(0, 0)

        # Columns
        grid.EnableDragColMove(False)
        grid.EnableDragColSize(True)
        grid.SetColLabelSize(30)
        grid.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        i = 0
        for namei in names:
            grid.SetColLabelValue(i, namei)
            i += 1

        # 设置内容
        # Rows
        grid.EnableDragRowSize(True)
        grid.SetRowLabelSize(80)
        grid.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Label Appearance

        # Cell Defaults
        grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)
        """"设置内容"""
        j = 0
        for result in results:
            i = 0
            for row in result:
                # 截段输出 numpy 抽样结果过长
                grid.SetCellValue(i, j, str(("%.3f" % row)))
                i = i + 1
            j += 1

        self.gbSizer_show.Add(grid, wx.GBPosition(x, y), wx.GBSpan(1, 3),
                              wx.ALL, 5)
        return y + size_of_par
Exemplo n.º 7
0
    def init_grid(self, grid):
        # Grid
        grid.CreateGrid(7, 2)
        grid.EnableEditing(False)
        grid.EnableGridLines(True)
        grid.SetGridLineColour(wx.Colour(0, 0, 0))
        grid.EnableDragGridSize(False)
        grid.SetMargins(0, 0)

        # Columns
        grid.EnableDragColMove(False)
        grid.EnableDragColSize(True)
        grid.SetColLabelSize(0)
        grid.SetColLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Rows
        grid.EnableDragRowSize(True)
        grid.SetRowLabelSize(0)
        grid.SetRowLabelAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)

        # Label Appearance

        # Cell Defaults
        grid.SetDefaultCellBackgroundColour(wx.Colour(255, 255, 255))
        grid.SetDefaultCellAlignment(wx.ALIGN_LEFT, wx.ALIGN_TOP)

        # Set Cell Values
        grid.SetCellValue(0, 0, " Variable")
        grid.SetCellValue(1, 0, " Name")
        grid.SetCellValue(2, 0, " Description")
        grid.SetCellValue(3, 0, " Unit")
        grid.SetCellValue(4, 0, " Name")
        grid.SetCellValue(5, 0, " Type")
        grid.SetCellValue(6, 0, " Abbreviation")

        grid.SetCellBackgroundColour(0, 0, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(0, 1, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(3, 0, wx.Colour(195, 195, 195))
        grid.SetCellBackgroundColour(3, 1, wx.Colour(195, 195, 195))
        grid.SetGridLineColour(wx.Colour(195, 195, 195))
        self.resize_grid_to_fill_white_space(grid)
 def buidUISizer(self):
     flagsR = wx.CENTER
     hsizer = wx.BoxSizer(wx.HORIZONTAL)
     for _ in range(3):
         vSizer = wx.BoxSizer(wx.VERTICAL)
         # Row idx = 0 : show the PLC name/type and the I/O usage.
         nameLb = wx.StaticText(self, label="PLC Name: ".ljust(15))
         self.nameLbList.append(nameLb)
         vSizer.Add(nameLb, flag=flagsR, border=2)
         vSizer.AddSpacer(10)
         gpioLbN = wx.StaticText(self, label="PLC I/O usage: ".ljust(15))
         vSizer.Add(gpioLbN, flag=flagsR, border=2)
         self.gpioLbList.append(gpioLbN)
         vSizer.AddSpacer(10)
         vSizer.Add(wx.StaticLine(self,
                                  wx.ID_ANY,
                                  size=(180, -1),
                                  style=wx.LI_HORIZONTAL),
                    flag=flagsR,
                    border=2)
         vSizer.AddSpacer(10)
         # Row idx =1 : show the PLC data.
         grid = wx.grid.Grid(self, -1)
         grid.CreateGrid(8, 4)
         grid.SetRowLabelSize(30)
         grid.SetColLabelSize(22)
         grid.SetColSize(0, 40)
         grid.SetColSize(1, 40)
         grid.SetColSize(2, 40)
         grid.SetColSize(3, 40)
         # Set the column label.
         grid.SetColLabelValue(0, 'IN')
         grid.SetColLabelValue(1, 'Val')
         grid.SetColLabelValue(2, 'OUT')
         grid.SetColLabelValue(3, 'Val')
         vSizer.Add(grid, flag=flagsR, border=2)
         self.gridList.append(grid)
         hsizer.Add(vSizer, flag=flagsR, border=2)
         hsizer.AddSpacer(5)
     return hsizer
Exemplo n.º 9
0
    def __init__(self, parent, id, G):
        wx.Frame.__init__(self, parent, id, 'Breadboard', size=(1194, 250))
        grid = wx.grid.Grid(self)
        grid.CreateGrid(10, 64)
        grid.SetRowLabelSize(22)
        grid.SetColMinimalAcceptableWidth(10)
        for row in range(10):
            t1 = chr(row + 97)
            grid.SetRowLabelValue(row, t1)
            for col in range(64):
                t2 = str(col + 1)
                t = t1 + t2
                grid.SetColLabelValue(col, t2)
                grid.SetColSize(col, 18)
                grid.SetCellValue(row, col, t)
                grid.SetCellBackgroundColour(row, col, wx.CYAN)
                grid.SetReadOnly(row, col, isReadOnly=True)
        print "Right click where you want to start."

        grid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnCellLeftClick)

        print G
Exemplo n.º 10
0
    def __init__(self, parent, id, TableTitle, row_headers, col_headers, data):
        wx.Frame.__init__(self, parent, id, title = TableTitle, size=(640,480))

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

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

        # mass table. Keep a reference for when the Peak Viewer uses this class
        grid = self.grid = wx.grid.Grid(pane, -1)
        grid.CreateGrid(len(row_headers), len(col_headers))

        # Set row/column Headers
        for i,row in enumerate(row_headers):
            grid.SetRowLabelValue(i, row)

        dc = wx.MemoryDC()
        dc.SelectObject(wx.NullBitmap)

        grid.SetRowLabelSize(dc.GetTextExtent(max(row_headers, key=lambda r: len(r)))[0])

        dc.Destroy()

        for i,col in enumerate(col_headers):
            grid.SetColLabelValue(i, col)

        # Print Data
        for row in range(len(row_headers)):
            for col in range(len(col_headers)):
                if data[row][col] is not None:
                    grid.SetCellValue(row, col, "%0.2f" % data[row][col])

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

        w,h = self.GetSize()
        self.SetMinSize((w/2,h/2))
Exemplo n.º 11
0
    def __init__(self, window):
        # This is how Python handles classes. __init__ is the special name for
        # the constructor of the class. The first parameter to every object
        # method is the object itself, called "self" by convention. self is
        # like "this" in Java/C++, except you have to explicitly mention it
        # whenever you want to use instance variables or methods.
        grid = wx.grid.Grid(parent=window)
        grid.CreateGrid(sudoku.ROW_SIZE, sudoku.ROW_SIZE)

        # Set row and column sizes, and fix them so the user can't change them
        grid.SetRowLabelSize(0)
        grid.SetColLabelSize(0)
        grid.SetDefaultRowSize(40, True)
        grid.SetDefaultColSize(40, True)
        grid.DisableDragGridSize()

        # Change cell attributes to work well for Sudoku displaying
        font = grid.GetDefaultCellFont()
        font.SetPointSize(20)
        grid.SetDefaultCellFont(font)
        grid.SetDefaultCellAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)

        self.grid = grid
Exemplo n.º 12
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)
Exemplo n.º 13
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent, -1)

        self.hand_type = {0:'No Pair', 1:'One Pair', 2:'Two Pair', 3:'Three of a Kind', 4:'Straight', 5:'Flush', 6:'Full House', 7:'Four of a Kind', 8:'Straight Flush', 9:'Five of a Kind'}

        # Initialize the hand so that it's easier to implement active min hand calc
        #self.card_array = [12,11,51,50,10,9,8,7]
        self.card_array = [53] * 9

        self.right_clicked_card = -1
        self.right_click_selection = -1
        self.last_flop_array = [53] * 9
        self.last_turn_array = [53] * 9
        self.last_showdown_array = [53] * 9
        self.flop_turn_results = ()
        self.flop_river_results = ()
        self.flop_better_hands = []
        self.turn_river_results = ()
        self.turn_better_hands = []
        self.showdown_results = ()
        self.showdown_better_hands = []

        self.better = ()

        self.minipanel_is_open = 0
        self.minipanel = -1

        grid = wx.grid.Grid(self, -1, size = wx.Size(500, 347), style = wx.SIMPLE_BORDER)
        grid.CreateGrid(9, 5)
        grid.SetColLabelValue(0, "Hand")
        grid.SetColLabelValue(1, "Count")
        grid.SetColLabelValue(2, "Odds 1:x")
        grid.SetColLabelValue(3, "Probability")
        grid.SetColLabelValue(4, "# Better")
        grid.SetColSize(0, 160)
        grid.SetColSize(1, COL_SIZE)
        grid.SetColSize(2, COL_SIZE)
        grid.SetColSize(3, COL_SIZE)
        grid.SetColSize(4, COL_SIZE)
        grid.SetRowSize(0, ROW_SIZE)
        grid.SetRowSize(1, ROW_SIZE)
        grid.SetRowSize(2, ROW_SIZE)
        grid.SetRowSize(3, ROW_SIZE)
        grid.SetRowSize(4, ROW_SIZE)
        grid.SetRowSize(5, ROW_SIZE)
        grid.SetRowSize(6, ROW_SIZE)
        grid.SetRowSize(7, ROW_SIZE)
        grid.SetRowSize(8, ROW_SIZE)
        grid.SetColLabelSize(30)
        grid.SetRowLabelSize(0)
        grid.EnableEditing(False)
        grid.EnableDragColSize(False)
        grid.EnableDragRowSize(False)
        grid.EnableDragGridSize(False)
        grid.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
        font = wx.Font(12, family = wx.ROMAN, style = wx.NORMAL, weight = wx.BOLD)
        grid.SetDefaultCellFont(font)
        # This is the magical line that turns off the scrollbars
        # Thank you: http://lists.wxwidgets.org/archive/wxPython-users/msg10178.html
        grid.SetMargins(-100,-100)

        self.grid = grid

        font = wx.Font(14, family = wx.MODERN, style = wx.NORMAL, weight = wx.BOLD)

        #self.title = wx.StaticText(self, -1, "", size=(250,25), style = wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTRE | wx.SIMPLE_BORDER, name = "Title")
        self.title = wx.StaticText(self, -1, "", size=(250,25), style = wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTRE, name = "Title")
        # font styles:
        # family = wx.DEFAULT, wx.DECORATIVE, wx.ROMAN, wx.SCRIPT, wx.SWISS, wx.MODERN
        # style = wx.NORMAL, wx.SLANT, wx.ITALIC
        # weight = wx.NORMAL, wx.LIGHT, wx.BOLD
        self.title.SetFont(font)

        title_sizer = wx.BoxSizer ( wx.HORIZONTAL )
        
        title_sizer.Add((30,30), 0, wx.ALIGN_CENTRE_VERTICAL)
        title_sizer.Add(self.title, 0, wx.ALIGN_CENTRE_VERTICAL)
        title_sizer.Add((30,30), 0, wx.ALIGN_CENTRE_VERTICAL)

        font = wx.Font(13, family = wx.MODERN, style = wx.NORMAL, weight = wx.BOLD)

        # call min_hand_eval here
        #current_h = self.MinHandEval()
        current_h = ""

        #self.hand_display = wx.StaticText(self, -1, current_h, size=(200,25), style = wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTRE | wx.SIMPLE_BORDER)
        self.hand_display = wx.StaticText(self, -1, current_h, size=(200,25), style = wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTRE)
        self.hand_display.SetFont(font)

        # hutchison index
        #h_index = hutchison(self.card_array[:4])
        h_index = ""
        #self.hutch_display = wx.StaticText(self, -1, h_index, size=(200,25), style = wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTRE | wx.SIMPLE_BORDER)
        self.hutch_display = wx.StaticText(self, -1, h_index, size=(200,25), style = wx.ST_NO_AUTORESIZE | wx.ALIGN_CENTRE)
        self.hutch_display.SetFont(font)

        hand_disp_sizer = wx.BoxSizer( wx.HORIZONTAL )

        hand_disp_sizer.Add(self.hutch_display, 0 , wx.ALIGN_CENTER_VERTICAL)
        hand_disp_sizer.Add((30,50), 0, wx.ALIGN_CENTRE_VERTICAL)
        hand_disp_sizer.Add(self.hand_display, 0, wx.ALIGN_CENTRE_VERTICAL)
        #hand_disp_sizer.Add((30,50), 0, wx.ALIGN_CENTRE_VERTICAL)

        self.button1 = wx.Button(self, ID_BUTTON1, "Turn", size=(70,30))
        self.button2 = wx.Button(self, ID_BUTTON2, "River", size=(70,30))
        self.button3 = wx.Button(self, ID_BUTTON3, "River+", size=(70,30))
        self.button6 = wx.Button(self, ID_BUTTON6, "Showdown", size=(70,30))
        self.button4 = wx.Button(self, ID_BUTTON4, "Reset", size=(70,30))
        self.button5 = wx.Button(self, ID_BUTTON5, "Panel", size=(70,30))

        self.button1.Disable()
        self.button2.Disable()
        self.button3.Disable()
        self.button4.Disable()
        self.button6.Disable()

        button_sizer = wx.BoxSizer( wx.HORIZONTAL )

        LARGE_BUTTON_SPACE = (20, 40)
        MEDIUM_BUTTON_SPACE = (12, 40)
        SMALL_BUTTON_SPACE = (2, 40)

        button_sizer.Add(self.button5, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(LARGE_BUTTON_SPACE, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(self.button1, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(SMALL_BUTTON_SPACE, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(self.button2, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(MEDIUM_BUTTON_SPACE, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(self.button3, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(MEDIUM_BUTTON_SPACE, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(self.button6, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(LARGE_BUTTON_SPACE, 0, wx.ALIGN_CENTRE_VERTICAL)
        button_sizer.Add(self.button4, 0, wx.ALIGN_CENTRE_VERTICAL)

        # Initialize the cards
        self.card1 = wx.StaticBitmap(self, ID_CARD_1, catalog[index[self.card_array[0]]].getBitmap(), name = "Card1")
        self.card2 = wx.StaticBitmap(self, ID_CARD_2, catalog[index[self.card_array[1]]].getBitmap(), name = "Card2")
        self.card3 = wx.StaticBitmap(self, ID_CARD_3, catalog[index[self.card_array[2]]].getBitmap(), name = "Card3")
        self.card4 = wx.StaticBitmap(self, ID_CARD_4, catalog[index[self.card_array[3]]].getBitmap(), name = "Card4")
        self.card5 = wx.StaticBitmap(self, ID_CARD_5, catalog[index[self.card_array[4]]].getBitmap(), name = "Card5")
        self.card6 = wx.StaticBitmap(self, ID_CARD_6, catalog[index[self.card_array[5]]].getBitmap(), name = "Card6")
        self.card7 = wx.StaticBitmap(self, ID_CARD_7, catalog[index[self.card_array[6]]].getBitmap(), name = "Card7")
        self.card8 = wx.StaticBitmap(self, ID_CARD_8, catalog[index[self.card_array[7]]].getBitmap(), name = "Card8")
        self.card9 = wx.StaticBitmap(self, ID_CARD_9, catalog[index[self.card_array[8]]].getBitmap(), name = "Card9")

        self.cards = (self.card1, self.card2, self.card3, self.card4, self.card5, self.card6, self.card7, self.card8, self.card9)

        card_sizer1 = wx.BoxSizer( wx.HORIZONTAL )
        card_sizer2 = wx.BoxSizer( wx.HORIZONTAL )

        LITTLE_SPACER = (5,5)
        BIG_SPACER = (25,5)
        HOLE_SPACER = (5,125)

        card_sizer2.Add(self.card1, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer2.Add(HOLE_SPACER, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer2.Add(self.card2, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer2.Add(HOLE_SPACER, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer2.Add(self.card3, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer2.Add(HOLE_SPACER, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer2.Add(self.card4, 0, wx.ALIGN_CENTRE_VERTICAL)

        card_sizer1.Add(self.card5, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(LITTLE_SPACER, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(self.card6, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(LITTLE_SPACER, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(self.card7, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(BIG_SPACER, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(self.card8, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(BIG_SPACER, 0, wx.ALIGN_CENTRE_VERTICAL)
        card_sizer1.Add(self.card9, 0, wx.ALIGN_CENTRE_VERTICAL)

        self.sizer = wx.BoxSizer( wx.VERTICAL )

        self.sizer.Add(title_sizer, 0, wx.ALIGN_CENTRE_HORIZONTAL)
        self.sizer.Add(grid, 0, wx.ALIGN_CENTRE_HORIZONTAL)
        self.sizer.Add(hand_disp_sizer, 0, wx.ALIGN_CENTRE_HORIZONTAL)
        self.sizer.Add(card_sizer1, 0, wx.ALIGN_CENTRE_HORIZONTAL)
        self.sizer.Add(card_sizer2, 0, wx.ALIGN_CENTRE_HORIZONTAL)

        self.sizer.Add(button_sizer, 0, wx.ALIGN_CENTRE_HORIZONTAL)
        
        self.SetSizer(self.sizer)
        self.SetAutoLayout(1)

        self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnCellRightClick, self.grid)
        self.Bind(wx.EVT_BUTTON, self.OnButton5, self.button5)
        self.Bind(wx.EVT_BUTTON, self.OnButton1, self.button1)
        self.Bind(wx.EVT_BUTTON, self.OnButton2, self.button2)
        self.Bind(wx.EVT_BUTTON, self.OnButton3, self.button3)
        self.Bind(wx.EVT_BUTTON, self.OnButton6, self.button6)
        self.Bind(wx.EVT_BUTTON, self.OnButton4, self.button4)
        self.card1.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card2.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card3.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card4.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card5.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card6.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card7.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card8.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card9.Bind(wx.EVT_LEFT_UP, self.LeftClick)
        self.card1.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card2.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card3.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card4.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card5.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card6.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card7.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card8.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.card9.Bind(wx.EVT_RIGHT_UP, self.RightClick)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_2)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_3)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_4)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_5)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_6)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_7)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_8)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_9)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_T)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_J)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_Q)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_K)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_A)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_S)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_H)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_D)
        self.Bind(wx.EVT_MENU, self.OnMenuSelection, id=ID_MENU_C)
Exemplo n.º 14
0
    def __init__(self, parent, square, size):
        self.size = size
        grid = wx.grid.Grid(parent, -1)
        grid.CreateGrid(self.size + 2, self.size + 2)

        # Set Sizer
        '''Sizer = wx.BoxSizer(wx.HORIZONTAL)
        Sizer.Add(grid, 0, wx.ALIGN_CENTER|wx.ALL, 5)
        parent.SetSizerAndFit(Sizer)'''

        # Set Labels not visible
        grid.SetRowLabelSize(0)
        grid.SetColLabelSize(0)
        
        # Set Row and Column size
        grid.SetDefaultRowSize(40)
        grid.SetDefaultColSize(40)

        # Print Square Values as string
        for j in range(2, self.size + 2):
            for i in range(2, self.size + 2):
                grid.SetCellAlignment(i-1, j-1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
                grid.SetCellValue(i-1, j-1, str(square[(i-1,j-1)]))
                grid.SetReadOnly(i-1, j-1)
        
        # Evaluate Rows Sum
        for i in range(1, self.size + 1):
            mg_num = self.evaluateRowSum(square, i)
            grid.SetCellAlignment(i, self.size+1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
            grid.SetCellBackgroundColour(i, self.size+1, wx.YELLOW)
            grid.SetCellValue(i, self.size+1, str(mg_num))
            grid.SetCellAlignment(i, 0, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
            grid.SetCellBackgroundColour(i, 0, wx.YELLOW)
            grid.SetCellValue(i, 0, str(mg_num))
            grid.SetReadOnly(i, 0)
            
        # Evaluate Columns Sum  
        for j in range(1, self.size + 1):
            mg_num = self.evaluateColSum(square, j)
            grid.SetCellAlignment(self.size+1, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
            grid.SetCellBackgroundColour(self.size+1, j, wx.GREEN)
            grid.SetCellValue(self.size+1, j, str(mg_num))
            grid.SetCellAlignment(0, j, wx.ALIGN_CENTER, wx.ALIGN_CENTER) 
            grid.SetCellBackgroundColour(0, j, wx.GREEN)
            grid.SetCellValue(0, j, str(mg_num)) 
            grid.SetReadOnly(0, j)
        
        #Evaluate Diagonal 1
        diag1 = self.evaluateDiag1(square)
        grid.SetCellAlignment(self.size+1, self.size+1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetCellBackgroundColour(self.size+1, self.size+1, wx.BLUE)
        grid.SetCellTextColour(self.size+1, self.size+1, wx.WHITE)
        grid.SetCellValue(self.size+1, self.size+1, str(diag1))
        grid.SetReadOnly(self.size+1, self.size+1)
        grid.SetCellAlignment(0, 0, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetCellBackgroundColour(0, 0, wx.BLUE)
        grid.SetCellTextColour(0, 0, wx.WHITE)
        grid.SetCellValue(0, 0, str(diag1))
        grid.SetReadOnly(0, 0)
        
        #Evaluate Diagonal 2
        diag2 = self.evaluateDiag2(square)
        grid.SetCellAlignment(0, self.size+1, wx.ALIGN_CENTER, wx.ALIGN_CENTER)
        grid.SetCellBackgroundColour(0, self.size+1, wx.RED)
        grid.SetCellTextColour(0, self.size+1, wx.WHITE)
        grid.SetCellValue(0, self.size+1, str(diag2))
        grid.SetReadOnly(0, self.size+1)
        grid.SetCellAlignment(self.size+1, 0, wx.ALIGN_CENTER, wx.ALIGN_CENTER) 
        grid.SetCellBackgroundColour(self.size+1, 0, wx.RED)
        grid.SetCellTextColour(self.size+1, 0, wx.WHITE)
        grid.SetCellValue(self.size+1, 0, str(diag2))   
        grid.SetReadOnly(self.size+1, 0)     

        parent.Show()
Exemplo n.º 15
0
    def __init__(self, parent, input_para):

        rect_parent = parent.GetRect()
        print rect_parent
        pos_target = rect_parent.GetTopRight()
        wx.Frame.__init__(self,
                          parent,
                          -1,
                          "Resource Grid",
                          pos=pos_target,
                          size=(1000, 700))
        panel = wx.Panel(self, -1)

        sizer_grid = wx.GridBagSizer(0, 0)
        usr_style = wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL
        grid = wx.grid.Grid(self, -1)
        grid.CreateGrid(12 * 2, 14)
        cell_width = 20

        grid.DisableDragColSize()
        grid.DisableDragGridSize()
        grid.DisableDragRowSize()
        grid.SetRowLabelAlignment(wx.CENTER, wx.CENTER)

        clo_num = grid.GetNumberCols()
        row_num = grid.GetNumberRows()

        for i in range(0, row_num):
            grid.SetRowLabelValue(i, str(row_num - i - 1))
            grid.AutoSizeRowLabelSize(i)
        grid.SetRowLabelSize(cell_width)
        grid.SetDefaultRowSize(cell_width)
        for j in range(0, clo_num):
            grid.SetColLabelValue(j, str(j))
            grid.AutoSizeColLabelSize(j)
        grid.SetRowLabelSize(cell_width)
        grid.SetDefaultColSize(cell_width)
        grid.SetDefaultCellBackgroundColour(wx.Colour(192, 192, 192))

        #pdcch
        for i in range(0, row_num):
            for j in range(0, clo_num):
                grid.SetReadOnly(i, j)
                if (j < input_para['pdcch_symbol']):
                    grid.SetCellBackgroundColour(i, j, wx.GREEN)
                    if ((int(grid.GetRowLabelValue(i)) - 1) % 4 == 0):
                        grid.SetCellBackgroundColour(i, j,
                                                     wx.Colour(66, 66, 111))
        #pdsch
        for i in range(0, row_num):
            for j in range(input_para['start_symbol'], clo_num):
                if (j - input_para['start_symbol'] <
                        input_para['symbol_length']):
                    grid.SetCellBackgroundColour(i, j,
                                                 wx.Colour(255, 255, 255))
        #pdsch dmrs
        for j in range(0, len(input_para['dmrs_pos_list'])):
            for i in range(0, row_num):
                if input_para['dmrs_length'] == 0 and j == 0:
                    grid.SetCellBackgroundColour(
                        i, input_para['dmrs_pos_list'][j],
                        wx.Colour(153, 204, 50))
                    continue
                if input_para['dmrs_length'] == 1 and (j == 1 or j == 0):
                    grid.SetCellBackgroundColour(
                        i, input_para['dmrs_pos_list'][j],
                        wx.Colour(153, 204, 50))
                    continue
                else:
                    grid.SetCellBackgroundColour(
                        i, input_para['dmrs_pos_list'][j],
                        wx.Colour(234, 234, 173))

        sizer_grid.Add(grid,
                       pos=(0, 0),
                       span=(5, 5),
                       flag=wx.EXPAND | usr_style)

        lbl_pdcch = wx.StaticText(self, -1, u'  PDCCH  ', style=usr_style)
        lbl_pdcch.SetBackgroundColour(wx.GREEN)
        sizer_grid.Add(lbl_pdcch,
                       pos=(7, 0),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        lbl_pdcch_dmrs = wx.StaticText(
            self,
            -1,
            u'  PDCCH DMRS  ',
            style=usr_style,
        )
        lbl_pdcch_dmrs.SetBackgroundColour(wx.Colour(66, 66, 111))
        lbl_pdcch_dmrs.SetForegroundColour(wx.Colour(255, 255, 255))
        sizer_grid.Add(
            lbl_pdcch_dmrs,
            pos=(7, 1),
            span=(1, 1),
            flag=wx.EXPAND | usr_style,
        )

        lbl_pdsch = wx.StaticText(self, -1, u'  PDXCH  ', style=usr_style)
        lbl_pdsch.SetBackgroundColour(wx.Colour(255, 255, 255))
        lbl_pdsch.SetForegroundColour(wx.Colour(0, 0, 0))
        sizer_grid.Add(lbl_pdsch,
                       pos=(7, 2),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        lbl_fl_dmrs = wx.StaticText(self,
                                    -1,
                                    u'Front Loaded DMRS',
                                    style=usr_style)
        lbl_fl_dmrs.SetBackgroundColour(wx.Colour(153, 204, 50))
        lbl_fl_dmrs.SetForegroundColour(wx.Colour(255, 255, 255))
        sizer_grid.Add(lbl_fl_dmrs,
                       pos=(8, 0),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        lbl_add_dmrs = wx.StaticText(self, -1, u'Add DMRS', style=usr_style)
        lbl_add_dmrs.SetBackgroundColour(wx.Colour(234, 234, 173))
        lbl_add_dmrs.SetForegroundColour(wx.Colour(0, 0, 0))
        sizer_grid.Add(lbl_add_dmrs,
                       pos=(8, 1),
                       span=(1, 1),
                       flag=wx.EXPAND | usr_style)

        b_close = wx.Button(self, -1, "Close")
        self.Bind(wx.EVT_BUTTON, self.close_window, b_close)
        sizer_grid.Add(b_close,
                       pos=(10, 0),
                       span=(2, 5),
                       flag=wx.EXPAND | usr_style)
        self.equal = b_close

        self.SetSizer(sizer_grid)
        sizer_grid.Fit(self)

        self.Show()
Exemplo n.º 16
0
 def InitUI(self): 
     vbox = wx.BoxSizer(wx.VERTICAL)
     (server, group, item) = self.rulePath
     labelText = u"地址:{}.{}.{}".format(server, group, item)
     addressLabel = wx.StaticText(self, -1, label=labelText)
     font = wx.Font(10, wx.DEFAULT, wx.NORMAL, wx.NORMAL)
     addressLabel.SetFont(font)
     vbox.Add(addressLabel, flag=(wx.ALL | wx.ALIGN_CENTER | wx.BOTTOM), border=5) 
     
     grid = wx.grid.Grid(self)
     grid.CreateGrid(6, 2)
     grid.SetDefaultRowSize(25)
     grid.SetColLabelValue(0, u"值")
     grid.SetColLabelValue(1, u"报警信息")
     
     grid.SetRowLabelValue(0, u'低低')
     grid.SetRowLabelValue(1, u'低')
     grid.SetRowLabelValue(2, u'高')
     grid.SetRowLabelValue(3, u'高高')
     grid.SetRowLabelValue(4, u'当')
     grid.SetRowLabelValue(5, u'间隔时间(分)')
     grid.SetRowLabelSize(70)
     
     # attr = wx.grid.GridCellAttr()
     # attr.SetEditor(wx.grid.GridCellChoiceEditor())
     # attr.SetRenderer(wx.grid.GridCellChoiceEditor(['5', '15', '30', '60'], True))
     grid.SetCellEditor(4, 0, wx.grid.GridCellChoiceEditor([u'真', u'假'], True))
     grid.SetCellValue(4, 0, u'假')
     
     grid.SetCellEditor(5, 0, wx.grid.GridCellChoiceEditor(['5', '15', '30', '60'], True))
     grid.SetCellValue(5, 0, '5')
     
     grid.SetColSize(0, 50)
     grid.SetColSize(1, 300)
     
     grid.SetDefaultCellAlignment(wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
     grid.SetCellValue(5, 1, u"当前温度:{}".format(self.itemValue[0]))
     grid.SetReadOnly(5, 1, True)
     
     vbox.Add(grid, proportion=1, flag=(wx.ALL | wx.ALIGN_CENTER))
     
     btn = wx.Button(self, -1, label=u"确定")
     btn.Bind(wx.EVT_BUTTON, lambda event, grid=grid: self.btnClick(event, grid))
     vbox.Add(btn, proportion=1, flag=(wx.TOP | wx.CENTRE), border=5)
     self.SetSizer(vbox)  
 
     if self.rule.isBool:
         (dang1, dang2) = self.rule.dang
         interal = self.rule.interal
         grid.SetCellValue(4, 0, u'真' if dang1 else u'假')
         grid.SetCellValue(4, 1, dang2)
         grid.SetCellValue(5, 0, interal)
     else:
         (lower1, lower2) = self.rule.lower
         (low1, low2) = self.rule.low
         (high1, high2) = self.rule.high
         (higher1, higher2) = self.rule.higher
         interal = self.rule.interal
             
         grid.SetCellValue(0, 0, lower1)
         grid.SetCellValue(0, 1, lower2)
         grid.SetCellValue(1, 0, low1)
         grid.SetCellValue(1, 1, low2)
         grid.SetCellValue(2, 0, high1)
         grid.SetCellValue(2, 1, high2)
         grid.SetCellValue(3, 0, higher1)
         grid.SetCellValue(3, 1, higher2)
             
         grid.SetCellValue(5, 0, interal)      
Exemplo n.º 17
0
def gridview(array, title="2d viewer", originLeftBottom=1):
    try:
        from scipy.sparse import spmatrix
        if not isinstance(array, spmatrix):
            array = N.asanyarray(array)
    except:
        array = N.asanyarray(array)

    if array.ndim == 1:
        array = array.view()
        array.shape = (-1, len(array))
    if len(array.shape) != 2:
        raise ValueError, "array must be of dimension 2"

    ###########size = (400,400)
    frame = wx.Frame(None, -1, title)
    #    grid = wx.Window(frame, -1)
    global grid
    grid = HugeTableGrid(frame, array, originLeftBottom)

    grid.EnableDragRowSize(0)
    grid.SetDefaultCellAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
    grid.SetFont(wx.SWISS_FONT)
    #grid.AutoSizeColumns()

    grid.SetDefaultColSize(40, True)
    grid.SetRowLabelSize(30)

    p1 = wx.Panel(frame, -1)
    p1_sizer = wx.BoxSizer(wx.HORIZONTAL)

    nz = 1
    if nz == 1:
        label = wx.StaticText(p1, -1, "---------->")
        #label.SetHelpText("This is the help text for the label")
        p1_sizer.Add(label, 0, wx.GROW | wx.ALL, 2)
        #z0 = 0
        #self.z = z0  ## CHECK worker thread

    else:
        #self.lastZ = -1 # remember - for checking if update needed
        #z0 = 0
        #self.z = z0
        #slider = wx.Slider(panel1, 1001, z0, 0, self.nz-1,
        #                   wx.DefaultPosition, wx.DefaultSize,
        #                   #wx.SL_VERTICAL
        #                   wx.SL_HORIZONTAL
        #                   | wx.SL_AUTOTICKS | wx.SL_LABELS )
        #slider.SetTickFreq(5, 1)
        #box.Add(slider, 1, wx.EXPAND)
        #box.Add(slider, 0, wx.GROW|wx.ALL, 2)
        #box.Add(slider, 1, wx.EXPAND)
        #wx.EVT_SLIDER(frame, slider.GetId(), self.OnSlider)
        #self.slider = slider
        pass

    label2 = wx.StaticText(p1, -1, "<- move mouse over image ->")
    #label2.SetHelpText("This is the help text for the label")

    #p1_sizer.Add(label2, 0, wx.GROW|wx.ALL, 2)
    p1.SetAutoLayout(True)
    p1.SetSizer(p1_sizer)

    sizer = wx.BoxSizer(wx.VERTICAL)
    sizer.Add(label2, 0, wx.GROW | wx.ALL, 2)
    sizer.Add(p1, 0, wx.GROW | wx.ALL, 2)
    sizer.Add(grid, 1, wx.EXPAND | wx.ALL, 5)

    frame.SetSizer(sizer)
    # sizer.SetSizeHints(frame)
    #2.4auto  frame.SetAutoLayout(1)
    sizer.Fit(frame)

    frame.Show(1)
    frame.Layout()  # hack for Linux-GTK