set different color at wx.HyperlinkCtrl label text

Hi

I have this code on a bigger frame and I want to choose the color of a clickable label text but this is not working.

What am I doing wrong here?

font2 = wx.Font(pointSize=10, family=wx.DEFAULT, style=wx.FONTSTYLE_NORMAL, weight=wx.NORMAL)

label = hl.HyperLinkCtrl(self.panel2, wx.ID_ANY, ‘NEW Project’, pos=(50,65))

label.Bind(hl.EVT_HYPERLINK_LEFT, self.newproject)

label.AutoBrowse(False)

label.SetColours(self.panel2, wx.Color(255, 0, 255), wx.Color(80, 50, 80)) # —> DOES NOT WORK!!!

label.NormalColour = wx.Color(100, 90, 255) # —> NEITHER THIS!

label.SetFont(font2)

The text label appears as normal, with the blue characteristic color. But I want to choose other colors.

Thx.

You need to use the correct Setter function, rather trying to set the property directly, it seems. Take a look at this doc:
http://www.wxpython.org/docs/api/wx.HyperlinkCtrl-class.html

SetHoverColour(self, colour) SetNormalColour(self, colour) SetVisitedColour(self, colour)

···

On Wednesday, June 11, 2014 11:46:49 AM UTC-7, Valdemar Domingos wrote:

Hi

I have this code on a bigger frame and I want to choose the color of a clickable label text but this is not working.

What am I doing wrong here?

font2 = wx.Font(pointSize=10, family=wx.DEFAULT, style=wx.FONTSTYLE_NORMAL, weight=wx.NORMAL)

label = hl.HyperLinkCtrl(self.panel2, wx.ID_ANY, ‘NEW Project’, pos=(50,65))

label.Bind(hl.EVT_HYPERLINK_LEFT, self.newproject)

label.AutoBrowse(False)

label.SetColours(self.panel2, wx.Color(255, 0, 255), wx.Color(80, 50, 80)) # —> DOES NOT WORK!!!

label.NormalColour = wx.Color(100, 90, 255) # —> NEITHER THIS!

label.SetFont(font2)

The text label appears as normal, with the blue characteristic color. But I want to choose other colors.

Thx.

Whoops, didn’t realize there were two closely named similar controls… which don’t share the same API calls (I don’t understand why there’s so much API fragmentation, ugh, weird).

Anyway, you’re simply not calling the setter correctly, you shouldn’t be passing in parent (self.panel2):

http://www.wxpython.org/docs/api/wx.lib.agw.hyperlink.HyperLinkCtrl-class.html#SetColours

Also check out the wxPython demos, there’s an agw folder in there and it has a HyperLinkCtrl.py demo.