Jump to content

[PYTHON] Tooltip MouseIn at ImageBox


Recommended Posts

Hello,
I'm trying to add MouseIn tooltip to ImageBox at uiRefine.py
(I want hover tooltip with item description on refine materials icon for ex. red pearl etc)

I try this code at AppendMaterial()


slot = self.__MakeSlot()
        slot.SetParent(self)
        slot.SetPosition(15, self.dialogHeight)

        itemImage = self.__MakeItemImage()
        itemImage.SetParent(slot)
        item.SelectItem(vnum)
        itemImage.LoadImage(item.GetIconImageFileName())

        # self.itemImage = itemImage # this is defined somewhere else
        self.itemImage.OnMouseOverIn(self.ShowTip())
        self.itemImage.OnMouseOverOut(self.HideTip())

I init tooltip at def Open():


self.txttooltip = uiToolTip.ToolTip()
self.txttooltip.HideToolTip()

but get syserr:


0529 13:54:42313 :: TypeError
0529 13:54:42313 :: : 
0529 13:54:42313 :: OnMouseOverIn() takes exactly 1 argument (2 given)
0529 13:54:42313 :: 

When I do self.itemImage.OnMouseOverIn = self.ShowTip()
syserr is clear but there's no tooltip, so I think it's bad use of this function

My defs:


def ShowTip(self):
        self.txttooltip.ClearToolTip()
        self.txttooltip.AppendTextLine("Description")
        self.txttooltip.Show()
        
def HideTip(self):
        self.txttooltip.Hide()

Anyone know how to do this?
Greetings.

Link to comment
Share on other sites

41 minutes ago, kodepiko said:

Hello,
I'm trying to add MouseIn tooltip to ImageBox at uiRefine.py
(I want hover tooltip with item description on refine materials icon for ex. red pearl etc)

I try this code at AppendMaterial()



	slot = self.__MakeSlot()

	        slot.SetParent(self)

	        slot.SetPosition(15, self.dialogHeight)


        itemImage = self.__MakeItemImage()         itemImage.SetParent(slot)         item.SelectItem(vnum)         itemImage.LoadImage(item.GetIconImageFileName())

        # self.itemImage = itemImage # this is defined somewhere else         self.itemImage.OnMouseOverIn(self.ShowTip())         self.itemImage.OnMouseOverOut(self.HideTip())

 

I init tooltip at def Open():



	self.txttooltip = uiToolTip.ToolTip()

	self.txttooltip.HideToolTip()


 

but get syserr:

 



	0529 13:54:42313 :: TypeError

	0529 13:54:42313 :: : 

	0529 13:54:42313 :: OnMouseOverIn() takes exactly 1 argument (2 given)

	0529 13:54:42313 :: 


 

When I do self.itemImage.OnMouseOverIn = self.ShowTip() syserr is clear but there's no tooltip, so I think it's bad use of this function

My defs:



	def ShowTip(self):

	        self.txttooltip.ClearToolTip()

	        self.txttooltip.AppendTextLine("Description")

	        self.txttooltip.Show()

	        

	def HideTip(self):

	        self.txttooltip.Hide()


 

Anyone know how to do this?
Greetings.

self.itemImage.OnMouseOverIn(self.ShowTip)
self.itemImage.OnMouseOverOut(self.HideTip)

  • Love 1
Link to comment
Share on other sites

  • Developer

OnMouseOverIn() and OnMouseOverOut() are the called to run the MouseEvent functions, you can't use them to set a mouse event.

You better use:

self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowToolTip)
self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.HideToolTip)

 

 

  • Love 2

when you return 0 and server doesn't boot:

unknown.png

Link to comment
Share on other sites

44 minutes ago, PACI said:

OnMouseOverIn() and OnMouseOverOut() are the called to run the MouseEvent functions, you can't use them to set a mouse event.

You better use:


self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowToolTip)
self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.HideToolTip)

 

Thanks, now syserr is clear but nothing happens when I point at image of weapon or pearl

34b975650e4d21ef088a6d4584729dce.gif

I just want to put tooltip item description when you point at materials of upgrading

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

2 hours ago, kodepiko said:

Thanks, now syserr is clear but nothing happens when I point at image of weapon or pearl

34b975650e4d21ef088a6d4584729dce.gif

I just want to put tooltip item description when you point at materials of upgrading

Well,if you copied paste what PACI wrote of course it wouldn't work.

Modify it to match your functions..

self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowTip)
self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.HideTip)

Does it appear like this in your code?

Also,make sure not to add () in the end.

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 2
Link to comment
Share on other sites

1 hour ago, PACI said:

That's right, I haven't seen your tooltip events, so you must edit those sentences with your tooltip events' name.

Of course I do, my tooltip functions are

 

def ShowTip(self):
        self.txttooltip.ClearToolTip()
        self.txttooltip.AppendTextLine("Description")
        self.txttooltip.Show()
        
    def HideTip(self):
        self.txttooltip.Hide()

 

and I use at def AppendMaterial():

 

self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowTip)
self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.HideTip)

 

1 hour ago, metin2-factory said:

Well,if you copied paste what PACI wrote of course it wouldn't work.

Modify it to match your functions..


self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowTip)
self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.HideTip)

Does it appear like this in your code?

Also,make sure not to add () in the end.

Obviously if I would do that syserr will not be clear because I don't have that defs, I said syserr is clear

I try with chat function to see it correctly triggering those functions or not

@update

Okay, it doesn't trigger so it must be bad trigger on itemImage (but it should work for item material icons)

DONE.

#Thread solved.

Thanks for trying to help guys, SAFE_SetStringEvent("MOUSE_OVER_OUT") works like a charm in this case :)

@metin2-factory - it worked as described in this topic, nothing more to add

  • Love 1
Link to comment
Share on other sites

37 minutes ago, kodepiko said:

Of course I do, my tooltip functions are

 


def ShowTip(self):
        self.txttooltip.ClearToolTip()
        self.txttooltip.AppendTextLine("Description")
        self.txttooltip.Show()
        
    def HideTip(self):
        self.txttooltip.Hide()

 

and I use at def AppendMaterial():

 


self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowTip)
self.itemImage.SAFE_SetStringEvent("MOUSE_OVER_OUT", self.HideTip)

 

Obviously if I would do that syserr will not be clear because I don't have that defs, I said syserr is clear

I try with chat function to see it correctly triggering those functions or not

@update

Okay, it doesn't trigger so it must be bad trigger on itemImage (but it should work for item material icons)

DONE.

#Thread solved.

Thanks for trying to help guys, SAFE_SetStringEvent("MOUSE_OVER_OUT") works like a charm in this case :)

You should write what you did so people with same problem can solve it by reading this topic :)

  • Love 1
Link to comment
Share on other sites

Do you guys have idea how to get item vnum or icon name of image I point with cursor? because I can't select item at this tooltip, I can't pass any arguments through the MOUSE_OVER function yep? like itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowTip("description")) - any ideas how to do item description of materials when I point them?

I just need to select item, but when I point material image I can't get any informations like vnum, is there a function which can get icon name by pointing on them? (without select item)

When I use item.getdescription directly at ShowTip function it just uses last selected item (for ex weapon or blessing scroll)

Link to comment
Share on other sites

I see you want to use for description in refine, you can start with this:

 

    

	def OverInItem(self, value_t):
		global description_refine
		import grp
		if description_refine:
			table_description = {
							30501 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30502 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30503 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30504 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30505 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30506 : ["[1] Value text","[2] Value text","[3] Value text"],								
			}
			try:
				self.tooltipItem.ClearToolTip()
				item.SelectItem(description_refine[value_t])
				self.tooltipItem.AutoAppendTextLine("%s" % item.GetItemName(), self.tooltipItem.TITLE_COLOR)
				self.tooltipItem.AppendSpace(5)
				self.tooltipItem.AutoAppendTextLine("Test value:", self.SPECIAL_POSITIVE_COLOR)			
				for i in xrange(len(table_description[description_refine[value_t]])):
					self.tooltipItem.AutoAppendTextLine("%s" % table_description[description_refine[value_t]][i])
				self.tooltipItem.AlignHorizonalCenter()
				self.tooltipItem.ShowToolTip()
			except:
				pass

 
  • Love 1
Link to comment
Share on other sites

51 minutes ago, VegaS said:

I see you want to use for description in refine, you can start with this:

 

    


	def OverInItem(self, value_t):
		global description_refine
		import grp
		if description_refine:
			table_description = {
							30501 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30502 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30503 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30504 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30505 : ["[1] Value text","[2] Value text","[3] Value text"],	
							30506 : ["[1] Value text","[2] Value text","[3] Value text"],								
			}
			try:
				self.tooltipItem.ClearToolTip()
				item.SelectItem(description_refine[value_t])
				self.tooltipItem.AutoAppendTextLine("%s" % item.GetItemName(), self.tooltipItem.TITLE_COLOR)
				self.tooltipItem.AppendSpace(5)
				self.tooltipItem.AutoAppendTextLine("Test value:", self.SPECIAL_POSITIVE_COLOR)			
				for i in xrange(len(table_description[description_refine[value_t]])):
					self.tooltipItem.AutoAppendTextLine("%s" % table_description[description_refine[value_t]][i])
				self.tooltipItem.AlignHorizonalCenter()
				self.tooltipItem.ShowToolTip()
			except:
				pass


 

 

Yes but at ImageBox class I can't pass functions any arguments like vnum so I can't show description correctly for the item, so this is only table, of course I can storage itemdescription of item and his vnum and at tooltip just show it, but I don't know how to get icon name or vnum

(so I can't get description from array because I don't know index of item I'm pointing and cant pass argument like this: itemImage.SAFE_SetStringEvent("MOUSE_OVER_IN", self.ShowTip(index))    ) which I'm pointing on with cursor

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.