The Toolkit 3: Back to The Drawing Board!
Ok so I gotta admit I made a mistake, I should have mapped out how the whole thing is gonna be planned, so I downloaded a neat software called Mindomo(link) to help me map out the whole thing and with that I managed to make this contraption.
The rest is under construction, and I don't need ya'll to see it so let's just use this today.
so, this idea behind this tool is to calculate leave and see if someone went beyond their allotted leave days or came back early, the paper document that employees sign from the commissioner aren't exactly the easiest to read and calculating how many days they left isn't all that easy either nor is seeing if they came back later. the day they first signed in is generally reported on the paper however, so I didn't feel like adding in a day returned field was needed.
so, it's just a matter of taking what the program says and comparing it to what is on the paper.
anyways the goal of this part of the project involves me:
- going back to the designer and making a back button to return the main menu cause easy stuff first
- making two fields for entering the allotted days off and the first day off in the designer.
- making a pull-down menu(combo-box) for the month to be selected.
- making a calendar(there is a calendar widget apparently) that is also meant to reflect just the month that has been selected.
- code the back button (it's easy duh).
- code up the two fields to take the values from them for usage.
- code the calendar (Idk if I have to code this, but I'll figure it out).
- use the values from the two fields and have it create a result based on the calendar.
- have the calendar visually reflect the return date.
- ???
- profit(I hope)
Alrighty then sounds easy enough.
lets start with the designer........ook done, that wasn't so bad(it only took 20 revisions):
got the back button, the days allotted, the first day off, the year of the calendar, the calendar, a drop-down menu for the months and a little grey output box.
neat
now it's time to code it.
...
.....
.........
which sets it to the first index or the 2nd page(first page is 0 index)
back button is pretty much the same but like reverse our button is called bckButton and the only difference is the currrentIndex is set to 0 instead of 1 which sends you back to the first page.
neeaat, easy stuff done, how much harder could doing the calendar possibly be?
2 hours later
maaan coding is hard.......
I just wanted the drop down menu to select the month but it was a huge pain in the *censored*😥
basically what ended up happening was looking for the proper attribute for the drop down and the calendar, but all of the tutorials were different versions and I had to go look for the documentation for certainty and ended up looking at the wrong one and I finally found out that I had to also include the year in order for the calendar month to change.
so the solution ended up being this:
drop down menu is monthSel and the calendar is calendar(I'm not a naming type of person), instead of clicked like last time, we are activating the dropdown menu. The setCurrentPage() attribute of calendar sets the current page of the calendar and it requires two arguments, a year and a page number(1-12). So I took the text(named year) that says 2024(self.year.text()) and I made it an integer or a number by putting it in int()
next argument is the page. from the documentation, 1 is January 2 is February and so on.
ok cool, thankfully the dropdown menu also has an index, but it starts with 0 so we just do "monthSel.currentIndex()+1", because the calendar starts at 1 but the drop down menu starts at 0, we have to add +1 so both start at 1.
whew, well that took a good bit longer than I thought it would take, so we'll finish the calculator next time!
I'm out!
Peace!
~~Justin Case
Comments
Post a Comment