Exemple #1
0
class wxgTagImageEAPnl(wx.ScrolledWindow):
	def __init__(self, *args, **kwds):
		# begin wxGlade: wxgTagImageEAPnl.__init__
		kwds["style"] = kwds.get("style", 0) | wx.BORDER_NONE | wx.TAB_TRAVERSAL
		wx.ScrolledWindow.__init__(self, *args, **kwds)
		self._TCTRL_description = wx.TextCtrl(self, wx.ID_ANY, "")
		self._TCTRL_filename = wx.TextCtrl(self, wx.ID_ANY, "")
		from wx.lib.statbmp import GenStaticBitmap
		self._BMP_image = GenStaticBitmap(self, wx.ID_ANY, wx.Bitmap(100, 100), style=wx.BORDER_SIMPLE)
		self._BTN_pick_image = wx.Button(self, wx.ID_ANY, _("&Pick"), style=wx.BU_EXACTFIT)

		self.__set_properties()
		self.__do_layout()

		self.Bind(wx.EVT_BUTTON, self._on_pick_image_button_pressed, self._BTN_pick_image)
		# end wxGlade

	def __set_properties(self):
		# begin wxGlade: wxgTagImageEAPnl.__set_properties
		self.SetScrollRate(10, 10)
		self._TCTRL_description.SetToolTip(_("A name for the tag.\n\nNote that there cannot be two tags with the same name."))
		self._TCTRL_filename.SetToolTip(_("An example file name for this image. Mainly used for deriving a suitable file extension."))
		self._BMP_image.SetMinSize((100, 100))
		self._BMP_image.SetToolTip(_("The image to use for the tag.\n\nDo not use a big image because the tag will be downscaled anyway."))
		self._BTN_pick_image.SetToolTip(_("Pick the file from which to load the tag image."))
		# end wxGlade

	def __do_layout(self):
		# begin wxGlade: wxgTagImageEAPnl.__do_layout
		_gszr_main = wx.FlexGridSizer(3, 2, 1, 3)
		__szr_image = wx.BoxSizer(wx.HORIZONTAL)
		__lbl_name = wx.StaticText(self, wx.ID_ANY, _("Tag name"))
		__lbl_name.SetForegroundColour(wx.Colour(255, 0, 0))
		_gszr_main.Add(__lbl_name, 0, wx.ALIGN_CENTER_VERTICAL, 0)
		_gszr_main.Add(self._TCTRL_description, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
		__lbl_fname = wx.StaticText(self, wx.ID_ANY, _("File name"))
		_gszr_main.Add(__lbl_fname, 0, wx.ALIGN_CENTER_VERTICAL, 0)
		_gszr_main.Add(self._TCTRL_filename, 0, wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 0)
		__lbl_image = wx.StaticText(self, wx.ID_ANY, _("Image"))
		__lbl_image.SetForegroundColour(wx.Colour(255, 0, 0))
		_gszr_main.Add(__lbl_image, 0, wx.ALIGN_CENTER_VERTICAL, 0)
		__szr_image.Add(self._BMP_image, 0, wx.ALIGN_CENTER | wx.ALL, 3)
		__szr_image.Add(self._BTN_pick_image, 0, wx.ALIGN_CENTER_VERTICAL, 0)
		_gszr_main.Add(__szr_image, 1, wx.EXPAND, 0)
		self.SetSizer(_gszr_main)
		_gszr_main.Fit(self)
		_gszr_main.AddGrowableCol(1)
		self.Layout()
		# end wxGlade

	def _on_pick_image_button_pressed(self, event):  # wxGlade: wxgTagImageEAPnl.<event_handler>
		print("Event handler '_on_pick_image_button_pressed' not implemented!")
		event.Skip()
Exemple #2
0
    def addDragDropItem(self, newid, icon, dragCallback, toolTip):
        """
		Add an item to the toolbar
		"""
        bmp = wx.Image(os.path.join(self.iconpath, icon),
                       wx.BITMAP_TYPE_ANY).ConvertToBitmap()
        bmp2 = wx.EmptyBitmap(38, 32)
        dc = wx.MemoryDC()
        dc.SelectObject(bmp2)

        #dc.SetPen(wx.Pen(self.GetBackgroundColour(),1))
        #dc.SetBrush(wx.Brush(self.GetBackgroundColour()))
        dc.SetPen(wx.Pen(wx.Colour(0, 0, 0), 1))
        dc.SetBrush(wx.Brush(wx.Colour(0, 0, 0)))
        dc.DrawRectangle(0, 0, 38, 32)

        x = 1
        y = 0
        dc.DrawBitmap(bmp, 7, 0)
        for i in range(0, 10):
            dc.SetPen(wx.Pen(wx.Colour(135, 135, 135), 1))
            dc.DrawLine(x, y, x + 6, y)
            y += 1
            dc.SetPen(wx.Pen(wx.Colour(100, 100, 100), 1))
            dc.DrawLine(x, y, x + 6, y)
            y += 1
            y += 2

        dc.SelectObject(wx.NullBitmap)
        self.icons[newid] = bmp2
        sbmp = StaticBitmap(self,
                            newid,
                            bmp,
                            style=wx.RAISED_BORDER,
                            size=(40, 40))
        self.sbmps[newid] = sbmp
        sbmp.Bind(wx.EVT_MOTION, dragCallback)
        #p.Bind(wx.EVT_MOTION,dragCallback)
        #self.sizer.Add(p,flag=wx.RIGHT,border=2)
        #p.Bind(               wx.EVT_LEFT_UP,self.onToolClick)
        self.sizer.Add(sbmp, flag=wx.RIGHT, border=2)

        sbmp.Bind(wx.EVT_LEFT_UP, self.onToolClick)

        sbmp.SetHelpText(toolTip.GetTip())
        sbmp.SetToolTip(toolTip)