Python wx.ALIGN_CENTRE Examples

The following are 22 code examples of wx.ALIGN_CENTRE(). 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: welcome.py    From DeepLabCut with GNU Lesser General Public License v3.0 6 votes vote down vote up
def __init__(self, parent, gui_size):
        h = gui_size[0]
        w = gui_size[1]
        wx.Panel.__init__(self, parent, -1, style=wx.SUNKEN_BORDER, size=(h, w))

        ##         design the panel
        sizer = wx.GridBagSizer(10, 7)
        # Add image of DLC
        icon = wx.StaticBitmap(self, bitmap=wx.Bitmap(dlc))
        sizer.Add(icon, pos=(0, 0), span=(0, 8), flag=wx.EXPAND | wx.BOTTOM, border=10)
        line = wx.StaticLine(self)
        sizer.Add(line, pos=(1, 0), span=(1, 8), flag=wx.EXPAND | wx.BOTTOM, border=10)

        # if editing this text make sure you add the '\n' to get the new line. The sizer is unable to format lines correctly.
        description = "DeepLabCut™ is an open source tool for markerless\npose estimation of user-defined body parts with deep learning.\nA. and M.W. Mathis Labs | http://www.deeplabcut.org\n \nWelcome to the DeepLabCut Project Manager GUI!\nTo get started, please click on the 'Manage Project'\n tab to create or load an existing project. \n "

        self.proj_name = wx.StaticText(self, label=description, style=wx.ALIGN_CENTRE)
        sizer.Add(self.proj_name, pos=(2, 3), border=10)
        sizer.AddGrowableCol(2)
        self.SetSizer(sizer)
        sizer.Fit(self) 
Example #2
Source File: ActionBase.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def Configure(self, *args):
        """
        This should be overridden in a subclass, if the plugin wants to have
        a configuration dialog.

        When the plugin is freshly added by the user to the configuration tree
        there are no *\*args* and you must therefore supply sufficient
        default arguments.
        If the plugin is reconfigured by the user, this method will be called
        with the same arguments as the :meth:`!__start__` method would receive.
        """
        panel = eg.ConfigPanel()
        panel.dialog.buttonRow.applyButton.Enable(False)
        label = panel.StaticText(
            eg.text.General.noOptionsAction,
            style=wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE
        )
        panel.sizer.Add((0, 0), 1, wx.EXPAND)
        panel.sizer.Add(label, 0, wx.ALIGN_CENTRE)
        panel.sizer.Add((0, 0), 1, wx.EXPAND)
        while panel.Affirmed():
            panel.SetResult() 
Example #3
Source File: PluginBase.py    From EventGhost with GNU General Public License v2.0 6 votes vote down vote up
def Configure(self, *args):
        """
        This should be overridden in a subclass, if the plugin wants to have
        a configuration dialog.

        When the plugin is freshly added by the user to the configuration tree
        there are no *\*args* and you must therefore supply sufficient
        default arguments.
        If the plugin is reconfigured by the user, this method will be called
        with the same arguments as the :meth:`!__start__` method would receive.
        """
        panel = eg.ConfigPanel()
        panel.dialog.buttonRow.applyButton.Enable(False)
        label = panel.StaticText(
            eg.text.General.noOptionsPlugin,
            style=wx.ALIGN_CENTRE | wx.ST_NO_AUTORESIZE
        )
        panel.sizer.Add((0, 0), 1, wx.EXPAND)
        panel.sizer.Add(label, 0, wx.ALIGN_CENTRE)
        panel.sizer.Add((0, 0), 1, wx.EXPAND)
        while panel.Affirmed():
            panel.SetResult() 
Example #4
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 #5
Source File: EtherCATManagementEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 6 votes vote down vote up
def CreateSyncManagerTable(self):
        """
        Create grid for "SyncManager"
        """
        # declare Table object
        self.SyncManagersTable = SyncManagersTable(self, [], GetSyncManagersTableColnames())
        self.SyncManagersGrid.SetTable(self.SyncManagersTable)
        # set grid alignment attr. (CENTER)
        self.SyncManagersGridColAlignements = [wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE,
                                               wx.ALIGN_CENTRE, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE]
        # set grid size
        self.SyncManagersGridColSizes = [40, 150, 100, 100, 100, 100]
        self.SyncManagersGrid.SetRowLabelSize(0)
        for col in range(self.SyncManagersTable.GetNumberCols()):
            attr = wx.grid.GridCellAttr()
            attr.SetAlignment(self.SyncManagersGridColAlignements[col], wx.ALIGN_CENTRE)
            self.SyncManagersGrid.SetColAttr(col, attr)
            self.SyncManagersGrid.SetColMinimalWidth(col, self.SyncManagersGridColSizes[col])
            self.SyncManagersGrid.AutoSizeColumn(col, False)

        self.RefreshSlaveInfos() 
Example #6
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
        """
        sdo_list = ['idx', 'subIdx', 'access', 'type', 'size', 'category', 'name', 'value']
        for row_idx in range(len(self.SDOs)):
            for col_idx in range(len(self.SDOs[row_idx])):
                self.SetCellValue(row_idx, col_idx, self.SDOs[row_idx][sdo_list[col_idx]])
                self.SetReadOnly(row_idx, col_idx, True)
                if col_idx < 5:
                    self.SetCellAlignment(row_idx, col_idx, wx.ALIGN_CENTRE, wx.ALIGN_CENTRE) 
Example #7
Source File: viewer_low_level_util.py    From dials with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def set_scroll_content(self):
        self.img_lst_v_sizer.Clear(True)

        for lst_1d in self.lst_2d_bmp:
            img_lst_hor_sizer = wx.BoxSizer(wx.HORIZONTAL)

            for i, i_bmp in enumerate(lst_1d):
                local_bitmap = wx.StaticBitmap(self, bitmap=i_bmp)
                if self.parent_panel.local_bbox is None:
                    slice_string = "Slice[" + str(i) + ":" + str(i + 1) + ", :, :]"
                else:
                    bbx = self.parent_panel.local_bbox
                    slice_string = "Image # " + str(bbx[4] + i)

                slice_sub_info_txt = wx.StaticText(self, -1, slice_string)

                sigle_slice_sizer = wx.BoxSizer(wx.VERTICAL)
                sigle_slice_sizer.Clear(True)

                sigle_slice_sizer.Add(
                    local_bitmap, proportion=0, flag=wx.ALIGN_CENTRE | wx.ALL, border=2
                )
                sigle_slice_sizer.Add(
                    slice_sub_info_txt,
                    proportion=0,
                    flag=wx.ALIGN_CENTRE | wx.ALL,
                    border=2,
                )
                img_lst_hor_sizer.Add(
                    sigle_slice_sizer,
                    proportion=0,
                    flag=wx.ALIGN_CENTER | wx.ALL,
                    border=2,
                )

            self.img_lst_v_sizer.Add(img_lst_hor_sizer, 0, wx.CENTER | wx.ALL, 10)

            self.n_img += 1

        self.parent_panel.Pframe.Layout()
        self.SetScrollRate(1, 1) 
Example #8
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 #9
Source File: OLVPrinter.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.
        """
        if self.engine.alwaysCenterColumnHeader:
            return [wx.ALIGN_CENTRE for i in range(self.left, self.right+1)]
        else:
            return self.GetColumnAlignments(olv, self.left, self.right) 
Example #10
Source File: OLVPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def GetColumnAlignments(self, olv, left, right):
        """
        Return the alignments of the given slice of columns
        """
        listAlignments = [olv.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 #11
Source File: OLVPrinter.py    From bookhub with MIT License 5 votes vote down vote up
def Normal(fontName="Arial"):
        """
        Return a reasonable default format for a report
        """
        fmt = ReportFormat()
        fmt.PageHeader.Font = wx.FFont(24, wx.FONTFAMILY_DEFAULT, face=fontName)
        fmt.PageHeader.TextAlignment = wx.ALIGN_CENTRE
        fmt.PageHeader.Add(FrameDecoration(pen=wx.Pen(wx.BLUE, 1), space=5))
        #fmt.PageHeader.Add(LineDecoration(pen=wx.Pen(wx.BLUE, 2), space=5))

        fmt.ReportHeader.Font = wx.FFont(36, wx.FONTFAMILY_DEFAULT, face=fontName)
        fmt.ReportHeader.TextColor = wx.RED
        fmt.ReportHeader.Padding = (0, 12, 0, 12)

        fmt.ListHeader.Add(LineDecoration(side=Decoration.BOTTOM, pen=wx.Pen(wx.GREEN, 1)))

        fmt.PageFooter.Font = wx.FFont(12, wx.FONTFAMILY_DEFAULT, face=fontName)
        fmt.PageFooter.TextAlignment = wx.ALIGN_RIGHT
        fmt.PageFooter.Add(LineDecoration(side=Decoration.TOP, pen=wx.Pen(wx.BLUE, 1), space=3))

        fmt.Row.Font = wx.FFont(12, wx.FONTFAMILY_DEFAULT, face=fontName)
        #fmt.ColumnHeader.CellPadding=25
        fmt.ColumnHeader.GridPen=wx.Pen(wx.RED, 1)
        fmt.Row.CellPadding=(10, 10, 0, 10)
        fmt.Row.GridPen=wx.Pen(wx.BLUE, 1)
        #fmt.ColumnHeader.Add(FrameDecoration(pen=wx.Pen(wx.RED, 1)))
        #fmt.Row.Add(FrameDecoration(pen=wx.Pen(wx.RED, 10)))
        #fmt.Row.Add(LineDecoration(side=Decoration.BOTTOM, pen=wx.Pen(wx.GREEN, 1)))

        return fmt

#====================================================================== 
Example #12
Source File: test_CustomIntCtrl.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def AddControls(self):
        vs = wx.BoxSizer(wx.VERTICAL)
        self.int_ctrl = controls.CustomIntCtrl(self.frame)
        self.txt_ctrl = wx.TextCtrl(self.frame)
        vs.Add(self.int_ctrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        vs.Add(self.txt_ctrl, 0, wx.ALIGN_CENTRE | wx.ALL, 5)
        self.frame.SetSizer(vs)
        vs.Fit(self.frame)
        self.frame.Show()
        self.frame.Raise()

        self.min_val = 50
        self.max_val = 100
        self.int_ctrl.SetBounds(self.min_val, self.max_val)
        self.ProcessEvents() 
Example #13
Source File: EtherCATManagementEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 5 votes vote down vote up
def SetValue(self, parent, data):
        """
            Set the data into the subtable.
            @param parent: RegisterNotebook object
            @param data: data
            """
        # lset label name and size
        Register_SubTable_Label = [(0, "Bits"), (1, "Name"),
                                   (2, "Value"), (3, "Enum")]

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

        self.SetColSize(1, 200)
        self.SetColSize(3, 200)

        # set data into table
        row = col = 0
        for rowData in data:
            col = 0
            for element in rowData:
                self.SetCellValue(row, col, element)
                self.SetCellAlignment(row, col, wx.ALIGN_CENTRE, wx.ALIGN_CENTER)
                self.SetReadOnly(row, col, True)
                col = col + 1
            row = row + 1


# -------------------------------------------------------------------------------
#                    For Master State Panel
# ------------------------------------------------------------------------------- 
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: 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 #16
Source File: loginScreen.py    From HH---POS-Accounting-and-ERP-Software with MIT License 5 votes vote down vote up
def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"POS and Accounting", pos = wx.DefaultPosition, size = wx.Size( 676,460 ), style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE|wx.TAB_TRAVERSAL )
		
		self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
		
		bSizer1 = wx.BoxSizer( wx.VERTICAL )
		
		self.panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		
		self.mainSizer = wx.BoxSizer( wx.VERTICAL )
		
		self.userName = wx.TextCtrl (self.panel, value="admin")
		self.mainSizer.Add( self.userName, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.passwd = wx.TextCtrl (self.panel, value="admin")
		self.mainSizer.Add( self.passwd, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.lgnButton = wx.Button(self.panel, label="Login")
		self.mainSizer.Add( self.lgnButton, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.panel.SetSizer( self.mainSizer )
		
		bSizer1.Add( self.panel, 1, wx.EXPAND |wx.ALL, 5 )
		
		self.SetSizer( bSizer1 )
		self.Layout()
		
		self.Centre( wx.BOTH )
		
		self.lgnButton.Bind(wx.EVT_BUTTON, self.attemptLogin) 
Example #17
Source File: loginScreen.py    From HH---POS-Accounting-and-ERP-Software with MIT License 5 votes vote down vote up
def __init__( self, parent ):
		wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"POS and Accounting", pos = wx.DefaultPosition, size = wx.Size( 676,460 ), style = wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE|wx.TAB_TRAVERSAL )
		
		self.SetSizeHints( wx.DefaultSize, wx.DefaultSize )
		
		bSizer1 = wx.BoxSizer( wx.VERTICAL )
		
		self.panel = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )
		
		self.mainSizer = wx.BoxSizer( wx.VERTICAL )
		
		self.userName = wx.TextCtrl (self.panel, value="admin")
		self.mainSizer.Add( self.userName, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.passwd = wx.TextCtrl (self.panel, value="admin")
		self.mainSizer.Add( self.passwd, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.lgnButton = wx.Button(self.panel, label="Login")
		self.mainSizer.Add( self.lgnButton, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.panel.SetSizer( self.mainSizer )
		
		bSizer1.Add( self.panel, 1, wx.EXPAND |wx.ALL, 5 )
		
		self.SetSizer( bSizer1 )
		self.Layout()
		
		self.Centre( wx.BOTH )
		
		self.lgnButton.Bind(wx.EVT_BUTTON, self.attemptLogin) 
Example #18
Source File: EtherCATManagementEditor.py    From OpenPLC_Editor with GNU General Public License v3.0 4 votes vote down vote up
def __init__(self, parent, data):
        """
        Constructor
        @param parent: Reference to the parent SDOPanelClass class
        @param data: SDO data after parsing "SDOParser" method
        """
        wx.grid.Grid.__init__(self, parent, -1, size=(830, 490),
                              style=wx.EXPAND | wx.ALIGN_CENTRE_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL)

        self.Controler = parent.Controler
        self.parent = parent
        self.SDOFlag = True
        if data is None:
            self.SDOs = []
        else:
            self.SDOs = data

        self.CreateGrid(len(self.SDOs), 8)
        SDOCellSize = [(0, 65), (1, 65), (2, 50), (3, 55),
                       (4, 40), (5, 200), (6, 250), (7, 85)]

        for (index, size) in SDOCellSize:
            self.SetColSize(index, size)

        self.SetRowLabelSize(0)

        SDOTableLabel = [(0, "Index"), (1, "Subindex"), (2, "Access"),
                         (3, "Type"), (4, "Size"), (5, "Category"),
                         (6, "Name"), (7, "Value")]

        for (index, label) in SDOTableLabel:
            self.SetColLabelValue(index, label)
            self.SetColLabelAlignment(index, wx.ALIGN_CENTRE)

        attr = wx.grid.GridCellAttr()

        # for SDO download
        self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.SDOModifyDialog)

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

        self.SetColLabelAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER)

        self.SetTableValue() 
Example #19
Source File: WindowDragFinder.py    From EventGhost with GNU General Public License v2.0 4 votes vote down vote up
def __init__(self, parent, startFunc, endFunc):
        self.startFunc = startFunc
        self.endFunc = endFunc

        self.text = eg.plugins.Window.FindWindow.text
        wx.PyWindow.__init__(self, parent, -1, style=wx.SIMPLE_BORDER)
        self.SetBackgroundColour(
            wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW)
        )
        self.lastTarget = None

        # load images
        self.dragBoxBitmap = GetInternalBitmap("findert")
        image = GetInternalImage('findertc')
        image.SetMaskColour(255, 0, 0)

        # since this image didn't come from a .cur file, tell it where the
        # hotspot is
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_X, 15)
        image.SetOptionInt(wx.IMAGE_OPTION_CUR_HOTSPOT_Y, 16)

        # make the image into a cursor
        self.cursor = wx.CursorFromImage(image)

        # the image of the drag target
        dragBoxImage = wx.StaticBitmap(self, -1, self.dragBoxBitmap)
        dragBoxImage.SetMinSize(self.dragBoxBitmap.GetSize())
        dragBoxImage.Bind(wx.EVT_LEFT_DOWN, self.OnDragboxClick)
        self.dragBoxImage = dragBoxImage

        # some description for the drag target
        dragBoxText = wx.StaticText(
            self,
            -1,
            self.text.drag2,
            style=wx.ALIGN_CENTRE
        )
        x1, y1 = dragBoxText.GetBestSize()
        dragBoxText.SetLabel(self.text.drag1)
        x2, y2 = dragBoxText.GetBestSize()
        dragBoxText.SetMinSize((max(x1, x2), max(y1, y2)))
        #dragBoxText.Bind(wx.EVT_LEFT_DOWN, self.OnDragboxClick)
        self.dragBoxText = dragBoxText

        self.Bind(wx.EVT_SIZE, self.OnSize)

        # put our drag target together
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        sizer.Add(dragBoxImage, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(dragBoxText, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_CENTER_HORIZONTAL)
        self.SetSizer(sizer)
        self.SetAutoLayout(True)
        sizer.Fit(self)
        self.SetMinSize(self.GetSize())
        wx.CallAfter(self.dragBoxImage.SetBitmap, self.dragBoxBitmap) 
Example #20
Source File: usersPanel.py    From HH---POS-Accounting-and-ERP-Software with MIT License 4 votes vote down vote up
def __init__( self, parent ):
		wx.Panel.__init__( self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )

		bSizer11 = wx.BoxSizer( wx.VERTICAL )
		
		self.newUser = wx.Button (self, label="New User")
		bSizer11.Add(self.newUser, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

		self.usersGrid = wx.grid.Grid( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( -1,700 ), 0 )
		
		p = self.populateTable()
		lenP = len(p)
		
		# Grid
		self.usersGrid.CreateGrid( lenP, 3 )
		self.usersGrid.EnableEditing( False )
		self.usersGrid.EnableGridLines( True )
		self.usersGrid.EnableDragGridSize( False )
		self.usersGrid.SetMargins( 0, 0 )
		
		# Populate Table
		col=0
		for x in p:
			row=0
			# if amount of invoice is smaller than the amount recieved yet, colour the cell red
			for y in list(x.values()):
				self.usersGrid.SetCellValue(col, row, str(y))
				row = row+1
			col = col+1
		
		# Columns
		self.usersGrid.SetColSize( 0, 30 )
		self.usersGrid.SetColSize( 1, 100 )
		#self.usersGrid.SetColSize( 2, 120 )
		#self.usersGrid.AutoSizeColumns()
		self.usersGrid.EnableDragColMove( True )
		self.usersGrid.EnableDragColSize( True )
		self.usersGrid.SetColLabelSize( 30 )
		self.usersGrid.SetColLabelValue( 0, u"ID" )
		self.usersGrid.SetColLabelValue( 1, u"Username" )
		#self.usersGrid.SetColLabelValue( 2, u" " )
		self.usersGrid.SetColLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
		
		# Rows
		self.usersGrid.EnableDragRowSize( False )
		self.usersGrid.SetRowLabelSize( 1 )
		self.usersGrid.SetRowLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
		
		# Label Appearance
		
		# Cell Defaults
		self.usersGrid.SetDefaultCellAlignment( wx.ALIGN_CENTRE, wx.ALIGN_TOP )
		bSizer11.Add( self.usersGrid, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.SetSizer( bSizer11 )
		self.Layout()
		bSizer11.Fit( self )
		
		self.usersGrid.Bind( wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.deleteUser )
		self.newUser.Bind( wx.EVT_BUTTON, self.createNewUser ) 
Example #21
Source File: ListCtrlPrinter.py    From bookhub with MIT License 4 votes vote down vote up
def DrawText(self, dc, txt, bounds, font=None, alignment=wx.ALIGN_LEFT, valignment=wx.ALIGN_CENTRE,
                 image=None, color=None, canWrap=True, imageIndex=-1, listCtrl=None):
        """
        Draw the given text in the given DC according to the given characteristics.

        This is the workhorse text drawing method for our reporting engine.

        The *font*, *alignment*, and *color* attributes are applied to the drawn text.

        If *image* is not None, it will be drawn to the left of the text. All text is indented
        by the width of the image, even if the text is multi-line.

        If *imageIndex* is 0 or more and *listCtrl* is not None, the corresponding image from
        the ListCtrl's small image list will be drawn to the left of the text.

        If *canWrap* is True, the text will be wrapped to fit within the given bounds. If it is False,
        then the first line of *txt* will be truncated at the edge of the given *bounds*.
        """
        GAP_BETWEEN_IMAGE_AND_TEXT = 4

        def _CalcBitmapPosition(r, height):
            if valignment == wx.ALIGN_TOP:
                return RectUtils.Top(r)
            elif valignment == wx.ALIGN_CENTER:
                return RectUtils.CenterY(r) - height / 2
            elif valignment == wx.ALIGN_BOTTOM:
                return RectUtils.Bottom(r) - height
            else:
                return RectUtils.Top(r)

        # Draw any image
        if image:
            y = _CalcBitmapPosition(bounds, image.Height)
            dc.DrawBitmap(image, RectUtils.Left(bounds), y)
            RectUtils.MoveLeftBy(bounds, image.GetWidth()+GAP_BETWEEN_IMAGE_AND_TEXT)
        elif listCtrl and imageIndex >=0:
            imageList = listCtrl.GetImageList(wx.IMAGE_LIST_SMALL)
            y = _CalcBitmapPosition(bounds, imageList.GetSize(0)[1])
            imageList.Draw(imageIndex, dc, RectUtils.Left(bounds), y, wx.IMAGELIST_DRAW_TRANSPARENT)
            RectUtils.MoveLeftBy(bounds, imageList.GetSize(0)[0]+GAP_BETWEEN_IMAGE_AND_TEXT)

        # Draw the text
        dc.SetFont(font or self.GetFont())
        dc.SetTextForeground(color or self.GetTextColor() or wx.BLACK)
        if canWrap:
            WordWrapRenderer.DrawString(dc, txt, bounds, alignment, valignment)
        else:
            WordWrapRenderer.DrawTruncatedString(dc, txt, bounds, alignment, valignment) 
Example #22
Source File: usersPanel.py    From HH---POS-Accounting-and-ERP-Software with MIT License 4 votes vote down vote up
def __init__( self, parent ):
		wx.Panel.__init__( self, parent, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL )

		bSizer11 = wx.BoxSizer( wx.VERTICAL )
		
		self.newUser = wx.Button (self, label="New User")
		bSizer11.Add(self.newUser, 0, wx.ALIGN_CENTRE|wx.ALL, 5)

		self.usersGrid = wx.grid.Grid( self, wx.ID_ANY, wx.DefaultPosition, wx.Size( -1,700 ), 0 )
		
		p = self.populateTable()
		lenP = len(p)
		
		# Grid
		self.usersGrid.CreateGrid( lenP, 3 )
		self.usersGrid.EnableEditing( False )
		self.usersGrid.EnableGridLines( True )
		self.usersGrid.EnableDragGridSize( False )
		self.usersGrid.SetMargins( 0, 0 )
		
		# Populate Table
		row=0
		for x in p:
			col=0
			# if amount of invoice is smaller than the amount recieved yet, colour the cell red
			for y in list(x.values()):
				self.usersGrid.SetCellValue(row, col, str(y))
				col = col+1
			row = row+1
		
		# Columns
		self.usersGrid.SetColSize( 0, 30 )
		self.usersGrid.SetColSize( 1, 100 )
		#self.usersGrid.SetColSize( 2, 120 )
		#self.usersGrid.AutoSizeColumns()
		self.usersGrid.EnableDragColMove( True )
		self.usersGrid.EnableDragColSize( True )
		self.usersGrid.SetColLabelSize( 30 )
		self.usersGrid.SetColLabelValue( 0, u"ID" )
		self.usersGrid.SetColLabelValue( 1, u"Username" )
		#self.usersGrid.SetColLabelValue( 2, u" " )
		self.usersGrid.SetColLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
		
		# Rows
		self.usersGrid.EnableDragRowSize( False )
		self.usersGrid.SetRowLabelSize( 1 )
		self.usersGrid.SetRowLabelAlignment( wx.ALIGN_CENTRE, wx.ALIGN_CENTRE )
		
		# Label Appearance
		
		# Cell Defaults
		self.usersGrid.SetDefaultCellAlignment( wx.ALIGN_CENTRE, wx.ALIGN_TOP )
		bSizer11.Add( self.usersGrid, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
		
		self.SetSizer( bSizer11 )
		self.Layout()
		bSizer11.Fit( self )
		
		self.usersGrid.Bind( wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.deleteUser )
		self.newUser.Bind( wx.EVT_BUTTON, self.createNewUser )