Python wx.ALIGN_TOP Examples

The following are 12 code examples of wx.ALIGN_TOP(). 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: 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 #2
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 #3
Source File: components.py    From pyFileFixity with MIT License 5 votes vote down vote up
def do_layout(self, parent):
    self.panel = wx.Panel(parent)

    self.radio_buttons = [wx.RadioButton(self.panel, -1) for _ in self.data]
    self.btn_names = [wx.StaticText(self.panel, label=btn_data['display_name'].title()) for btn_data in self.data]
    self.help_msgs = [wx.StaticText(self.panel, label=btn_data['help'].title()) for btn_data in self.data]
    self.option_stings = [btn_data['commands'] for btn_data in self.data]

    # box = wx.StaticBox(self.panel, -1, label=self.data['group_name'])
    box = wx.StaticBox(self.panel, -1, label='Set Verbosity Level')
    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.Bind(wx.EVT_RADIOBUTTON, self.onSetter, button)

    self.panel.SetSizer(vertical_container)
    self.panel.Bind(wx.EVT_SIZE, self.onResize)
    return self.panel 
Example #4
Source File: components2.py    From pyFileFixity with MIT License 5 votes vote down vote up
def do_layout(self, parent):
    self.panel = wx.Panel(parent)

    self.radio_buttons = [wx.RadioButton(self.panel, -1) for _ in self.data]
    self.btn_names = [wx.StaticText(self.panel, label=btn_data['display_name'].title()) for btn_data in self.data]
    self.help_msgs = [wx.StaticText(self.panel, label=btn_data['help'].title()) for btn_data in self.data]
    self.option_stings = [btn_data['commands'] for btn_data in self.data]

    # box = wx.StaticBox(self.panel, -1, label=self.data['group_name'])
    box = wx.StaticBox(self.panel, -1, label='Set Verbosity Level')
    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.Bind(wx.EVT_RADIOBUTTON, self.onSetter, button)

    self.panel.SetSizer(vertical_container)
    self.panel.Bind(wx.EVT_SIZE, self.onResize)
    return self.panel 
Example #5
Source File: commondialogs.py    From CANFestivino with GNU Lesser General Public License v2.1 5 votes vote down vote up
def _init_coll_MiddleGridSizer_Items(self, parent):
        parent.AddWindow(self.Select, 0, border=0, flag=wx.ALIGN_BOTTOM)
        parent.AddWindow(self.Unselect, 0, border=0, flag=wx.ALIGN_TOP) 
Example #6
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 #7
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 #8
Source File: configuration_dialogs.py    From superpaper with MIT License 4 votes vote down vote up
def create_display_opts(self, num_disps):
        """Create sizer for display perspective options."""
        self.sizer_disp_opts = wx.StaticBoxSizer(wx.HORIZONTAL, self,
                                                 "Display perspective configuration")
        statbox_disp_opts = self.sizer_disp_opts.GetStaticBox()
        cols = 8
        gap = 5
        self.grid = wx.FlexGridSizer(cols, gap, gap)

        # header
        hd_id = wx.StaticText(statbox_disp_opts, -1, "Display")
        hd_sax = wx.StaticText(statbox_disp_opts, -1, "Swivel axis")
        hd_san = wx.StaticText(statbox_disp_opts, -1, "Swivel angle")
        hd_sol = wx.StaticText(statbox_disp_opts, -1, "Sw. ax. lat. off.")
        hd_sod = wx.StaticText(statbox_disp_opts, -1, "Sw. ax. dep. off.")
        hd_tan = wx.StaticText(statbox_disp_opts, -1, "Tilt angle")
        hd_tov = wx.StaticText(statbox_disp_opts, -1, "Ti. ax. ver. off.")
        hd_tod = wx.StaticText(statbox_disp_opts, -1, "Ti. ax. dep. off.")
        self.grid.Add(hd_id, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)
        self.grid.Add(hd_sax, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)
        self.grid.Add(hd_san, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)
        self.grid.Add(hd_sol, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)
        self.grid.Add(hd_sod, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)
        self.grid.Add(hd_tan, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)
        self.grid.Add(hd_tov, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)
        self.grid.Add(hd_tod, 0, wx.LEFT|wx.RIGHT|wx.BOTTOM, 1)

        # Fill grid rows
        self.grid_rows = []
        for i in range(num_disps):
            row = self.display_opt_widget_row(i)
            self.grid_rows.append(row)
            sizer_row = [(item, 0, wx.ALL|wx.ALIGN_RIGHT|wx.ALIGN_CENTER_VERTICAL, 1)
                         for item in row]
            self.grid.AddMany(sizer_row)

        # Build sizer
        self.sizer_disp_opts.Add(self.grid, 0, wx.ALL|wx.EXPAND, 5)

        # help
        self.button_help_data = wx.BitmapButton(statbox_disp_opts, bitmap=self.help_bmp)
        self.button_help_data.Bind(wx.EVT_BUTTON, self.onHelpData)
        self.sizer_disp_opts.AddStretchSpacer()
        self.sizer_disp_opts.Add(self.button_help_data, 0,
                                 wx.ALIGN_TOP|wx.RIGHT, 5) 
Example #9
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 ) 
Example #10
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 #11
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 #12
Source File: viewer_low_level_util.py    From dials with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
def __init__(self, outer_panel):
        super(buttons_panel, self).__init__(outer_panel)
        self.parent_panel = outer_panel

        Show_Its_CheckBox = wx.CheckBox(self, -1, "Show I nums")
        Show_Its_CheckBox.SetValue(True)
        Show_Its_CheckBox.Bind(wx.EVT_CHECKBOX, self.OnItsCheckbox)

        self.my_sizer = wx.BoxSizer(wx.VERTICAL)
        self.my_sizer.Add(Show_Its_CheckBox, proportion=0, flag=wx.ALIGN_TOP, border=5)

        if self.parent_panel.segn_lst_in is not None:
            Show_Msk_CheckBox = wx.CheckBox(self, -1, "Show Mask")
            Show_Msk_CheckBox.SetValue(True)
            Show_Msk_CheckBox.Bind(wx.EVT_CHECKBOX, self.OnMskCheckbox)

            self.my_sizer.Add(
                Show_Msk_CheckBox, proportion=0, flag=wx.ALIGN_TOP, border=5
            )

            masck_conv_str = "\n Mask Convention:"
            masck_conv_str += "\n [Valid]                      =  \\\\\\\\\\\\  "
            masck_conv_str += "\n [Foreground]           =  //////  "
            masck_conv_str += "\n [Background]          =  ||||||  "
            masck_conv_str += "\n [BackgroundUsed]  =  ------"

            label_mask = wx.StaticText(self, -1, masck_conv_str)
            self.my_sizer.Add(label_mask, proportion=0, flag=wx.ALIGN_TOP, border=5)

        label_palette = wx.StaticText(self, -1, "\nColour Palettes")

        self.RadButtb2w = wx.RadioButton(self, -1, "black2white")
        self.RadButtw2b = wx.RadioButton(self, -1, "white2black")
        self.RadButtha = wx.RadioButton(self, -1, "hot ascend")
        self.RadButthd = wx.RadioButton(self, -1, "hot descend")

        self.RadButtb2w.Bind(wx.EVT_RADIOBUTTON, self.OnButtb2w)
        self.RadButtw2b.Bind(wx.EVT_RADIOBUTTON, self.OnButtw2b)
        self.RadButtha.Bind(wx.EVT_RADIOBUTTON, self.OnButtha)
        self.RadButthd.Bind(wx.EVT_RADIOBUTTON, self.OnButthd)

        self.my_sizer.Add(label_palette, proportion=0, flag=wx.ALIGN_TOP, border=5)

        self.my_sizer.Add(self.RadButtb2w, proportion=0, flag=wx.ALIGN_TOP, border=5)
        self.my_sizer.Add(self.RadButtw2b, proportion=0, flag=wx.ALIGN_TOP, border=5)
        self.my_sizer.Add(self.RadButtha, proportion=0, flag=wx.ALIGN_TOP, border=5)
        self.my_sizer.Add(self.RadButthd, proportion=0, flag=wx.ALIGN_TOP, border=5)

        self.my_sizer.SetMinSize((50, 300))
        self.SetSizer(self.my_sizer)