Hello everyone! Hope the new year has started off good for you all. ๐
To kick things off, I have a new script available - which is a simple store where your players can buy items in different categories. Check the preview to see how it works and looks like.
The store is a screen which contains the categories list to the right where you can pick what kind of items you want to browse, and then the items for the selected category shows up to the left.
Each item shows how many is in stock and how much it costs. You can only buy one thing at a time buy clicking the buy button, so there's no bulk buying at this time.
There's a few Python functions which will help you manage the store and are simple to use. These help with things like, buying items, adding new items, checking the price of an item, updating price, removing items and more. More might be added in the future depending on your feedback.
There's some example usage in the label called "my_label" that you can have a look at to see how to use them.
Most of the code is pretty self-explanatory and there's a few comments here and there to help you understand what everything does. Still, if you have any questions you can leave them in the comments below.

The store's items and categories are contained in a nested dictionary. Now it might look daunting for those who haven't used python dictionaries before, but it's not as complicated as it might seem. However, if you have never worked with them before I highly recommend reading up about them as they're are worth learning about.
So this shop_items dictionary contains another dictionary which has all the categories (fruits and vegetables). Inside a category we then have another dictionary which contains all the items in that category (apple, lemon, banana etc). These items also contains dictionaries which gives details about the items like price and amount.
Keep this structure when you add you own items to the list.
The shop screen has two viewports inside a frame displayable. One is for the categories list and one is for the items. This is so that they can be scrolled if the content doesn't fit.
Since viewports don't have a background property, we have a frame inside each of them to set a background color. Then we have the content which for the categories list is a vbox to align each category vertically, and for the items it's two grids. One grid makes up the slots, and the other makes up the items that go on top.
You will want to change the slots size's and how many there are according to your liking.

Both of these grids uses for loops to automatically create as many slots and items as needed. It's important to make sure the first grid (the slots) has the same amount of columns and rows as the iterations of the loop. So in this case there's 5 rows and 5 columns of slots, which means the loop needs to run 25 times to make all of those.
For the items (the second grid), we make sure it has the same number of columns and rows as the slots, and then loop through the items in the "shop_items" list for the currently selected category (code: for item in shop_items[selected_shop_category]). This will grab all the items (ex: apple, banana, orange etc) and display them as individual images inside a frame. Inside that frame we then have the stock text and a buy button with the price for the item in question.
Study the code and make adjustments as you please.
If you have any questions, feel free to leave them below and I'll see how I can help.
Pytem
2024-01-07 18:50:07 +0000 UTC