Jump to content

Open() takes exactly 3 arguments


Recommended Posts

Hello community.
I installed offline shop by great but i have this error when i press OK to open the shop:

Quote
Open() takes exactly 3 arguments (2 given)

 

These are my functions: (interfacemodule.py)

Quote
	def OpenPrivateShopBuilder(self):

		if not self.inputDialog:
			return True

		if not len(self.inputDialog.GetText()):
			return True

		self.privateShopBuilder.Open(self.inputDialog.GetText())
		self.ClosePrivateShopInputNameDialog()
		return True

 

uiprivateshopbuilder:

Quote
	def Open(self, title,days):

		self.days = days
		self.title = title

		if len(title) > 25:
			title = title[:22] + "..."

		self.itemStock = {}
		shop.ClearPrivateShopStock()
		self.nameLine.SetText(title)
		self.SetCenterPosition()
		self.Refresh()
		self.Show()

		global g_isBuildingPrivateShop
		g_isBuildingPrivateShop = True

		if app.WJ_ENABLE_TRADABLE_ICON:
			self.ItemListIdx = []

 

Any ideas? thanks in advance.

Link to comment
Share on other sites

  • Premium

Before I tell you the solution, you need to understand exactly what the problem is:

Open() takes exactly 3 arguments (2 given)

This means that a function is expecting to recieve 3 informations:

def new_func(arg1, arg2, arg3):
  print("this func works!")

# new_func(1, 2) # This won't work because we're only sending 2 infos

new_func(1, 2, 3) # This will work since the func is expecting 3 arguments

 

Now, with that in mind, let's indentify the problem:

# So, we know that the open is getting 3 arguments
def Open(self, title,days):

# And we're calling the function with this:
self.privateShopBuilder.Open(self.inputDialog.GetText())

We now know that it's wrong since the function is expecting 3 infos and we are sending it once

This means that we probably want to do this... right?

self.privateShopBuilder.Open(1, 2, 3)

Well, yes (the logical is correct) but in this case, it's wrong.

In the beginning of the function, notice the word self. I can go to a deep explanation but it's not relevant to the topic. Let's just say you can ignore since it's used to represent the class where the function is.

 

But what does that mean?

Remember the initial error?

Open() takes exactly 3 arguments (2 given)

The function is recieving 2 arguments: self and title.

 

We need to send 2 infos, instead of 1:

def Open(self, title,days): # title and days
self.privateShopBuilder.Open(self.inputDialog.GetText()) # we're ONLY sending title, where's the "days"?

You probably didn't follow the tutorial at interfarcemodule.py, check the files again.

 

Quick solution:

self.privateShopBuilder.Open(self.inputDialog.GetText(), 1) # The 1 represents the day, probably how many days to open an offline shop (?)

 

  • Love 1
  • Love 2
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.