Jump to content

Recommended Posts

i m using Ava2 metiN2 file 
when i try to create a simple button step i do 
/uiscript/uiscript
 

import uiscriptlocale

window = {
    "name":"SimpleBonusWindow",
    "style":("movable","float","attach"),
    "x":300, "y":200,
    "width":200, "height":100,

    "children": [
        {
            "name":"close_button",
            "type":"button",
            "x":170, "y":0, "text":"X"
        },
        {
            "name":"example_button",
            "type":"button",
            "x": 60, "y": 40, "text":"Show HP"
        },
    ],
}

then /root
 

import ui
import wndMgr
import localeInfo
import item
import player
import chat
class CustomBtnWindow(ui.ScriptWindow):
    def __init__(self):
        super(CustomBtnWindow, self).__init__()
        self.bonusList = []

    def LoadWindow(self):
        pyScrLoader = ui.PythonScriptLoader()
        pyScrLoader.LoadScriptFile(self, "UIScript/CustomBtn.py")

        self.btnClose = self.GetChild("close_button")
        self.btnClose.SetEvent(ui.__mem_func__(self.Close))

        self.btnExample = self.GetChild("example_button")
        self.btnExample.SetEvent(ui.__mem_func__(self.OnExampleClick))

    def OnExampleClick(self):
        # For demo: fetch a stat and display in chat
        stat = player.GetStatus(item.APPLY_MAX_HP)
        chat.AppendChat(chat.CHAT_TYPE_INFO, "Max HP: %d" % stat)
    def OnPressEscapeKey(self):
        self.Close()
        return True

    def Close(self):
        wndMgr.Hide(self.hWnd)

/root/interfacemodule.py

def __MakeButton(self):
		self.Btn = uiCustomBtn.CustomButton()
		self.Btn.LoadWindow()
		# self.Btn.Hide()

def MakeInterface(self):
	self.__MakeButton()

0730 12:41:15592 :: 
networkModule.py(line:188) SetSelectCharacterPhase
system.py(line:177) __hybrid_import
system.py(line:142) _process_result
introSelect.py(line:18) <module>
system.py(line:177) __hybrid_import
system.py(line:142) _process_result
uiInventory.py(line:23) <module>
system.py(line:177) __hybrid_import
system.py(line:142) _process_result
game.py(line:68) <module>
system.py(line:177) __hybrid_import
system.py(line:142) _process_result
interfaceModule.py(line:142) <module>
system.py(line:184) __hybrid_import

networkModule.SetSelectCharacterPhase - <type 'exceptions.ImportError'>:No module named uiCustomBtn

0730 12:41:15593 :: ============================================================================================================
0730 12:41:15593 :: Abort!!!!


i followed same way as a module called tablebonus where you show bonsu of the character

Link to comment
https://metin2.dev/topic/33887-adding-simple-ui-button/
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

you have to import the uiCustomBtn class in the interfacemodule.

 

def __MakeButton(self):
	self.Btn = uiCustomBtn.CustomButton() # this is causing the error.
	self.Btn.LoadWindow()
	# self.Btn.Hide()

def MakeInterface(self):
	self.__MakeButton()

the error says it all

Quote

:No module named uiCustomBtn

no uiCustomBtn module found in "interfacemodule.py"

Link to comment
https://metin2.dev/topic/33887-adding-simple-ui-button/#findComment-171641
Share on other sites

2 minutes ago, ricksanches5248 said:

you have to import the uiCustomBtn class in the interfacemodule.

 

def __MakeButton(self):
	self.Btn = uiCustomBtn.CustomButton() # this is causing the error.
	self.Btn.LoadWindow()
	# self.Btn.Hide()

def MakeInterface(self):
	self.__MakeButton()

the error says it all

no uiCustomBtn module found in "interfacemodule.py"

i did it i jsut didnt mentionne it.

let say i just imported anything custom python file will not work

Edited by breaak
Link to comment
https://metin2.dev/topic/33887-adding-simple-ui-button/#findComment-171642
Share on other sites

On 7/30/2025 at 7:43 PM, ricksanches5248 said:

whats in here?

interfaceModule.py(line:142) <module>

 

you can see the my post i mentionned it
the prboelm i did test.py on same level as game.py it give me the error i dont know if there is some source client thing because i didnt touch at all source only client file

Link to comment
https://metin2.dev/topic/33887-adding-simple-ui-button/#findComment-171651
Share on other sites

what i would do is, make a new file in the root/ folder and name it: uiCustomBtn.py

1. paste your code in

import ui
import wndMgr
import localeInfo
import item
import player
import chat

class CustomBtnWindow(ui.ScriptWindow):
    def __init__(self):
        super(CustomBtnWindow, self).__init__()
        self.bonusList = []

    def LoadWindow(self):
        pyScrLoader = ui.PythonScriptLoader()
        pyScrLoader.LoadScriptFile(self, "UIScript/CustomBtn.py")

        self.btnClose = self.GetChild("close_button")
        self.btnClose.SetEvent(ui.__mem_func__(self.Close))

        self.btnExample = self.GetChild("example_button")
        self.btnExample.SetEvent(ui.__mem_func__(self.OnExampleClick))

    def OnExampleClick(self):
        # For demo: fetch a stat and display in chat
        stat = player.GetStatus(item.APPLY_MAX_HP)
        chat.AppendChat(chat.CHAT_TYPE_INFO, "Max HP: %d" % stat)
    def OnPressEscapeKey(self):
        self.Close()
        return True

    def Close(self):
        wndMgr.Hide(self.hWnd)

2. In the first lines of root/interfacemodule.py, where all imports are located, add the following import:

from uiCustomBtn import CustomBtnWindow

3. change the method in root/interfacemodule.py like this

def __MakeButton(self):
	self.Btn = CustomBtnWindow()
	self.Btn.LoadWindow()
	# self.Btn.Hide()

def MakeInterface(self):
	self.__MakeButton()
Spoiler

What is causing the error so far?
 

self.Btn = uiCustomBtn.CustomButton()

1. uiCustomBtn must refer to a file or module.
2. In that file/module, there is no class or function named CustomButton

 

Link to comment
https://metin2.dev/topic/33887-adding-simple-ui-button/#findComment-171655
Share on other sites

2 hours ago, ricksanches5248 said:

what i would do is, make a new file in the root/ folder and name it: uiCustomBtn.py

1. paste your code in

import ui
import wndMgr
import localeInfo
import item
import player
import chat

class CustomBtnWindow(ui.ScriptWindow):
    def __init__(self):
        super(CustomBtnWindow, self).__init__()
        self.bonusList = []

    def LoadWindow(self):
        pyScrLoader = ui.PythonScriptLoader()
        pyScrLoader.LoadScriptFile(self, "UIScript/CustomBtn.py")

        self.btnClose = self.GetChild("close_button")
        self.btnClose.SetEvent(ui.__mem_func__(self.Close))

        self.btnExample = self.GetChild("example_button")
        self.btnExample.SetEvent(ui.__mem_func__(self.OnExampleClick))

    def OnExampleClick(self):
        # For demo: fetch a stat and display in chat
        stat = player.GetStatus(item.APPLY_MAX_HP)
        chat.AppendChat(chat.CHAT_TYPE_INFO, "Max HP: %d" % stat)
    def OnPressEscapeKey(self):
        self.Close()
        return True

    def Close(self):
        wndMgr.Hide(self.hWnd)

2. In the first lines of root/interfacemodule.py, where all imports are located, add the following import:

from uiCustomBtn import CustomBtnWindow

3. change the method in root/interfacemodule.py like this

def __MakeButton(self):
	self.Btn = CustomBtnWindow()
	self.Btn.LoadWindow()
	# self.Btn.Hide()

def MakeInterface(self):
	self.__MakeButton()
  Hide contents

What is causing the error so far?
 

self.Btn = uiCustomBtn.CustomButton()

1. uiCustomBtn must refer to a file or module.
2. In that file/module, there is no class or function named CustomButton

 

it still doesnt work i told you the problem is on file doesnt recognize the module i should register it i think somewhere 

Link to comment
https://metin2.dev/topic/33887-adding-simple-ui-button/#findComment-171656
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • 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.