Wesnoth Unit Creator App
Moderator: Forum Moderators
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Wesnoth Unit Creator App
Hi, everyone!
I didn't know where to post this so I posted it here. Moderators may move this topic to its rightful subthread if I posted in the wrong place.
As the title suggests, I have coded a GUI interface for making Wesnoth unit files.
This is how the current version looks: Yes, I am well aware that I forgot to add a level entry field for it, but this is just a demo and I can always add it in later as well as the other stuff.
This is the source code link:
The Github Repo
For simplicity and avoiding compiling errors for external tests, I have used built-in modules only. QtWidgets would be better but tkinter is the module for the current version.
Please use python 3.7.6 or above for compiling it. I am a bit skeptical on the new 3.8 version of Python so I stayed with the 3.7 version.
Lastly, I would like to hear what the Wesnoth Community has to say regarding this.
I didn't know where to post this so I posted it here. Moderators may move this topic to its rightful subthread if I posted in the wrong place.
As the title suggests, I have coded a GUI interface for making Wesnoth unit files.
This is how the current version looks: Yes, I am well aware that I forgot to add a level entry field for it, but this is just a demo and I can always add it in later as well as the other stuff.
Code: Select all
[unit_type]
id = "Orcish Dumbass"
name = "Orcish Dumbass"
race = "orc"
hitpoints = "50"
experience = "150"
advances_to = "null"
description = "This is a sample unit."
[/unit_type]
The Github Repo
For simplicity and avoiding compiling errors for external tests, I have used built-in modules only. QtWidgets would be better but tkinter is the module for the current version.
Please use python 3.7.6 or above for compiling it. I am a bit skeptical on the new 3.8 version of Python so I stayed with the 3.7 version.
Lastly, I would like to hear what the Wesnoth Community has to say regarding this.
Last edited by Lord-Knightmare on December 30th, 2019, 8:28 pm, edited 1 time in total.
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Wesnoth Unit Creator App
I can see that there's a lot of stuff that can be added. Just to say a few things, a checkbutton for {AMLA_DEFAULT} (I've noticed your comment in the code), spinboxes for numerical values like hitpoints, a combobox for the alignment field...Lord-Knightmare wrote: ↑December 29th, 2019, 8:18 am Yes, I am well aware that I forgot to add a level entry field for it, but this is just a demo and I can always add it in later as well as the other stuff.
Oh, right, there's no combobox widget in plain Tkinter, you'll have to import the tkinter.ttk module on top of it. My recommendation is to always use ttk on top of Tkinter, otherwise you'll miss some additional widgets and your GUI will get the terrible look Tk applications are (in)famous for.
Fun fact: on Debian-like Linux distributions, tkinter isn't installed by default, so you don't have any guarantee that it's always imported. The script also needs a shebang on its first line.Lord-Knightmare wrote: ↑December 29th, 2019, 8:18 am For simplicity and avoiding compiling errors for external tests, I have used built-in modules only. QtWidgets would be better but tkinter is the module for the current version.
Is there any reason for this? Besides, I don't see anything that shouldn't work on 3.8 or even 3.6...Lord-Knightmare wrote: ↑December 29th, 2019, 8:18 am I am a bit skeptical on the new 3.8 version of Python so I stayed with the 3.7 version.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Wesnoth Unit Creator App
Update!
Okay, I have added unit level and an AMLA enabler in the GUI of the app. Additionally, I have included a file_name selector so the app can generate outputs indefinitely or as much as the user wants.
tkk kinda broke the
More clarification please? Maybe a coded example?
Current State:
GUI: Sample output: I guess a further improvement can be made to include image file paths for both the unit and the portrait. And, I guess that just leaves the
As for the animations, I am still not sure that if want to push into that much depth but I guess I can add in support for the
Okay, I have added unit level and an AMLA enabler in the GUI of the app. Additionally, I have included a file_name selector so the app can generate outputs indefinitely or as much as the user wants.
I ran into a problem which is showing as IntVar()/StringVar() not being accepted for the checkbox option. I enabled the AMLA to default to "Yes". Any available fix on this?I can see that there's a lot of stuff that can be added. Just to say a few things, a checkbutton for {AMLA_DEFAULT} (I've noticed your comment in the code), spinboxes for numerical values like hitpoints, a combobox for the alignment field...
Oh, right, there's no combobox widget in plain Tkinter, you'll have to import the tkinter.ttk module on top of it. My recommendation is to always use ttk on top of Tkinter, otherwise you'll miss some additional widgets and your GUI will get the terrible look Tk applications are (in)famous for.
tkk kinda broke the
'fg'
and 'bg'
keys but that's not really relevant.I don't have the faintest clue on what this even means?The script also needs a shebang on its first line.
More clarification please? Maybe a coded example?
Most packages haven't been ported to 3.8 yet so in order to compile it into an app later on, I need to stick to python3.7 for the time being. pyinstaller and py2app do not work with python 3.8.Is there any reason for this? Besides, I don't see anything that shouldn't work on 3.8 or even 3.6...
Current State:
GUI: Sample output: I guess a further improvement can be made to include image file paths for both the unit and the portrait. And, I guess that just leaves the
[attack][/attack]
tags.As for the animations, I am still not sure that if want to push into that much depth but I guess I can add in support for the
{GENERIC_ANIMATION WEAPON_NAME UNIT_IMAGE SOUND}
.Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Wesnoth Unit Creator App
I suggest removing filename selection, instead generate it based on id.
Not sure if it already works that way, but advances_to could suggest based on other files in same directory.
Not sure if it already works that way, but advances_to could suggest based on other files in same directory.
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Wesnoth Unit Creator App
I do not think that should be done. UnitI suggest removing filename selection, instead generate it based on id.
id
can have whitespaces but filenames need to have underscores instead of whitespaces. AFAIK, python has a built-in function "String".replace(" ","_")
to replace one part of a string with another stated part so, I can try tinkering with it.Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Wesnoth Unit Creator App
Id is allowed to have whitespace, but I believe it should not.
https://github.com/wesnoth/wesnoth/issues/1847 whitespaces are supported for compatibility only.
https://github.com/wesnoth/wesnoth/issues/1847 whitespaces are supported for compatibility only.
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Wesnoth Unit Creator App
StringVar() isn't accepted for the variable= key (and not var=, this one doesn't have any meaning in Tkinter), but either IntVar() or the less known BooleanVar() should work.Lord-Knightmare wrote: ↑December 30th, 2019, 8:24 pm I ran into a problem which is showing as IntVar()/StringVar() not being accepted for the checkbox option. I enabled the AMLA to default to "Yes". Any available fix on this?
That's because in ttk how a widget looks is handled by styles. On Windows and MacOS, the style used by default makes the application look like a native one.Lord-Knightmare wrote: ↑December 30th, 2019, 8:24 pm tkk kinda broke the 'fg' and 'bg' keys but that's not really relevant.
Lord-Knightmare wrote: ↑December 30th, 2019, 8:24 pm I don't have the faintest clue on what this even means?
More clarification please? Maybe a coded example?
Code: Select all
#!/usr/bin/env python3
Two other things I noticed:
- on name= and description= there's no translation mark added;
- since a unit description can be quite long, you might consider replacing its Entry widget with a Text widget.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Wesnoth Unit Creator App
Not sure how but this isn't working either.StringVar() isn't accepted for the variable= key (and not var=, this one doesn't have any meaning in Tkinter), but either IntVar() or the less known BooleanVar() should work.
I knew about this but I never knew this was addressed as a "shebang". Guess I know now.In Unix-like systems, this line tells the OS which interpreter should be used to run the script if said script has the executable permission set up.
I have added these in the current version.on name= and description= there's no translation mark added;
since a unit description can be quite long, you might consider replacing its Entry widget with a Text widget.
GUI Appearance
Sample Output
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Wesnoth Unit Creator App
The term probably comes from "Sharp Bang", i.e., the "Sharp" character (#) followed by the "Bang" character (!).Lord-Knightmare wrote: ↑December 31st, 2019, 10:46 pm I knew about this but I never knew this was addressed as a "shebang". Guess I know now.
https://en.wikipedia.org/wiki/Shebang_(Unix)#Etymology
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Wesnoth Unit Creator App
At line 64 of your script, inside the addAMLACheckbox method, you have this line:
Code: Select all
# self.check_amla['var'] = self.amla_var
This one should work instead:
Code: Select all
self.check_amla['variable'] = self.amla_var
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Wesnoth Unit Creator App
It's been commented out for a reason. If it's not commented, the entire program fails to compile and I get this:At line 64 of your script, inside the addAMLACheckbox method, you have this line:
Code: Select all
self.check_amla['variable'] = self.amla_var
AttributeError: 'Application' object has no attribute 'amla_var'
Code: Select all
self.amla_var = BooleanVar(self)
self.amla_var.set(1)
self.amla = ""
Tried that too. Same case.This one should work instead:
EDIT:
I tried to handle the error and made the program compile without commenting out the line
Code: Select all
try:
self.check_amla['variable'] = self.amla_var
except AttributeError as e:
# show message at terminal
# but allow program to still compile
print(e)
'Application' object has no attribute 'amla_var'
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
- Elvish_Hunter
- Posts: 1575
- Joined: September 4th, 2009, 2:39 pm
- Location: Lintanir Forest...
Re: Wesnoth Unit Creator App
OK, I found where the problem isLord-Knightmare wrote: ↑January 2nd, 2020, 1:17 pm This is what I got from the Terminal:Code: Select all
'Application' object has no attribute 'amla_var'
This is your __init__ method:
Code: Select all
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
self.amla_var = BooleanVar(self)
self.amla_var.set(1)
self.amla = ""
Code: Select all
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.amla_var = BooleanVar()
self.amla_var.set(1)
self.amla = ""
self.createWidgets()
self.label_amla = Label(self)
should become self.label_amla = Label(self.frame)
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
- Lord-Knightmare
- Discord Moderator
- Posts: 2363
- Joined: May 24th, 2010, 5:26 pm
- Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
- Contact:
Re: Wesnoth Unit Creator App
It was that simple?You use the createWidgets method before creating the self.amla_var attribute; at this point, your widget cannot find your variable. To get rid of the error, I just moved the createWidgets call after the variable declaration. Like this:
Thank you!
I did this and everything is now working.This happens because LabelFrame is a container widget, just like Frame, so if you want something to be inside of it you have to specify it as parent in children widgets. For example,self.label_amla = Label(self)
should becomeself.label_amla = Label(self.frame)
The latest commit is working fine. Now, I can package this as an executable app as version
1.0
.For version
2.0
I have plans on making further additions such as attacks and image files and in that order. For attacks, I am going to add a new frame and there will be dropdown lists for ranged and type. As for weapon specials, I am guessing it will have to be a dropdown list too.Current GUI interface: Sample Output files:
Edit: (for Windows Users):
This is the app file which ~9MB in size. Download and do notify me if it's working or not.
Pyinstaller is giving me an epic headache. It's been compressed in a RAR file so uncompress it first.
The App
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
Re: Wesnoth Unit Creator App
Nothing to handle graphics and animations?
Beheld the origins of BFW.
Max G on WIF
Rank 🌟🌟🌟🌟🌟
Max G on WIF
Rank 🌟🌟🌟🌟🌟