Jump to content

[UI]TextLink (botón de texto sin botón)


Shang
 Share

Recommended Posts

Hola zoneros, hace tiempo que no posteo una mierda así q me decidí a postear este object que hice hace un ratillo. Se trata de un texto que actua como botón pero sólo es texto.

 

875dbfdab37a4a4e8f019173b9dedfef.gif

 

Código py:

class TextLink(ui.Window):

	## COLORS
	NORMAL_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
	OVER_COLOR = 0xff1457c7
	DOWN_COLOR = 0xff0f3e8c
	
	def __init__(self):
		ui.Window.__init__(self)
		
		self.eventFunc = None
		self.eventArgs = None
		
		self.text = ui.TextLine()
		self.text.SetParent(self)
		self.text.Show()

		self.underline = ui.Line()
		self.underline.SetParent(self)
		self.underline.SetColor(self.NORMAL_COLOR)
		self.underline.Hide()
		
	def __del__(self):
		ui.Window.__del__(self)
		
	def SetText(self, text):
		self.text.SetText(text)
		self.SetSize(self.text.GetTextSize()[0], self.text.GetTextSize()[1])
		self.underline.SetPosition(0, self.text.GetTextSize()[1])
		self.underline.SetWindowHorizontalAlignCenter()
		self.underline.SetSize(self.text.GetTextSize()[0], 0)
		
	def OnMouseOverIn(self):
		self.text.SetPackedFontColor(self.OVER_COLOR)
		self.underline.SetColor(self.OVER_COLOR)
		self.underline.Show()
		
	def OnMouseOverOut(self):
		self.text.SetPackedFontColor(self.NORMAL_COLOR)
		self.underline.Hide()
		
	def OnMouseLeftButtonDown(self):
		self.text.SetPackedFontColor(self.DOWN_COLOR)
		self.underline.SetColor(self.DOWN_COLOR)
		self.underline.Show()
		
	def OnMouseLeftButtonUp(self):
		if self.eventFunc:
			apply(self.eventFunc, self.eventArgs)
		self.OnMouseOverOut()
			
	def SetEvent(self, event, *args):
		self.eventFunc = event
		self.eventArgs = args
Link to comment
Share on other sites

  • 9 months later...

 

Hola zoneros, hace tiempo que no posteo una mierda así q me decidí a postear este object que hice hace un ratillo. Se trata de un texto que actua como botón pero sólo es texto.

 

875dbfdab37a4a4e8f019173b9dedfef.gif

 

Código py:

class TextLink(ui.Window):

	## COLORS
	NORMAL_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
	OVER_COLOR = 0xff1457c7
	DOWN_COLOR = 0xff0f3e8c
	
	def __init__(self):
		ui.Window.__init__(self)
		
		self.eventFunc = None
		self.eventArgs = None
		
		self.text = ui.TextLine()
		self.text.SetParent(self)
		self.text.Show()

		self.underline = ui.Line()
		self.underline.SetParent(self)
		self.underline.SetColor(self.NORMAL_COLOR)
		self.underline.Hide()
		
	def __del__(self):
		ui.Window.__del__(self)
		
	def SetText(self, text):
		self.text.SetText(text)
		self.SetSize(self.text.GetTextSize()[0], self.text.GetTextSize()[1])
		self.underline.SetPosition(0, self.text.GetTextSize()[1])
		self.underline.SetWindowHorizontalAlignCenter()
		self.underline.SetSize(self.text.GetTextSize()[0], 0)
		
	def OnMouseOverIn(self):
		self.text.SetPackedFontColor(self.OVER_COLOR)
		self.underline.SetColor(self.OVER_COLOR)
		self.underline.Show()
		
	def OnMouseOverOut(self):
		self.text.SetPackedFontColor(self.NORMAL_COLOR)
		self.underline.Hide()
		
	def OnMouseLeftButtonDown(self):
		self.text.SetPackedFontColor(self.DOWN_COLOR)
		self.underline.SetColor(self.DOWN_COLOR)
		self.underline.Show()
		
	def OnMouseLeftButtonUp(self):
		if self.eventFunc:
			apply(self.eventFunc, self.eventArgs)
		self.OnMouseOverOut()
			
	def SetEvent(self, event, *args):
		self.eventFunc = event
		self.eventArgs = args

 

Gracias por el aporte. AÚN espero el registro en esa interfaz....

 

Att. EW2

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...