Python wx.ALIGN_LEFT Examples

The following are 30 code examples of wx.ALIGN_LEFT(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wx , or try the search function .
Example #1
Source File: mining.py    From nuxhash with GNU General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, *args, **kwargs):
        wx.dataview.DataViewListCtrl.__init__(self, parent, *args, **kwargs)
        self._Settings = None
        self.Disable()
        self.AppendTextColumn('Algorithm', width=wx.COL_WIDTH_AUTOSIZE)
        self.AppendColumn(
                wx.dataview.DataViewColumn('Devices', DeviceListRenderer(),
                                           1, align=wx.ALIGN_LEFT,
                                           width=wx.COL_WIDTH_AUTOSIZE),
                'string')
        self.AppendTextColumn('Speed', width=wx.COL_WIDTH_AUTOSIZE)
        self.AppendTextColumn('Revenue')

        pub.subscribe(self._OnSettings, 'data.settings')
        pub.subscribe(self._OnStartMining, 'mining.start')
        pub.subscribe(self._OnStopMining, 'mining.stop')
        pub.subscribe(self._OnMiningStatus, 'mining.status') 
Example #2
Source File: new_properties.py    From wxGlade with MIT License 6 votes vote down vote up
def create_editor(self, panel, sizer):
        label_text = self._find_label()
        self.checkbox = wx.CheckBox(panel, -1, '', name=label_text)
        self._display_value()
        self.label_ctrl = label = self._get_label(label_text, panel, name=label_text)

        if config.preferences.use_checkboxes_workaround:
            size = self.checkbox.GetSize()
            self.checkbox.SetLabel(label_text)
            self.checkbox.SetMaxSize(size)

        hsizer = wx.BoxSizer(wx.HORIZONTAL)
        #hsizer.Add(label, 2, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)
        hsizer.Add(label, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALL, 3)
        #hsizer.SetItemMinSize(0, config.label_initial_width, -1)
        #hsizer.AddSpacer(20)
        hsizer.Add(self.checkbox, 0, wx.ALIGN_LEFT | wx.ALL, 3)
        hsizer.AddStretchSpacer(5)
        sizer.Add(hsizer, 0, wx.EXPAND)
        self._set_tooltip(label, self.checkbox)
        self.checkbox.Bind(wx.EVT_CHECKBOX, self.on_change_val)
        self.editing = True 
Example #3
Source File: ListCtrlPrinter.py    From bookhub with MIT License 6 votes vote down vote up
def __init__(self):
        """
        """
        self.padding = None
        self.decorations = list()
        self.font = wx.FFont(11, wx.FONTFAMILY_SWISS, face="Gill Sans")
        self.textColor = None
        self.textAlignment = wx.ALIGN_LEFT
        self.alwaysCenter = False
        self.canWrap = False

        #THINK: These attributes are only for grids. Should we have a GridBlockFormat object?
        self.cellPadding = None
        self.gridPen = None

    #----------------------------------------------------------------------------
    # Accessing 
Example #4
Source File: TF_Output_Var_Box.py    From topoflow with MIT License 6 votes vote down vote up
def Timestep_Box(self):

        #---------------------------------------------
        #  Create sizer box for the process timestep
        #---------------------------------------------
        timestep = self.data.timestep
        unit_str  = "[" + timestep.units + "]"
        L1    = wx.StaticText(self, -1, timestep.label + ":")
        text  = wx.TextCtrl(self,   -1, timestep.value)
        L2    = wx.StaticText(self, -1, unit_str)
        #-------------------------------------------------------        
        box   = wx.BoxSizer(wx.HORIZONTAL | wx.ALIGN_LEFT)
        proportion = 0  # (do not use 1)
        box.Add((self.hgap, self.hgap), proportion)
        box.Add(L1)
        box.Add((self.hgap, self.hgap), proportion)
        box.Add(text)
        box.Add((self.hgap, self.hgap), proportion)
        box.Add(L2)

        return box
    
    #   Timestep_Box()
    #---------------------------------------------------------------- 
Example #5
Source File: ConfigPanel.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def AddGrid(self, grid, vgap=6, hgap=5):
        columns = self.maxRowNum
        sizer = wx.GridBagSizer(vgap, hgap)
        sizer.SetFlexibleDirection(wx.HORIZONTAL)
        rowFlagsGet = self.rowFlags.get
        colFlagsGet = self.colFlags.get
        for rowNum, (row, kwargs) in enumerate(grid):
            if kwargs.get("growable", False):
                sizer.AddGrowableRow(rowNum)
            for colNum, ctrl in enumerate(row):
                if ctrl is None:
                    ctrl = (1, 1)
                elif type(ctrl) in types.StringTypes:
                    ctrl = wx.StaticText(self, -1, ctrl)

                flags = rowFlagsGet(rowNum, 0) | colFlagsGet(colNum, 0)
                flags |= (wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_LEFT)
                sizer.Add(ctrl, (rowNum, colNum), (1, 1), flags)

            if colNum < columns - 1:
                sizer.SetItemSpan(ctrl, (1, columns - colNum + 1))
        self.sizer.Add(sizer, 1, wx.EXPAND) 
Example #6
Source File: sct_plugin.py    From spinalcordtoolbox with MIT License 6 votes vote down vote up
def __init__(self, parent):
        # TODO: try to use MessageBox instead, as they already include buttons, icons, etc.
        wx.Dialog.__init__(self, parent, title="SCT Processing")
        self.SetSize((300, 120))

        vbox = wx.BoxSizer(wx.VERTICAL)
        lbldesc = wx.StaticText(self, id=wx.ID_ANY, label="Processing, please wait...")
        vbox.Add(lbldesc, 0, wx.ALIGN_LEFT | wx.ALL, 10)

        btns = self.CreateSeparatedButtonSizer(wx.CANCEL)
        vbox.Add(btns, 0, wx.ALIGN_LEFT | wx.ALL, 5)

        hbox = wx.BoxSizer(wx.HORIZONTAL)

        # TODO: use a nicer image, showing two gears (similar to ID_EXECUTE)
        save_ico = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_TOOLBAR, (50, 50))
        img_info = wx.StaticBitmap(self, -1, save_ico, wx.DefaultPosition, (save_ico.GetWidth(), save_ico.GetHeight()))

        hbox.Add(img_info, 0, wx.ALL, 10)
        hbox.Add(vbox, 0, wx.ALL, 0)

        self.SetSizer(hbox)
        self.Centre()
        self.CenterOnParent()
        # TODO: retrieve action from the cancel button 
Example #7
Source File: WordWrapRenderer.py    From bookhub with MIT License 6 votes vote down vote up
def OnPaint(self, evt):
            dc = wx.PaintDC(self)
            inset = (20, 20, 20, 20)
            rect = [inset[0], inset[1], self.GetSize().width-(inset[0]+inset[2]), self.GetSize().height-(inset[1]+inset[3])]

            # Calculate exactly how high the wrapped is going to be and put a frame around it.
            dc.SetFont(self.font)
            dc.SetPen(wx.RED_PEN)
            rect[3] = WordWrapRenderer.CalculateHeight(dc, self.text, rect[2])
            dc.DrawRectangle(*rect)
            WordWrapRenderer.DrawString(dc, self.text, rect, wx.ALIGN_LEFT)
            #WordWrapRenderer.DrawTruncatedString(dc, self.text, rect, wx.ALIGN_CENTER_HORIZONTAL,s ellipse=wx.CENTER)

            #bmp = wx.EmptyBitmap(rect[0]+rect[2], rect[1]+rect[3])
            #mdc = wx.MemoryDC(bmp)
            #mdc.SetBackground(wx.Brush("white"))
            #mdc.Clear()
            #mdc.SetFont(self.font)
            #mdc.SetPen(wx.RED_PEN)
            #rect[3] = WordWrapRenderer.CalculateHeight(mdc, self.text, rect[2])
            #mdc.DrawRectangle(*rect)
            #WordWrapRenderer.DrawString(mdc, self.text, rect, wx.ALIGN_LEFT)
            #del mdc
            #dc = wx.ScreenDC()
            #dc.DrawBitmap(bmp, 20, 20) 
Example #8
Source File: WordWrapRenderer.py    From bookhub with MIT License 6 votes vote down vote up
def DrawTruncatedString(dc, text, bounds, align=wx.ALIGN_LEFT, valign=wx.ALIGN_TOP, ellipse=wx.RIGHT, ellipseChars="..."):
        """
        Draw the given text truncated to the given bounds.

        bounds must be a wx.Rect or a 4-element collection: (left, top, width, height).

        If allowClipping is True, this method changes the clipping region so that no
        text is drawn outside of the given bounds.
        """
        if not text:
            return

        if align == wx.ALIGN_CENTER:
            align = wx.ALIGN_CENTER_HORIZONTAL

        if valign == wx.ALIGN_CENTER:
            valign = wx.ALIGN_CENTER_VERTICAL

        try:
            bounds = wx.Rect(*bounds)
        except:
            pass
        lines = WordWrapRenderer._Truncate(dc, text, bounds[2], ellipse, ellipseChars)
        dc.DrawLabel(lines, bounds, align|valign) 
Example #9
Source File: __init__.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def __init__(self, parent, lngth):
        gridlib.Grid.__init__(self, parent)
        self.SetRowLabelSize(0)
        self.SetColLabelSize(0)
        self.SetDefaultRowSize(16)
        self.SetScrollLineX(1)
        self.SetScrollLineY(1)
        self.EnableEditing(False)
        self.EnableDragColSize(False)
        self.EnableDragRowSize(False)
        self.EnableDragGridSize(False)
        self.EnableGridLines(False)
        self.SetColMinimalAcceptableWidth(8)
        self.CreateGrid(lngth, 3)
        attr = gridlib.GridCellAttr()
        attr.SetAlignment(wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
        self.SetColAttr(1,attr)
        self.SetSelectionMode(gridlib.Grid.wxGridSelectRows)
        self.Bind(gridlib.EVT_GRID_CMD_SELECT_CELL, self.onGridSelectCell, self) 
Example #10
Source File: ForceVariableDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def InitCtrlBool(self, info_sizer, defaultValue):
        """Add button to change value of boolean variable"""
        self.ValueCtrl = wx.ToggleButton(self, label=_("Toggle value"))
        value = GetTypeValue[self.IEC_Type](defaultValue)
        if value is not None:
            self.ValueCtrl.SetValue(value)

        info_sizer.AddWindow(self.ValueCtrl, border=10,
                             flag=wx.ALIGN_LEFT | wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT | wx.GROW) 
Example #11
Source File: dialog_gettool.py    From iqiyi-parser with MIT License 5 votes vote down vote up
def __init__(self, parent, title, total_byte, dlm):
        wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=title, pos=wx.DefaultPosition, size=wx.DefaultSize,
                           style=wx.DEFAULT_DIALOG_STYLE)
        self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)

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

        self.gauge_progress = wx.Gauge(self, wx.ID_ANY, 10000, wx.DefaultPosition, wx.DefaultSize, wx.GA_HORIZONTAL)
        self.gauge_progress.SetValue(524)
        self.global_sizer.Add(self.gauge_progress, 0, wx.ALL | wx.EXPAND, 5)

        sizer_info = wx.BoxSizer(wx.HORIZONTAL)

        self.text_percent = wx.StaticText(self, wx.ID_ANY, u"0.0%", wx.DefaultPosition, wx.DefaultSize,
                                            wx.ALIGN_LEFT)
        self.text_percent.Wrap(-1)

        sizer_info.Add(self.text_percent, 1, wx.ALL, 5)

        self.total_byte = total_byte
        self.format_int = '%0' + str(len(str(self.total_byte))) + 'd/%0' + str(len(str(self.total_byte))) + 'd'

        self.text_progress = wx.StaticText(self, wx.ID_ANY, self.format_int % (0, self.total_byte), wx.DefaultPosition, wx.DefaultSize,
                                            wx.ALIGN_RIGHT)
        self.text_progress.Wrap(-1)

        sizer_info.Add(self.text_progress, 1, wx.ALIGN_RIGHT | wx.ALL, 5)

        self.global_sizer.Add(sizer_info, 1, wx.EXPAND, 5)

        self.SetSizer(self.global_sizer)
        self.Layout()
        self.global_sizer.Fit(self)

        self.Centre(wx.BOTH)
        self.Bind(wx.EVT_CLOSE, self.onClose)

        self.timer = wx.Timer()

        self.timer.SetOwner(self, wx.ID_ANY)
        self.dlm = dlm 
Example #12
Source File: EtherCATManagementEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, info, entry, count):
        """
        Constructor
        @param parent: Reference to the parent PDONoteBook class
        @param info : data structure including entry index, sub index, name, length, type
        @param entry : data structure including index, name, entry number
        @param count : page number
        """
        wx.grid.Grid.__init__(self, parent, -1, size=(500, 400), pos=wx.Point(0, 0),
                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)

        self.Controler = parent.Controler

        self.PDOInfo = info
        self.PDOEntry = entry
        self.Count = count

        self.CreateGrid(self.PDOInfo[self.Count]['number_of_entry'], 5)
        self.SetColLabelSize(25)
        self.SetRowLabelSize(0)

        PDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Length"),
                         (3, "Type"), (4, "Name")]

        for (index, label) in PDOTableLabel:
            self.SetColLabelValue(index, label)

        PDOCellSize = [(0, 45), (1, 65), (2, 55), (3, 40), (4, 300)]

        for (index, size) in PDOCellSize:
            self.SetColSize(index, size)
            self.SetColLabelAlignment(index, wx.ALIGN_LEFT)

        attr = wx.grid.GridCellAttr()

        for i in range(5):
            self.SetColAttr(i, attr)

        self.SetTableValue() 
Example #13
Source File: EtherCATManagementEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def SetTableValue(self):
        """
        Cell is filled by new parsing data in XML
        """
        list_index = 0
        # number of entry
        for i in range(self.Count + 1):
            list_index += self.PDOInfo[i]['number_of_entry']

        start_value = list_index - self.PDOInfo[self.Count]['number_of_entry']

        pdo_list = ['entry_index', 'subindex', 'bitlen', 'type', 'name']
        for row_idx in range(self.PDOInfo[self.Count]['number_of_entry']):
            for col_idx in range(len(self.PDOEntry[row_idx])):
                # entry index is converted hex value.
                if col_idx == 0:
                    self.SetCellValue(row_idx, col_idx, hex(self.PDOEntry[start_value][pdo_list[col_idx]]))
                else:
                    self.SetCellValue(row_idx, col_idx, str(self.PDOEntry[start_value][pdo_list[col_idx]]))
                if col_idx != 4:
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE)
                else:
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_LEFT, wx.ALIGN_CENTRE)
                self.SetReadOnly(row_idx, col_idx, True)
                self.SetRowSize(row_idx, 25)
            start_value += 1


# -------------------------------------------------------------------------------
#                    For EEPROM Access Main Panel
#                 (This class explain EEPROM Access)
# ------------------------------------------------------------------------------- 
Example #14
Source File: EtherCATManagementEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def SetValue(self, value):
        """
        Set data in the table
        @param value: EEPROM data list of which element is 1 Byte hex data
        """
        # set label name and size
        self.SetRowLabelSize(100)
        for col in range(self.Col):
            if col == 16:
                self.SetColLabelValue(16, "Text View")
                self.SetColSize(16, (self.GetSize().x-120)*4//20)
            else:
                self.SetColLabelValue(col, '%s' % col)
                self.SetColSize(col, (self.GetSize().x-120)//20)

        # set data into table
        row = col = 0
        for row_idx in value:
            col = 0
            self.SetRowLabelValue(row, "0x"+"{:0>4x}".format(row*(self.Col-1)))
            for hex in row_idx:
                self.SetCellValue(row, col, hex)

                if col == 16:
                    self.SetCellAlignment(row, col, wx.ALIGN_LEFT, wx.ALIGN_CENTER)
                else:
                    self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER)

                self.SetReadOnly(row, col, True)
                col = col + 1
            row = row + 1


# -------------------------------------------------------------------------------
#                    For Register Access Panel
# ------------------------------------------------------------------------------- 
Example #15
Source File: ForceVariableDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, parent, iec_type, defaultValue=""):
        """
        Constructor
        @param parent: Parent wx.Window of dialog for modal
        @param iec_type: IEC type of variable (string). For example 'BOOL', 'LREAL'.
        @param defaultValue: current variable value as string. Default is empty string.
        """
        wx.Dialog.__init__(
            self, parent,
            name='ForceVariableDialog',
            title=_("Please enter value for a \"%s\" variable:") % iec_type,
            style=wx.DEFAULT_DIALOG_STYLE, pos=wx.DefaultPosition)

        self.IEC_Type = iec_type
        info_sizer = wx.BoxSizer(wx.VERTICAL)

        message_label = wx.StaticText(self, label=_("Forcing Variable Value"))
        info_sizer.AddWindow(message_label, border=10,
                             flag=wx.ALIGN_LEFT | wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT)

        if GetTypeValue[self.IEC_Type] in [getinteger, getfloat]:
            self.InitCtrlNumber(info_sizer, defaultValue)
        elif self.IEC_Type == "BOOL":
            self.InitCtrlBool(info_sizer, defaultValue)
        else:
            self.InitCtrlDefault(info_sizer, defaultValue)
        self.GetEnteredValue = self.GetValueDefault

        button_sizer = self.CreateButtonSizer(wx.OK | wx.CANCEL | wx.CENTRE)
        self.Bind(wx.EVT_BUTTON, self.OnOK, button_sizer.GetAffirmativeButton())
        info_sizer.AddSizer(button_sizer, border=10, flag=wx.ALIGN_RIGHT | wx.ALL)

        self.SetSizer(info_sizer)
        self.Fit()
        self.ValueCtrl.SetFocus()

    # ---------------------------------
    # default type methods
    # --------------------------------- 
Example #16
Source File: ForceVariableDialog.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def InitCtrlNumber(self, info_sizer, defaultValue):
        """Add controls to change float and integer variables"""
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        self.InitCtrlDefault(sizer, defaultValue)
        self.SpinButtonCtrl = wx.SpinButton(self, style=wx.HORIZONTAL | wx.SP_WRAP)
        sizer.AddWindow(self.SpinButtonCtrl, border=10,
                        flag=wx.ALIGN_LEFT | wx.GROW | wx.TOP | wx.LEFT | wx.RIGHT | wx.EXPAND)
        self.Bind(wx.EVT_SPIN_UP, self.SpinButtonChanged)
        self.Bind(wx.EVT_SPIN_DOWN, self.SpinButtonChanged)
        info_sizer.AddWindow(sizer, proportion=1, flag=wx.EXPAND) 
Example #17
Source File: footer.py    From me-ica with GNU Lesser General Public License v2.1 5 votes vote down vote up
def _do_layout(self):
    self.stop_button.Hide()
    self.restart_button.Hide()

    v_sizer = wx.BoxSizer(wx.VERTICAL)
    h_sizer = wx.BoxSizer(wx.HORIZONTAL)

    h_sizer.Add(self.progress_bar, 0, wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 20)
    self.progress_bar.Hide()

    h_sizer.AddStretchSpacer(1)
    h_sizer.Add(self.cancel_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 20)
    h_sizer.Add(self.start_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 20)
    h_sizer.Add(self.stop_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 20)

    v_sizer.AddStretchSpacer(1)
    v_sizer.Add(h_sizer, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND)

    h_sizer.Add(self.edit_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 10)
    h_sizer.Add(self.restart_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 10)
    h_sizer.Add(self.close_button, 0, wx.ALIGN_RIGHT | wx.RIGHT, 20)
    self.edit_button.Hide()
    self.restart_button.Hide()
    self.close_button.Hide()

    v_sizer.AddStretchSpacer(1)
    self.SetSizer(v_sizer) 
Example #18
Source File: CustomTree.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        CT.CustomTreeCtrl.__init__(self, *args, **kwargs)

        self.BackgroundBitmap = None
        self.BackgroundAlign = wx.ALIGN_LEFT | wx.ALIGN_TOP

        self.AddMenu = None
        self.Enabled = False

        self.Bind(wx.EVT_SCROLLWIN, self.OnScroll)
        self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp) 
Example #19
Source File: WordWrapRenderer.py    From bookhub with MIT License 5 votes vote down vote up
def DrawString(dc, text, bounds, align=wx.ALIGN_LEFT, valign=wx.ALIGN_TOP, allowClipping=False):
        """
        Draw the given text word-wrapped within the given bounds.

        bounds must be a wx.Rect or a 4-element collection: (left, top, width, height).

        If allowClipping is True, this method changes the clipping region so that no
        text is drawn outside of the given bounds.
        """
        if not text:
            return

        if align == wx.ALIGN_CENTER:
            align = wx.ALIGN_CENTER_HORIZONTAL

        if valign == wx.ALIGN_CENTER:
            valign = wx.ALIGN_CENTER_VERTICAL

        # DrawLabel only accepts a wx.Rect
        try:
            bounds = wx.Rect(*bounds)
        except:
            pass

        if allowClipping:
            clipper = wx.DCClipper(dc, bounds)

        # There is a bug in the wordwrap routine where a string that needs truncated and
        # that ends with a single space causes the method to throw an error (wx 2.8).
        # Our simple, but not always accurate, is to remove trailing spaces.
        # This won't catch single trailing space imbedded in a multiline string.
        text = text.rstrip(' ')

        lines = wordwrap(text, bounds[2], dc, True)
        dc.DrawLabel(lines, bounds, align|valign) 
Example #20
Source File: OLVPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def __init__(self):
        """
        """
        self.padding = None
        self.decorations = list()
        self.font = wx.FFont(14, wx.FONTFAMILY_SWISS, face="Gill Sans")
        self.textColor = None
        self.textAlignment = wx.ALIGN_LEFT
        self.cellPadding = None
        self.gridPen = None

    #----------------------------------------------------------------------------
    # Accessing 
Example #21
Source File: OLVPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def DrawText(self, dc, txt, bounds, font=None, alignment=wx.ALIGN_LEFT, image=None, color=None):
        """
        """
        dc.SetFont(font or self.GetFont())
        dc.SetTextForeground(color or self.GetTextColor() or wx.BLACK)
        WordWrapRenderer.DrawString(dc, txt, bounds, alignment, allowClipping=False)



#====================================================================== 
Example #22
Source File: ListCtrlPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def Normal(headerFontName="Gill Sans", rowFontName="Times New Roman"):
        """
        Return a reasonable default format for a report
        """
        fmt = ReportFormat()
        fmt.IsShrinkToFit = True

        fmt.PageHeader.Font = wx.FFont(12, wx.FONTFAMILY_DEFAULT, face=headerFontName)
        fmt.PageHeader.Line(wx.BOTTOM, wx.BLUE, 2, space=5)
        fmt.PageHeader.Padding = (0, 0, 0, 12)

        fmt.ListHeader.Font = wx.FFont(26, wx.FONTFAMILY_SWISS, wx.FONTFLAG_BOLD, face=headerFontName)
        fmt.ListHeader.TextColor = wx.WHITE
        fmt.ListHeader.Padding = (0, 12, 0, 12)
        fmt.ListHeader.TextAlignment = wx.ALIGN_LEFT
        fmt.ListHeader.Background(wx.BLUE, wx.WHITE, space=(16, 4, 0, 4))

        fmt.GroupTitle.Font = wx.FFont(14, wx.FONTFAMILY_DEFAULT, face=headerFontName)
        fmt.GroupTitle.Line(wx.BOTTOM, wx.BLUE, 4, toColor=wx.WHITE, space=5)
        fmt.GroupTitle.Padding = (0, 12, 0, 12)

        fmt.PageFooter.Font = wx.FFont(10, wx.FONTFAMILY_DEFAULT, face=headerFontName)
        fmt.PageFooter.Background(wx.WHITE, wx.BLUE, space=(0, 4, 0, 4))

        fmt.ColumnHeader.Font = wx.FFont(14, wx.FONTFAMILY_DEFAULT, wx.FONTFLAG_BOLD, face=headerFontName)
        fmt.ColumnHeader.CellPadding = 2
        fmt.ColumnHeader.Background(wx.Colour(192, 192, 192))
        fmt.ColumnHeader.GridPen = wx.Pen(wx.WHITE, 1)
        fmt.ColumnHeader.Padding = (0, 0, 0, 12)
        fmt.ColumnHeader.AlwaysCenter = True

        fmt.Row.Font = wx.FFont(12, wx.FONTFAMILY_DEFAULT, face=rowFontName)
        fmt.Row.Line(wx.BOTTOM, pen=wx.Pen(wx.BLUE, 1, wx.DOT), space=3)
        fmt.Row.CellPadding = 2
        fmt.Row.CanWrap = True

        return fmt 
Example #23
Source File: ListCtrlPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def GetAlignments(self):
        """
        Return a list indicating how the text within each cell is aligned.
        """
        return (wx.ALIGN_LEFT, wx.ALIGN_CENTER_HORIZONTAL, wx.ALIGN_RIGHT)

#---------------------------------------------------------------------------- 
Example #24
Source File: ListCtrlPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def GetColumnAlignments(self, lv, left, right):
        """
        Return the alignments of the given slice of columns
        """
        listAlignments = [lv.GetColumn(i).GetAlign() for i in range(left, right+1)]
        mapping = {
            wx.LIST_FORMAT_LEFT: wx.ALIGN_LEFT,
            wx.LIST_FORMAT_RIGHT: wx.ALIGN_RIGHT,
            wx.LIST_FORMAT_CENTRE: wx.ALIGN_CENTRE,
        }
        return [mapping[x] for x in listAlignments]



#---------------------------------------------------------------------------- 
Example #25
Source File: viewer_tools.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __init__(self, *args, **kwargs):
        kwargs["style"] = kwargs.get("style", 0) | wx.BORDER_NONE
        super(ImageChooserControl, self).__init__(*args, **kwargs)

        self._slider = wx.Slider(self, -1, style=wx.SL_AUTOTICKS)
        self._slider.SetMin(1)
        self._label = wx.StaticText(self, -1, "Some Text")

        # Work out the maximum size of the text so that we can cut off the slider to allow room
        if WX3:
            _, size_y = self._label.GetAdjustedBestSize()
            self._label.SetFont(self._label.GetFont().Italic())
            self.size_y = max(size_y, self._label.GetAdjustedBestSize()[1])
        else:
            _, size_y = self._label.GetEffectiveMinSize()
            self._label.SetFont(self._label.GetFont().Italic())
            self.size_y = max(size_y, self._label.GetEffectiveMinSize()[1])

        # Use a horizontal box to control vertical alignment
        labelSizer = wx.BoxSizer(wx.HORIZONTAL)
        labelSizer.Add(self._label, flag=wx.ALL | wx.ALIGN_BOTTOM)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self._slider, flag=wx.ALL | wx.ALIGN_LEFT)
        sizer.Add(labelSizer, proportion=1, flag=wx.EXPAND)
        self.SetSizer(sizer) 
Example #26
Source File: tydesk.py    From tydesk with GNU General Public License v3.0 5 votes vote down vote up
def NotReady(self):
    self.vbox.Clear(True)      
    self.vbox.AddSpacer(50)
    stWarn = wx.StaticText(self.pLeft, -1, u'终端尚未接入!请先点击右侧终端接入按钮')
    stWarn.SetForegroundColour((255,0,0))
    self.vbox.Add(stWarn, 0, wx.ALIGN_LEFT | wx.LEFT | wx.BOTTOM, 20)
    self.pLeft.SetSizer(self.vbox)
    self.pLeft.Layout() 
Example #27
Source File: header.py    From me-ica with GNU Lesser General Public License v2.1 5 votes vote down vote up
def _do_layout(self):
    vsizer = wx.BoxSizer(wx.VERTICAL)
    sizer = wx.BoxSizer(wx.HORIZONTAL)
    headings_sizer = self.build_heading_sizer()
    sizer.Add(headings_sizer, 1, wx.ALIGN_LEFT | wx.ALIGN_CENTER_HORIZONTAL | wx.EXPAND | wx.LEFT, PAD_SIZE)
    sizer.Add(self.settings_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
    sizer.Add(self.running_img, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
    sizer.Add(self.check_mark, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
    sizer.Add(self.error_symbol, 0, wx.ALIGN_RIGHT | wx.EXPAND | wx.RIGHT, PAD_SIZE)
    self.running_img.Hide()
    self.check_mark.Hide()
    self.error_symbol.Hide()
    vsizer.Add(sizer, 1, wx.EXPAND)
    self.SetSizer(vsizer) 
Example #28
Source File: components.py    From me-ica with GNU Lesser General Public License v2.1 5 votes vote down vote up
def do_layout(self, parent, titles, msgs):
    self.panel = wx.Panel(parent)

    self.radio_buttons = [wx.RadioButton(self.panel, -1) for _ in titles]
    self.btn_names = [wx.StaticText(self.panel, label=title.title()) for title in titles]
    self.help_msgs = [wx.StaticText(self.panel, label=msg.title()) for msg in msgs]

    # box = wx.StaticBox(self.panel, -1, label=self.data['group_name'])
    box = wx.StaticBox(self.panel, -1, label='')
    vertical_container = wx.StaticBoxSizer(box, wx.VERTICAL)

    for button, name, help in zip(self.radio_buttons, self.btn_names, self.help_msgs):

      hbox = wx.BoxSizer(wx.HORIZONTAL)

      hbox.Add(button, 0, wx.ALIGN_TOP | wx.ALIGN_LEFT)
      hbox.Add(name, 0, wx.LEFT, 10)

      vertical_container.Add(hbox, 0, wx.EXPAND)

      vertical_container.Add(help, 1, wx.EXPAND | wx.LEFT, 25)
      vertical_container.AddSpacer(5)

    self.panel.SetSizer(vertical_container)
    self.panel.Bind(wx.EVT_SIZE, self.onResize)
    self.panel.Bind(wx.EVT_RADIOBUTTON, self.showz)
    return self.panel 
Example #29
Source File: statisticspage.py    From magpy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def doLayout(self):
      mainSizer = wx.BoxSizer(wx.HORIZONTAL)
      gridSizer = wx.FlexGridSizer(3, 2, 5,10)
      gridSizer.AddMany([(self.timeLabel),
            (0, 0),
            (self.statisticsLabel),
            (self.valuesLabel),
            (self.statisticsTextCtrl, 1, wx.EXPAND),
            (self.valuesTextCtrl, 1, wx.EXPAND)])
      gridSizer.AddGrowableRow(2, 1)
      gridSizer.AddGrowableCol(1, 1)
      gridSizer.AddGrowableCol(0, 1)
      mainSizer.Add(gridSizer, proportion = 2,
            flag = wx.ALIGN_LEFT | wx.ALL |wx.EXPAND, border=5)
      self.SetSizer(mainSizer) 
Example #30
Source File: reportpage.py    From magpy with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def doLayout(self):
        mainSizer = wx.BoxSizer(wx.VERTICAL)
        mainSizer.Add(self.logger, 0, wx.ALIGN_LEFT | wx.ALL, 3)
        mainSizer.Add(self.saveLoggerButton, 0, wx.ALIGN_LEFT | wx.ALL, 3)
        self.SetSizerAndFit(mainSizer)